pybvc.controller package

Submodules

pybvc.controller.controller module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

controller.py: Controller’s properties and communication methods

class pybvc.controller.controller.Controller(ipAddr, portNum, adminName, adminPassword, timeout=5)

Class that represents a Controller device.

add_netconf_node(node)
Connect a netconf device to the controller
(for example connect vrouter to controller via NETCONF)
Parameters:nodepybvc.controller.netconfnode.NetconfNode
Returns:Status, JSON response from controller.
Return type:pybvc.common.status.OperStatus, JSON providing response from adding netconf noed.
  • STATUS.CONN_ERROR: If the controller did not respond.

. Provider info is empty. - STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not . provide any status. Provider info is . empty. - STATUS.OK: Success. Provider info is valid. - STATUS.HTTP_ERROR: If the controller responded with an error . status code.

brief_json()

Returns JSON representation of this object (brief info).

build_inventory_object(operational=True)
build_netconf_config_object(netconf_id)
build_netconf_config_objects()
build_netconf_node_inventory_object(node_id, operational=True)
build_openflow_node_inventory_object(node_id, operational=True)
build_topology_object(topo_name)
check_node_config_status(nodeId)

Return the configuration status of the node:

Parameters:nodeId (string) – Identifier for the node for which to get the config status
Returns:Configuration status of the node.
Return type:None or pybvc.common.status.OperStatus
  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded

    but did not provide any status.

  • STATUS.NODE_CONFIGURED: If the node is configured.

  • STATUS.DATA_NOT_FOUND: If node is not configured.

check_node_conn_status(nodeId)

Return the connection status of the node to the controller:

Parameters:nodeId (string) – Identifier for the node for which to get the config status
Returns:Status of the node’s connection to the controller.
Return type:None or pybvc.common.status.OperStatus
  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded

    but did not provide any status.

  • STATUS.NODE_CONNECTED: If the node is connected

  • STATUS.NODE_DISCONNECTED: If the node is not connected

  • STATUS.DATA_NOT_FOUND: If node is not configured.

  • STATUS.HTTP_ERROR: If the controller responded with

    an error status code.

create_data_change_event_subscription(datastore, scope, path)
delete_netconf_node(netconfdev=None, nodename=None)

Disconnect a netconf device from the controller :param netconfdev:

Returns:Status, None.
Return type:pybvc.common.status.OperStatus, JSON providing response from adding netconf noed.
  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status.

  • STATUS.OK: Success.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_all_nodes_conn_status()
Return a list of nodes and the status of their connection
to the controller.
Returns:Status, list of nodes the status of their connection to the controller
Return type:pybvc.common.status.OperStatus, list of dict [{node:<node id>, connected:<boolean>},...]
  • STATUS.CONN_ERROR: If the controller did not respond. List is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. List is empty.

  • STATUS.OK: Success. List is valid.

  • STATUS.DATA_NOT_FOUND: Success. List is empty.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_all_nodes_in_config()

Return a list of nodes in the controller’s configuration data store

Returns:Status, list of nodes in the config data store of the controller
Return type:pybvc.common.status.OperStatus, list
  • STATUS.CONN_ERROR: If the controller did not respond. List is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. List is empty.

  • STATUS.OK: Success. List is valid.

  • STATUS.DATA_NOT_FOUND: Success. List is empty.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_config_modules()

Return a list of configuration modules.

Returns:Status, configuration modules.
Return type:pybvc.common.status.OperStatus, JSON listing modules and their operational state
  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did

    not provide any status.

  • STATUS.OK: Success.

  • STATUS.DATA_NOT_FOUND: Data missing or in unexpected format.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_ext_mount_config_url(node)
get_ext_mount_operational_url(node)
get_inventory_nodes_yang_schema_path()
get_module_operational_state(moduleType, moduleName)

Return operational state for specified module.

Parameters:
  • moduleType (string) – module type
  • moduleName (string) – module name
Returns:

Status, operational state for specified module.

Return type:

pybvc.common.status.OperStatus, JSON providing operational state

  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did

    not provide any status. State info is empty.

  • STATUS.OK: Success. State info is valid.

  • STATUS.DATA_NOT_FOUND: Data missing or in unexpected format.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_netconf_nodes_conn_status()
