def post(self, tenant_id=None, network_id=None): logger.debug("request url - %s", self.get_request_uri()) logger.debug("request params - tenant_id: %s",tenant_id) ret = {} try: body = HostSchema().deserialize(json.loads(self.request.body)) logger.debug(str(body)) res = mul.add_del_fabric_port_tnid( int(body['dpid'], 16), str(tenant_id), str(network_id), str(body['in_port']), True) if res == 1: ret = {"succeess" : "new openstack host added"} elif res == -2: raise Exception, "tenant id is not uuid format" elif res == -3: raise Exception, "network id is not uuid format" else: raise Exception, "add openstack host fail" check = self.__add_fabric_host(tenant_id, network_id, body) self.finish(ret) except Exception, e: ret.update({"error_message" : "failed to add openstack host" , "reason" : str(e)}) self.send_error(400)
def delete(self, tenant_id=None, network_id=None): logger.debug("request url - %s", self.get_request_uri()) logger.debug("request params - tenant_id: %s",tenant_id) ret = {} try : body = HostSchema().deserialize(json.loads(self.request.body)) logger.debug(str(body)) res = mul.add_del_fabric_port_tnid(int(body['datapath_id'], 16), str(tenant_id), str(network_id), str(body['port']), False) if res == 1: ret = {"succeess" : "new openstack host deleted"} elif res == -2: raise Exception, "tenant id is not uuid format" elif res == -3: raise Exception, "network id is not uuid format" else: raise Exception, "del openstack host fail" except Exception, e: ret.update({"error_message" : "failed to del openstack host" , "reason" : str(e)})