当前位置: 首页>>代码示例>>Python>>正文


Python xml_utils.loads函数代码示例

本文整理汇总了Python中networkapi.infrastructure.xml_utils.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Trata as requisições de POST para inserir um grupo de equipamento.

        URL: egrupo/
        """
        try:
            if not has_perm(user, AdminPermission.EQUIPMENT_GROUP_MANAGEMENT, AdminPermission.WRITE_OPERATION):
                return self.not_authorized()

            xml_map, attrs_map = loads(request.raw_post_data)
            self.log.debug('XML_MAP: %s', xml_map)

            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.')

            egroup_map = networkapi_map.get('grupo')
            if egroup_map is None:
                return self.response_error(3, u'Não existe valor para a tag grupo do XML de requisição.')

            name = egroup_map.get('nome')
            if not is_valid_string_maxsize(name, 100):
                self.log.error(u'Parameter name is invalid. Value: %s', name)
                raise InvalidValueError(None, 'name', name)

            egroup = EGrupo()
            egroup.nome = name
            egroup.create(user)

            return self.response(dumps_networkapi({'grupo': {'id': egroup.id}}))

        except InvalidValueError, e:
            return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:33,代码来源:GrupoResource.py

示例2: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Handle POST requests to set Environment template

            URLs: /environment/set_template/<environment_id>/
        """

        try:

            environment_id = kwargs.get('environment_id')
            if not is_valid_int_greater_equal_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)

            if not has_perm(user,
                            AdminPermission.VLAN_MANAGEMENT,
                            AdminPermission.WRITE_OPERATION):
                return self.not_authorized()

            xml_map, attrs_map = loads(request.raw_post_data)

            self.log.debug('XML_MAP: %s', xml_map)

            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('environment')
            if environment_map is None:
                return self.response_error(3, u'Não existe valor para a tag ambiente do XML de requisição.')

            name = environment_map.get('name')
            network = environment_map.get('network')

            if int(environment_id) != 0:

                Ambiente().get_by_pk(environment_id)

                if network == IP_VERSION.IPv4[1]:
                    Ambiente.objects.filter(
                        id=environment_id).update(ipv4_template=name)
                elif network == IP_VERSION.IPv6[1]:
                    Ambiente.objects.filter(
                        id=environment_id).update(ipv6_template=name)
                else:
                    return self.response_error(269, 'network', network)
            else:
                if network == IP_VERSION.IPv4[1]:
                    Ambiente.objects.filter(
                        ipv4_template=name).update(ipv4_template='')
                elif network == IP_VERSION.IPv6[1]:
                    Ambiente.objects.filter(
                        ipv6_template=name).update(ipv6_template='')
                else:
                    return self.response_error(269, 'network', network)

            return self.response(dumps_networkapi({}))

        except InvalidValueError, e:
            return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:60,代码来源:EnvironmentSetTemplateResource.py

示例3: 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

