本文整理汇总了Python中networkapi.util.is_valid_int_greater_zero_param函数的典型用法代码示例。如果您正苦于以下问题:Python is_valid_int_greater_zero_param函数的具体用法?Python is_valid_int_greater_zero_param怎么用?Python is_valid_int_greater_zero_param使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_valid_int_greater_zero_param函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handle_post
def handle_post(self, request, user, *args, **kwargs):
"""Handles POST requests associate environment to ip config
URL: ipconfig/
"""
try:
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
return self.not_authorized()
# Business Validations
# 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'Não existe valor para a tag networkapi do XML de requisição.')
environment_map = networkapi_map.get('ambiente')
if environment_map is None:
return self.response_error(3, u'Não existe valor para a tag ambiente do XML de requisição.')
# Get XML data
id_environment = environment_map.get('id_environment')
id_ip_config = environment_map.get('id_ip_config')
# Valid environment
if not is_valid_int_greater_zero_param(id_environment):
raise InvalidValueError(None, 'id_environment', id_environment)
# Valid ip config
if not is_valid_int_greater_zero_param(id_ip_config):
raise InvalidValueError(None, 'id_ip_config', id_ip_config)
# Environment must exists
environment = Ambiente().get_by_pk(id_environment)
# Ip config must exists
ip_conf = IPConfig().get_by_pk(id_ip_config)
# Makes the relationship
config = ConfigEnvironment()
config.ip_config = ip_conf
config.environment = environment
config.save(user)
# Make return xml
conf_env_map = dict()
conf_env_map['id_config_do_ambiente'] = config.id
return self.response(dumps_networkapi({'config_do_ambiente': conf_env_map}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:60,代码来源:EnvironmentIpConfigResource.py
示例2: handle_put
def handle_put(self, request, user, *args, **kwargs):
'''Trata as requisições de PUT para inserir o relacionamento entre IP e Equipamento.
URL: ip/<id_ip>/equipamento/<id_equipamento>/$
'''
try:
ip_id = kwargs.get('id_ip')
equip_id = kwargs.get('id_equipamento')
if not is_valid_int_greater_zero_param(ip_id):
self.log.error(
u'The ip_id parameter is not a valid value: %s.', ip_id)
raise InvalidValueError(None, 'ip_id', ip_id)
if not is_valid_int_greater_zero_param(equip_id):
self.log.error(
u'The equip_id parameter is not a valid value: %s.', equip_id)
raise InvalidValueError(None, 'equip_id', equip_id)
Ip.get_by_pk(ip_id)
with distributedlock(LOCK_IP_EQUIPMENT % (ip_id, equip_id)):
ip_equipment = insert_ip_equipment(ip_id, equip_id, user)
ipequipamento_map = dict()
ipequipamento_map['id'] = ip_equipment.id
map = dict()
map['ip_equipamento'] = ipequipamento_map
return self.response(dumps_networkapi(map))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:34,代码来源:IpResource.py
示例3: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""
Handles DELETE requests to create a relationship of Environment with EnvironmentVip.
URL: environment/<environment_id>/environmentvip/<environment_vip_id>/
"""
self.log.info("Remove a relationship of Environment with EnvironmentVip")
try:
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
self.log.error(u"User does not have permission to perform the operation.")
raise UserNotAuthorizedError(None)
# Valid Environment
environment_id = kwargs.get("environment_id")
if not is_valid_int_greater_zero_param(environment_id):
self.log.error(u"The environment_id parameter is not a valid value: %s.", environment_id)
raise InvalidValueError(None, "environment_id", environment_id)
# Valid EnvironmentVip ID
environment_vip_id = kwargs.get("environment_vip_id")
if not is_valid_int_greater_zero_param(environment_vip_id):
self.log.error(u"The id_environment_vip parameter is not a valid value: %s.", environment_vip_id)
raise InvalidValueError(None, "environment_vip_id", environment_vip_id)
# Business Validations
# Existing Environment ID
environment = Ambiente.get_by_pk(environment_id)
# Existing EnvironmentVip ID
environment_vip = EnvironmentVip.get_by_pk(environment_vip_id)
# Business Rules
environment_environment_vip = EnvironmentEnvironmentVip().get_by_environment_environment_vip(
environment.id, environment_vip.id
)
server_pool_list = EnvironmentEnvironmentVip.get_server_pool_member_by_environment_environment_vip(
environment_environment_vip
)
# Valid integraty between environment/environmentvip related with reals
# if exists reals fot this environment then raise a exception
if server_pool_list:
raise EnvironmentEnvironmentServerPoolLinked({"environment": environment.name})
# Delete
environment_environment_vip.delete()
# Return nothing
return self.response(dumps_networkapi({}))
except UserNotAuthorizedError:
return self.not_authorized()
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:59,代码来源:EnvironmentEnvironmentVipAssociationResource.py
示例4: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Treat DELETE requests to remove IP and Equipment relationship.
URL: ip/<id_ip>/equipamento/<id_equipamento>/$
"""
try:
ip_id = kwargs.get('id_ip')
equip_id = kwargs.get('id_equipamento')
if not is_valid_int_greater_zero_param(ip_id):
self.log.error(
u'The ip_id parameter is not a valid value: %s.', ip_id)
raise InvalidValueError(None, 'ip_id', ip_id)
if not is_valid_int_greater_zero_param(equip_id):
self.log.error(
u'The equip_id parameter is not a valid value: %s.', equip_id)
raise InvalidValueError(None, 'equip_id', equip_id)
Ip.get_by_pk(ip_id)
Equipamento.get_by_pk(equip_id)
with distributedlock(LOCK_IP_EQUIPMENT % (ip_id, equip_id)):
ipv4 = Ip.get_by_pk(ip_id)
equipament = Equipamento.get_by_pk(equip_id)
# Delete vlan's cache
destroy_cache_function([ipv4])
# delete equipment's cache
destroy_cache_function([equip_id], True)
server_pool_member_list = ServerPoolMember.objects.filter(
ip=ipv4)
if server_pool_member_list.count() != 0:
# IP associated with Server Pool
server_pool_name_list = set()
for member in server_pool_member_list:
item = '{}: {}'.format(
member.server_pool.id, member.server_pool.identifier)
server_pool_name_list.add(item)
server_pool_name_list = list(server_pool_name_list)
server_pool_identifiers = ', '.join(server_pool_name_list)
raise IpCantRemoveFromServerPool({'ip': mount_ipv4_string(ipv4), 'equip_name': equipament.nome, 'server_pool_identifiers': server_pool_identifiers},
'Ipv4 não pode ser disassociado do equipamento %s porque ele está sendo utilizando nos Server Pools (id:identifier) %s' % (equipament.nome, server_pool_identifiers))
remove_ip_equipment(ip_id, equip_id, user)
return self.response(dumps_networkapi({}))
except IpCantRemoveFromServerPool, e:
return self.response_error(385, e.cause.get('ip'), e.cause.get('equip_name'), e.cause.get('server_pool_identifiers'))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:59,代码来源:IpResource.py
示例5: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""
Handles DELETE requests to remove a relationship of OptionVip with EnvironmentVip.
URL: optionvip/<id_option_vip>/environmentvip/<id_environment_vip>/
"""
self.log.info("Remove a relationship of OptionVip with EnvironmentVip")
try:
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.OPTION_VIP, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Valid OptionVip ID
option_vip_id = kwargs.get('id_option_vip')
if not is_valid_int_greater_zero_param(option_vip_id):
self.log.error(
u'The id_option_vip parameter is not a valid value: %s.', option_vip_id)
raise InvalidValueError(None, 'id_option_vip', option_vip_id)
# Valid EnvironmentVip ID
environment_vip_id = kwargs.get('id_environment_vip')
if not is_valid_int_greater_zero_param(environment_vip_id):
self.log.error(
u'The id_environment_vip parameter is not a valid value: %s.', environment_vip_id)
raise InvalidValueError(
None, 'id_environment_vip', environment_vip_id)
# Business Validations
# Existing OptionVip ID
option_vip = OptionVip.get_by_pk(option_vip_id)
# Existing EnvironmentVip ID
environment_vip = EnvironmentVip.get_by_pk(environment_vip_id)
# Business Rules
# Find
opt_vip_env_vip = OptionVipEnvironmentVip().get_by_option_environment(
option_vip.id, environment_vip.id)
# Delete
opt_vip_env_vip.delete()
# Return nothing
return self.response(dumps_networkapi({}))
except UserNotAuthorizedError:
return self.not_authorized()
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:58,代码来源:OptionVipEnvironmentVipAssociationResource.py
示例6: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Treat DELETE requests to dissociate User and Group.
URL: usergroup/user/<id_user>/ugroup/<id_group>/dissociate/
"""
try:
self.log.info('Dissociate User and Group.')
# User permission
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_user = kwargs.get('id_user')
id_group = kwargs.get('id_group')
# Valid ID User
if not is_valid_int_greater_zero_param(id_user):
self.log.error(
u'The id_user parameter is not a valid value: %s.', id_user)
raise InvalidValueError(None, 'id_user', id_user)
# Valid ID Group
if not is_valid_int_greater_zero_param(id_group):
self.log.error(
u'The id_group parameter is not a valid value: %s.', id_group)
raise InvalidValueError(None, 'id_group', id_group)
# Find User by ID to check if it exist
Usuario.get_by_pk(id_user)
# Find Group by ID to check if it exist
UGrupo.get_by_pk(id_group)
# Find UserGroup by ID to check if it exist
user_group = UsuarioGrupo.get_by_user_group(id_user, id_group)
with distributedlock(LOCK_USER_GROUP % (id_user, id_group)):
try:
# remove UserGroup
user_group.delete()
except Exception, e:
self.log.error(u'Failed to remove the UserGroup.')
raise GrupoError(e, u'Failed to remove the UserGroup.')
return self.response(dumps_networkapi({}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:55,代码来源:UserGroupDissociateResource.py
示例7: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Trata as requisições de GET para listar os direitos de grupo de usuários em grupo de equipamentos.
URLs: direitosgrupoequipamento/$
direitosgrupoequipamento/ugrupo/<id_grupo_usuario>/$
direitosgrupoequipamento/egrupo/<id_grupo_equipamento>/$
direitosgrupoequipamento/<id_direito>/$
"""
try:
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.READ_OPERATION):
return self.not_authorized()
map_list = []
right_id = kwargs.get('id_direito')
if not is_valid_int_greater_zero_param(right_id, False):
self.log.error(
u'The right_id parameter is not a valid value: %s.', right_id)
raise InvalidValueError(None, 'right_id', right_id)
if right_id is not None:
map_list.append(
self.__get_direito_map(DireitosGrupoEquipamento.get_by_pk(right_id)))
else:
ugroup = kwargs.get('id_grupo_usuario')
egroup = kwargs.get('id_grupo_equipamento')
if not is_valid_int_greater_zero_param(ugroup, False):
self.log.error(
u'The ugroup_id parameter is not a valid value: %s.', ugroup)
raise InvalidValueError(None, 'ugroup_id', ugroup)
if not is_valid_int_greater_zero_param(egroup, False):
self.log.error(
u'The egroup_id parameter is not a valid value: %s.', egroup)
raise InvalidValueError(None, 'egroup_id', egroup)
if ugroup is not None:
UGrupo.get_by_pk(ugroup)
if egroup is not None:
EGrupo.get_by_pk(egroup)
rights = DireitosGrupoEquipamento.search(ugroup, None, egroup)
for right in rights:
map_list.append(self.__get_direito_map(right))
return self.response(dumps_networkapi({'direito_grupo_equipamento': map_list}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:53,代码来源:GrupoResource.py
示例8: handle_put
def handle_put(self, request, user, *args, **kwargs):
"""Treat PUT requests to associate Filter and TipoEquipamento.
URL: filter/<filter_id>/equiptype/<equiptype_id>
"""
try:
self.log.info('')
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
return self.not_authorized()
if not is_valid_int_greater_zero_param(kwargs['id_filter']):
self.log.error(
u'Parameter id_filter is invalid. Value: %s.', kwargs['id_filter'])
raise InvalidValueError(None, 'id_filter', kwargs['id_filter'])
else:
# Check existence
fil = Filter().get_by_pk(kwargs['id_filter'])
if not is_valid_int_greater_zero_param(kwargs['id_equiptype']):
self.log.error(
u'Parameter id_equiptype is invalid. Value: %s.', kwargs['id_equiptype'])
raise InvalidValueError(
None, 'id_equiptype', kwargs['id_equiptype'])
else:
# Check existence
tp_equip = TipoEquipamento().get_by_pk(kwargs['id_equiptype'])
association = FilterEquipType()
association.filter = fil
association.equiptype = tp_equip
# Check existence
association.validate()
# Save association
association.save()
fil_et_map = dict()
fil_et_map['id'] = association.id
return self.response(dumps_networkapi({'equiptype_filter_xref': fil_et_map}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:50,代码来源:FilterAssociateResource.py
示例9: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Trata uma requisição DELETE para excluir uma informação de acesso a equipamento
URL: /equipamentoacesso/id_equipamento/id_tipo_acesso/
"""
# Verifica acesso e obtém dados do request
try:
# Obtém argumentos passados na URL
id_equipamento = kwargs.get('id_equipamento')
# Valid ID Equipment
if not is_valid_int_greater_zero_param(id_equipamento):
self.log.error(
u'The id_equipamento parameter is not a valid value: %s.', id_equipamento)
raise InvalidValueError(None, 'id_equipamento', id_equipamento)
id_tipo_acesso = kwargs.get('id_tipo_acesso')
# Valid ID Equipment
if not is_valid_int_greater_zero_param(id_tipo_acesso):
self.log.error(
u'The id_tipo_acesso parameter is not a valid value: %s.', id_tipo_acesso)
raise InvalidValueError(None, 'id_tipo_acesso', id_tipo_acesso)
Equipamento.get_by_pk(id_equipamento)
TipoAcesso.get_by_pk(id_tipo_acesso)
# Após obtenção do id_equipamento podemos verificar a permissão
if not has_perm(user,
AdminPermission.EQUIPMENT_MANAGEMENT,
AdminPermission.WRITE_OPERATION,
None,
id_equipamento,
AdminPermission.EQUIP_WRITE_OPERATION):
return self.not_authorized()
with distributedlock(LOCK_EQUIPMENT_ACCESS % id_tipo_acesso):
# Remove a informação de acesso a equipamento
EquipamentoAcesso.remove(user, id_equipamento, id_tipo_acesso)
# Retorna response vazio em caso de sucesso
return self.response(dumps_networkapi({}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:48,代码来源:EquipamentoAcessoResource.py
示例10: handle_get
def handle_get(self, request, user, *args, **kwargs):
try:
self.log.info('Get rules in Environment')
# User permission
if not has_perm(user, AdminPermission.VIP_VALIDATION, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_env = kwargs.get('id_env')
if not is_valid_int_greater_zero_param(id_env):
self.log.error(
u'The id_env parameter is not a valid value: %s.', id_env)
raise InvalidValueError(None, 'id_env', id_env)
Ambiente.objects.get(pk=id_env)
rules = Rule.objects.filter(environment=id_env, vip=None)
rule_list = []
for rule in rules:
rule_list.append(model_to_dict(rule))
return self.response(dumps_networkapi({'rules': rule_list}))
except InvalidValueError, e:
self.log.error(
u'Parameter %s is invalid. Value: %s.', e.param, e.value)
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:28,代码来源:RuleGetResource.py
示例11: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Treat DELETE requests to remove Group User.
URL: ugroup/<id_ugroup>/
"""
try:
self.log.info('Remove Group User')
# User permission
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_ugroup = kwargs.get('id_ugroup')
# Valid Group User ID
if not is_valid_int_greater_zero_param(id_ugroup):
self.log.error(
u'The id_ugroup parameter is not a valid value: %s.', id_ugroup)
raise InvalidValueError(None, 'id_ugroup', id_ugroup)
# Find Group User by ID to check if it exist
ugroup = UGrupo.get_by_pk(id_ugroup)
with distributedlock(LOCK_GROUP_USER % id_ugroup):
ugroup.delete()
return self.response(dumps_networkapi({}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:33,代码来源:GroupUserAlterRemoveResource.py
示例12: generate_and_deploy_channel_config_sync
def generate_and_deploy_channel_config_sync(user, id_channel):
if not is_valid_int_greater_zero_param(id_channel):
raise exceptions.InvalidIdInterfaceException()
channel = PortChannel.get_by_pk(id_channel)
interfaces = channel.list_interfaces()
#group interfaces by equipment
equipment_interfaces = dict()
for interface in interfaces:
if interface.equipamento.id not in equipment_interfaces:
equipment_interfaces[interface.equipamento.id] = []
equipment_interfaces[interface.equipamento.id].append(interface)
files_to_deploy = {}
for equipment_id in equipment_interfaces.keys():
grouped_interfaces = equipment_interfaces[equipment_id]
file_to_deploy = _generate_config_file(grouped_interfaces)
files_to_deploy[equipment_id] = file_to_deploy
#TODO Deploy config file
#make separate threads
for equipment_id in files_to_deploy.keys():
lockvar = LOCK_INTERFACE_DEPLOY_CONFIG % (equipment_id)
equipamento = Equipamento.get_by_pk(equipment_id)
status_deploy = deploy_config_in_equipment_synchronous(files_to_deploy[equipment_id], equipamento, lockvar)
return status_deploy
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:30,代码来源:facade.py
示例13: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Treat DELETE requests to remove Filters.
URL: filter/<id_filter>/
"""
try:
self.log.info('Remove Filter')
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
return self.not_authorized()
if not is_valid_int_greater_zero_param(kwargs['id_filter']):
self.log.error(
u'Parameter id_filter is invalid. Value: %s.', kwargs['id_filter'])
raise InvalidValueError(None, 'id_filter', kwargs['id_filter'])
else:
# Check existence
fil = Filter().get_by_pk(kwargs['id_filter'])
try:
# Remove filter and its relationships
fil.delete()
except Exception, e:
self.log.error(u'Failed to remove the filter.')
raise e
return self.response(dumps_networkapi({}))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:33,代码来源:FilterAlterRemoveResource.py
示例14: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Treat requests GET to get Group User.
URL: ugroup/get/<id_ugroup>/
"""
try:
self.log.info("Get Group User by ID")
id_ugroup = kwargs.get('id_ugroup')
# User permission
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.READ_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Valid Group User ID
if not is_valid_int_greater_zero_param(id_ugroup):
self.log.error(
u'The id_ugroup parameter is not a valid value: %s.', id_ugroup)
raise InvalidValueError(None, 'id_ugroup', id_ugroup)
# Find Group User by ID to check if it exist
ugroup = UGrupo.get_by_pk(id_ugroup)
ugroup_map = dict()
ugroup_map['user_group'] = model_to_dict(ugroup)
return self.response(dumps_networkapi(ugroup_map))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:33,代码来源:GroupUserGetByIdResource.py
示例15: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Treat requests DELETE to remove Rule.
URL: rule/delete/<id_rule>/
"""
try:
self.log.info('Delete rule from an environment')
# User permission
if not has_perm(user, AdminPermission.VIP_VALIDATION, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_rule = kwargs.get('id_rule')
if not is_valid_int_greater_zero_param(id_rule):
self.log.error(
u'The id_rule parameter is not a valid value: %s.', id_rule)
raise InvalidValueError(None, 'id_rule', id_rule)
rule = Rule.objects.get(pk=id_rule)
rule.delete()
return self.response(dumps_networkapi({}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:29,代码来源:RuleResource.py
示例16: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Treat requests GET to get Group Equipment.
URL: egroup/<id_egroup>/
"""
try:
self.log.info('Get Group Equipment by ID')
id_egroup = kwargs.get('id_egroup')
# User permission
if not has_perm(user, AdminPermission.EQUIPMENT_GROUP_MANAGEMENT, AdminPermission.READ_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Valid Group Equipment ID
if not is_valid_int_greater_zero_param(id_egroup):
self.log.error(
u'The id_egroup parameter is not a valid value: %s.', id_egroup)
raise InvalidValueError(None, 'id_egroup', id_egroup)
# Find Group Equipment by ID to check if it exist
egroup = EGrupo.get_by_pk(id_egroup)
egroup_map = dict()
egroup_map['group_equipament'] = model_to_dict(egroup)
return self.response(dumps_networkapi(egroup_map))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:33,代码来源:GroupEquipmentResource.py
示例17: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Treat GET requests to get a Filter by id.
URL: filter/get/<id_filter>/
"""
try:
self.log.info("Get Filter by id")
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.ENVIRONMENT_MANAGEMENT, AdminPermission.READ_OPERATION):
self.log.error(u"User does not have permission to perform the operation.")
return self.not_authorized()
if not is_valid_int_greater_zero_param(kwargs["id_filter"]):
self.log.error(u"Parameter id_filter is invalid. Value: %s.", kwargs["id_filter"])
raise InvalidValueError(None, "id_filter", kwargs["id_filter"])
else:
# Check existence
fil = Filter().get_by_pk(kwargs["id_filter"])
filter_dict = model_to_dict(fil)
filter_dict["equip_types"] = list()
for fil_equip_type in fil.filterequiptype_set.all():
filter_dict["equip_types"].append(model_to_dict(fil_equip_type.equiptype))
return self.response(dumps_networkapi({"filter": filter_dict}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:32,代码来源:FilterGetByIdResource.py
示例18: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Treat requests GET to get Administrative Permission by the identifier.
URL: aperms/get/<id_perm>/
"""
try:
self.log.info("Get Administrative Permission by the identifier")
# User permission
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.READ_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_perm = kwargs.get('id_perm')
# Valid Administrative Permission ID
if not is_valid_int_greater_zero_param(id_perm):
self.log.error(
u'The id_perm parameter is not a valid value: %s.', id_perm)
raise InvalidValueError(None, 'id_perm', id_perm)
# Find Administrative Permission by ID to check if it exist
perm = PermissaoAdministrativa.get_by_pk(id_perm)
perms_map = dict()
perms_map['perm'] = model_to_dict(perm)
return self.response(dumps_networkapi(perms_map))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:34,代码来源:AdministrativePermissionGetByIdResource.py
示例19: get_by_pk
def get_by_pk(pk):
"""
Get Vip Request By Pk
:param pk: Identifier For Vip Request
:return: Dict
"""
if not is_valid_int_greater_zero_param(pk):
raise exceptions.InvalidIdVipRequestException()
vip_request = RequisicaoVips.objects.get(id=pk)
data = vip_request.variables_to_map()
data['id'] = vip_request.id
data['validado'] = convert_boolean_to_int(vip_request.validado)
data['vip_criado'] = convert_boolean_to_int(vip_request.vip_criado)
data['id_ip'] = vip_request.ip_id
data['id_ipv6'] = vip_request.ipv6_id
data['id_healthcheck_expect'] = vip_request.healthcheck_expect_id
data['l7_filter'] = vip_request.l7_filter
data['rule_id'] = vip_request.rule_id
data['trafficreturn'] = vip_request.trafficreturn.nome_opcao_txt
data['dsrl3']=999
try:
dsrl3_to_vip_obj = DsrL3_to_Vip.get_by_vip_id(vip_request.id)
data['dsrl3'] = dsrl3_to_vip_obj.id_dsrl3
except ObjectDoesNotExist, e:
pass
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:31,代码来源:facade.py
示例20: handle_get
def handle_get(self, request, user, *args, **kwargs):
"""Treat requests GET to get User by the identifier.
URL: user/get/<id_user>/
"""
try:
self.log.info("Get User by the identifier")
# User permission
if not has_perm(user, AdminPermission.USER_ADMINISTRATION, AdminPermission.READ_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
id_user = kwargs.get('id_user')
# Valid User ID
if not is_valid_int_greater_zero_param(id_user):
self.log.error(
u'The id_user parameter is not a valid value: %s.', id_user)
raise InvalidValueError(None, 'id_user', id_user)
# Find User by ID to check if it exist
usr = Usuario.get_by_pk(id_user)
user_map = dict()
user_map['usuario'] = model_to_dict(usr)
user_map['usuario']['grupos'] = user_map['usuario']['grupos'] if user_map['usuario'][
'grupos'] is not None and len(user_map['usuario']['grupos']) > 0 else [None]
return self.response(dumps_networkapi(user_map))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:35,代码来源:UserGetByIdResource.py
注:本文中的networkapi.util.is_valid_int_greater_zero_param函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论