本文整理汇总了Python中networkapi.ambiente.models.EnvironmentVip.valid_environment_vip方法的典型用法代码示例。如果您正苦于以下问题:Python EnvironmentVip.valid_environment_vip方法的具体用法?Python EnvironmentVip.valid_environment_vip怎么用?Python EnvironmentVip.valid_environment_vip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkapi.ambiente.models.EnvironmentVip
的用法示例。
在下文中一共展示了EnvironmentVip.valid_environment_vip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_post
# 需要导入模块: from networkapi.ambiente.models import EnvironmentVip [as 别名]
# 或者: from networkapi.ambiente.models.EnvironmentVip import valid_environment_vip [as 别名]
def handle_post(self, request, user, *args, **kwargs):
"""Treat requests POST to insert Environment VIP.
URL: environmentvip/
"""
try:
self.log.info('Add Environment VIP')
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_VIP, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Load XML data
xml_map, attrs_map = loads(request.raw_post_data)
# XML data format
networkapi_map = xml_map.get('networkapi')
if networkapi_map is None:
return self.response_error(3, u'There is no value to the networkapi tag of XML request.')
environmentvip_map = networkapi_map.get('environment_vip')
if environmentvip_map is None:
return self.response_error(3, u'There is no value to the environment_vip tag of XML request.')
# New Environment Vip
environment_vip = EnvironmentVip()
# Valid Environment Vip
environment_vip.valid_environment_vip(environmentvip_map)
try:
# Save Environment Vip
environment_vip.save()
except Exception, e:
self.log.error(u'Failed to save the environment vip.')
raise EnvironmentVipError(
e, u'Failed to save the environment vip')
environment_map = dict()
environment_map['id'] = environment_vip.id
return self.response(dumps_networkapi({'environment_vip': environment_map}))