def show(self, req, *args, **kwargs): try: url = req.url if len(args) != 1: raise BadRequest(resource="netservice operation", msg=url) json_body = req.body context = req.context dic = json.loads(json_body) list_ = ['id'] dic_body = tools.firewall_params(dic, list_) LOG.info(_LI("get_vlan body is %(json)s, args is %(args)s," "kwargs is %(kwargs)s"), {"json": dic, "args": args, "kwargs": kwargs}) response = self.manager.get_netservice(context, dic_body) return response except Nca47Exception as e: LOG.error(_LE('Nca47Exception! error info: ' + e.message)) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as e: self.response.status = 500 return tools.ret_info(self.response.status, e.value) except Exception as e: LOG.error(_LE('Exception! error info: ' + e.message)) self.response.status = 500 message = "the values of the body format is error" return tools.ret_info(self.response.status, message)
def create(self, req, *args, **kwargs): try: url = req.url if len(args) != 1: raise BadRequest(resource="vlan operation", msg=url) json_body = req.body context = req.context dic = json.loads(json_body) list_ = ['tenant_id', 'dc_name', 'vlan_id', 'network_zone', 'ipaddr', "ifnames"] dic_body = tools.firewall_params(dic, list_) LOG.info(_LI("add_vlan body is %(json)s,args is %(args)s," "kwargs is %(kwargs)s"), {"json": dic, "args": args, "kwargs": kwargs}) response = self.manager.create_vlan(context, dic_body) return response except Nca47Exception as e: LOG.error(_LE('Nca47Exception! error info: ' + e.message)) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as e: self.response.status = 500 return tools.ret_info(self.response.status, e.value) except Exception as e: LOG.error(_LE('Exception! error info: ' + e.message)) self.response.status = 500 message = "the values of the body format is error" return tools.ret_info(self.response.status, message)