class Controller(object): def __init__(self, conf): LOG.debug("[Topology api] Creating Switch Manager controller with config:" "loadkulclouds.py %s", conf) self.conf = conf self.create_schema = Switch_schema() @utils.verify_version def index(self, req, version): LOG.debug("[Topology api] Show list of switches. Request: %s", req) result = core_api.switch_get_index(self.conf, version) return result @utils.http_success_code(202) @utils.verify_version_argument def create(self, req, version, body): LOG.debug("[Topology api] Got create request. Request: %s", req) #here we need to decide which device should be used params = self.create_schema.deserialize(body) LOG.debug("Headers: %s", req.headers) # We need to create LB object and return its id result = core_api.create_switch(self.conf, version, params) return result @utils.http_success_code(204) @utils.verify_version def delete(self, req, version, dpid): LOG.debug("[Topology api] Got delete request. Request: %s", req) result=core_api.delete_switch(self.conf, version, dpid) return result @utils.verify_version def show(self, req, version, dpid): LOG.debug("[Topology api] Got info request. Request: %s", req) try: result = core_api.switch_get_data(self.conf, version, dpid) except Exception as e: raise webob.exc.HTTPBadRequest(content_type='application_json',body='There is no target switch') return result @utils.verify_version def details(self, req, version, dpid): LOG.debug("[Topology api] Got info request. Request: %s", req) result = core_api.switch_show_details(self.conf, version, dpid) return result @utils.http_success_code(202) @utils.verify_version_argument def update(self, req, version, dpid, body): LOG.debug("[Topology api] Got update request. Request: %s", req) params = self.create_schema.deserialize(body) result = core_api.update_switch(self.conf, version, dpid, params) return result
def __init__(self, conf): LOG.debug("[Topology api] Creating Switch Manager controller with config:" "loadkulclouds.py %s", conf) self.conf = conf self.create_schema = Switch_schema()