示例4: handle_get

    def handle_get(self, request, user, *args, **kwargs):
        """Trata uma requisição PUT para alterar informações de um channel.
        URL: channel/get-by-name/
        """
        # Get request data and check permission

        try:
            self.log.info("Get Channel")

            # User permission
            if not has_perm(user, AdminPermission.EQUIPMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
                self.log.error(
                    u'User does not have permission to perform the operation.')
                raise UserNotAuthorizedError(None)

            # Get XML data
            xml_map, attrs_map = loads(request.raw_post_data)

            networkapi_map = xml_map.get('networkapi')
            if networkapi_map is None:
                return self.response_error(3, u'There is no networkapi tag in XML request.')

            channel_name = kwargs.get('channel_name')

            channel = PortChannel.get_by_name(channel_name)
            channel = model_to_dict(channel)

            return self.response(dumps_networkapi({'channel': channel}))


        except InvalidValueError, e:
            return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:32,代码来源:InterfaceChannelResource.py

示例5: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Handles POST requests to save a new Rule

        URL: rule/save/
        """
        try:
            self.log.info('Save rule to 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)

            # 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.')

            rule_map = networkapi_map.get('map')
            if rule_map is None:
                return self.response_error(3, u'There is no value to the environment_vip tag  of XML request.')

            # Get XML data
            id_env = rule_map['id_env']
            name = rule_map['name']
            contents = rule_map['contents'] if type(
                rule_map['contents']) is list else [rule_map['contents'], ]
            blocks_id = rule_map['blocks_id'] if type(
                rule_map['blocks_id']) is list else [rule_map['blocks_id'], ]

            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)

            if not name or len(name) > 80:
                self.log.error(
                    u'The name parameter is not a valid value: %s.', name)
                raise InvalidValueError(None, 'name', name)

            environment = Ambiente.get_by_pk(id_env)

            new_rule = Rule()
            new_rule.name = name
            new_rule.environment = environment
            new_rule.save()

            self.__save_rule_contents(
                contents, blocks_id, environment, new_rule, user)

            return self.response(dumps_networkapi({}))

        except AmbienteNotFoundError, e:
            self.log.error('Environment not found')
            return self.response_error(112)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:59,代码来源:RuleResource.py

示例6: handle_put

    def handle_put(self, request, user, *args, **kwargs):
        """Treat PUT requests to edit Access Type.

        URL: /tipoacesso/<id_tipo_acesso>/

        """

        try:
            if not has_perm(user, AdminPermission.ACCESS_TYPE_MANAGEMENT, AdminPermission.WRITE_OPERATION):
                self.log.error(u"User does not have permission to perform the operation.")
                raise UserNotAuthorizedError(None)

            # Valid Access Type ID
            tipo_acesso_id = kwargs.get("id_tipo_acesso")
            if not is_valid_int_greater_zero_param(tipo_acesso_id):
                self.log.error(u"The tipo_acesso_id parameter is not a valid value: %s.", tipo_acesso_id)
                raise InvalidValueError(None, "tipo_acesso_id", tipo_acesso_id)

            xml_map, attrs_map = loads(request.raw_post_data)

            networkapi_map = xml_map.get("networkapi")
            if networkapi_map is None:
                return self.response_error(3, u"There is no networkapi tag in request XML.")

            tipo_acesso_map = networkapi_map.get("tipo_acesso")
            if tipo_acesso_map is None:
                return self.response_error(3, u"There is no tipo_acesso tag in request XML.")

            # Valid protocol
            protocol = tipo_acesso_map.get("protocolo")
            if (
                not is_valid_string_minsize(protocol, 3)
                or not is_valid_string_maxsize(protocol, 45)
                or not is_valid_regex(protocol, r"^[- a-zA-Z0-9]+$")
            ):
                self.log.error(u"Parameter protocol is invalid. Value: %s", protocol)
                raise InvalidValueError(None, "protocol", protocol)

            # Verify existence
            tpa = TipoAcesso.get_by_pk(tipo_acesso_id)

            tpa.protocolo = protocol

            try:
                if len(TipoAcesso.objects.filter(protocolo__iexact=protocol).exclude(id=tpa.id)) > 0:
                    raise DuplicateProtocolError(None, u"Access Type with protocol %s already exists" % protocol)
            except TipoAcesso.DoesNotExist:
                pass

            with distributedlock(LOCK_TYPE_ACCESS % tipo_acesso_id):

                try:
                    # save access type
                    tpa.save(user)
                except Exception, e:
                    self.log.error(u"Failed to update TipoAcesso.")
                    raise TipoAcessoError(e, u"Failed to update TipoAcesso.")

            return self.response(dumps_networkapi({}))
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:59,代码来源:TipoAcessoResource.py

示例7: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Treat requests POST to add Brand.

        URL: brand/
        """

        try:

            self.log.info("Add Brand")

            # User permission
            if not has_perm(user, AdminPermission.BRAND_MANAGEMENT, 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.')

            brand_map = networkapi_map.get('brand')
            if brand_map is None:
                return self.response_error(3, u'There is no value to the brand tag  of XML request.')

            # Get XML data
            name = brand_map.get('name')

            # Valid name
            if not is_valid_string_minsize(name, 3) or not is_valid_string_maxsize(name, 100):
                self.log.error(u'Parameter name is invalid. Value: %s', name)
                raise InvalidValueError(None, 'name', name)

            try:
                Marca.get_by_name(name)
                raise MarcaNameDuplicatedError(
                    None, u'Marca com o nome %s já cadastrada.' % name)
            except MarcaNotFoundError:
                pass

            brand = Marca()

            # set variables
            brand.nome = name

            try:
                # save Brand
                brand.save(user)
            except Exception, e:
                self.log.error(u'Failed to save the Brand.')
                raise EquipamentoError(e, u'Failed to save the Brand.')

            brand_map = dict()
            brand_map['brand'] = model_to_dict(brand, exclude=["nome"])

            return self.response(dumps_networkapi(brand_map))
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:59,代码来源:BrandAddResource.py

示例8: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Trata as requisições de POST para alterar a senha de um Usuario.

        URL: user-change-pass/
        """

        try:
            xml_map, attrs_map = loads(request.raw_post_data)
            self.log.info('Change user password')

            # User permission
            if not has_perm(user, AdminPermission.AUTHENTICATE, AdminPermission.WRITE_OPERATION):
                self.log.error(
                    u'User does not have permission to perform the operation.')
                raise UserNotAuthorizedError(None)

            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.')

            user_map = networkapi_map.get('user')
            if user_map is None:
                return self.response_error(3, u'Não existe valor para a tag usuario do XML de requisição.')

            # Get XML data
            id_user = user_map.get('user_id')
            password = user_map.get('password')

            # 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 pwd
            if not is_valid_string_minsize(password, 3) or not is_valid_string_maxsize(password, 45):
                self.log.error(u'Parameter password is invalid. Value: ****')
                raise InvalidValueError(None, 'password', '****')

            # Find User by ID to check if it exist
            usr = Usuario.get_by_pk(id_user)

            with distributedlock(LOCK_USER % id_user):

                # set variable
                usr.pwd = hashlib.md5(password).hexdigest()

                try:
                    # update User
                    usr.save(user)
                except Exception, e:
                    self.log.error(u'Failed to update the user.')
                    raise UsuarioError(e, u'Failed to update the user.')

                return self.response(dumps_networkapi({}))

        except InvalidValueError, e:
            return self.response_error(269, e.param, e.value)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:58,代码来源:UsuarioChangePassResource.py

示例9: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Trata as requisições de POST para inserir um Roteiro.

        URL: roteiro/
        """

        try:
            if not has_perm(user, AdminPermission.SCRIPT_MANAGEMENT, AdminPermission.WRITE_OPERATION):
                return self.not_authorized()

            xml_map, attrs_map = loads(request.raw_post_data)
            self.log.debug('XML_MAP: %s', xml_map)

            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.')

            script_map = networkapi_map.get('roteiro')
            if script_map is None:
                return self.response_error(3, u'Não existe valor para a tag roteiro do XML de requisição.')

            script_type_id = script_map.get('id_tipo_roteiro')
            if script_type_id is None:
                return self.response_error(194)

            script_name = script_map.get('nome')
            if script_name is None:
                return self.response_error(195)

            script = Roteiro()

            script.tipo_roteiro = TipoRoteiro()
            try:
                script.tipo_roteiro.id = int(script_type_id)
            except (TypeError, ValueError):
                self.log.error(
                    u'Valor do id_tipo_roteiro inválido: %s.', script_type_id)
                return self.response_error(158, script_type_id)

            script.roteiro = script_name
            script.descricao = script_map.get('descricao')

            script.create(user)

            script_map = dict()
            script_map['id'] = script.id
            networkapi_map = dict()
            networkapi_map['roteiro'] = script_map

            return self.response(dumps_networkapi(networkapi_map))

        except TipoRoteiroNotFoundError:
            return self.response_error(158, script_type_id)
        except RoteiroNameDuplicatedError:
            return self.response_error(250, script_name)
        except XMLError, x:
            self.log.error(u'Erro ao ler o XML da requisicao.')
            return self.response_error(3, x)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:58,代码来源:RoteiroResource.py

示例10: handle_put

    def handle_put(self, request, user, *args, **kwargs):
        """Treat requests PUT to change Environment VIP.

        URL: environmentvip/<id_environment_vip>/
        """

        try:

            self.log.info('Change Environment VIP')

            id_environment_vip = kwargs.get('id_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.')

            # Valid Environment VIP ID
            if not is_valid_int_greater_zero_param(id_environment_vip):
                self.log.error(
                    u'The id_environment_vip parameter is not a valid value: %s.', id_environment_vip)
                raise InvalidValueError(
                    None, 'id_environment_vip', id_environment_vip)

            # Find Environment VIP by ID to check if it exist
            environment_vip = EnvironmentVip.get_by_pk(id_environment_vip)

            with distributedlock(LOCK_ENVIRONMENT_VIP % id_environment_vip):

                # Valid Environment Vip
                environment_vip.valid_environment_vip(environmentvip_map)

                try:
                    # Update Environment Vip
                    environment_vip.save()
                except Exception, e:
                    self.log.error(u'Failed to update the environment vip.')
                    raise EnvironmentVipError(
                        e, u'Failed to update the environment vip')

                return self.response(dumps_networkapi({}))

        except InvalidValueError, e:
            return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:57,代码来源:EnvironmentVipResource.py

示例11: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        '''Trata as requisições de POST para inserir uma requisição de VIP.'''

        try:
            xml_map, attrs_map = loads(
                request.raw_post_data, ['transbordo', 'porta', 'real'])
        except XMLError, x:
            self.log.error(u'Erro ao ler o XML da requisição.')
            return self.response_error(3, x)
开发者ID:andrewsmedina,项目名称:GloboNetworkAPI,代码行数:9,代码来源:RequisicaoVipsResource.py

示例12: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Treat requests POST to add Logical Environment.

        URL: logicalenvironment/
        """

        try:

            self.log.info('Add Logical Environment')

            # 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)

            # 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.')

            logical_environment_map = networkapi_map.get('logical_environment')
            if logical_environment_map is None:
                return self.response_error(3, u'There is no value to the logical_environment tag  of XML request.')

            # Get XML data
            name = logical_environment_map.get('name')

            try:
                AmbienteLogico.get_by_name(name)
                raise AmbienteLogicoNameDuplicatedError(
                    None, u'Já existe um Ambiente Lógico com o valor name %s.' % name)
            except AmbienteLogicoNotFoundError:
                pass

            log_env = AmbienteLogico()

            # set variables
            log_env.nome = name

            try:
                # save Logical Environment
                log_env.save()
            except Exception, e:
                self.log.error(u'Failed to save the Logical Environment.')
                raise AmbienteError(
                    e, u'Failed to save the Logical Environment.')

            log_env_map = dict()
            log_env_map['logical_environment'] = model_to_dict(
                log_env, exclude=['nome'])

            return self.response(dumps_networkapi(log_env_map))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:56,代码来源:LogicalEnvironmentAddResource.py

示例13: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Treat requests POST to add Division Dc.

        URL: divisiondc/
        """

        try:

            self.log.info('Add Division Dc')

            # 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)

            # 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.')

            division_dc_map = networkapi_map.get('division_dc')
            if division_dc_map is None:
                return self.response_error(3, u'There is no value to the division_dc tag  of XML request.')

            # Get XML data
            name = division_dc_map.get('name')

            try:
                DivisaoDc.get_by_name(name)
                raise DivisaoDcNameDuplicatedError(
                    None, u'Já existe um divisào dc com o valor name %s.' % name)
            except DivisaoDcNotFoundError:
                pass

            division_dc = DivisaoDc()

            # set variables
            division_dc.nome = name

            try:
                # save Division Dc
                division_dc.save()
            except Exception, e:
                self.log.error(u'Failed to save the Division Dc.')
                raise AmbienteError(e, u'Failed to save the Division Dc.')

            division_dc_map = dict()
            division_dc_map['division_dc'] = model_to_dict(
                division_dc, exclude=['nome'])

            return self.response(dumps_networkapi(division_dc_map))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:55,代码来源:DivisionDcAddResource.py

示例14: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        """Treat requests POST to add Group l3.

        URL: groupl3/
        """

        try:

            self.log.info('Add Group l3')

            # 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)

            # 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.')

            group_l3_map = networkapi_map.get('group_l3')
            if group_l3_map is None:
                return self.response_error(3, u'There is no value to the group_l3 tag  of XML request.')

            # Get XML data
            name = group_l3_map.get('name')

            try:
                GrupoL3.get_by_name(name)
                raise GrupoL3NameDuplicatedError(
                    None, u'Já existe um grupo l3 com o valor name %s.' % name)
            except GroupL3NotFoundError:
                pass

            l3_group = GrupoL3()

            # set variables
            l3_group.nome = name

            try:
                # save Group l3
                l3_group.save()
            except Exception, e:
                self.log.error(u'Failed to save the Group l3.')
                raise AmbienteError(e, u'Failed to save the Group l3.')

            l3_group_map = dict()
            l3_group_map['group_l3'] = model_to_dict(
                l3_group, exclude=['nome'])

            return self.response(dumps_networkapi(l3_group_map))
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:55,代码来源:GroupL3AddResource.py

示例15: handle_post

    def handle_post(self, request, user, *args, **kwargs):
        '''Trata as requisições de POST para inserir um IP e associá-lo a um equipamento.

        URL: ip/
        '''

        try:
            xml_map, attrs_map = loads(request.raw_post_data)
        except XMLError, x:
            self.log.error(u'Erro ao ler o XML da requisição.')
            return self.response_error(3, x)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:11,代码来源:IpResource.py


注:本文中的networkapi.infrastructure.xml_utils.loads函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。