本文整理汇总了Python中nca47.common.i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_gmember
def create_gmember(self, context, obj_dic):
values = ["ip", "port", "enable", "name"]
driver_dic = tools.input_dic(values, obj_dic)
gslb_obj = {}
gslb_obj["gmember_name"] = obj_dic['name']
gslb_obj["current_user"] = self.auth_name
dic = tools.dict_merge(driver_dic, gslb_obj)
dic.pop('name')
LOG.info(_LI("create the gmember values with dic format"
"is %(json)s of dervice"), {"json": dic})
url = (self.host + ":" + str(self.port) +
'/dc/' + obj_dic["gslb_zone_name"] + "/gmember")
LOG.info(_LI("create gmember url:" + url))
headers = {'Content-type': 'application/json'}
data = json.dumps(dic)
auth = (self.auth_name, self.auth_pw)
LOG.info(_LI("create gmember url:" + url))
response = requests.post(url, data=data,
headers=headers, auth=auth, verify=False)
if response.status_code is None:
raise NonExistDevices
if response.status_code is not 200:
raise ZdnsErrMessage(self.zdns_error.getMessage(response.
status_code))
return response.json()
示例2: report_agent_state
def report_agent_state(self, context, agent_info):
LOG.info(_LI("updating agent state: Replying rpc client's "
"report_agent_state."))
agent_obj = objects.Agent(context, **agent_info)
# Check the target agent object whether exist in DB
conditions = {}
conditions['dc_name'] = agent_info['dc_name']
conditions['network_zone'] = agent_info['network_zone']
conditions['agent_ip'] = agent_info['agent_ip']
conditions['agent_nat_ip'] = agent_info['agent_nat_ip']
conditions['agent_type'] = agent_info['agent_type']
conditions['deleted'] = False
target_agent = None
try:
target_agent = agent_obj.get_object(context, **conditions)
except:
LOG.info(_LI('cannot find related agent record in DB, so think '
'this agent info as new, need to save in DB'))
pass
if target_agent:
update_agent = {}
update_agent['update_time'] = timeutils.utcnow()
update_agent['availiable'] = 'yes'
update_agent['status'] = 'OK'
update_infos = objects.Agent(context, **update_agent)
agent_obj.update(context, target_agent['id'],
update_infos.as_dict())
else:
agent_obj.availiable = 'yes'
agent_obj.status = 'OK'
agent_obj.update_time = timeutils.utcnow()
agent_obj.create(context, agent_obj.as_dict())
return agent
示例3: update_operation_history
def update_operation_history(self, context, id_, **kwargs):
opt_params = {}
opt_params['operation_status'] = kwargs['status']
opt_obj = objects.OperationHistory(context, **opt_params)
LOG.info(_LI("updating operation history record in DB"))
opt_obj.update(context, id_, opt_obj.as_dict())
LOG.info(_LI("update operation history record in DB successful!"))
return None
示例4: create_syngroup
def create_syngroup(self, context, obj_dic):
gslb_obj = ["name", "dcs", "probe_range", "pass"]
driver_dic = tools.input_dic(gslb_obj, obj_dic)
driver_dic["current_user"] = self.auth_name
LOG.info(_LI("create the syngroup values with dic format\
is %(json)s of dervice"),
{"json": driver_dic})
url = (self.host + ":" + str(self.port) +
'/syngroup')
headers = {'Content-type': 'application/json'}
data = json.dumps(driver_dic)
auth = (self.auth_name, self.auth_pw)
LOG.info(_LI("create syngroup url:" + url))
obj_dic['id'] = obj_dic['name']
return obj_dic
示例5: create_gmember
def create_gmember(self, context, obj_dic):
values = ["ip", "port", "enable", "name"]
driver_dic = tools.input_dic(values, obj_dic)
gslb_obj = {}
gslb_obj["gmember_name"] = obj_dic['name']
gslb_obj["current_user"] = self.auth_name
dic = tools.dict_merge(driver_dic, gslb_obj)
dic.pop('name')
LOG.info(_LI("create the gmember values with dic format"
"is %(json)s of dervice"), {"json": dic})
url = (self.host + ":" + str(self.port) +
'/dc/' + obj_dic["gslb_zone_name"] + "/gmember")
LOG.info(_LI("create gmember url:" + url))
return {"refcnt": "10", "id": "test_gmember_id"}
示例6: list
def list(self, req, *args, **kwargs):
try:
url = req.url
if len(args) > 1:
raise BadRequest(resource="SecurityZone getAll", msg=url)
context = req.context
body_values = json.loads(req.body)
valid_attributes = ["tenant_id", "dc_name", "network_zone"]
values = tools.validat_values(body_values, valid_attributes)
# get_all the SecurityZone values with dic format
LOG.info(_LI("get_all SecurityZone body is %(json)s"), {"json": body_values})
response = self.manager.get_securityZones(context, values)
return response
except Nca47Exception as e:
self.response.status = e.code
LOG.error(_LE("Error exception! error info: %" + e.message))
LOG.exception(e)
self.response.status = e.code
return tools.ret_info(e.code, e.message)
except MessagingException as exception:
self.response.status = 500
message = exception.value
return tools.ret_info(self.response.status, message)
except Exception as exception:
LOG.exception(exception)
self.response.status = 500
message = "the values of the body format error"
return tools.ret_info(self.response.status, message)
示例7: show
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)
示例8: update_gmap
def update_gmap(self, context, obj_dic):
name = obj_dic["name"]
gslb_obj = ["enable", "algorithm", "last_resort_pool",
"gpool_list"]
driver_dic = tools.input_dic(gslb_obj, obj_dic)
driver_dic["current_user"] = self.auth_name
LOG.info(_LI("update the gmap values with dic format\
is %(json)s of dervice"),
{"json": driver_dic})
url = (self.host + ":" + str(self.port) + '/gmap/' +
name)
headers = {'Content-type': 'application/json'}
data = json.dumps(driver_dic)
auth = (self.auth_name, self.auth_pw)
LOG.info(_LI("create gmap url:" + url))
return obj_dic
示例9: create
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)
示例10: remove
def remove(self, req, *args, **kwargs):
try:
url = req.url
if len(args) > 1:
raise BadRequest(resource="VRF del", msg=url)
context = req.context
body_values = json.loads(req.body)
valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id']
values = tools.validat_values(body_values, valid_attributes)
# input the vrf values with dic format
LOG.info(_LI("delete the vrf values with dic format\
is %(json)s"),
{"json": body_values})
response = self.manager.del_vrf(context, values)
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 RemoteError 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
return tools.ret_info(self.response.status, e.message)
示例11: remove
def remove(self, req, *args, **kwargs):
try:
url = req.url
if len(args) > 1:
raise BadRequest(resource="SNAT del", msg=url)
context = req.context
body_values = json.loads(req.body)
valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id']
values = tools.validat_values(body_values, valid_attributes)
# input the snat values with dic format
LOG.info(_LI("delete Staticnat body is %(json)s"),
{"json": body_values})
response = self.manager.del_snat(context, values)
return response
except Nca47Exception as e:
self.response.status = e.code
LOG.error(_LE('Error exception! error info: %' + e.message))
LOG.exception(e)
self.response.status = e.code
return tools.ret_info(e.code, e.message)
except MessagingException as exception:
self.response.status = 500
message = exception.value
return tools.ret_info(self.response.status, message)
except Exception as exception:
LOG.exception(exception)
self.response.status = 500
message = "the values of the body format error"
return tools.ret_info(self.response.status, message)
示例12: create
def create(self, req, *args, **kwargs):
try:
url = req.url
if len(args) > 1:
raise BadRequest(resource="SecurityZone create", msg=url)
context = req.context
body_values = json.loads(req.body)
# ADTEC_COMMENT: 需要加上vfwname 参数
valid_attributes = ["tenant_id", "dc_name", "network_zone", "name", "ifnames", "priority"]
values = tools.validat_values(body_values, valid_attributes)
# input the SecurityZone values with dic format
LOG.info(_LI("input add_SecurityZone body is %(json)s"), {"json": body_values})
values["name"] = values["tenant_id"] + "_" + values["network_zone"] + "_" + values["name"]
response = self.manager.create_securityZone(context, values)
return response
except Nca47Exception as e:
self.response.status = e.code
LOG.error(_LE("Error exception! error info: %" + e.message))
LOG.exception(e)
self.response.status = e.code
return tools.ret_info(e.code, e.message)
except MessagingException as exception:
self.response.status = 500
message = exception.value
return tools.ret_info(self.response.status, message)
except Exception as exception:
LOG.exception(exception)
self.response.status = 500
message = "the values of the body format error"
return tools.ret_info(self.response.status, message)
示例13: get_rrs
def get_rrs(self, context, zone_id):
url = (self.host + ":" + str(self.port) + '/views/' + self.view_id +
'/zones/' + zone_id + '/rrs')
LOG.info(_LI("get_rrs :" + url))
res = {
"total_size": 2, "page_num": 1,
"resources":
[
{
"comment": "", "name": "www.baidu.",
"type": "NS", "ttl": 3600, "state": "",
"href": "/views/default/zones/www.baidu/rrs/"
"www.baidu.$3600$NS$bnMud3d3LmJhaWR1Lg==",
"klass": "IN", "rdata": "ns.www.baidu.",
"reverse_name": "baidu.www",
"id": "www.baidu.$3600$NS$bnMud3d3LmJhaWR1Lg==",
"is_shared": ""
},
{
"comment": "", "name": "ns.www.baidu.",
"type": "A", "ttl": 3600, "state": "",
"href": "/views/default/zones/www.baidu/rrs/"
"ns.www.baidu.$3600$A$MTI3LjAuMC4x",
"klass": "IN", "rdata": "127.0.0.1",
"reverse_name": "baidu.www.ns",
"id": "ns.www.baidu.$3600$A$MTI3LjAuMC4x",
"is_shared": ""
}
],
"page_size": 2
}
return res
示例14: list
def list(self, req, *args, **kwargs):
try:
url = req.url
# if len(args) > 1:
# raise BadRequest(resource="gslb_zone getAll", msg=url)
context = req.context
search_opts = {}
search_opts.update(req.GET)
# input the staticnat values with dic format
LOG.info(_LI("get_all the gslb_zone"))
response = self.manager.get_gslb_zones(context, search_opts)
return response
except Nca47Exception as e:
self.response.status = e.code
LOG.error(_LE('Error exception! error info: %' + e.message))
LOG.exception(e)
self.response.status = e.code
return tools.ret_info(e.code, e.message)
except RemoteError as exception:
self.response.status = 500
message = exception.value
return tools.ret_info(self.response.status, message)
except Exception as e:
LOG.exception(e)
self.response.status = 500
return tools.ret_info(self.response.status, e.message)
示例15: remove
def remove(self, req, id, *args, **kwargs):
try:
url = req.url
# if len(args) > 1:
# raise BadRequest(resource="gslb_zone del", msg=url)
context = req.context
body_values={}
# body_values = json.loads(req.body)
gslb_zone_id = id
body_values["id"] = gslb_zone_id
# input the gslb_zone values with dic format
LOG.info(_LI("delete the gslb_zone values with dic format\
is %(json)s"),
{"json": body_values})
response = self.manager.del_gslb_zone(context, body_values)
return response
except Nca47Exception as e:
self.response.status = e.code
LOG.error(_LE('Error exception! error info: %' + e.message))
LOG.exception(e)
self.response.status = e.code
return tools.ret_info(e.code, e.message)
except RemoteError as exception:
self.response.status = 500
message = exception.value
return tools.ret_info(self.response.status, message)
except Exception as e:
LOG.exception(e)
self.response.status = 500
return tools.ret_info(self.response.status, e.message)