Return a list of NETCONF nodes and the status of their connection
to the controller.
Returns:Status, list of nodes the status of their connection to the controller
Return type:pybvc.common.status.OperStatus, list of dict [{node:<node id>, connected:<boolean>},...]
  • STATUS.CONN_ERROR: If the controller did not respond. List is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. List is empty.

  • STATUS.OK: Success. List is valid.

  • STATUS.DATA_NOT_FOUND: Success. List is empty.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_netconf_nodes_in_config()
Return a list of NETCONF nodes in the controller’s configuration
data store
Returns:Status, list of nodes in the config data store of the controller
Return type:pybvc.common.status.OperStatus, list
  • STATUS.CONN_ERROR: If the controller did not respond. List is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. List is empty.

  • STATUS.OK: Success. List is valid.

  • STATUS.DATA_NOT_FOUND: Success. List is empty.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_netconf_operations(nodeName)

Return a list of operations supported by the indicated node.

Parameters:nodeName (string) – Name of the node
Returns:A tuple: Status, operations supported by indicated node.
Return type:pybvc.common.status.OperStatus, JSON listing the operations
  • STATUS.CONN_ERROR: If the controller did not respond.

    Operations info is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did

    not provide any status. Operations info is empty.

  • STATUS.OK: Success. Operations info is valid.

  • STATUS.DATA_NOT_FOUND: Data missing or in unexpected format.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_network_topology_yang_schema_path(topo_id=None)
get_node_config_url(node)
get_node_info(nodeId)
get_node_operational_url(node)
get_nodes_operational_list()
get_openflow_nodes_operational_list()
get_openflow_operational_flows_total_cnt()
get_schema(nodeName, schemaId, schemaVersion)

Return a YANG schema for the indicated schema on the indicated node.

Parameters:
  • nodeName (string) – Name of the node
  • schemaId (string) – Id of the schema
  • schemaVersion (string) – Version of the schema
Returns:

Status, YANG schema.

Return type:

pybvc.common.status.OperStatus, YANG schema

  • STATUS.CONN_ERROR: If the controller did not respond. schema is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. schema is empty.

  • STATUS.OK: Success. Result is valid.

  • STATUS.DATA_NOT_FOUND: Data missing or in unexpected format.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_schemas(nodeName)

Return a list of YANG model schemas for the node.

Parameters:nodeName (string) – Name of the node
Returns:Status, list of YANG schemas for the node.
Return type:pybvc.common.status.OperStatus, JSON listing information about the YANG schemas for the node
  • STATUS.CONN_ERROR: If the controller did not respond. List is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. List is empty.

  • STATUS.OK: Success. List is valid.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_service_provider_info(name)

Return info about a single service provider.

Parameters:name (string) – Name of the provider
Returns:Status, info about the service provider
Return type:pybvc.common.status.OperStatus, JSON providing info about the service provider
  • STATUS.CONN_ERROR: If the controller did not respond.

. Provider info is empty. - STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not . provide any status. provider info is . empty. - STATUS.OK: Success. Provider info is valid. - STATUS.DATA_NOT_FOUND: Data missing or in unexpected format. - STATUS.HTTP_ERROR: If the controller responded with an error . status code.

get_service_providers_info()

Return a list of service providers available.

Returns:Status, list of service providers
Return type:pybvc.common.status.OperStatus, JSON providing list of service providers
  • STATUS.CONN_ERROR: If the controller did not respond.

. Provider info is empty. - STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not . provide any status. provider info is . empty. - STATUS.OK: Success. Provider info is valid. - STATUS.DATA_NOT_FOUND: Data missing or in unexpected format. - STATUS.HTTP_ERROR: If the controller responded with an error . status code.

get_sessions_info(nodeName)

Return sessions for indicated node.

Parameters:nodeName (string) – Name of the node
Returns:Status, list of sessions for indicated node
Return type:pybvc.common.status.OperStatus, JSON providing sessions
  • STATUS.CONN_ERROR: If the controller did not respond.

. Session info is empty. - STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not . provide any status. Session info is . empty. - STATUS.OK: Success. Session info is valid. - STATUS.DATA_NOT_FOUND: Data missing or in unexpected format. - STATUS.HTTP_ERROR: If the controller responded with an error . status code.

get_streams_info()

Return streams available for subscription.

Returns:Status, list of streams
Return type:pybvc.common.status.OperStatus, JSON providing list of streams
  • STATUS.CONN_ERROR: If the controller did not respond.

    Stream info is empty.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status. stream info is empty.

  • STATUS.OK: Success. Stream info is valid.

  • STATUS.DATA_NOT_FOUND: Data missing or in unexpected format.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

