compass.api package

Submodules

compass.api.api module

Define all the RestfulAPI entry points

class compass.api.api.Cluster

Bases: flask_restful.Resource

Creates cluster and lists cluster details; Update and list the cluster’s configuration information.

ENDPOINT = '/clusters'
NETWORKING = 'networking'
PARTITION = 'partition'
SECURITY = 'security'
get(cluster_id, resource=None)

Lists details of the specified cluster if resource is not specified. Otherwise, lists details of the resource of this cluster

Parameters:
  • cluster_id – the unique identifier of the cluster
  • resource – the resource name(security, networking, partition)
mediatypes(resource_cls)
methods = ['GET', 'POST', 'PUT']
post()

Create a new cluster.

Parameters:
  • name – the name of the cluster
  • adapter_id – the unique identifier of the adapter
put(cluster_id, resource)

Update the resource information of the specified cluster in database

Parameters:
  • cluster_id – the unique identifier of the cluster
  • resource – resource name(security, networking, partition)
class compass.api.api.ClusterHost

Bases: flask_restful.Resource

List details of the cluster host by host id

ENDPOINT = '/clusterhosts'
get(host_id)

Lists details of the specified cluster host

Parameters:host_id – the unique identifier of the host
mediatypes(resource_cls)
methods = ['GET']
class compass.api.api.ClusterHostConfig

Bases: flask_restful.Resource

Lists and update/delete cluster host configurations

delete(host_id, subkey)

Delete one attribute in configuration of the specified cluster host

Parameters:
  • host_id – the unique identifier of the host
  • subkey – the attribute name in configuration
get(host_id)

Lists configuration details of the specified cluster host

Parameters:host_id – the unique identifier of the host
mediatypes(resource_cls)
methods = ['DELETE', 'GET', 'PUT']
put(host_id)

Update configuration of the specified cluster host

Parameters:host_id – the unique identifier of the host
class compass.api.api.ClusterInstallingProgress

Bases: flask_restful.Resource

Get cluster installing progress information

get(cluster_id)

Lists progress details of a specific cluster

Parameters:cluster_id – the unique identifier of the cluster
mediatypes(resource_cls)
methods = ['GET']

Bases: flask_restful.Resource

Lists dashboard links

ENDPOINT = '/dashboardlinks/'
get()

Return a list of dashboard links

mediatypes(resource_cls)
methods = ['GET']
class compass.api.api.HostInstallingProgress

Bases: flask_restful.Resource

Get host installing progress information

get(host_id)

Lists progress details of a specific cluster host

Parameters:host_id – the unique identifier of the host
mediatypes(resource_cls)
methods = ['GET']
class compass.api.api.Machine

Bases: flask_restful.Resource

List details of the machine with specific machine id

ENDPOINT = '/machines'
get(machine_id)

Lists details of the specified machine.

Parameters:machine_id – the unique identifier of the machine
mediatypes(resource_cls)
methods = ['GET']
class compass.api.api.MachineList

Bases: flask_restful.Resource

Query machines by filters

ENDPOINT = '/machines'
LIMIT = 'limit'
PORT = 'port'
SWITCHID = 'switchId'
VLANID = 'vladId'
get()

Lists details of machines, optionally filtered by some conditions as the following.

Parameters:
  • switchId – the unique identifier of the switch
  • vladId – the vlan ID
  • port – the port number
  • limit – the number of records expected to return
mediatypes(resource_cls)
methods = ['GET']
class compass.api.api.Switch

Bases: flask_restful.Resource

Get and update a single switch information

ENDPOINT = '/switches'
delete(switch_id)

No implementation.

Parameters:switch_id – the unique identifier of the switch.
get(switch_id)

Lists details of the specified switch.

Parameters:switch_id – switch ID in db
mediatypes(resource_cls)
methods = ['DELETE', 'GET', 'PUT']
put(switch_id)

Update an existing switch information.

Parameters:switch_id – the unqiue identifier of the switch
class compass.api.api.SwitchList

Bases: flask_restful.Resource

Query detals of switches and poll swithes

ENDPOINT = '/switches'
LIMIT = 'limit'
SWITCHIP = 'switchIp'
SWITCHIPNETWORK = 'switchIpNetwork'
get()

