api module¶
This module is part of the nmeta suite running on top of Ryu SDN controller to provide network identity and flow metadata. . It provides methods for RESTful API connectivity.
-
class
api.
Api
(_nmeta, _config, _wsgi)¶ Bases:
object
This class is instantiated by nmeta.py and provides methods for RESTful API connectivity.
-
IP_PATTERN
= '\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$){4}\\b'¶
-
url_dpae_base
= '/nmeta/v2/aux/'¶
-
url_dpae_uuid
= '/nmeta/v2/aux/{uri_uuid}'¶
-
url_dpae_uuid_keepalive
= '/nmeta/v2/aux/{uri_uuid}/keepalive/'¶
-
url_dpae_uuid_main_policy
= '/nmeta/v2/aux/{uri_uuid}/main_policy/'¶
-
url_dpae_uuid_sendconfpkt
= '/nmeta/v2/aux/{uri_uuid}/send_conf_packet/'¶
-
url_dpae_uuid_tc_classify
= '/nmeta/v2/aux/{uri_uuid}/services/tc/classify/'¶
-
url_dpae_uuid_tc_opt_rules
= '/nmeta/v2/aux/{uri_uuid}/services/tc/opt_rules/'¶
-
url_dpae_uuid_tc_state
= '/nmeta/v2/aux/{uri_uuid}/services/tc/state/'¶
-
url_idmac
= '/nmeta/v2/id/mac/'¶
-
-
class
api.
JSON_Body
(req_body)¶ Bases:
object
Represents a JSON-encoded body of an HTTP request. Doesn’t do logging, but does set .error when things don’t go to plan with a friendly message.
-
decode
(req_body)¶ Passed an allegedly JSON body and see if it decodes. Set error variable for exceptions
-
validate
(key_list)¶ Passed a list of keys and check that they exist in the JSON. If they don’t return 0 and set error to description of first missing key that was found
-
-
exception
api.
NotFoundError
(msg=None, **kwargs)¶ Bases:
ryu.exception.RyuException
-
message
= 'Error occurred talking to function <TBD>'¶
-
-
class
api.
RESTAPIController
(req, link, data, **config)¶ Bases:
ryu.app.wsgi.ControllerBase
This class is used to control REST API access to the nmeta data and control functions
-
rest_dpae_create
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_delete
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_keepalive
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_main_policy_read
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_read
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_read_uuid
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_send_sniff_conf_pkt
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_tc_classify_advice
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_tc_opt_rules_read
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_dpae_tc_state_update
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
rest_idmac_read
(*args, **kwargs)¶ Run a REST command and return appropriate response. Keys/Values returned to this wrapper in a dictionary. Valid Keys are:
‘msg’: the data to return in the message body ‘location’: a new location for the resource ‘status’: HTTP status code to return
-
-
api.
rest_command
(func)¶ REST API command template
-
api.
version_compare
(version1, version2)¶ Compare two semantic version numbers and return 1 if they are the same major version number