get_topology_ids()
http_delete_request(url, data, headers)
Sends HTTP DELETE request to a remote server
and returns the response.
Parameters:
  • url (string) – The complete url including protocol: http://www.example.com/path/to/resource
  • data (string) – The data to include in the body of the request. Typically set to None.
  • headers (dict) – The headers to include in the request.
Returns:

The response from the http request.

Return type:

None or requests.response <http://docs.python-requests.org/en/latest/api/#requests.Response>

http_get_request(url, data, headers, timeout=None)
Sends HTTP GET request to a remote server
and returns the response.
Parameters:
  • url (string) – The complete url including protocol: http://www.example.com/path/to/resource
  • data (string) – The data to include in the body of the request. Typically set to None.
  • headers (dict) – The headers to include in the request.
  • timeout (string) – Pass a timeout for longlived queries
Returns:

The response from the http request.

Return type:

None or requests.response <http://docs.python-requests.org/en/latest/api/#requests.Response>

http_post_request(url, data, headers)
Sends HTTP POST request to a remote server
and returns the response.
Parameters:
  • url (string) – The complete url including protocol: http://www.example.com/path/to/resource
  • data (string) – The data to include in the body of the request. Typically set to None.
  • headers (dict) – The headers to include in the request.
Returns:

The response from the http request.

Return type:

None or requests.response <http://docs.python-requests.org/en/latest/api/#requests.Response>

http_put_request(url, data, headers)
Sends HTTP PUT request to a remote server
and returns the response.
Parameters:
  • url (string) – The complete url including protocol: http://www.example.com/path/to/resource
  • data (string) – The data to include in the body of the request. Typically set to None.
  • headers (dict) – The headers to include in the request.
Returns:

The response from the http request.

Return type:

None or requests.response <http://docs.python-requests.org/en/latest/api/#requests.Response>

modify_netconf_node_in_config(netconfdev)

Modify connected netconf device’s info in the controller

Parameters:netconfdevpybvc.controller.netconfnode.NetconfNode
Returns:Status, None.
Return type:pybvc.common.status.OperStatus, JSON providing response from adding netconf noed.
  • STATUS.CONN_ERROR: If the controller did not respond.

  • STATUS.CTRL_INTERNAL_ERROR: If the controller responded but did not

    provide any status.

  • STATUS.OK: Success.

  • STATUS.HTTP_ERROR: If the controller responded with an error

    status code.

subscribe_to_stream(stream_name)
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

pybvc.controller.inventory module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

inventory.py: Controller’s inventory parser

class pybvc.controller.inventory.Inventory(inv_json=None)

Class that represents current state of the Controller’s inventory store.

add_netconf_node(node)
add_openflow_node(node)
get_netconf_node(node_id)
get_netconf_node_ids()
get_openflow_node(node_id)
get_openflow_node_flows_cnt(node_id)
get_openflow_node_ids()
class pybvc.controller.inventory.NetconfCapableNode(clazz, inv_json=None, inv_dict=None)

Class that represents current state of a NETCONF capable node. Helper class of the ‘Inventory’ class.

get_conn_status()
get_current_capabilities()
get_id()
get_initial_capabilities()
is_connected()
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

class pybvc.controller.inventory.NetconfConfigModule(d)

Class that represents NETCONF node configuration module on the Controller

get_admin_name()
get_admin_pswd()
get_conn_timeout()
get_ip_address()
get_max_conn_attempts()
get_name()
get_retry_conn_timeout()
get_tcp_port()
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

class pybvc.controller.inventory.OpenFlowCapableNode(inv_json=None, inv_dict=None)

Class that represents current state of an OpenFlow capable node in the Controller’s inventory store. Helper class of the ‘Inventory’ class.

get_capabilities()
get_description()
get_flow_tables_cnt()
get_flows_cnt()
get_flows_in_table_cnt(table_id)
get_group_features()
get_group_ids()
get_groups_total_num()
get_hardware_info()
get_id()
get_ip_address()
get_manufacturer_info()
get_max_buffers_info()
get_max_tables_info()
get_meter_features()
get_port_id(port_num)
get_port_ids()
get_port_name(port_id)
get_port_number(port_id)
get_port_obj(port_id)
get_serial_number()
get_software_info()
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

class pybvc.controller.inventory.OpenFlowPort(d)

Class that represents current state of an OpenFlow enabled port. Helper class of the ‘OpenFlowCapableNode’ class.