List details of all switches, optionally filtered by some conditions. Note: switchIp and swtichIpNetwork cannot be combined to use.

Parameters:
  • switchIp – switch IP address
  • switchIpNetwork – switch IP network
  • limit – the number of records excepted to return
mediatypes(resource_cls)
methods = ['GET', 'POST']
post()

Insert switch IP and the credential to db. Invoke a task to poll switch at the same time.

Parameters:
  • ip – switch IP address
  • credential – a dict for accessing the switch
compass.api.api.execute_cluster_action(cluster_id)

Execute the specified action to the cluster.

Parameters:
  • cluster_id – the unique identifier of the cluster
  • addHosts – the action of adding excepted hosts to the cluster
  • removeHosts – the action of removing expected hosts from the cluster
  • replaceAllHosts – the action of removing all existing hosts in cluster and add new hosts
  • deploy – the action of starting to deploy
compass.api.api.list_adapter(adapter_id)

Lists details of the specified adapter.

Parameters:adapter_id – the unique identifier of the adapter
compass.api.api.list_adapter_roles(adapter_id)

Lists details of all roles of the specified adapter

Parameters:adapter_id – the unique identifier of the adapter
compass.api.api.list_adapters()

Lists details of the adapters, optionally filtered by adapter name.

Parameters:name – the name of the adapter
compass.api.api.list_clusterhosts()

Lists details of all cluster hosts, optionally filtered by some conditions.

Parameters:
  • hostname – the name of the host
  • clstername – the name of the cluster
compass.api.api.list_clusters()

Lists the details of all clusters

compass.api.errors module

Exception and its handler

exception compass.api.errors.InputMissingError

Bases: exceptions.Exception

Define the insufficient input exception

exception compass.api.errors.MethodNotAllowed

Bases: exceptions.Exception

Define the exception which invalid method is called

exception compass.api.errors.ObjectDoesNotExist

Bases: exceptions.Exception

Define the exception for referring non-existing object

exception compass.api.errors.ObjectDuplicateError

Bases: exceptions.Exception

Define the duplicated object exception

exception compass.api.errors.UserInvalidUsage

Bases: exceptions.Exception

Define the exception for fault usage of users

compass.api.errors.handle_duplicate_object(error, failed_objs=None)

Handler of ObjectDuplicateError Exception

compass.api.errors.handle_invalid_usage(error)

Handler of UserInvalidUsage Exception

compass.api.errors.handle_mssing_input(error)

Handler of InputMissingError Exception

compass.api.errors.handle_not_allowed_method(error)

Handler of MethodNotAllowed Exception

compass.api.errors.handle_not_exist(error, failed_objs=None)

Handler of ObjectDoesNotExist Exception

compass.api.util module

Utils for API usage

compass.api.util.add_resource(*args, **kwargs)

Add resource

compass.api.util.flatten_dict(dictionary, output, flat_key='')

This function will convert the dictionary into a list For example: dict = {‘a’:{‘b’: ‘c’}, ‘d’: ‘e’} ==> list = [‘a/b/c’, ‘d/e’]

compass.api.util.is_valid_gateway(ip_addr)

Valid the format of gateway

compass.api.util.is_valid_ip(ip_address)

Valid the format of an Ip address

compass.api.util.is_valid_ipnetowrk(ip_network)

Valid the format of an Ip network

compass.api.util.is_valid_netmask(ip_addr)

Valid the format of a netmask

compass.api.util.is_valid_networking_config(config)

Valid the format of networking config

compass.api.util.is_valid_partition_config(config)

Valid the configuration format

compass.api.util.is_valid_security_config(config)

Valid the format of security section in config

compass.api.util.make_json_response(status_code, data)

Wrap json format to the reponse object

compass.api.util.update_dict_value(searchkey, newvalue, dictionary)

Update dictionary value

compass.api.util.valid_host_config(config)

valid_format is used to check if the input config is qualified the required fields and format. The key is the required field and format of the input config The value is the validator function name of the config value

Module contents

Table Of Contents

Previous topic

compass.actions package

Next topic

compass.db package

This Page