get_bytes_received()
get_bytes_transmitted()
get_current_features()
get_current_speed()
get_forwarding_state()
get_mac_address()
get_packets_received()
get_packets_transmitted()
get_port_id()
get_port_name()
get_port_number()
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

pybvc.controller.netconfnode module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

netconfnode.py: Controller’s NETCONF node specific properties

class pybvc.controller.netconfnode.NetconfNode(controller=None, nodeName=None, ipAddr=None, portNum=None, adminName=None, adminPassword=None, tcpOnly=False)

Bases: object

Class that represents a NETCONF capable server device.

Parameters:
  • controllerpybvc.controller.controller.Controller
  • nodeName (string) – The name of the node
  • ipAddr (string) – The ip address for the netconf device
  • portNum (int) – The port number to communicate NETCONF to the device
  • adminName (string) – The username to authenticate setup of the NETCONF communication
  • adminPassword (string) – The password to authenticate setup of the NETCONF communication
  • tcpOnly (boolean) – Use TCP only or not.
Returns:

The newly created NetconfNode instance.

Return type:

pybvc.controller.netconfnode.NetconfNode

to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

pybvc.controller.notification module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

notification.py: Parser for notification events received from Controller

class pybvc.controller.notification.FlowInfo(event)
to_string()
class pybvc.controller.notification.InventoryChangeEvent(event)

Parser for the data change event located in the inventory change notification message received from the Controller. Helper subclass for the ‘InventoryChangeNotification’ class.

created()
deleted()
do_print()
get_flow_entry_id()
get_node_id()
get_path()
is_flow_entry()
is_node()
is_switch()
updated()
class pybvc.controller.notification.InventoryChangeNotification(event)

Parser for notification messages generated by the Controller when it detects changes in its internal inventory data store.

flows_added()
flows_removed()
get_time()
nodes_added()
nodes_removed()
print_events()
class pybvc.controller.notification.NetworkTopologyChangeNotification(event)

Parser for notification messages generated by the Controller when it detects changes in the network topology data tree.

get_time()
hosts_added()
hosts_removed()
print_events()
switches_added()
switches_removed()
class pybvc.controller.notification.PathInfo(info)

Represents the path to the node in the Controller’s internal data tree where the change has been detected. Helper subclass for the ‘NetworkTopologyChangeNotification’ and ‘InventoryChangeNotification’ classes.

do_print()
class pybvc.controller.notification.TopoChangeEvent(event)

Parser for the data change event located in the network topology change notification message received from the Controller. Helper subclass for the ‘NetworkTopologyChangeNotification’ class.

created()
deleted()
do_print()
get_node_id()
get_path()
is_host()
is_node()
is_switch()
updated()
pybvc.controller.notification.yang_nsname_to_prefix(nsname)
pybvc.controller.notification.yang_prefix_to_nsname(prefix)

pybvc.controller.openflownode module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

openflownode.py: Controller’s OpenFlow node specific properties

class pybvc.controller.openflownode.OpenflowNode(controller=None, nodeName=None)

Bases: object

Class that represents a NETCONF capable server device.

to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

pybvc.controller.topology module

@authors: Sergei Garbuzov @status: Development @version: 1.1.0

topology.py: Controller’s topology parser

A link in the topology instance. Helper class of the ‘Topology’ class

get_id()
get_src_node_id()
is_dst_node(node)
is_dst_node_port(node, pnum)
is_host_to_switch()
is_loopback()
is_switch_to_host()
is_switch_to_switch()
to_string()

Returns string representation of this object.

class pybvc.controller.topology.Node(d)

A node in the topology instance. Helper class of the ‘Topology’ class

get_id()
get_ip_address_for_mac(mac_addr)
get_mac_address()
get_openflow_id()
get_port_numbers()
get_type_str()
is_host()
is_switch()
to_json()

Returns JSON representation of this object.

to_string()

Returns string representation of this object.

class pybvc.controller.topology.Topology(topo_json=None, topo_dict=None)

Class that represents Controller’s view on a Network Topology instance.

add_node(node)
get_host_ids()
get_hosts()
get_hosts_cnt()
get_id()
get_node_by_id(node_id)
get_nodes()
get_peer_list_for_node(node)
get_peer_list_for_node_port_(node, pnum)
get_switch(switch_id)
get_switch_ids()
get_switches()
get_switches_cnt()
to_string()

Returns string representation of this object.

Module contents