networkapiclient package¶
Submodules¶
networkapiclient.Ambiente module¶
- class networkapiclient.Ambiente.Ambiente(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add_expect_string_healthcheck(expect_string)[source]¶
Inserts a new healthckeck_expect with only expect_string.
Parameters: expect_string – expect_string. Returns: Dictionary with the following structure: {'healthcheck_expect': {'id': < id >}}
Raises: - InvalidParameterError – The value of expect_string is invalid.
- HealthCheckExpectJaCadastradoError – There is already a healthcheck_expect registered with the same data.
- HealthCheckExpectNaoExisteError – Healthcheck_expect not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_healthcheck_expect(id_ambiente, expect_string, match_list)[source]¶
Insere um novo healthckeck_expect e retorna o seu identificador.
Parameters: - expect_string – expect_string.
- id_ambiente – Identificador do ambiente lógico.
- match_list – match list.
Returns: Dicionário com a seguinte estrutura: {‘healthcheck_expect’: {‘id’: < id >}}
Raises: - InvalidParameterError – O identificador do ambiente, match_lis,expect_string, são inválidos ou nulo.
- HealthCheckExpectJaCadastradoError – Já existe um healthcheck_expect com os mesmos dados cadastrados.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- add_ip_range(id_environment, id_ip_config)[source]¶
Makes relationship of environment with ip config and returns your id.
Parameters: - id_environment – Environment ID.
- id_ip_config – IP Configuration ID.
Returns: Following dictionary:
{‘config_do_ambiente’: {‘id_config_do_ambiente’: < id_config_do_ambiente >}}
Raises: - InvalidParameterError – Some parameter was invalid.
- ConfigEnvironmentDuplicateError – Error saving duplicate Environment Configuration.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- alterar(id_ambiente, id_grupo_l3, id_ambiente_logico, id_divisao, link, id_filter=None, acl_path=None, ipv4_template=None, ipv6_template=None, min_num_vlan_1=None, max_num_vlan_1=None, min_num_vlan_2=None, max_num_vlan_2=None, vrf=None)[source]¶
Altera os dados de um ambiente a partir do seu identificador.
Parameters: - id_ambiente – Identificador do ambiente.
- id_grupo_l3 – Identificador do grupo layer 3.
- id_ambiente_logico – Identificador do ambiente lógico.
- id_divisao – Identificador da divisão data center.
- id_filter – Filter identifier.
- link – Link
- acl_path – Path where the ACL will be stored
- ipv4_template – Template that will be used in Ipv6
- ipv6_template – Template that will be used in Ipv4
- min_num_vlan_1 – Min 1 num vlan valid for this environment
- max_num_vlan_1 – Max 1 num vlan valid for this environment
- min_num_vlan_2 – Min 2 num vlan valid for this environment
- max_num_vlan_2 – Max 2 num vlan valid for this environment
Returns: None
Raises: - InvalidParameterError – O identificador do ambiente, o identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos.
- GrupoL3NaoExisteError – Grupo layer 3 não cadastrado.
- AmbienteLogicoNaoExisteError – Ambiente lógico não cadastrado.
- DivisaoDcNaoExisteError – Divisão data center não cadastrada.
- AmbienteDuplicadoError – Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já cadastrado.
- AmbienteNaoExisteError – Ambiente não cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- associate(environment_id, environment_vip_id)[source]¶
Associate a news Environment on Environment VIP and returns its identifier.
Parameters: - environment_id – Identifier of the Environment. Integer value and greater than zero.
- environment_vip_id – Identifier of the Environment VIP. Integer value and greater than zero.
Returns: Following dictionary:
{'environment_environment_vip': {'id': < id >}}
Raises: - InvalidParameterError – The value of environment_id or environment_vip_id is invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_healthcheck_por_id(id_healthcheck)[source]¶
Get HealthCheck by id.
Parameters: id_healthcheck – HealthCheck ID. Returns: Following dictionary: {'healthcheck_expect': {'match_list': < match_list >, 'expect_string': < expect_string >, 'id': < id >, 'ambiente': < ambiente >}}
Raises: - HealthCheckNaoExisteError – HealthCheck not registered.
- InvalidParameterError – HealthCheck identifier is null and invalid.
- DataBaseError – Can’t connect to networkapi database.
- XMLError – Failed to generate the XML response.
- buscar_por_equipamento(nome_equipamento, ip_equipamento)[source]¶
Obtém um ambiente a partir do ip e nome de um equipamento.
Parameters: - nome_equipamento – Nome do equipamento.
- ip_equipamento – IP do equipamento no formato XXX.XXX.XXX.XXX.
Returns: Dicionário com a seguinte estrutura:
{'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}}
Raises: - IpError – IP não cadastrado para o equipamento.
- InvalidParameterError – O nome e/ou o IP do equipamento são vazios ou nulos, ou o IP é inválido.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- buscar_por_id(id_ambiente)[source]¶
Obtém um ambiente a partir da chave primária (identificador).
Parameters: id_ambiente – Identificador do ambiente. Returns: Dicionário com a seguinte estrutura: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'acl_path': < acl_path >, 'ipv4_template': < ipv4_template >, 'ipv6_template': < ipv6_template >, 'ambiente_rede': < ambiente_rede >}}
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidParameterError – Identificador do ambiente é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- configuration_list_all(environment_id)[source]¶
List all prefix configurations by environment in DB
Returns: Following dictionary: {'lists_configuration': [{ 'id': <id_ipconfig>, 'subnet': <subnet>, 'type': <type>, 'new_prefix': <new_prefix>, }, ... ]}
Raises: - InvalidValueError – Invalid ID for Environment.
- AmbienteNotFoundError – Environment not registered.
- DataBaseError – Failed into networkapi access data base.
- XMLError – Networkapi failed to generate the XML response.
- configuration_remove(environment_id, configuration_id)[source]¶
Remove Prefix Configuration
Returns: None
Raises: - InvalidValueError – Invalid Id for Environment or IpConfig.
- IPConfigNotFoundError – Ipconfig not resgistred.
- AmbienteNotFoundError – Environment not registered.
- DataBaseError – Failed into networkapi access data base.
- XMLError – Networkapi failed to generate the XML response.
- configuration_save(id_environment, network, prefix, ip_version, network_type)[source]¶
Add new prefix configuration
Parameters: - id_environment – Identifier of the Environment. Integer value and greater than zero.
- network – Network Ipv4 or Ipv6.
- prefix – Prefix 0-32 to Ipv4 or 0-128 to Ipv6.
- ip_version – v4 to IPv4 or v6 to IPv6
- network_type – type network
Returns: Following dictionary:
{'network':{'id_environment': <id_environment>, 'id_vlan': <id_vlan>, 'network_type': <network_type>, 'network': <network>, 'prefix': <prefix>} }
Raises: - ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered.
- InvalidValueError – Invalid Id for environment or network or network_type or prefix.
- AmbienteNotFoundError – Environment not registered.
- DataBaseError – Failed into networkapi access data base.
- XMLError – Networkapi failed to generate the XML response.
- delete_rule(id_rule)[source]¶
Removes an environment rule
Parameters: id_rule – Rule id
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- disassociate(environment_id, environment_vip_id)[source]¶
Remove a relationship of Environment with EnvironmentVip.
Parameters: - environment_id – Identifier of the Environment. Integer value and greater than zero.
- environment_vip_id – Identifier of the Environment VIP. Integer value and greater than zero.
Returns: Nothing
Raises: - InvalidParameterError – Environment/Environment VIP identifier is null and/or invalid.
- EnvironmentNotFoundError – Environment not registered.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- EnvironmentError – Option vip is not associated with the environment vip
- UserNotAuthorizedError – User does not have authorization to make this association.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_all_rules(id_env)[source]¶
Save an environment rule
Parameters: id_env – Environment id Returns: Estrutura: { 'rules': [{'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > },... ]}
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- get_blocks(id_env)[source]¶
Get blocks by environment
Parameters: id_env – Environment id Returns: Following dictionary: {'blocks': [{'id' : <id>, 'content' : <content>},...] }
Raises: - UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- get_environment_template(name, network)[source]¶
Get environments by template name
Parameters: - name – Template name.
- network – IPv4 or IPv6.
Returns: Following dictionary:
{'ambiente': [divisao_dc - ambiente_logico - grupo_l3, other envs...] }
Raises: - InvalidParameterError – Invalid param.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
Get all Environment by Environment Vip.
Returns: Following dictionary: {'ambiente': [{ 'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3>, 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico>, 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, 'link': <link> }, ... ]}
Raises: - EnvironmentVipNotFoundError – Environment VIP not registered.
- DataBaseError – Can’t connect to networkapi database.
- XMLError – Failed to generate the XML response.
- get_rule_by_pk(id_rule)[source]¶
Get a rule by its identifier
Parameters: id_rule – Rule identifier. Returns: Seguinte estrutura { 'rule': {'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > }}
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- inserir(id_grupo_l3, id_ambiente_logico, id_divisao, link, id_filter=None, acl_path=None, ipv4_template=None, ipv6_template=None, min_num_vlan_1=None, max_num_vlan_1=None, min_num_vlan_2=None, max_num_vlan_2=None, vrf=None)[source]¶
Insere um novo ambiente e retorna o seu identificador.
Parameters: - id_grupo_l3 – Identificador do grupo layer 3.
- id_ambiente_logico – Identificador do ambiente lógico.
- id_divisao – Identificador da divisão data center.
- id_filter – Filter identifier.
- link – Link
- acl_path – Path where the ACL will be stored
- ipv4_template – Template that will be used in Ipv6
- ipv6_template – Template that will be used in Ipv4
- min_num_vlan_1 – Min 1 num vlan valid for this environment
- max_num_vlan_1 – Max 1 num vlan valid for this environment
- min_num_vlan_2 – Min 2 num vlan valid for this environment
- max_num_vlan_2 – Max 2 num vlan valid for this environment
Returns: Dicionário com a seguinte estrutura: {‘ambiente’: {‘id’: < id >}}
Raises: - InvalidParameterError – O identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos.
- GrupoL3NaoExisteError – Grupo layer 3 não cadastrado.
- AmbienteLogicoNaoExisteError – Ambiente lógico não cadastrado.
- DivisaoDcNaoExisteError – Divisão datacenter não cadastrada.
- AmbienteDuplicadoError – Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- insert_with_ip_range(id_l3_group, id_logical_environment, id_division, id_ip_config, link, id_filter=None)[source]¶
Insert new environment with ip config and returns your id.
Parameters: - id_l3_group – Layer 3 Group ID.
- id_logical_environment – Logical Environment ID.
- id_division – Data Center Division ID.
- id_filter – Filter identifier.
- id_ip_config – IP Configuration ID.
- link – Link.
Returns: Following dictionary: {‘ambiente’: {‘id’: < id >}}
Raises: - ConfigEnvironmentDuplicateError – Error saving duplicate Environment Configuration.
- InvalidParameterError – Some parameter was invalid.
- GrupoL3NaoExisteError – Layer 3 Group not found.
- AmbienteLogicoNaoExisteError – Logical Environment not found.
- DivisaoDcNaoExisteError – Data Center Division not found.
- AmbienteDuplicadoError – Environment with this parameters already exists.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_acl_path()[source]¶
Get all distinct acl paths.
Returns: Dictionary with the following structure: {'acl_paths': [ < acl_path >, ... ]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all()[source]¶
List all environments in DB
Returns: Following dictionary: {'ambiente': [{ 'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3>, 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico>, 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, 'link': <link> }, ... ]}
Raises DataBaseError: Falha na networkapi ao acessar o banco de dados.
- list_no_blocks()[source]¶
List all environments in DB without blocks
Returns: Following dictionary: {'ambiente': [{'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3> 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico> 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, 'link': <link> }, ... ]}
Raises DataBaseError: Falha na networkapi ao acessar o banco de dados.
- listar(id_divisao=None, id_ambiente_logico=None)[source]¶
Lista os ambientes filtrados conforme parâmetros informados.
Se os dois parâmetros têm o valor None então retorna todos os ambientes. Se o id_divisao é diferente de None então retorna os ambientes filtrados pelo valor de id_divisao. Se o id_divisao e id_ambiente_logico são diferentes de None então retorna os ambientes filtrados por id_divisao e id_ambiente_logico.
Parameters: - id_divisao – Identificador da divisão de data center.
- id_ambiente_logico – Identificador do ambiente lógico.
Returns: Dicionário com a seguinte estrutura:
{'ambiente': [{'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}, ... demais ambientes ... ]}
Raises: - DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_healtchcheck_expect_distinct()[source]¶
Get all expect_string.
Returns: Dictionary with the following structure: {'healthcheck_expect': [ 'expect_string': < expect_string >, ... demais healthcheck_expects ...]}
Raises: - InvalidParameterError – Identifier is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_healthcheck_expect(id_ambiente)[source]¶
Lista os healthcheck_expect´s de um ambiente.
Parameters: id_ambiente – Identificador do ambiente. Returns: Dicionário com a seguinte estrutura: {'healthcheck_expect': [{'id': < id_healthcheck_expect >, 'expect_string': < expect_string >, 'match_list': < match_list >, 'id_ambiente': < id_ambiente >}, ... demais healthcheck_expects ...]}
Raises: - InvalidParameterError – O identificador do ambiente é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_equip(equip_id)[source]¶
Lista todos os ambientes por equipamento especifico.
Returns: Dicionário com a seguinte estrutura: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}}
Raises: - DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remover(id_ambiente)[source]¶
Remove um ambiente a partir de seu identificador.
Parameters: id_ambiente – Identificador do ambiente.
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- AmbienteError – Ambiente está associado a um equipamento e/ou a uma VLAN.
- InvalidParameterError – O identificador do ambiente é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- save_blocks(id_env, blocks)[source]¶
Save blocks from environment
Parameters: - id_env – Environment id
- blocks – Lists of blocks in order. Ex: [‘content one’, ‘content two’, ...]
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- save_rule(name, id_env, contents, blocks_id)[source]¶
Save an environment rule
Parameters: - name – Name of the rule
- id_env – Environment id
- contents – Lists of contents in order. Ex: [‘content one’, ‘content two’, ...]
- blocks_id – Lists of blocks id or 0 if is as custom content. Ex: [‘0’, ‘5’, ‘0’ ...]
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- set_template(id_environment, name, network)[source]¶
Set template value. If id_environment = 0, set ‘’ to all environments related with the template name.
Parameters: - id_environment – Environment Identifier.
- name – Template Name.
- network – IPv4 or IPv6.
Returns: None
Raises: - InvalidParameterError – Invalid param.
- AmbienteNaoExisteError – Ambiente não cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- update_blocks(id_env, blocks)[source]¶
Update blocks from environment
Parameters: - id_env – Environment id
- blocks – Lists of blocks in order. Ex: [‘content one’, ‘content two’, ...]
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- update_rule(name, id_env, contents, blocks_id, id_rule)[source]¶
Save an environment rule
Parameters: - name – Name of the rule
- id_env – Environment id
- contents – Lists of contents in order. Ex: [‘content one’, ‘content two’, ...]
- blocks_id – Lists of blocks id or 0 if is as custom content. Ex: [‘0’, ‘5’, ‘0’ ...]
- id_rule – Rule id
Returns: None
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidValueError – Invalid parameter.
- UserNotAuthorizedError – Permissão negada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
networkapiclient.AmbienteLogico module¶
- class networkapiclient.AmbienteLogico.AmbienteLogico(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_logicalenvironment, name)[source]¶
Change Logical Environment from by the identifier.
Parameters: - id_logicalenvironment – Identifier of the Logical Environment. Integer value and greater than zero.
- name – Logical Environment name. String with a minimum 2 and maximum of 80 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Logical Environment or name is null and invalid.
- NomeAmbienteLogicoDuplicadoError – There is already a registered Logical Environment with the value of name.
- AmbienteLogicoNaoExisteError – Logical Environment not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name)[source]¶
Inserts a new Logical Environment and returns its identifier.
Parameters: name – Logical Environment name. String with a minimum 2 and maximum of 80 characters Returns: Dictionary with the following structure: {'logical_environment': {'id': < id_logical_environment >}}
Raises: - InvalidParameterError – Name is null and invalid.
- NomeAmbienteLogicoDuplicadoError – There is already a registered Logical Environment with the value of name.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Logical Environment.
Returns: Dictionary with the following structure: {'logical_environment': [{'id': < id >, 'nome': < nome >}, ...more Logical Environment...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_logicalenvironment)[source]¶
Remove Logical Environment from by the identifier.
Parameters: id_logicalenvironment – Identifier of the Logical Environment. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Logical Environment is null and invalid.
- AmbienteLogicoNaoExisteError – Logical Environment not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.ApiGenericClient module¶
- class networkapiclient.ApiGenericClient.ApiGenericClient(networkapi_url, user, password, user_ldap=None, log_level='INFO')[source]¶
Bases: object
Class inherited by all NetworkAPI-Client classes who implements access methods to new pattern rest networkAPI.
- delete(uri, data=None)[source]¶
Sends a DELETE request.
@param uri: Uri of Service API.
@raise NetworkAPIClientError: Client failed to access the API.
- get(uri)[source]¶
Sends a GET request.
@param uri: Uri of Service API. @param data: Requesting Data. Default: None
@raise NetworkAPIClientError: Client failed to access the API.
networkapiclient.ApiVipRequest module¶
- class networkapiclient.ApiVipRequest.ApiVipRequest(networkapi_url, user, password, user_ldap=None, log_level='INFO')[source]¶
Bases: networkapiclient.ApiGenericClient.ApiGenericClient
- create(vips)[source]¶
Method to create vip’s
Parameters: vips – List containing vip’s desired to be created on database Returns: None
- create_vip(vip_request_ids)[source]¶
Method to create vip request
param vip_request_ids: vip_request ids
- delete(ids)[source]¶
Method to delete vip’s by their id’s
Parameters: ids – Identifiers of vip’s Returns: None
- delete_vip_request(vip_request_ids)[source]¶
Method to delete vip request
param vip_request_ids: vip_request ids
- deploy(ids)[source]¶
Method to deploy vip’s
Parameters: vips – List containing vip’s desired to be deployed on equipment Returns: None
- get(ids, **kwargs)[source]¶
Method to get vips by their id’s
Parameters: - ids – List containing identifiers of vip’s
- include – Array containing fields to include on response.
- exclude – Array containing fields to exclude on response.
- fields – Array containing fields to override default fields.
- kind – Determine if result will be detailed (‘detail’) or basic (‘basic’).
Returns: Dict containing vip’s
- get_vip_request(vip_request_id)[source]¶
Method to get vip request
param vip_request_id: vip_request id
- get_vip_request_details(vip_request_id)[source]¶
Method to get details of vip request
param vip_request_id: vip_request id
- option_vip_by_environmentvip(environment_vip_id)[source]¶
List Option Vip by Environment Vip
param environment_vip_id: Id of Environment Vip
- redeploy(vips)[source]¶
Method to redeploy vip’s
Parameters: vips – List containing vip’s desired to updated on equipment Returns: None
- remove_vip(vip_request_ids)[source]¶
Method to delete vip request
param vip_request_ids: vip_request ids
- save_vip_request(vip_request)[source]¶
Method to save vip request
param vip_request: vip_request object
- search(**kwargs)[source]¶
Method to search vip’s based on extends search.
Parameters: - search – Dict containing QuerySets to find vip’s.
- include – Array containing fields to include on response.
- exclude – Array containing fields to exclude on response.
- fields – Array containing fields to override default fields.
- kind – Determine if result will be detailed (‘detail’) or basic (‘basic’).
Returns: Dict containing vip’s
- undeploy(ids, clean_up=0)[source]¶
Method to undeploy vip’s
Parameters: vips – List containing vip’s desired to be undeployed on equipment Returns: None
- update(vips)[source]¶
Method to update vip’s
Parameters: vips – List containing vip’s desired to updated Returns: None
networkapiclient.BlockRule module¶
- class networkapiclient.BlockRule.BlockRule(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- get_rule_by_id(rule_id)[source]¶
Get rule by indentifier.
Parameters: rule_id – Rule identifier Returns: Dictionary with the following structure: {'rule': {'environment': < environment_id >, 'content': < content >, 'custom': < custom >, 'id': < id >, 'name': < name >}}
Raises: - UserNotAuthorizedError – User dont have permition.
- InvalidParameterError – RULE identifier is null or invalid.
- DataBaseError – Can’t connect to networkapi database.
networkapiclient.ClientFactory module¶
- class networkapiclient.ClientFactory.ClientFactory(networkapi_url, user, password, user_ldap=None, log_level='INFO')[source]¶
Bases: object
Factory to create entities for NetworkAPI-Client.
- create_api_object_group_permission_general()[source]¶
Get an instance of Api Vip Requests services facade.
- create_api_v4_virtual_interface()[source]¶
Get an instance of Api Virtual Interface services facade.
- create_direito_grupo_equipamento()[source]¶
Get an instance of direito_grupo_equipamento services facade.
networkapiclient.Config module¶
networkapiclient.DireitoGrupoEquipamento module¶
- class networkapiclient.DireitoGrupoEquipamento.DireitoGrupoEquipamento(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_direito, leitura, escrita, alterar_config, exclusao)[source]¶
Altera os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
Parameters: - id_direito – Identificador do direito grupo equipamento.
- leitura – Indicação de permissão de leitura (‘0’ ou ‘1’).
- escrita – Indicação de permissão de escrita (‘0’ ou ‘1’).
- alterar_config – Indicação de permissão de alterar_config (‘0’ ou ‘1’).
- exclusao – Indicação de permissão de exclusão (‘0’ ou ‘1’).
Returns: None
Raises: - InvalidParameterError – Pelo menos um dos parâmetros é nulo ou inválido.
- ValorIndicacaoDireitoInvalidoError – Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
- DireitoGrupoEquipamentoNaoExisteError – Direito Grupo Equipamento não cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- buscar_por_id(id_direito)[source]¶
Obtém os direitos de um grupo de usuário e um grupo de equipamento.
Parameters: id_direito – Identificador do direito grupo equipamento. Returns: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': {'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}}
Raises: - InvalidParameterError – O identificador do direito grupo equipamento é nulo ou inválido.
- DireitoGrupoEquipamentoNaoExisteError – Direito Grupo Equipamento não cadastrado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- inserir(id_grupo_usuario, id_grupo_equipamento, leitura, escrita, alterar_config, exclusao)[source]¶
Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador.
Parameters: - id_grupo_usuario – Identificador do grupo de usuário.
- id_grupo_equipamento – Identificador do grupo de equipamento.
- leitura – Indicação de permissão de leitura (‘0’ ou ‘1’).
- escrita – Indicação de permissão de escrita (‘0’ ou ‘1’).
- alterar_config – Indicação de permissão de alterar_config (‘0’ ou ‘1’).
- exclusao – Indicação de permissão de exclusão (‘0’ ou ‘1’).
Returns: Dicionário com a seguinte estrutura: {‘direito_grupo_equipamento’: {‘id’: < id>}}
Raises: - InvalidParameterError – Pelo menos um dos parâmetros é nulo ou inválido.
- GrupoEquipamentoNaoExisteError – Grupo de Equipamento não cadastrado.
- GrupoUsuarioNaoExisteError – Grupo de Usuário não cadastrado.
- ValorIndicacaoDireitoInvalidoError – Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
- DireitoGrupoEquipamentoDuplicadoError – Já existe direitos cadastrados para o grupo de usuário e grupo de equipamento informados.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- listar()[source]¶
Lista todos os direitos de grupos de usuário em grupos de equipamento.
Returns: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]}
Raises: - DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_grupo_equipamento(id_grupo_equipamento)[source]¶
Lista todos os direitos de grupos de usuário em um grupo de equipamento.
Parameters: id_grupo_equipamento – Identificador do grupo de equipamento para filtrar a pesquisa. Returns: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]}
Raises: - InvalidParameterError – O identificador do grupo de equipamento é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_grupo_usuario(id_grupo_usuario)[source]¶
Lista todos os direitos de um grupo de usuário em grupos de equipamento.
Parameters: id_grupo_usuario – Identificador do grupo de usuário para filtrar a pesquisa. Returns: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]}
Raises: - InvalidParameterError – O identificador do grupo de usuário é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remover(id_direito)[source]¶
Remove os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
Parameters: id_direito – Identificador do direito grupo equipamento
Returns: None
Raises: - DireitoGrupoEquipamentoNaoExisteError – Direito Grupo Equipamento não cadastrado.
- InvalidParameterError – O identificador do direito grupo equipamento é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
networkapiclient.DivisaoDc module¶
- class networkapiclient.DivisaoDc.DivisaoDc(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_divisiondc, name)[source]¶
Change Division Dc from by the identifier.
Parameters: - id_divisiondc – Identifier of the Division Dc. Integer value and greater than zero.
- name – Division Dc name. String with a minimum 2 and maximum of 80 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Division Dc or name is null and invalid.
- NomeDivisaoDcDuplicadoError – There is already a registered Division Dc with the value of name.
- DivisaoDcNaoExisteError – Division Dc not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name)[source]¶
Inserts a new Division Dc and returns its identifier.
Parameters: name – Division Dc name. String with a minimum 2 and maximum of 80 characters Returns: Dictionary with the following structure: {'division_dc': {'id': < id_division_dc >}}
Raises: - InvalidParameterError – Name is null and invalid.
- NomeDivisaoDcDuplicadoError – There is already a registered Division Dc with the value of name.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Division Dc.
Returns: Dictionary with the following structure: {'division_dc': [{'id': < id >, 'name': < name >}, ...more Division Dc...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_divisiondc)[source]¶
Remove Division Dc from by the identifier.
Parameters: id_divisiondc – Identifier of the Division Dc. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Division Dc is null and invalid.
- DivisaoDcNaoExisteError – Division Dc not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.EnvironmentVIP module¶
- class networkapiclient.EnvironmentVIP.EnvironmentVIP(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add(finalidade_txt, cliente_txt, ambiente_p44_txt, description)[source]¶
Inserts a new Environment VIP and returns its identifier.
Parameters: - finalidade_txt – Finality. String with a maximum of 50 characters and respect [a-zA-Z_-]
- cliente_txt – ID Client. String with a maximum of 50 characters and respect [a-zA-Z_-]
- ambiente_p44_txt – Environment P44. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: Following dictionary:
{'environment_vip': {'id': < id >}}
Raises: - InvalidParameterError – The value of finalidade_txt, cliente_txt or ambiente_p44_txt is invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- alter(id_environment_vip, finalidade_txt, cliente_txt, ambiente_p44_txt, description)[source]¶
Change Environment VIP from by the identifier.
Parameters: - id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero.
- finalidade_txt – Finality. String with a maximum of 50 characters and respect [a-zA-Z_-]
- cliente_txt – ID Client. String with a maximum of 50 characters and respect [a-zA-Z_-]
- ambiente_p44_txt – Environment P44. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: None
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- InvalidParameterError – The value of finalidade_txt, cliente_txt or ambiente_p44_txt is invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_ambientep44_por_finalidade_cliente(finalidade_txt, cliente_txt)[source]¶
Search ambiente_p44_txt environment vip
Returns: Dictionary with the following structure: {‘ambiente_p44_txt’: 'id':<'id_ambientevip'>, ‘finalidade’: <'finalidade_txt'>, 'cliente_txt: <'cliente_txt'>', 'ambiente_p44: <'ambiente_p44'>',}
Raises: - InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_cliente_por_finalidade(finalidade_txt)[source]¶
Search cliente_txt environment vip
Returns: Dictionary with the following structure: {‘cliente_txt’: ‘finalidade’: <'finalidade_txt'>, 'cliente_txt: <'cliente_txt'>'}
Raises: - InvalidParameterError – finalidade_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_finalidade()[source]¶
Search finalidade_txt environment vip
Returns: Dictionary with the following structure: - ::
- {‘finalidade’: ‘finalidade’: <’finalidade_txt’>}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_vips(id_environment_vip)[source]¶
Get to list all the VIPs related to Environment VIP from by the identifier.
Parameters: id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero. Returns: Dictionary with the following structure: {‘vip_< id >’: {‘id’: < id >, ‘validado’: < validado >, ‘finalidade’: < finalidade >, ‘cliente’: < cliente >, ‘ambiente’: < ambiente >, ‘cache’: < cache >, ‘metodo_bal’: < método_bal >, ‘persistencia’: < persistencia >, ‘healthcheck_type’: < healthcheck_type >, ‘healthcheck’: < healthcheck >, ‘timeout’: < timeout >, ‘host’: < host >, ‘maxcon’: < maxcon >, ‘dsr’: < dsr >, ‘bal_ativo’: < bal_ativo >, ‘transbordos’:{‘transbordo’:[< transbordo >]}, ‘reals’:{‘real’:[{‘real_name’:< real_name >, ‘real_ip’:< real_ip >}]}, ‘portas_servicos’:{‘porta’:[< porta >]}, ‘vip_criado’: < vip_criado >, ‘id_ip’: < id_ip >, ‘id_ipv6’: < id_ipv6 >, ‘id_healthcheck_expect’: < id_healthcheck_expect >}}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all()[source]¶
List all environment vips
Returns: Following dictionary: {'environment_vip': [{'id': <id>, 'finalidade_txt': <finalidade_txt>, 'cliente_txt': <cliente_txt>, 'ambiente_p44_txt': <ambiente_p44_txt> } {... other environments vip ...}]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all_available(id_vlan)[source]¶
List all environment vips availables
Returns: Following dictionary: {'environment_vip': [{'id': <id>, 'finalidade_txt': <finalidade_txt>, 'cliente_txt': <cliente_txt>, 'ambiente_p44_txt': <ambiente_p44_txt> } {... other environments vip ...}]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remove(id_environment_vip)[source]¶
Remove Environment VIP from by the identifier.
Parameters: id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- EnvironmentVipError – There networkIPv4 or networkIPv6 associated with environment vip.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- search(id_environment_vip=None, finalidade_txt=None, cliente_txt=None, ambiente_p44_txt=None)[source]¶
Search Environment VIP from by parameters.
Case the id parameter has been passed, the same it has priority over the other parameters.
Parameters: - id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero.
- finalidade_txt – Finality. String with a maximum of 50 characters and respect [a-zA-Z_-]
- cliente_txt – ID Client. String with a maximum of 50 characters and respect [a-zA-Z_-]
- ambiente_p44_txt – Environment P44. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: Following dictionary:
{‘environment_vip’: {‘id’: < id >, ‘finalidade_txt’: < finalidade_txt >, ‘finalidade’: < finalidade >, ‘cliente_txt’: < cliente_txt >, ‘ambiente_p44_txt’: < ambiente_p44_txt >}}
Raises: - InvalidParameterError – The value of id_environment_vip, finalidade_txt, cliente_txt or ambiente_p44_txt is invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Equipamento module¶
- class networkapiclient.Equipamento.Equipamento(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add_ipv4(id_network_ipv4, id_equipamento, descricao)[source]¶
Allocate an IP on a network to an equipment. Insert new IP for network and associate to the equipment
Parameters: - id_network_ipv4 – ID for NetworkIPv4.
- id_equipamento – ID for Equipment.
- descricao – Description for IP.
Returns: Following dictionary:
{'ip': {'id': < id_ip >, 'id_network_ipv4': < id_network_ipv4 >, 'oct1’: < oct1 >, 'oct2': < oct2 >, 'oct3': < oct3 >, 'oct4': < oct4 >, 'descricao': < descricao >}}
Raises: - InvalidParameterError – Invalid ID for NetworkIPv4 or Equipment.
- InvalidParameterError – The value of description is invalid.
- EquipamentoNaoExisteError – Equipment not found.
- RedeIPv4NaoExisteError – NetworkIPv4 not found.
- IPNaoDisponivelError – There is no network address is available to create the VLAN.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_ipv6(id_network_ipv6, id_equip, description)[source]¶
Allocate an IP on a network to an equipment. Insert new IP for network and associate to the equipment
Parameters: - id_network_ipv6 – ID for NetworkIPv6.
- id_equip – ID for Equipment.
- description – Description for IP.
Returns: Following dictionary:
{'ip': {'id': < id_ip >, 'id_network_ipv6': < id_network_ipv6 >, 'bloco1': < bloco1 >, 'bloco2': < bloco2 >, 'bloco3': < bloco3 >, 'bloco4': < bloco4 >, 'bloco5': < bloco5 >, 'bloco6': < bloco6 >, 'bloco7': < bloco7 >, 'bloco8': < bloco8 >, 'descricao': < descricao >}}
Raises: - InvalidParameterError – NetworkIPv6 identifier or Equipament identifier is null and invalid,
- InvalidParameterError – The value of description is invalid.
- EquipamentoNaoExisteError – Equipment not found.
- RedeIPv6NaoExisteError – NetworkIPv6 not found.
- IPNaoDisponivelError – There is no network address is available to create the VLAN.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- associar_grupo(id_equipamento, id_grupo_equipamento)[source]¶
Associa um equipamento a um grupo.
Parameters: - id_equipamento – Identificador do equipamento.
- id_grupo_equipamento – Identificador do grupo de equipamento.
Returns: Dicionário com a seguinte estrutura: {‘equipamento_grupo’:{‘id’: < id_equip_do_grupo >}}
Raises: - GrupoEquipamentoNaoExisteError – Grupo de equipamento não cadastrado.
- InvalidParameterError – O identificador do equipamento e/ou do grupo são nulos ou inválidos.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- EquipamentoError – Equipamento já está associado ao grupo.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- associar_ip(id_equipamento, id_ip)[source]¶
Associa um IP a um equipamento.
Parameters: - id_equipamento – Identificador do equipamento.
- id_ip – Identificador do IP.
Returns: Dicionário com a seguinte estrutura: {‘ip_equipamento’: {‘id’: < id_ip_do_equipamento >}}
Raises: - EquipamentoNaoExisteError – Equipamento não cadastrado.
- IpNaoExisteError – IP não cadastrado.
- IpError – IP já está associado ao equipamento.
- InvalidParameterError – O identificador do equipamento e/ou do IP são nulos ou inválidos.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- associate_ipv6(id_equip, id_ipv6)[source]¶
Associates an IPv6 to a equipament.
Parameters: - id_equip – Identifier of the equipment. Integer value and greater than zero.
- id_ipv6 – Identifier of the ip. Integer value and greater than zero.
Returns: Dictionary with the following structure: {‘ip_equipamento’: {‘id’: < id_ip_do_equipamento >}}
Raises: - EquipamentoNaoExisteError – Equipment is not registered.
- IpNaoExisteError – IP not registered.
- IpError – IP is already associated with the equipment.
- InvalidParameterError – Identifier of the equipment and/or IP is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- criar_ip(id_vlan, id_equipamento, descricao)[source]¶
Aloca um IP em uma VLAN para um equipamento.
Insere um novo IP para a VLAN e o associa ao equipamento.
Parameters: - id_vlan – Identificador da vlan.
- id_equipamento – Identificador do equipamento.
- descricao – Descriçao do IP.
Returns: Dicionário com a seguinte estrutura:
{'ip': {'id': < id_ip >, 'id_network_ipv4': < id_network_ipv4 >, 'oct1’: < oct1 >, 'oct2': < oct2 >, 'oct3': < oct3 >, 'oct4': < oct4 >, 'descricao': < descricao >}}
Raises: - InvalidParameterError – O identificador da VLAN e/ou do equipamento são nulos ou inválidos.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- VlanNaoExisteError – VLAN não cadastrada.
- IPNaoDisponivelError – Não existe IP disponível para a VLAN informada.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- edit(id_equip, nome, id_tipo_equipamento, id_modelo, maintenance=None)[source]¶
Change Equipment from by the identifier.
Parameters: - id_equip – Identifier of the Equipment. Integer value and greater than zero.
- nome – Equipment name. String with a minimum 3 and maximum of 30 characters
- id_tipo_equipamento – Identifier of the Equipment Type. Integer value and greater than zero.
- id_modelo – Identifier of the Model. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Equipment, model, equipment type or name is null and invalid.
- EquipamentoNaoExisteError – Equipment not registered.
- TipoEquipamentoNaoExisteError – Equipment Type not registered.
- ModeloEquipamentoNaoExisteError – Model not registered.
- GrupoEquipamentoNaoExisteError – Group not registered.
- EquipamentoError – Equipamento com o nome duplicado ou Equipamento do grupo “Equipamentos Orquestração” somente poderá ser criado com tipo igual a “Servidor Virtual”.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- find_equips(name, iexact, environment, equip_type, group, ip, pagination)[source]¶
Find vlans by all search parameters
Parameters: - name – Filter by vlan name column
- iexact – Filter by name will be exact?
- environment – Filter by environment ID related
- equip_type – Filter by equipment_type ID related
- group – Filter by equipment group ID related
- ip – Filter by each octs in ips related
- pagination – Class with all data needed to paginate
Returns: Following dictionary:
{'equipamento': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >, 'ambiente_name': < divisao_dc-ambiente_logico-grupo_l3 > 'redeipv4': [ { all networkipv4 related } ], 'redeipv6': [ { all networkipv6 related } ] }, 'total': {< total_registros >} }
Raises: - InvalidParameterError – Some parameter was invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_all()[source]¶
Return all equipments in database
Returns: Dictionary with the following structure: - ::
- {‘equipaments’: {‘name’ :< name_equipament >}, {... demais equipamentos ...} }
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_ips_by_equipment_and_environment(equip_nome, id_ambiente)[source]¶
Search Group Equipment from by the identifier.
Parameters: id_egroup – Identifier of the Group Equipment. Integer value and greater than zero. Returns: Dictionary with the following structure: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]}
Raises: - InvalidParameterError – Group Equipment is null and invalid.
- GrupoEquipamentoNaoExisteError – Group Equipment not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
Find reals related with equipment
Parameters: id_equip – Identifier of equipment Returns: Following dictionary: {'vips': [{'port_real': < port_real >, 'server_pool_member_id': < server_pool_member_id >, 'ip': < ip >, 'port_vip': < port_vip >, 'host_name': < host_name >, 'id_vip': < id_vip >, ...], 'equip_name': < equip_name > }}
Raises: - EquipamentoNaoExisteError – Equipment not registered.
- InvalidParameterError – Some parameter was invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name, id_equipment_type, id_model, id_group, maintenance=False)[source]¶
Inserts a new Equipment and returns its identifier
Além de inserir o equipamento, a networkAPI também associa o equipamento ao grupo informado.
Parameters: - name – Equipment name. String with a minimum 3 and maximum of 30 characters
- id_equipment_type – Identifier of the Equipment Type. Integer value and greater than zero.
- id_model – Identifier of the Model. Integer value and greater than zero.
- id_group – Identifier of the Group. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'equipamento': {'id': < id_equipamento >}, 'equipamento_grupo': {'id': < id_grupo_equipamento >}}
Raises: - InvalidParameterError – The identifier of Equipment type, model, group or name is null and invalid.
- TipoEquipamentoNaoExisteError – Equipment Type not registered.
- ModeloEquipamentoNaoExisteError – Model not registered.
- GrupoEquipamentoNaoExisteError – Group not registered.
- EquipamentoError – Equipamento com o nome duplicado ou Equipamento do grupo “Equipamentos Orquestração” somente poderá ser criado com tipo igual a “Servidor Virtual”.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- list_all()[source]¶
Return all equipments in database
Returns: Dictionary with the following structure: {'equipaments': {'name' :< name_equipament >}, {... demais equipamentos ...} }
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_by_group(id_egroup)[source]¶
Search Group Equipment from by the identifier.
Parameters: id_egroup – Identifier of the Group Equipment. Integer value and greater than zero. Returns: Dictionary with the following structure: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]}
Raises: - InvalidParameterError – Group Equipment is null and invalid.
- GrupoEquipamentoNaoExisteError – Group Equipment not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_por_id(id)[source]¶
Obtém um equipamento a partir do seu identificador.
Parameters: id – ID do equipamento. Returns: Dicionário com a seguinte estrutura: {'equipamento': {'id': < id_equipamento >, 'nome': < nome_equipamento >, 'id_tipo_equipamento': < id_tipo_equipamento >, 'nome_tipo_equipamento': < nome_tipo_equipamento >, 'id_modelo': < id_modelo >, 'nome_modelo': < nome_modelo >, 'id_marca': < id_marca >, 'nome_marca': < nome_marca >}}
Raises: - EquipamentoNaoExisteError – Equipamento com o id informado não cadastrado.
- InvalidParameterError – O nome do equipamento é nulo ou vazio.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_nome(nome)[source]¶
Obtém um equipamento a partir do seu nome.
Parameters: nome – Nome do equipamento. Returns: Dicionário com a seguinte estrutura: {'equipamento': {'id': < id_equipamento >, 'nome': < nome_equipamento >, 'id_tipo_equipamento': < id_tipo_equipamento >, 'nome_tipo_equipamento': < nome_tipo_equipamento >, 'id_modelo': < id_modelo >, 'nome_modelo': < nome_modelo >, 'id_marca': < id_marca >, 'nome_marca': < nome_marca >}}
Raises: - EquipamentoNaoExisteError – Equipamento com o nome informado não cadastrado.
- InvalidParameterError – O nome do equipamento é nulo ou vazio.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_tipo_ambiente(id_tipo_equipamento, id_ambiente)[source]¶
Lista os equipamentos de um tipo e que estão associados a um ambiente.
Parameters: - id_tipo_equipamento – Identificador do tipo do equipamento.
- id_ambiente – Identificador do ambiente.
Returns: Dicionário com a seguinte estrutura:
{'equipamento': [{'id': < id_equipamento >, 'nome': < nome_equipamento >, 'id_tipo_equipamento': < id_tipo_equipamento >, 'nome_tipo_equipamento': < nome_tipo_equipamento >, 'id_modelo': < id_modelo >, 'nome_modelo': < nome_modelo >, 'id_marca': < id_marca >, 'nome_marca': < nome_marca > }, ... demais equipamentos ...]}
Raises: - InvalidParameterError – O identificador do tipo de equipamento e/ou do ambiente são nulos ou inválidos.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remove_ipv6(id_equip, id_ipv6)[source]¶
Remove an IPv6 to a equipament.
Parameters: - id_equip – Identifier of the equipment. Integer value and greater than zero.
- id_ipv6 – Identifier of the ip. Integer value and greater than zero.
Returns: None
Raises: - EquipamentoNaoExisteError – Equipment is not registered.
- IpNaoExisteError – IP not registered.
- IpError – Dont IP is already associated with the equipment.
- InvalidParameterError – Identifier of the equipment and/or IP is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_equipamento)[source]¶
Remove um equipamento a partir do seu identificador.
Além de remover o equipamento, a API também remove:
- O relacionamento do equipamento com os tipos de acessos.
- O relacionamento do equipamento com os roteiros.
- O relacionamento do equipamento com os IPs.
- As interfaces do equipamento.
- O relacionamento do equipamento com os ambientes.
- O relacionamento do equipamento com os grupos.
Parameters: id_equipamento – Identificador do equipamento.
Returns: None
Raises: - EquipamentoNaoExisteError – Equipamento não cadastrado.
- InvalidParameterError – O identificador do equipamento é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remover_grupo(id_equipamento, id_grupo)[source]¶
Remove a associação de um equipamento com um grupo de equipamento.
Parameters: - id_equipamento – Identificador do equipamento.
- id_grupo – Identificador do grupo de equipamento.
Returns: None
Raises: - EquipamentoGrupoNaoExisteError – Associação entre grupo e equipamento não cadastrada.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- EquipmentDontRemoveError – Failure to remove an association between an equipment and a group because the group is related only to a group.
- InvalidParameterError – O identificador do equipamento e/ou do grupo são nulos ou inválidos.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remover_ip(id_equipamento, id_ip)[source]¶
Removes association of IP and Equipment. If IP has no other association with equipments, IP is also removed.
Parameters: - id_equipamento – Equipment identifier
- id_ip – IP identifier.
Returns: None
Raises: - VipIpError – Ip can’t be removed because there is a created Vip Request.
- IpEquipCantDissociateFromVip – Equipment is the last balancer for created Vip Request.
- IpError – IP not associated with equipment.
- InvalidParameterError – Equipment or IP identifier is none or invalid.
- EquipamentoNaoExisteError – Equipment doesn’t exist.
- DataBaseError – Networkapi failed to access database.
- XMLError – Networkapi failed to build response XML.
networkapiclient.EquipamentoAcesso module¶
- class networkapiclient.EquipamentoAcesso.EquipamentoAcesso(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- edit_by_id(id_equip_acesso, id_tipo_acesso, fqdn, user, password, enable_pass)[source]¶
Edit access type, fqdn, user, password and enable_pass of the relationship of equipment and access type.
Parameters: - id_tipo_acesso – Access type identifier.
- id_equip_acesso – Equipment identifier.
- fqdn – Equipment FQDN.
- user – User.
- password – Password.
- enable_pass – Enable access.
Returns: None
Raises: - InvalidParameterError – The parameters fqdn, user, password or access type id are invalid or none.
- EquipamentoAcessoNaoExisteError – Equipment access type relationship doesn’t exist.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_access(id_access)[source]¶
Get Equipment Access by id.
Returns: Dictionary with following: {'equipamento_acesso': {'id_equipamento': < id_equipamento >, 'fqdn': < fqdn >, 'user': < user >, 'pass': < pass >, 'id_tipo_acesso': < id_tipo_acesso >, 'enable_pass': < enable_pass >}}
- inserir(id_equipamento, fqdn, user, password, id_tipo_acesso, enable_pass)[source]¶
Add new relationship between equipment and access type and returns its id.
Parameters: - id_equipamento – Equipment identifier.
- fqdn – Equipment FQDN.
- user – User.
- password – Password.
- id_tipo_acesso – Access Type identifier.
- enable_pass – Enable access.
Returns: Dictionary with the following: {‘equipamento_acesso’: {‘id’: < id >}}
Raises: - EquipamentoNaoExisteError – Equipment doesn’t exist.
- TipoAcessoNaoExisteError – Access Type doesn’t exist.
- EquipamentoAcessoError – Equipment and access type already associated.
- InvalidParameterError – The parameters equipment id, fqdn, user, password or access type id are invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_by_equip(name)[source]¶
List all equipment access by equipment name
Returns: Dictionary with the following structure: {‘equipamento_acesso’:[ {'id': <id_equiptos_access>, 'equipamento': <id_equip>, 'fqdn': <fqdn>, 'user': <user>, 'password': <pass> 'tipo_acesso': <id_tipo_acesso>, 'enable_pass': <enable_pass> }]}
Raises: - InvalidValueError – Invalid parameter.
- EquipamentoNotFoundError – Equipment name not found in database.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List Equipment Access relationships.
Return only the relationships from equipments the user have write permissions in one of the equipment groups
Returns: Dictionary with the following: {'equipamento_acesso': [{'id_equipamento': < id_equipamento >, 'fqdn': < fqdn >, 'user': < user >, 'pass': < pass >, 'id_tipo_acesso': < id_tipo_acesso >, 'enable_pass': < enable_pass >, 'protocolo_tipo_acesso': < protocol_tipo_acesso >}, ... other equipment_access ....]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_tipo_acesso, id_equipamento)[source]¶
Removes relationship between equipment and access type.
Parameters: - id_equipamento – Equipment identifier.
- id_tipo_acesso – Access type identifier.
Returns: None
Raises: - EquipamentoNaoExisteError – Equipment doesn’t exist.
- EquipamentoAcessoNaoExisteError – Relationship between equipment and access type doesn’t exist.
- InvalidParameterError – Equipment and/or access type id is/are invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.EquipamentoAmbiente module¶
- class networkapiclient.EquipamentoAmbiente.EquipamentoAmbiente(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- inserir(id_equipment, id_environment, is_router=0)[source]¶
Inserts a new Related Equipment with Environment and returns its identifier
Parameters: - id_equipment – Identifier of the Equipment. Integer value and greater than zero.
- id_environment – Identifier of the Environment. Integer value and greater than zero.
- is_router – Identifier of the Environment. Boolean value.
Returns: Dictionary with the following structure:
{'equipamento_ambiente': {'id': < id_equipment_environment >}}
Raises: - InvalidParameterError – The identifier of Equipment or Environment is null and invalid.
- AmbienteNaoExisteError – Environment not registered.
- EquipamentoNaoExisteError – Equipment not registered.
- EquipamentoAmbienteError – Equipment is already associated with the Environment.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_equipment, id_environment)[source]¶
Remove Related Equipment with Environment from by the identifier.
Parameters: - id_equipment – Identifier of the Equipment. Integer value and greater than zero.
- id_environment – Identifier of the Environment. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Environment, Equipament is null and invalid.
- EquipamentoNotFoundError – Equipment not registered.
- EquipamentoAmbienteNaoExisteError – Environment not registered.
- VipIpError – IP-related equipment is being used for a request VIP.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- update(id_equipment, id_environment, is_router)[source]¶
Remove Related Equipment with Environment from by the identifier.
Parameters: - id_equipment – Identifier of the Equipment. Integer value and greater than zero.
- id_environment – Identifier of the Environment. Integer value and greater than zero.
- is_router – Identifier of the Environment. Boolean value.
Returns: None
Raises: - InvalidParameterError – The identifier of Environment, Equipament is null and invalid.
- EquipamentoNotFoundError – Equipment not registered.
- EquipamentoAmbienteNaoExisteError – Environment not registered.
- VipIpError – IP-related equipment is being used for a request VIP.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
networkapiclient.EquipamentoRoteiro module¶
- class networkapiclient.EquipamentoRoteiro.EquipamentoRoteiro(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- inserir(id_equipment, id_script)[source]¶
Inserts a new Related Equipment with Script and returns its identifier
Parameters: - id_equipment – Identifier of the Equipment. Integer value and greater than zero.
- id_script – Identifier of the Script. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'equipamento_roteiro': {'id': < id_equipment_script >}}
Raises: - InvalidParameterError – The identifier of Equipment or Script is null and invalid.
- RoteiroNaoExisteError – Script not registered.
- EquipamentoNaoExisteError – Equipment not registered.
- EquipamentoRoteiroError – Equipment is already associated with the script.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- list_by_equip(name)[source]¶
List all equipment script by equipment name
Returns: Dictionary with the following structure: {‘equipamento_roteiro’:[ {'id': <id_equipment_script>, 'roteiro_id': <id_script>, 'roteiro_name': <name_script>, 'roteiro_desc': <desc_script>, 'tipo_roteiro_id': <id_script_type>, 'tipo_roteiro_name': <name_script_type>, 'tipo_roteiro_desc': <desc_script_type>, }], 'equipamento': {'id': <id_equipment>, 'name': <name_equipment>,}}
Raises: - InvalidParameterError – Name is null and invalid.
- EquipamentoNotFoundError – Equipment name not found in database.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- listar()[source]¶
List all Related Equipment with Script.
Somente retorna os relacionamentos dos equipamentos que o usuário autenticado tem permissão de leitura em pelo menos um grupo do equipamento.
Returns: Dictionary with the following structure: {'equipamento_roteiro': [{'roteiro': {'nome_tipo_roteiro': < nome_tipo_roteiro >, 'descricao': < descricao >, 'nome': < nome >, 'id': < id >, 'id_tipo_roteiro': < id_tipo_roteiro >, 'descricao_tipo_roteiro': < descrição_tipo_roteiro >}, 'equipamento': {'id_modelo': < id_modelo >, 'nome': < nome >, 'nome_marca': < nome_marca >, 'nome_modelo': < nome_modelo >, 'id_marca': < id_marca >, 'nome_tipo_equipamento': < nome_tipo_equipamento >, 'id_tipo_equipamento': < id_tipo_equipamento >, 'id': < id >}}, ... demais equipamento_roteiro´s ...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- remover(id_equipment, id_script)[source]¶
Remove Related Equipment with Script from by the identifier.
Parameters: - id_equipment – Identifier of the Equipment. Integer value and greater than zero.
- id_script – Identifier of the Script. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Equipment or Script is null and invalid.
- RoteiroNaoExisteError – Script not registered.
- EquipamentoNaoExisteError – Equipment not registered.
- EquipamentoRoteiroNaoExisteError – Equipment is not associated with the script.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
networkapiclient.EspecificacaoGrupoVirtual module¶
- class networkapiclient.EspecificacaoGrupoVirtual.EspecificacaoGrupoVirtual[source]¶
Bases: object
Classe auxiliar para construção dos parâmetros das chamadas para provisionar ou remover grupo virtual.
- add_equipamento(id_tipo_equipamento, id_modelo, prefixo, id_grupo, id_vlan, descricao_vlan)[source]¶
Adiciona um equipamento na lista de equipamentos para operação de inserir/alterar um grupo virtual.
Parameters: - id_tipo_equipamento – Identificador do tipo de equipamento.
- id_modelo – Identificador do modelo do equipamento.
- prefixo – Prefixo do nome do equipamento.
- id_grupo – Identificador do grupo do equipamento.
- id_vlan – Identificador da VLAN para criar um IP para o equipamento.
- descricao_vlan – Descrição do IP que será criado.
Returns: None
- add_equipamento_remove(id, id_ip, ids_ips_vips)[source]¶
Adiciona um equipamento na lista de equipamentos para operação de remover um grupo virtual.
Parameters: - id – Identificador do equipamento.
- id_ip – Identificador do IP do equipamento.
- ids_ips_vips – Lista com os identificadores de IPs criados para cada VIP e associados ao equipamento.
Returns: None
- add_vip(id, real_name_sufixo, id_vlan, descricao_vlan, id_vlan_real, descricao_vlan_real, balanceadores, id_healthcheck_expect, finalidade, cliente, ambiente, cache, metodo_bal, persistencia, healthcheck_type, healthcheck, timeout, host, maxcon, dsr, bal_ativo, transbordos, portas, real_maps, id_requisicao_vip, areanegocio='Orquestra', nome_servico='Orquestra', l7_filter=None, reals_prioritys=None, reals_weights=None)[source]¶
Adiciona um VIP na lista de VIPs para operação de inserir/alterar um grupo virtual.
Os parâmetros abaixo somente são necessários para a operação de alteração:
- ‘real_maps’: Deverá conter os reals atualmente criados para a requisição de VIP.
- ‘id_requisicao_vip’: O identificador da requisição que deverá ser alterada.
Os parâmetros abaixo somente são necessários para a operação de inserção:
- ‘id_vlan’: Identificador da VLAN para criar o IP do VIP.
- ‘descricao_vlan’: Descrição do IP do VIP.
- balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
Parameters: - id – Identificador do VIP utilizado pelo sistema de orquestração.
- real_name_sufixo – Sufixo utilizado para criar os reals_names dos equipamentos na requisição de VIP.
- id_vlan – Identificador da VLAN para criar um IP para o VIP.
- descricao_vlan – Descrição do IP que será criado para o VIP.
- id_vlan_real – Identificador da VLAN para criar os IPs dos equipamentos no VIP.
- descricao_vlan_real – Descrição dos IPs que serão criados para os equipamentos no VIP.
- balanceadores – Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
- id_healthcheck_expect – Identificador do healthcheck_expect para criar a requisição de VIP.
- finalidade – Finalidade da requisição de VIP.
- cliente – Cliente da requisição de VIP.
- ambiente – Ambiente da requisição de VIP.
- cache – Cache da requisição de VIP.
- metodo_bal – Método de balanceamento da requisição de VIP.
- persistencia – Persistência da requisição de VIP.
- healthcheck_type – Healthcheck_type da requisição de VIP.
- healthcheck – Healthcheck da requisição de VIP.
- timeout – Timeout da requisição de VIP.
- host – Host da requisição de VIP.
- maxcon – Máximo número de conexão da requisição de VIP.
- dsr – DSR da requisição de VIP.
- bal_ativo – Balanceador ativo da requisição de VIP.
- transbordos – Lista com os IPs dos transbordos da requisição de VIP.
- portas – Lista com as portas da requisição de VIP.
- real_maps – Lista dos mapas com os dados dos reals da requisição de VIP. Cada mapa deverá ter a estrutura: {‘real_name’:< real_name>, ‘real_ip’:< real_ip>}
- id_requisicao_vip – Identificador da requisição de VIP para operação de alterar um grupo virtual.
- areanegocio – Área de negócio para a requisição de VIP (é utilizado ‘Orquestra’ caso seja None).
- nome_servico – Nome do serviço para a requisição de VIP (é utilizado ‘Orquestra’ caso seja None).
- l7_filter – Filtro L7 para a requisição de VIP.
- reals_prioritys – Lista dos dados de prioridade dos reals da requisição de VIP (lista de zeros, caso seja None).
- reals_weights – Lista dos dados de pesos dos reals da requisição de VIP (lista de zeros, caso seja None).
Returns: None
- add_vip_incremento(id)[source]¶
Adiciona um vip à especificação do grupo virtual.
Parameters: id – Identificador de referencia do VIP.
networkapiclient.EventLog module¶
- class networkapiclient.EventLog.EventLog(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- find_logs(user_name, first_date, start_time, last_date, end_time, action, functionality, parameter, pagination)[source]¶
Search all logs, filtering by the given parameters. :param user_name: Filter by user_name :param first_date: Sets initial date for begin of the filter :param start_time: Sets initial time :param last_date: Sets final date :param end_time: Sets final time and ends the filter. That defines the searching gap :param action: Filter by action (Create, Update or Delete) :param functionality: Filter by class :param parameter: Filter by parameter :param pagination: Class with all data needed to paginate
Returns: Following dictionary: {'eventlog': {'id_usuario' : < id_user >, 'hora_evento': < hora_evento >, 'acao': < acao >, 'funcionalidade': < funcionalidade >, 'parametro_anterior': < parametro_anterior >, 'parametro_atual': < parametro_atual > } 'total' : {< total_registros >} }
Raises: - InvalidParameterError – Some parameter was invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_choices()[source]¶
Returns a dictionary with the values used to construct the select box of actions, functionalities and users.
Returns: the following dictionary: {'choices_map': {'usuario' : [{ 'usuario' : < user_id > 'usuario__nome' : < nome > 'usuario__user' : < user > }] 'acao' : ['action1', 'action2', 'action3' .. 'actionN'] 'funcionalidade' : ['functionality1', 'functionality2', .. 'functionalityN'] }}
networkapiclient.Filter module¶
- class networkapiclient.Filter.Filter(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add(name, description)[source]¶
Inserts a new Filter and returns its identifier.
Parameters: - name – Name. String with a maximum of 100 characters and respect [a-zA-Z_-]
- description – Description. String with a maximum of 200 characters and respect [a-zA-Z_-]
Returns: Following dictionary:
{'filter': {'id': < id >}}
Raises: - InvalidParameterError – The value of name or description is invalid.
- FilterDuplicateError – A filter named by name already exists.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- alter(id_filter, name, description)[source]¶
Change Filter by the identifier.
Parameters: - id_filter – Identifier of the Filter. Integer value and greater than zero.
- name – Name. String with a maximum of 50 characters and respect [a-zA-Z_-]
- description – Description. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: None
Raises: - InvalidParameterError – Filter identifier is null and invalid.
- InvalidParameterError – The value of name or description is invalid.
- FilterNotFoundError – Filter not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- associate(et_id, id_filter)[source]¶
Create a relationship between Filter and TipoEquipamento.
Parameters: - et_id – Identifier of TipoEquipamento. Integer value and greater than zero.
- id_filter – Identifier of Filter. Integer value and greater than zero.
Returns: Following dictionary:
{'equiptype_filter_xref': {'id': < id_equiptype_filter_xref >} }
Raises: - InvalidParameterError – TipoEquipamento/Filter identifier is null and/or invalid.
- TipoEquipamentoNaoExisteError – TipoEquipamento not registered.
- FilterNotFoundError – Filter not registered.
- FilterEqTypeAssociationError – TipoEquipamento and Filter already associated.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- dissociate(id_filter, id_eq_type)[source]¶
Removes relationship between Filter and TipoEquipamento.
Parameters: - id_filter – Identifier of Filter. Integer value and greater than zero.
- id_eq_type – Identifier of TipoEquipamento. Integer value, greater than zero.
Returns: None
Raises: - FilterNotFoundError – Filter not registered.
- TipoEquipamentoNotFoundError – TipoEquipamento not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get(id_filter)[source]¶
Get filter by id.
Parameters: id_filter – Identifier of the Filter. Integer value and greater than zero. Returns: Following dictionary: {‘filter’: {‘id’: < id >, ‘name’: < name >, ‘description’: < description >}}
Raises: - InvalidParameterError – The value of id_filter is invalid.
- FilterNotFoundError – Filter not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all()[source]¶
List all filters
Returns: Following dictionary: {'filter': [{'id': <id>, 'name': <name>, 'description': <description>, 'equip_types': [<TipoEquipamento>, {...demais TipoEquipamento's...}]} {... demais filters ...}] }
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remove(id_filter)[source]¶
Remove Filter by the identifier.
Parameters: id_filter – Identifier of the Filter. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Filter identifier is null and invalid.
- FilterNotFoundError – Filter not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.GenericClient module¶
- class networkapiclient.GenericClient.GenericClient(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: object
Class inherited by all NetworkAPI-Client classes who implements access methods to networkAPI.
- get_error(xml)[source]¶
Obtem do XML de resposta, o código e a descrição do erro.
O XML corresponde ao corpo da resposta HTTP de código 500.
Parameters: xml – XML contido na resposta da requisição HTTP. Returns: Tupla com o código e a descrição do erro contido no XML: (< codigo_erro>, < descricao_erro>)
- get_url(postfix)[source]¶
Constroe e retorna a URL completa para acesso à networkAPI.
Parameters: postfix – Posfixo a ser colocado na URL básica. Ex: /ambiente Returns: URL completa.
- response(code, xml, force_list=None)[source]¶
- Cria um dicionário com os dados de retorno da requisição HTTP ou
- lança uma exceção correspondente ao erro ocorrido.
- Se a requisição HTTP retornar o código 200 então este método retorna o
- dicionário com os dados da resposta.
- Se a requisição HTTP retornar um código diferente de 200 então este método
- lança uma exceção correspondente ao erro.
Todas as exceções lançadas por este método deverão herdar de NetworkAPIClientError.
Parameters: - code – Código de retorno da requisição HTTP.
- xml – XML ou descrição (corpo) da resposta HTTP.
- force_list – Lista com as tags do XML de resposta que deverão ser transformadas obrigatoriamente em uma lista no dicionário de resposta.
Returns: Dicionário com os dados da resposta HTTP retornada pela networkAPI.
- submit(map, method, postfix)[source]¶
Realiza um requisição HTTP para a networkAPI.
Parameters: - map – Dicionário com os dados para gerar o XML enviado no corpo da requisição HTTP.
- method – Método da requisição HTTP (‘GET’, ‘POST’, ‘PUT’ ou ‘DELETE’).
- postfix – Posfixo a ser colocado na URL básica de acesso à networkAPI. Ex: /ambiente
Returns: Tupla com o código e o corpo da resposta HTTP: (< codigo>, < descricao>)
Raises NetworkAPIClientError: Erro durante a chamada HTTP para acesso à networkAPI.
networkapiclient.GrupoEquipamento module¶
- class networkapiclient.GrupoEquipamento.GrupoEquipamento(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_egrupo, nome)[source]¶
Altera os dados de um grupo de equipamento a partir do seu identificador.
Parameters: - id_egrupo – Identificador do grupo de equipamento.
- nome – Nome do grupo de equipamento.
Returns: None
Raises: - InvalidParameterError – O identificador e/ou o nome do grupo são nulos ou inválidos.
- GrupoEquipamentoNaoExisteError – Grupo de equipamento não cadastrado.
- NomeGrupoEquipamentoDuplicadoError – Nome do grupo de equipamento duplicado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- associa_equipamento(id_equip, id_grupo_equipamento)[source]¶
Associa um equipamento a um grupo.
Parameters: - id_equip – Identificador do equipamento.
- id_grupo_equipamento – Identificador do grupo de equipamento.
Returns: Dicionário com a seguinte estrutura: {‘equipamento_grupo’:{‘id’: < id_equip_do_grupo >}}
Raises: - GrupoEquipamentoNaoExisteError – Grupo de equipamento não cadastrado.
- InvalidParameterError – O identificador do equipamento e/ou do grupo são nulos ou inválidos.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- EquipamentoError – Equipamento já está associado ao grupo.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- inserir(nome)[source]¶
Insere um novo grupo de equipamento e retorna o seu identificador.
Parameters: nome – Nome do grupo de equipamento.
Returns: Dicionário com a seguinte estrutura: {‘grupo’: {‘id’: < id >}}
Raises: - InvalidParameterError – Nome do grupo é nulo ou vazio.
- NomeGrupoEquipamentoDuplicadoError – Nome do grupo de equipmaneto duplicado.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- listar()[source]¶
Lista todos os grupos de equipamentos.
Returns: Dicionário com a seguinte estrutura: {'grupo': [{'id': < id >, 'nome': < nome >}, ... demais grupos ...]}
Raises: - DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- listar_por_equip(equip_id)[source]¶
Lista todos os grupos de equipamentos por equipamento especifico.
Returns: Dicionário com a seguinte estrutura: {'grupo': [{'id': < id >, 'nome': < nome >}, ... demais grupos ...]}
Raises: - DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remove(id_equipamento, id_egrupo)[source]¶
Remove a associacao de um grupo de equipamento com um equipamento a partir do seu identificador.
Parameters: - id_egrupo – Identificador do grupo de equipamento.
- id_equipamento – Identificador do equipamento.
Returns: None
Raises: - EquipamentoNaoExisteError – Equipamento não cadastrado.
- GrupoEquipamentoNaoExisteError – Grupo de equipamento não cadastrado.
- InvalidParameterError – O identificador do grupo é nulo ou inválido.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- remover(id_egrupo)[source]¶
Remove um grupo de equipamento a partir do seu identificador.
Parameters: id_egrupo – Identificador do grupo de equipamento.
Returns: None
Raises: - GrupoEquipamentoNaoExisteError – Grupo de equipamento não cadastrado.
- InvalidParameterError – O identificador do grupo é nulo ou inválido.
- GroupDontRemoveError –
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- search(id_egroup)[source]¶
Search Group Equipament from by the identifier.
Parameters: id_egroup – Identifier of the Group Equipament. Integer value and greater than zero. Returns: Following dictionary: {‘group_equipament’: {‘id’: < id_egrupo >, ‘nome’: < nome >} }
Raises: - InvalidParameterError – Group Equipament identifier is null and invalid.
- GrupoEquipamentoNaoExisteError – Group Equipament not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.GrupoL3 module¶
- class networkapiclient.GrupoL3.GrupoL3(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_groupl3, name)[source]¶
Change Group L3 from by the identifier.
Parameters: - id_groupl3 – Identifier of the Group L3. Integer value and greater than zero.
- name – Group L3 name. String with a minimum 2 and maximum of 80 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Group L3 or name is null and invalid.
- NomeGrupoL3DuplicadoError – There is already a registered Group L3 with the value of name.
- GrupoL3NaoExisteError – Group L3 not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name)[source]¶
Inserts a new Group L3 and returns its identifier.
Parameters: name – Group L3 name. String with a minimum 2 and maximum of 80 characters Returns: Dictionary with the following structure: {'group_l3': {'id': < id_group_l3 >}}
Raises: - InvalidParameterError – Name is null and invalid.
- NomeGrupoL3DuplicadoError – There is already a registered Group L3 with the value of name.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Group L3.
Returns: Dictionary with the following structure: {'group_l3': [{'id': < id >, 'name': < name >}, ...more Group L3...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_groupl3)[source]¶
Remove Group L3 from by the identifier.
Parameters: id_groupl3 – Identifier of the Group L3. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Group L3 is null and invalid.
- GrupoL3NaoExisteError – Group L3 not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.GrupoUsuario module¶
- class networkapiclient.GrupoUsuario.GrupoUsuario(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_user_group, name, read, write, edit, remove)[source]¶
Edit user group data from its identifier.
Parameters: - id_user_group – User group id.
- name – User group name.
- read – If user group has read permission (‘S’ ou ‘N’).
- write – If user group has write permission (‘S’ ou ‘N’).
- edit – If user group has edit permission (‘S’ ou ‘N’).
- remove – If user group has remove permission (‘S’ ou ‘N’).
Returns: None
Raises: - NomeGrupoUsuarioDuplicadoError – User group name already exists.
- ValorIndicacaoPermissaoInvalidoError – Read, write, edit or remove value is invalid.
- GrupoUsuarioNaoExisteError – User Group not found.
- InvalidParameterError – At least one of the parameters is invalid or none.
- DataBaseError – Networkapi failed to access database.
- XMLError – Networkapi fails generating response XML.
- inserir(name, read, write, edit, remove)[source]¶
Insert new user group and returns its identifier.
Parameters: - name – User group’s name.
- read – If user group has read permission (‘S’ ou ‘N’).
- write – If user group has write permission (‘S’ ou ‘N’).
- edit – If user group has edit permission (‘S’ ou ‘N’).
- remove – If user group has remove permission (‘S’ ou ‘N’).
Returns: Dictionary with structure: {‘user_group’: {‘id’: < id >}}
Raises: - InvalidParameterError – At least one of the parameters is invalid or none..
- NomeGrupoUsuarioDuplicadoError – User group name already exists.
- ValorIndicacaoPermissaoInvalidoError – Read, write, edit or remove value is invalid.
- DataBaseError – Networkapi failed to access database.
- XMLError – Networkapi fails generating response XML.
- listar()[source]¶
List all user groups.
Returns: Dictionary with structure: {'user_group': [{'escrita': < escrita >, 'nome': < nome >, 'exclusao': < exclusao >, 'edicao': < edicao >, 'id': < id >, 'leitura': < leitura >}, ... other groups ...]}
Raises: - DataBaseError – Networkapi failed to access database.
- XMLError – Networkapi fails generating response XML.
- remover(id_user_group)[source]¶
Removes a user group by its id.
Parameters: id_user_group – User Group’s identifier. Valid integer greater than zero.
Returns: None
Raises: - GrupoUsuarioNaoExisteError – User Group not found.
- InvalidParameterError – User Group id is invalid or none.
- DataBaseError – Networkapi failed to access database.
- XMLError – Networkapi fails generating response XML.
- search(id_ugroup)[source]¶
Search Group User by its identifier.
Parameters: id_ugroup – Identifier of the Group User. Integer value and greater than zero. Returns: Following dictionary: {‘user_group’: {'escrita': < escrita >, 'nome': < nome >, 'exclusao': < exclusao >, 'edicao': < edicao >, 'id': < id >, 'leitura': < leitura >}}
Raises: - InvalidParameterError – Group User identifier is none or invalid.
- GrupoUsuarioNaoExisteError – Group User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.GrupoVirtual module¶
Title: Infrastructure NetworkAPI Author: globo.com / TQI Copyright: ( c ) 2009 globo.com todos os direitos reservados.
- class networkapiclient.GrupoVirtual.GrupoVirtual(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- provisionar(equipamentos, vips)[source]¶
Realiza a inserção ou alteração de um grupo virtual para o sistema de Orquestração de VM.
Parameters: - equipamentos – Lista de equipamentos gerada pelo método “add_equipamento” da classe “EspecificacaoGrupoVirtual”.
- vips – Lista de VIPs gerada pelo método “add_vip” da classe “EspecificacaoGrupoVirtual”.
Returns: Retorno da operação de inserir ou alterar um grupo virtual:
{'equipamentos': {'equipamento': [{'id': < id>, 'nome': < nome>, 'ip': {'id': < id>, 'id_vlan': < id_vlan>, 'oct4': < oct4>, 'oct3': < oct3>, 'oct2': < oct2>, 'oct1': < oct1>, 'descricao': < descricao>}, 'vips': {'vip': [{'id': < id>, 'ip': {'id': < id>, 'id_vlan': < id_vlan>, 'oct4': < oct4>, 'oct3': < oct3>, 'oct2': < oct2>, 'oct1': < oct1>, 'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]}, 'vips': {'vip': [{'id': < id>, 'ip': {'id': < id>, 'id_vlan': < id_vlan>, 'oct4': < oct4>, 'oct3': < oct3>, 'oct2': < oct2>, 'oct1': < oct1>, 'descricao': < descricao>}, 'requisicao_vip': {'id': < id>}}, ... demais vips...]}} {'equipamentos': {'equipamento': [{'id': < id>, 'nome': < nome>, 'ip': {'id': < id>, 'id_vlan': < id_vlan>, 'oct4': < oct4>, 'oct3': < oct3>, 'oct2': < oct2>, 'oct1': < oct1>, 'descricao': < descricao>}, 'vips': {'vip': [{'id': < id>, 'ip': {'id': < id>, 'id_vlan': < id_vlan>, 'oct4': < oct4>, 'oct3': < oct3>, 'oct2': < oct2>, 'oct1': < oct1>, 'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]}, 'vips': {'vip': [{'id': < id>, 'requisicao_vip': {'id': < id>}}, ... demais vips...]}}
Raises: - InvalidParameterError – Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- VlanNaoExisteError – VLAN não cadastrada.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- IPNaoDisponivelError – Não existe IP disponível para a VLAN informada.
- TipoEquipamentoNaoExisteError – Tipo de equipamento não cadastrado.
- ModeloEquipamentoNaoExisteError – Modelo do equipamento não cadastrado.
- GrupoEquipamentoNaoExisteError – Grupo de equipamentos não cadastrado.
- EquipamentoError – Equipamento com o nome duplicado ou Equipamento do grupo “Equipamentos Orquestração” somente poderá ser criado com tipo igual a “Servidor Virtual”.
- IpNaoExisteError – IP não cadastrado.
- IpError – IP já está associado ao equipamento.
- VipNaoExisteError – Requisição de VIP não cadastrada.
- HealthCheckExpectNaoExisteError – Healthcheck_expect não cadastrado.
- remover_provisionamento(equipamentos, vips)[source]¶
Remove o provisionamento de um grupo virtual para o sistema de Orquestração VM.
Parameters: - equipamentos – Lista de equipamentos gerada pelo método “add_equipamento_remove” da classe “EspecificacaoGrupoVirtual”.
- vips – Lista de VIPs gerada pelo método “add_vip_remove” da classe “EspecificacaoGrupoVirtual”.
Returns: None
Raises: - InvalidParameterError – Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
- IpNaoExisteError – IP não cadastrado.
- EquipamentoNaoExisteError – Equipamento não cadastrado.
- IpError – IP não está associado ao equipamento.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
networkapiclient.Interface module¶
- class networkapiclient.Interface.Interface(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_interface, nome, protegida, descricao, id_ligacao_front, id_ligacao_back, tipo=None, vlan=None)[source]¶
Edit an interface by its identifier.
Equipment identifier is not changed.
Parameters: - nome – Interface name.
- protegida – Indication of protected (‘0’ or ‘1’).
- descricao – Interface description.
- id_ligacao_front – Front end link interface identifier.
- id_ligacao_back – Back end link interface identifier.
- id_interface – Interface identifier.
Returns: None
Raises: - InvalidParameterError – The parameters interface id, nome and protegida are none or invalid.
- NomeInterfaceDuplicadoParaEquipamentoError – There is already an interface with this name for this equipment.
- InterfaceNaoExisteError – Front link interface and/or back link interface doesn’t exist.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_by_id(id_interface)[source]¶
Get an interface by id.
Parameters: id_interface – Interface identifier. Returns: Following dictionary: {'interface': {'id': < id >, 'interface': < interface >, 'descricao': < descricao >, 'protegida': < protegida >, 'tipo_equip': < id_tipo_equipamento >, 'equipamento': < id_equipamento >, 'equipamento_nome': < nome_equipamento > 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, 'nome_equip_l_back': < equipment_name > }}
Raises: - InvalidParameterError – Interface identifier is invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(nome, protegida, descricao, id_ligacao_front, id_ligacao_back, id_equipamento, tipo=None, vlan=None)[source]¶
Insert new interface for an equipment.
Parameters: - nome – Interface name.
- protegida – Indication of protected (‘0’ or ‘1’).
- descricao – Interface description.
- id_ligacao_front – Front end link interface identifier.
- id_ligacao_back – Back end link interface identifier.
- id_equipamento – Equipment identifier.
Returns: Dictionary with the following: {‘interface’: {‘id’: < id >}}
Raises: - EquipamentoNaoExisteError – Equipment does not exist.
- InvalidParameterError – The parameters nome, protegida and/or equipment id are none or invalid.
- NomeInterfaceDuplicadoParaEquipamentoError – There is already an interface with this name for this equipment.
- InterfaceNaoExisteError – Front link interface and/or back link interface doesn’t exist.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all_by_equip(id_equipamento)[source]¶
List all interfaces of an equipment.
Parameters: id_equipamento – Equipment identifier. Returns: Following dictionary: {'interfaces': [ {'id': < id >, 'interface': < interface >, 'descricao': < descricao >, 'protegida': < protegida >, 'tipo_equip': < id_tipo_equipamento >, 'equipamento': < id_equipamento >, 'equipamento_nome': < nome_equipamento > 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, 'nome_equip_l_back': < equipment_name > }, ... other interfaces ...]}
Raises: - InvalidParameterError – Equipment identifier is invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_connections(nome_interface, id_equipamento)[source]¶
List interfaces linked to back and front of specified interface.
Parameters: - nome_interface – Interface name.
- id_equipamento – Equipment identifier.
Returns: Dictionary with the following:
{'interfaces':[ {'id': < id >, 'interface': < nome >, 'descricao': < descricao >, 'protegida': < protegida >, 'equipamento': < id_equipamento >, 'tipo_equip': < id_tipo_equipamento >, 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, 'nome_equip_l_back': < equipment_name > }, ... other interfaces ...]}
Raises: - InterfaceNaoExisteError – Interface doesn’t exist or is not associated with this equipment.
- EquipamentoNaoExisteError – Equipment doesn’t exist.
- InvalidParameterError – Interface name and/or equipment identifier are none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_ligacoes(nome_interface, id_equipamento)[source]¶
List interfaces linked to back and front of specified interface.
Parameters: - nome_interface – Interface name.
- id_equipamento – Equipment identifier.
Returns: Dictionary with the following:
{'interface': [{'protegida': < protegida >, 'nome': < nome >, 'id_ligacao_front': < id_ligacao_front >, 'id_equipamento': < id_equipamento >, 'id': < id >, 'descricao': < descricao >, 'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]}
Raises: - InterfaceNaoExisteError – Interface doesn’t exist or is not associated with this equipment.
- EquipamentoNaoExisteError – Equipment doesn’t exist.
- InvalidParameterError – Interface name and/or equipment identifier are none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_por_equipamento(id_equipamento)[source]¶
List all interfaces of an equipment.
Parameters: id_equipamento – Equipment identifier. Returns: Dictionary with the following: {'interface': [{'protegida': < protegida >, 'nome': < nome >, 'id_ligacao_front': < id_ligacao_front >, 'id_equipamento': < id_equipamento >, 'id': < id >, 'descricao': < descricao >, 'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]}
Raises: - InvalidParameterError – Equipment identifier is invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remove_connection(id_interface, back_or_front)[source]¶
Remove a connection between two interfaces
Parameters: - id_interface – One side of relation
- back_or_front – This side of relation is back(0) or front(1)
Returns: None
Raises: - InterfaceInvalidBackFrontError – Front or Back of interfaces not match to remove connection
- InvalidParameterError – Interface id or back or front indicator is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_interface)[source]¶
Remove an interface by its identifier.
Parameters: id_interface – Interface identifier.
Returns: None
Raises: - InterfaceNaoExisteError – Interface doesn’t exist.
- InterfaceError – Interface is linked to another interface.
- InvalidParameterError – The interface identifier is invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Ip module¶
- class networkapiclient.Ip.Ip(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- assoc_ipv4(id_ip, id_equip, id_net)[source]¶
Associate an IP4 with equipment.
Parameters: - id_ip – IPv4 identifier.
- id_equip – Equipment identifier. Integer value and greater than zero.
- id_net – Network identifier. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – IPv4, Equipment or Network identifier is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- assoc_ipv6(id_ip, id_equip, id_net)[source]¶
Associate an IP6 with equipment.
Parameters: - id_ip – IPv6 identifier.
- id_equip – Equipment identifier. Integer value and greater than zero.
- id_net – Network identifier. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – IPv6, Equipment or Network identifier is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_por_ip_ambiente(ip, id_environment)[source]¶
Get IP with an associated environment.
Parameters: - ip – IP address in the format x1.x2.x3.x4.
- id_environment – Identifier of the environment. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'ip': {'id': < id >, 'id_vlan': < id_vlan >, 'oct4': < oct4 >, 'oct3': < oct3 >, 'oct2': < oct2 >, 'oct1': < oct1 >, 'descricao': < descricao > }}
Raises: - IpNaoExisteError – IP is not registered or not associated with environment.
- InvalidParameterError – The environment identifier and/or IP is/are null or invalid.
- DataBaseError – Networkapi failed to access the database.
- check_vip_ip(ip, id_evip)[source]¶
Get a Ipv4 or Ipv6 for Vip request
Parameters: ip – IPv4 or Ipv6. ‘xxx.xxx.xxx.xxx or xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx’ Returns: Dictionary with the following structure: {'ip': {'ip': < ip - octs for ipv4, blocks for ipv6 - >, 'id': <id>, 'network4 or network6'}}.
Raises: - IpNaoExisteError – Ipv4 or Ipv6 not found.
- EnvironemntVipNotFoundError – Vip environment not found.
- IPNaoDisponivelError – Ip not available for Vip Environment.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – Ip string or vip environment is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- delete_ip4(id_ip)[source]¶
Delete an IP4
Parameters: id_ip – Ipv4 identifier. Integer value and greater than zero.
Returns: None
Raises: - IpNotFoundError – IP is not registered.
- DataBaseError – Networkapi failed to access the database.
- delete_ip6(id_ip)[source]¶
Delete an IP6
Parameters: id_ip – Ipv6 identifier. Integer value and greater than zero.
Returns: None
Raises: - IpNotFoundError – IP is not registered.
- DataBaseError – Networkapi failed to access the database.
- edit_ipv4(ip4, descricao, id_ip)[source]¶
Edit a IP4
Parameters: - ip4 – An IP4 available to save in format x.x.x.x.
- id_ip – IP identifier. Integer value and greater than zero.
- descricao – IP description.
Returns: None
- edit_ipv6(ip6, descricao, id_ip)[source]¶
Edit a IP6
Parameters: - ip6 – An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx.
- descricao – IP description.
- id_ip – Ipv6 identifier. Integer value and greater than zero.
Returns: None
- find_ip4_by_id(id_ip)[source]¶
Get an IP by ID
Parameters: id_ip – IP identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: { ips { id: <id_ip4>, oct1: <oct1>, oct2: <oct2>, oct3: <oct3>, oct4: <oct4>, equipamento: [ {all equipamentos related} ] , descricao: <descricao>} }
Raises: - IpNotAvailableError – Network dont have available IP.
- NetworkIPv4NotFoundError – Network was not found.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – Ip identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- find_ip4_by_network(id_network)[source]¶
List IPv4 from network.
Parameters: id_network – Networkv ipv4 identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: {'ip': {'id': < id >, 'id_vlan': < id_vlan >, 'oct4': < oct4 >, 'oct3': < oct3 >, 'oct2': < oct2 >, 'oct1': < oct1 >, 'descricao': < descricao > 'equipamento': [ { all name equipamentos related } ], }}
Raises: - IpNaoExisteError – Network does not have any ips.
- InvalidParameterError – Network identifier is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- find_ip6_by_id(id_ip)[source]¶
Get an IP6 by ID
Parameters: id_ip – IP6 identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: {'ip': {'id': < id >, 'block1': <block1>, 'block2': <block2>, 'block3': <block3>, 'block4': <block4>, 'block5': <block5>, 'block6': <block6>, 'block7': <block7>, 'block8': <block8>, 'descricao': < description >, 'equipamento': [ { all name equipamentos related} ], }}
Raises: - IpNotAvailableError – Network dont have available IPv6.
- NetworkIPv4NotFoundError – Network was not found.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – IPv6 identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- find_ip6_by_network(id_network)[source]¶
List IPv6 from network.
Parameters: id_network – Network ipv6 identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: {'ip': {'id': < id >, 'id_vlan': < id_vlan >, 'block1': <block1>, 'block2': <block2>, 'block3': <block3>, 'block4': <block4>, 'block5': <block5>, 'block6': <block6>, 'block7': <block7>, 'block8': <block8>, 'descricao': < description > 'equipamento': [ { all name equipamentos related } ], }}
Raises: - IpNaoExisteError – Network does not have any ips.
- InvalidParameterError – Network identifier is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- find_ips_by_equip(id_equip)[source]¶
Get Ips related to equipment by its identifier
Parameters: id_equip – Equipment identifier. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{ ips: { ipv4:[ id: <id_ip4>, oct1: <oct1>, oct2: <oct2>, oct3: <oct3>, oct4: <oct4>, descricao: <descricao> ] ipv6:[ id: <id_ip6>, block1: <block1>, block2: <block2>, block3: <block3>, block4: <block4>, block5: <block5>, block6: <block6>, block7: <block7>, block8: <block8>, descricao: <descricao> ] } }
Raises: - UserNotAuthorizedError – User dont have permission to list ips.
- InvalidParameterError – Equipment identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_available_ip4(id_network)[source]¶
Get a available IP in the network ipv4
Parameters: id_network – Network identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: {'ip': {'ip': < available_ip >}}
Raises: - IpNotAvailableError – Network dont have available IP for insert a new IP
- NetworkIPv4NotFoundError – Network is not found
- UserNotAuthorizedError – User dont have permission to get a available IP
- InvalidParameterError – Network identifier is null or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_available_ip4_for_vip(id_evip, name)[source]¶
Get and save a available IP in the network ipv6 for vip request
Parameters: - id_evip – Vip environment identifier. Integer value and greater than zero.
- name – Ip description
Returns: Dictionary with the following structure:
{'ip': {'oct1': < oct1 >, 'oct2': < oct2 >, 'oct3': < oct3 >, 'oct4': < oct4 >, 'networkipv4': <networkipv4>, 'id': <id>, 'descricao': <descricao>}}
Raises: - IpNotAvailableError – Network dont have available IP for vip environment.
- EnvironmentVipNotFoundError – Vip environment not registered.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – Vip environment identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_available_ip6(id_network6)[source]¶
Get a available IP in Network ipv6
Parameters: id_network6 – Network ipv6 identifier. Integer value and greater than zero. Returns: Dictionary with the following structure: {'ip6': {'ip6': < available_ip6 >}}
Raises: - IpNotAvailableError – Network dont have available IP.
- NetworkIPv4NotFoundError – Network was not found.
- UserNotAuthorizedError – User dont have permission to get a available IP.
- InvalidParameterError – Network ipv6 identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_available_ip6_for_vip(id_evip, name)[source]¶
Get and save a available IP in the network ipv6 for vip request
Parameters: - id_evip – Vip environment identifier. Integer value and greater than zero.
- name – Ip description
Returns: Dictionary with the following structure:
{'ip': {'bloco1':<bloco1>, 'bloco2':<bloco2>, 'bloco3':<bloco3>, 'bloco4':<bloco4>, 'bloco5':<bloco5>, 'bloco6':<bloco6>, 'bloco7':<bloco7>, 'bloco8':<bloco8>, 'id':<id>, 'networkipv6':<networkipv6>, 'description':<description>}}
Raises: - IpNotAvailableError – Network dont have available IP for vip environment.
- EnvironmentVipNotFoundError – Vip environment not registered.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – Vip environment identifier is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_ip_by_equip_and_vip(equip_name, id_evip)[source]¶
Get a available IP in the Equipment related Environment VIP
Parameters: - equip_name – Equipment Name.
- id_evip – Vip environment identifier. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{ 'ipv4': [ {'id': < id >, 'ip': < ip >, 'network': { 'id': < id >, 'network': < network >, 'mask': < mask >, }} ... ], 'ipv6': [ {'id': < id >, 'ip': < ip >, 'network': { 'id': < id >, 'network': < network >, 'mask': < mask >, }} ... ] }
Raises: - InvalidParameterError – Vip environment identifier or equipment name is none or invalid.
- EquipamentoNotFoundError – Equipment not registered.
- EnvironmentVipNotFoundError – Vip environment not registered.
- UserNotAuthorizedError – User dont have permission to perform operation.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_ipv4(id_ip)[source]¶
Get IPv4 by id.
Parameters: id_ip – ID of IPv4. Returns: Dictionary with the following structure: {'ip': {'id': < id >, 'networkipv4': < networkipv4 >, 'oct4': < oct4 >, 'oct3': < oct3 >, 'oct2': < oct2 >, 'oct1': < oct1 >, 'descricao': < descricao >, 'equipamentos': [ { all name of equipments related } ] , }}
Raises: - IpNaoExisteError – IP is not registered.
- InvalidParameterError – IP identifier is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_ipv4_or_ipv6(ip)[source]¶
Get a Ipv4 or Ipv6 by IP
Parameters: ip – IPv4 or Ipv6. ‘xxx.xxx.xxx.xxx or xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx’ Returns: Dictionary with the following structure: {'ips': [{'oct4': < oct4 >, 'oct2': < oct2 >, 'oct3': < oct3 >, 'oct1': < oct1 >, 'version': < version >, 'networkipv4': < networkipv4 >, 'id': < id >, 'descricao': < descricao >}, ... ] }. or {'ips': [ {'block1': < block1 >, 'block2': < block2 >, 'block3': < block3 >, 'block4': < block4 >, 'block5': < block5 >, 'block6': < block6 >, 'block7': < block7 >, 'block8': < block8 >, 'version': < version >, 'networkipv6': < networkipv6 >, 'id': < id >, 'descricao': < descricao >}, ... ] }.
Raises: - IpNaoExisteError – Ipv4 or Ipv6 not found.
- UserNotAuthorizedError – User dont have permission to perform operation.
- InvalidParameterError – Ip string is none or invalid.
- XMLError – Networkapi failed to generate the XML response.
- DataBaseError – Networkapi failed to access the database.
- get_ipv6(id_ip)[source]¶
Get IPv6 by id.
Parameters: id_ip – ID of IPv6. Returns: Dictionary with the following structure: {'ip': {'id': < id >, 'networkipv6': < networkipv6 >, 'block1': < block1 >, 'block2': < block2 >, 'block3': < block3 >, 'block4': < block4 >, 'block5': < block5 >, 'block6': < block6 >, 'block7': < block7 >, 'block8': < block8 >, 'description': < description >, 'equipamentos': [ { all name of equipments related } ] , }}
Raises: - IpNaoExisteError – IP is not registered.
- InvalidParameterError – IP identifier is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- save_ipv4(ip4, id_equip, descricao, id_net)[source]¶
Save a IP4 and associate with equipment
Parameters: - ip4 – An IP4 available to save in format x.x.x.x.
- id_equip – Equipment identifier. Integer value and greater than zero.
- descricao – IP description.
- id_net – Network identifier. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{ ip: { id: <id_ip4>, oct1: <oct1>, oct2: <oct2>, oct3: <oct3>, oct4: <oct4>, equipamento: [ { all equipamentos related } ] , descricao: <descricao> } }
- save_ipv6(ip6, id_equip, descricao, id_net)[source]¶
Save an IP6 and associate with equipment
Parameters: - ip6 – An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx.
- id_equip – Equipment identifier. Integer value and greater than zero.
- descricao – IPv6 description.
- id_net – Network identifier. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'ipv6': {'id': < id >, 'block1': <block1>, 'block2': <block2>, 'block3': <block3>, 'block4': <block4>, 'block5': <block5>, 'block6': <block6>, 'block7': <block7>, 'block8': <block8>, 'descricao': < description >, 'equipamento': [ { all name equipamentos related } ], }}
- search_ipv6_environment(ipv6, id_environment)[source]¶
Get IPv6 with an associated environment.
Parameters: - ipv6 – IPv6 address in the format x1:x2:x3:x4:x5:x6:x7:x8.
- id_environment – Environment identifier. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'ipv6': {'id': < id >, 'id_vlan': < id_vlan >, 'bloco1': < bloco1 >, 'bloco2': < bloco2 >, 'bloco3': < bloco3 >, 'bloco4': < bloco4 >, 'bloco5': < bloco5 >, 'bloco6': < bloco6 >, 'bloco7': < bloco7 >, 'bloco8': < bloco8 >, 'descricao': < descricao > }}
Raises: - IpNaoExisteError – IPv6 is not registered or is not associated to the environment.
- AmbienteNaoExisteError – Environment not found.
- InvalidParameterError – Environment identifier and/or IPv6 string is/are none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Marca module¶
- class networkapiclient.Marca.Marca(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_brand, name)[source]¶
Change Brand from by the identifier.
Parameters: - id_brand – Identifier of the Brand. Integer value and greater than zero.
- name – Brand name. String with a minimum 3 and maximum of 100 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Brand or name is null and invalid.
- NomeMarcaDuplicadoError – There is already a registered Brand with the value of name.
- MarcaNaoExisteError – Brand not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name)[source]¶
Inserts a new Brand and returns its identifier
Parameters: name – Brand name. String with a minimum 3 and maximum of 100 characters Returns: Dictionary with the following structure: {'marca': {'id': < id_brand >}}
Raises: - InvalidParameterError – Name is null and invalid.
- NomeMarcaDuplicadoError – There is already a registered Brand with the value of name.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Brand.
Returns: Dictionary with the following structure: {‘brand’: [{‘id’: < id >, ‘nome’: < nome >}, ... too Brands ...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_brand)[source]¶
Remove Brand from by the identifier.
Parameters: id_brand – Identifier of the Brand. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Brand is null and invalid.
- MarcaNaoExisteError – Brand not registered.
- MarcaError – The brand is associated with a model.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Modelo module¶
- class networkapiclient.Modelo.Modelo(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_model, id_brand, name)[source]¶
Change Model from by the identifier.
Parameters: - id_model – Identifier of the Model. Integer value and greater than zero.
- id_brand – Identifier of the Brand. Integer value and greater than zero.
- name – Model name. String with a minimum 3 and maximum of 100 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Model, Brand or name is null and invalid.
- MarcaNaoExisteError – Brand not registered.
- ModeloEquipamentoNaoExisteError – Model not registered.
- NomeMarcaModeloDuplicadoError – There is already a registered Model with the value of name and brand.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- inserir(id_brand, name)[source]¶
Inserts a new Model and returns its identifier
Parameters: - id_brand – Identifier of the Brand. Integer value and greater than zero.
- name – Model name. String with a minimum 3 and maximum of 100 characters
Returns: Dictionary with the following structure:
{'model': {'id': < id_model >}}
Raises: - InvalidParameterError – The identifier of Brand or name is null and invalid.
- NomeMarcaModeloDuplicadoError – There is already a registered Model with the value of name and brand.
- MarcaNaoExisteError – Brand not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- listar()[source]¶
List all Model.
Returns: Dictionary with the following structure: {‘model’: [{‘id’: < id >, ‘nome’:< nome >, ‘id_marca’:< id_marca >, ‘nome_marca’:< nome_marca >}, ... too Model ... ]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- listar_por_marca(id_brand)[source]¶
List all Model by Brand.
Parameters: id_brand – Identifier of the Brand. Integer value and greater than zero. Returns: Dictionary with the following structure: {‘model’: [{‘id’: < id >, ‘nome’: < nome >, ‘id_marca’: < id_marca >}, ... too Model ...]}
Raises: - InvalidParameterError – The identifier of Brand is null and invalid.
- MarcaNaoExisteError – Brand not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- remover(id_model)[source]¶
Remove Model from by the identifier.
Parameters: id_model – Identifier of the Model. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Model is null and invalid.
- ModeloEquipamentoNaoExisteError – Model not registered.
- ModeloEquipamentoError – The Model is associated with a equipment.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
networkapiclient.Network module¶
- class networkapiclient.Network.DHCPRelayIPv4(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.ApiGenericClient.ApiGenericClient
- add(networkipv4_id, ipv4_id)[source]¶
List all DHCPRelayIPv4.
Param: networkipv4_id, ipv4_id Returns: Following dictionary: { “networkipv4”: <networkipv4_id>, “id”: <id>, “ipv4”: { “oct4”: <oct4>, “oct2”: <oct2>, “oct3”: <oct3>, “oct1”: <oct1>, “ip_formated”: “<string IPv4>”, “networkipv4”: <networkipv4_id>, “id”: <ipv4_id>, “descricao”: “<string description>”}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- get_by_pk(dhcprelayv4_id)[source]¶
List DHCPRelayIPv4 by ID
Param: dhcprelayv4_id Returns: Following dictionary: { “networkipv4”: <networkipv4_id>, “id”: <id>, “ipv4”: { “oct4”: <oct4>, “oct2”: <oct2>, “oct3”: <oct3>, “oct1”: <oct1>, “ip_formated”: “<string IPv4>”, “networkipv4”: <networkipv4_id>, “id”: <ipv4_id>, “descricao”: “<string description>”}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- list(networkipv4=None, ipv4=None)[source]¶
List all DHCPRelayIPv4.
Param: networkipv4: networkipv4 id - list all dhcprelay filtering by networkipv4 id ipv4: ipv4 id - list all dhcprelay filtering by ipv4 id Returns: Following dictionary: [ { “networkipv4”: <networkipv4_id>, “id”: <id>, “ipv4”: {“oct4”: <oct4>, “oct2”: <oct2>, “oct3”: <oct3>, “oct1”: <oct1>, “ip_formated”: “<string IPv4>”, “networkipv4”: <networkipv4_id>, “id”: <ipv4_id>, “descricao”: “<string description>”}, {...}
]
Raises NetworkAPIException: Falha ao acessar fonte de dados
- class networkapiclient.Network.DHCPRelayIPv6(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.ApiGenericClient.ApiGenericClient
- add(networkipv6_id, ipv6_id)[source]¶
List all DHCPRelayIPv4.
Param: Object DHCPRelayIPv4 Returns: Following dictionary: { “networkipv6”: <networkipv4_id>, “id”: <id>, “ipv6”: { “block1”: <block1>, “block2”: <block2>, “block3”: <block3>, “block4”: <block4>, “block5”: <block5>, “block6”: <block6>, “block7”: <block7>, “block8”: <block8>, “ip_formated”: “<string IPv6>”, “networkipv6”: <networkipv6_id>, “id”: <ipv6_id>, “description”: “<string description>”}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- get_by_pk(dhcprelayv6_id)[source]¶
List DHCPRelayIPv6 by ID
Param: dhcprelayv4_id Returns: Following dictionary: { “networkipv6”: <networkipv4_id>, “id”: <id>, “ipv6”: { “block1”: <block1>, “block2”: <block2>, “block3”: <block3>, “block4”: <block4>, “block5”: <block5>, “block6”: <block6>, “block7”: <block7>, “block8”: <block8>, “ip_formated”: “<string IPv6>”, “networkipv6”: <networkipv6_id>, “id”: <ipv6_id>, “description”: “<string description>”}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- list(networkipv6=None, ipv6=None)[source]¶
List all DHCPRelayIPv6.
Param: networkipv6: networkipv6 id - list all dhcprelay filtering by networkipv6 id ipv6: ipv6 id - list all dhcprelay filtering by ipv6 id Returns: Following dictionary: [ { “networkipv6”: <networkipv4_id>, “id”: <id>, “ipv6”: {“block1”: <block1>, “block2”: <block2>, “block3”: <block3>, “block4”: <block4>, “block5”: <block5>, “block6”: <block6>, “block7”: <block7>, “block8”: <block8>, “ip_formated”: “<string IPv6>”, “networkipv6”: <networkipv6_id>, “id”: <ipv6_id>, “description”: “<string description>”}, {...}
]
Raises NetworkAPIException: Falha ao acessar fonte de dados
- class networkapiclient.Network.Network(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add_network(network, id_vlan, id_network_type, id_environment_vip=None, cluster_unit=None)[source]¶
Add new network
Parameters: - network – IPV4 or IPV6 (ex.: “10.0.0.3/24”)
- id_vlan – Identifier of the Vlan. Integer value and greater than zero.
- id_network_type – Identifier of the NetworkType. Integer value and greater than zero.
- id_environment_vip – Identifier of the Environment Vip. Integer value and greater than zero.
Returns: Following dictionary:
{'network':{'id': <id_network>, 'rede': <network>, 'broadcast': <broadcast> (if is IPv4), 'mask': <net_mask>, 'id_vlan': <id_vlan>, 'id_tipo_rede': <id_network_type>, 'id_ambiente_vip': <id_ambiente_vip>, 'active': <active>} }
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv4.
- NetworkIPRangeEnvError – Other environment already have this ip range.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_network_ipv4(id_vlan, id_tipo_rede, id_ambiente_vip=None, prefix=None)[source]¶
Add new networkipv4
Parameters: - id_vlan – Identifier of the Vlan. Integer value and greater than zero.
- id_tipo_rede – Identifier of the NetworkType. Integer value and greater than zero.
- id_ambiente_vip – Identifier of the Environment Vip. Integer value and greater than zero.
- prefix – Prefix.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >}}
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv4.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_network_ipv4_hosts(id_vlan, id_tipo_rede, num_hosts, id_ambiente_vip=None)[source]¶
Add new networkipv4
Parameters: - id_vlan – Identifier of the Vlan. Integer value and greater than zero.
- id_tipo_rede – Identifier of the NetworkType. Integer value and greater than zero.
- num_hosts – Number of hosts expected. Integer value and greater than zero.
- id_ambiente_vip – Identifier of the Environment Vip. Integer value and greater than zero.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >}}
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv4.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_network_ipv6(id_vlan, id_tipo_rede, id_ambiente_vip=None, prefix=None)[source]¶
Add new networkipv6
Parameters: - id_vlan – Identifier of the Vlan. Integer value and greater than zero.
- id_tipo_rede – Identifier of the NetworkType. Integer value and greater than zero.
- id_ambiente_vip – Identifier of the Environment Vip. Integer value and greater than zero.
- prefix – Prefix.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'rede_oct5': < rede_oct4 >, 'rede_oct6': < rede_oct4 >, 'rede_oct7': < rede_oct4 >, 'rede_oct8': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'mascara_oct5': < mascara_oct4 >, 'mascara_oct6': < mascara_oct4 >, 'mascara_oct7': < mascara_oct4 >, 'mascara_oct8': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >}}
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv6.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- add_network_ipv6_hosts(id_vlan, id_tipo_rede, num_hosts, id_ambiente_vip=None)[source]¶
Add new networkipv6
Parameters: - id_vlan – Identifier of the Vlan. Integer value and greater than zero.
- id_tipo_rede – Identifier of the NetworkType. Integer value and greater than zero.
- num_hosts – Number of hosts expected. Integer value and greater than zero.
- id_ambiente_vip – Identifier of the Environment Vip. Integer value and greater than zero.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'rede_oct5': < rede_oct4 >, 'rede_oct6': < rede_oct4 >, 'rede_oct7': < rede_oct4 >, 'rede_oct8': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'mascara_oct5': < mascara_oct4 >, 'mascara_oct6': < mascara_oct4 >, 'mascara_oct7': < mascara_oct4 >, 'mascara_oct8': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >}}
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv6.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- create_networks(ids, id_vlan)[source]¶
Set column ‘active = 1’ in tables redeipv4 and redeipv6]
Parameters: ids – ID for NetworkIPv4 and/or NetworkIPv6 Returns: Nothing
- deallocate_network_ipv4(id_network_ipv4)[source]¶
Deallocate all relationships between NetworkIPv4.
Parameters: id_network_ipv4 – ID for NetworkIPv4
Returns: Nothing
Raises: - InvalidParameterError – Invalid ID for NetworkIPv4.
- NetworkIPv4NotFoundError – NetworkIPv4 not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- deallocate_network_ipv6(id_network_ipv6)[source]¶
Deallocate all relationships between NetworkIPv6.
Parameters: id_network_ipv6 – ID for NetworkIPv6
Returns: Nothing
Raises: - InvalidParameterError – Invalid ID for NetworkIPv6.
- NetworkIPv6NotFoundError – NetworkIPv6 not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- edit_network(id_network, ip_type, id_net_type, id_env_vip=None, cluster_unit=None)[source]¶
Edit a network 4 or 6
Parameters: - id_network – Identifier of the Network. Integer value and greater than zero.
- id_net_type – Identifier of the NetworkType. Integer value and greater than zero.
- id_env_vip – Identifier of the Environment Vip. Integer value and greater than zero.
- ip_type – Identifier of the Network IP Type: 0 = IP4 Network; 1 = IP6 Network;
Returns: None
Raises: - TipoRedeNaoExisteError – NetworkType not found.
- InvalidParameterError – Invalid ID for Vlan or NetworkType.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- IPNaoDisponivelError – Network address unavailable to create a NetworkIPv4.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_network_ipv4(id_network)[source]¶
Get networkipv4
Parameters: id_network – Identifier of the Network. Integer value and greater than zero. Returns: Following dictionary: {'network': {'id': < id_networkIpv6 >, 'network_type': < id_tipo_rede >, 'ambiente_vip': < id_ambiente_vip >, 'vlan': <id_vlan> 'oct1': < rede_oct1 >, 'oct2': < rede_oct2 >, 'oct3': < rede_oct3 >, 'oct4': < rede_oct4 > 'blocK': < bloco >, 'mask_oct1': < mascara_oct1 >, 'mask_oct2': < mascara_oct2 >, 'mask_oct3': < mascara_oct3 >, 'mask_oct4': < mascara_oct4 >, 'active': < ativada >, 'broadcast':<'broadcast>, }}
Raises: - NetworkIPv4NotFoundError – NetworkIPV4 not found.
- InvalidValueError – Invalid ID for NetworkIpv4
- NetworkIPv4Error – Error in NetworkIpv4
- XMLError – Networkapi failed to generate the XML response.
- get_network_ipv6(id_network)[source]¶
Get networkipv6
Parameters: id_network – Identifier of the Network. Integer value and greater than zero. Returns: Following dictionary: {'network': {'id': < id_networkIpv6 >, 'network_type': < id_tipo_rede >, 'ambiente_vip': < id_ambiente_viṕ >, 'vlan': <id_vlan> 'block1': < rede_oct1 >, 'block2': < rede_oct2 >, 'block3': < rede_oct3 >, 'block4': < rede_oct4 >, 'block5': < rede_oct4 >, 'block6': < rede_oct4 >, 'block7': < rede_oct4 >, 'block8': < rede_oct4 >, 'blocK': < bloco >, 'mask1': < mascara_oct1 >, 'mask2': < mascara_oct2 >, 'mask3': < mascara_oct3 >, 'mask4': < mascara_oct4 >, 'mask5': < mascara_oct4 >, 'mask6': < mascara_oct4 >, 'mask7': < mascara_oct4 >, 'mask8': < mascara_oct4 >, 'active': < ativada >, }}
Raises: - NetworkIPv6NotFoundError – NetworkIPV6 not found.
- InvalidValueError – Invalid ID for NetworkIpv6
- NetworkIPv6Error – Error in NetworkIpv6
- XMLError – Networkapi failed to generate the XML response.
- remove_networks(ids)[source]¶
Set column ‘active = 0’ in tables redeipv4 and redeipv6]
Parameters: ids – ID for NetworkIPv4 and/or NetworkIPv6
Returns: Nothing
Raises: - NetworkInactiveError – Unable to remove the network because it is inactive.
- InvalidParameterError – Invalid ID for Network or NetworkType.
- NetworkIPv4NotFoundError – NetworkIPv4 not found.
- NetworkIPv6NotFoundError – NetworkIPv6 not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.OptionVIP module¶
- class networkapiclient.OptionVIP.OptionVIP(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- add(tipo_opcao, nome_opcao_txt)[source]¶
Inserts a new Option VIP and returns its identifier.
Parameters: - tipo_opcao – Type. String with a maximum of 50 characters and respect [a-zA-Z_-]
- nome_opcao_txt – Name Option. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: Following dictionary:
{'option_vip': {'id': < id >}}
Raises: - InvalidParameterError – The value of tipo_opcao or nome_opcao_txt is invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- alter(id_option_vip, tipo_opcao, nome_opcao_txt)[source]¶
Change Option VIP from by the identifier.
Parameters: - id_option_vip – Identifier of the Option VIP. Integer value and greater than zero.
- tipo_opcao – Type. String with a maximum of 50 characters and respect [a-zA-Z_-]
- nome_opcao_txt – Name Option. String with a maximum of 50 characters and respect [a-zA-Z_-]
Returns: None
Raises: - InvalidParameterError – Option VIP identifier is null and invalid.
- InvalidParameterError – The value of tipo_opcao or nome_opcao_txt is invalid.
- OptionVipNotFoundError – Option VIP not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- associate(id_option_vip, id_environment_vip)[source]¶
Create a relationship of OptionVip with EnvironmentVip.
Parameters: - id_option_vip – Identifier of the Option VIP. Integer value and greater than zero.
- id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero.
Returns: Following dictionary
{'opcoesvip_ambiente_xref': {'id': < id_opcoesvip_ambiente_xref >} }
Raises: - InvalidParameterError – Option VIP/Environment VIP identifier is null and/or invalid.
- OptionVipNotFoundError – Option VIP not registered.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- OptionVipError – Option vip is already associated with the environment vip.
- UserNotAuthorizedError – User does not have authorization to make this association.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_balanceamento_opcvip(id_ambiente_vip)[source]¶
Search nome_opcao_txt of Option VIP when tipo_opcao = ‘Balanceamento’ by environmentvip_id
Returns: Dictionary with the following structure: {‘balanceamento_opt’: ‘balanceamento_opt’: <'nome_opcao_txt'>}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_grupo_cache_opcvip(id_ambiente_vip)[source]¶
Search nome_opcao_txt of Option VIP when tipo_opcao = ‘Grupo de Caches’ by environmentvip_id
Returns: Dictionary with the following structure: {‘grupocache_opt’: ‘grupocache_opt’: <'nome_opcao_txt'>}
Raises: - EnvironmentVipNotFoundError – Ambiente VIP não encontrado
- OptionVipError – Falha na requisição.
- EnvironmentVipError – Falha na requisição.
- InvalidParameterError – O identificador da requisição de VIP é inválido ou nulo.
- ScriptError – Falha ao executar o script.
- DataBaseError – Falha na networkapi ao acessar o banco de dados.
- XMLError – Falha na networkapi ao gerar o XML de resposta.
- buscar_healthchecks(id_ambiente_vip)[source]¶
Search healthcheck by environmentvip_id
Returns: Dictionary with the following structure: {'healthcheck_opt': [{'name': <name>, 'id': <id>},...]}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – id_ambiente_vip is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_idtrafficreturn_opcvip(nome_opcao_txt)[source]¶
Search id of Option VIP when tipo_opcao = ‘Retorno de trafego’
Returns: Dictionary with the following structure: {‘trafficreturn_opt’: ‘trafficreturn_opt’: <'id'>}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_persistencia_opcvip(id_ambiente_vip)[source]¶
Search nome_opcao_txt of Option VIP when tipo_opcao = ‘Persistencia’ by environmentvip_id
Returns: Dictionary with the following structure: {‘persistencia_opt’: ‘persistencia_opt’: <'nome_opcao_txt'>}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_rules(id_ambiente_vip, id_vip='')[source]¶
Search rules by environmentvip_id
Returns: Dictionary with the following structure: {'name_rule_opt': [{'name_rule_opt': <name>, 'id': <id>}, ...]}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_timeout_opcvip(id_ambiente_vip)[source]¶
Buscar nome_opcao_txt das Opcoes VIp quando tipo_opcao = ‘Timeout’ pelo environmentvip_id
Returns: Dictionary with the following structure: - ::
- {‘timeout_opt’: ‘timeout_opt’: <’nome_opcao_txt’>}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- buscar_trafficreturn_opcvip(id_ambiente_vip)[source]¶
Search nome_opcao_txt of Option VIP when tipo_opcao = ‘Persistencia’ by environmentvip_id
Returns: Dictionary with the following structure: {‘persistencia_opt’: ‘persistencia_opt’: <'nome_opcao_txt'>}
Raises: - InvalidParameterError – Environment VIP identifier is null and invalid.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – finalidade_txt and cliente_txt is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- disassociate(id_option_vip, id_environment_vip)[source]¶
Remove a relationship of OptionVip with EnvironmentVip.
Parameters: - id_option_vip – Identifier of the Option VIP. Integer value and greater than zero.
- id_environment_vip – Identifier of the Environment VIP. Integer value and greater than zero.
Returns: Nothing
Raises: - InvalidParameterError – Option VIP/Environment VIP identifier is null and/or invalid.
- OptionVipNotFoundError – Option VIP not registered.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- OptionVipError – Option vip is not associated with the environment vip
- UserNotAuthorizedError – User does not have authorization to make this association.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_all()[source]¶
Get all Option VIP.
Returns: Dictionary with the following structure: {‘option_vip’: [{‘id’: < id >, ‘tipo_opcao’: < tipo_opcao >, ‘nome_opcao_txt’: < nome_opcao_txt >}, ... other option vips ...] }
Raises: - OptionVipNotFoundError – Option VIP not registered.
- DataBaseError – Can’t connect to networkapi database.
- XMLError – Failed to generate the XML response.
- get_option_vip(id_environment_vip)[source]¶
Get all Option VIP by Environment Vip.
Returns: Dictionary with the following structure: {‘option_vip’: [{‘id’: < id >, ‘tipo_opcao’: < tipo_opcao >, ‘nome_opcao_txt’: < nome_opcao_txt >}, ... too option vips ...] }
Raises: - EnvironmentVipNotFoundError – Environment VIP not registered.
- DataBaseError – Can’t connect to networkapi database.
- XMLError – Failed to generate the XML response.
- remove(id_option_vip)[source]¶
Remove Option VIP from by the identifier.
Parameters: id_option_vip – Identifier of the Option VIP. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Option VIP identifier is null and invalid.
- OptionVipNotFoundError – Option VIP not registered.
- OptionVipError – Option VIP associated with environment vip.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- search(id_option_vip)[source]¶
Search Option VIP from by the identifier.
Parameters: id_option_vip – Identifier of the Option VIP. Integer value and greater than zero. Returns: Following dictionary: {‘option_vip’: {‘id’: < id_option_vip >, ‘tipo_opcao’: < tipo_opcao >, ‘nome_opcao_txt’: < nome_opcao_txt >} }
Raises: - InvalidParameterError – Option VIP identifier is null and invalid.
- OptionVipNotFoundError – Option VIP not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Pagination module¶
networkapiclient.PermissaoAdministrativa module¶
- class networkapiclient.PermissaoAdministrativa.PermissaoAdministrativa(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_perm, id_permission, read, write, id_group)[source]¶
Change Administrative Permission from by the identifier.
Parameters: - id_perm – Identifier of the Administrative Permission. Integer value and greater than zero.
- id_permission – Identifier of the Permission. Integer value and greater than zero.
- read – Read. 0 or 1
- write – Write. 0 or 1
- id_group – Identifier of the Group of User. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Administrative Permission, identifier of Permission, identifier of Group of User, read or write is null and invalid.
- ValorIndicacaoPermissaoInvalidoError – The value of read or write is null and invalid.
- PermissaoAdministrativaNaoExisteError – Administrative Permission not registered.
- GrupoUsuarioNaoExisteError – Group of User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(id_permission, read, write, id_group)[source]¶
Inserts a new Administrative Permission and returns its identifier.
Parameters: - id_permission – Identifier of the Permission. Integer value and greater than zero.
- read – Read. 0 or 1
- write – Write. 0 or 1
- id_group – Identifier of the Group of User. Integer value and greater than zero.
Returns: Dictionary with the following structure:
{'perm': {'id': < id_perm >}}
Raises: - InvalidParameterError – The identifier of Administrative Permission, identifier of Group of User, read or write is null and invalid.
- ValorIndicacaoPermissaoInvalidoError – The value of read or write is null and invalid.
- PermissaoAdministrativaDuplicadaError – Function already registered for the user group.
- GrupoUsuarioNaoExisteError – Group of User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_by_group(id_ugroup)[source]¶
Search Administrative Permission by Group User by identifier.
Parameters: id_ugroup – Identifier of the Group User. Integer value and greater than zero. Returns: Dictionary with the following structure: {'perms': [{'ugrupo': < ugrupo_id >, 'permission': { 'function' < function >, 'id': < id > }, 'id': < id >, 'escrita': < escrita >, 'leitura': < leitura >}, ... ] }
Raises: - InvalidParameterError – Group User is null and invalid.
- UGrupoNotFoundError – Group User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Administrative Permission.
Returns: Dictionary with the following structure: {'perms': [{'ugrupo': < ugrupo_id >, 'permission': < permission_id >, 'id': < id >, 'escrita': < escrita >, 'leitura': < leitura >}, ... demais permissões ...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_perms)[source]¶
Remove Administrative Permission from by the identifier.
Parameters: id_perms – Identifier of the Administrative Permission. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Administrative Permission is null and invalid.
- PermissaoAdministrativaNaoExisteError – Administrative Permission not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- search(id_perm)[source]¶
Search Administrative Permission from by the identifier.
Parameters: id_perm – Identifier of the Administrative Permission. Integer value and greater than zero. Returns: Following dictionary: {'perm': {'ugrupo': < ugrupo_id >, 'permission': < permission_id >, 'id': < id >, 'escrita': < escrita >, 'leitura': < leitura >}}
Raises: - InvalidParameterError – Group User identifier is null and invalid.
- PermissaoAdministrativaNaoExisteError – Administrative Permission not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Permission module¶
networkapiclient.Pool module¶
- class networkapiclient.Pool.Pool(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.ApiGenericClient.ApiGenericClient
- create(pools)[source]¶
Create Pools Running Script And Update to Created
Parameters: pools – List of pools Returns: None on success :raise PoolDoesNotExistException :raise ScriptCreatePoolException :raise InvalidIdPoolException :raise NetworkAPIException
- disable(ids)[source]¶
Disable Pool Members Running Script
Parameters: ids – List of ids Returns: None on success :raise PoolMemberDoesNotExistException :raise InvalidIdPoolMemberException :raise ScriptDisablePoolException :raise NetworkAPIException
- enable(ids)[source]¶
Enable Pool Members Running Script
Parameters: ids – List of ids Returns: None on success :raise PoolMemberDoesNotExistException :raise InvalidIdPoolMemberException :raise ScriptEnablePoolException :raise NetworkAPIException
- get_equip_by_ip(id_ip)[source]¶
Get equipment by IP id
Parameters: id_ip – IP id Returns: Following dictionary:{ “equipamento” :[{ “id”: < id > “tipo_equipamento”: < tipo_equipamento >, “modelo”: < modelo >, “nome”: < nome >, “grupos”: < grupos >}]
Raises NetworkAPIException: Falha ao acessar fonte de dados
- inserir(identifier, default_port, environment, balancing, healthcheck_type, healthcheck_expect, healthcheck_request, old_healthcheck_id, maxcon, ip_list_full, nome_equips, id_equips, priorities, weight, ports_reals, servicedownaction=None)[source]¶
- list_all(environment_id, pagination)[source]¶
List All Pools To Populate Datatable
Parameters: pagination – Object Pagination Returns: Following dictionary:{ “total” : < total >, “pools” :[{ “id”: < id > “default_port”: < default_port >, “identifier”: < identifier >, “healthcheck”: < healthcheck >,}, ... too ... ]}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- list_all_by_reqvip(id_vip, pagination)[source]¶
List All Pools To Populate Datatable
Parameters: pagination – Object Pagination Returns: Following dictionary:{ “total” : < total >, “pools” :[{ “id”: < id > “default_port”: < default_port >, “identifier”: < identifier >, “healthcheck”: < healthcheck >,}, ... too ... ]}
Raises NetworkAPIException: Falha ao acessar fonte de dados
- list_by_environment(environment_id)[source]¶
Disable Pool Members Running Script
Parameters: ids – List of ids Returns: Following dictionary:{ “pools” :[{ “id”: < id > “default_port”: < default_port >, “identifier”: < identifier >, “healthcheck”: < healthcheck >,}, ... too ... ]}
:raise ObjectDoesNotExistException :raise ValidationException :raise NetworkAPIException
- list_healthchecks()[source]¶
List all healthchecks
Returns: Following dictionary: {'ambiente': [{ 'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3>, 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico>, 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, 'link': <link> }, ... ]}
Raises DataBaseError: Falha na networkapi ao acessar o banco de dados.
- list_pool_members(pool_id)[source]¶
Disable Pool Members Running Script
Parameters: ids – List of ids Returns: :raise ObjectDoesNotExistException :raise ValidationException :raise NetworkAPIException
- remove(pools)[source]¶
Remove Pools Running Script And Update to Not Created
Parameters: ids – List of ids Returns: None on success :raise ScriptRemovePoolException :raise InvalidIdPoolException :raise NetworkAPIException
- save(id, identifier, default_port, environment, balancing, healthcheck_type, healthcheck_expect, healthcheck_request, maxcon, ip_list_full, nome_equips, id_equips, priorities, weight, ports_reals, id_pool_member, servicedownaction=None)[source]¶
- save_reals(id_server_pool, ip_list_full, nome_equips, id_equips, priorities, weight, ports_reals, id_pool_member)[source]¶
networkapiclient.Roteiro module¶
- class networkapiclient.Roteiro.Roteiro(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_script, id_script_type, script, description, model=None)[source]¶
Change Script from by the identifier.
Parameters: - id_script – Identifier of the Script. Integer value and greater than zero.
- id_script_type – Identifier of the Script Type. Integer value and greater than zero.
- script – Script name. String with a minimum 3 and maximum of 40 characters
- description – Script description. String with a minimum 3 and maximum of 100 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Script, script Type, script or description is null and invalid.
- RoteiroNaoExisteError – Script not registered.
- TipoRoteiroNaoExisteError – Script Type not registered.
- NomeRoteiroDuplicadoError – Script already registered with informed.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(id_script_type, script, model, description)[source]¶
Inserts a new Script and returns its identifier.
Parameters: - id_script_type – Identifier of the Script Type. Integer value and greater than zero.
- script – Script name. String with a minimum 3 and maximum of 40 characters
- description – Script description. String with a minimum 3 and maximum of 100 characters
Returns: Dictionary with the following structure:
{'script': {'id': < id_script >}}
Raises: - InvalidParameterError – The identifier of Script Type, script or description is null and invalid.
- TipoRoteiroNaoExisteError – Script Type not registered.
- NomeRoteiroDuplicadoError – Script already registered with informed.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Script.
Returns: Dictionary with the following structure: {‘script’: [{‘id’: < id >, ‘tipo_roteiro’: < tipo_roteiro >, ‘nome’: < nome >, ‘descricao’: < descricao >}, ...more Script...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_por_equipamento(id_equipment)[source]¶
List all Script related Equipment.
Parameters: id_equipment – Identifier of the Equipment. Integer value and greater than zero. Returns: Dictionary with the following structure: {script': [{‘id’: < id >, ‘nome’: < nome >, ‘descricao’: < descricao >, ‘id_tipo_roteiro’: < id_tipo_roteiro >, ‘nome_tipo_roteiro’: < nome_tipo_roteiro >, ‘descricao_tipo_roteiro’: < descricao_tipo_roteiro >}, ...more Script...]}
Raises: - InvalidParameterError – The identifier of Equipment is null and invalid.
- EquipamentoNaoExisteError – Equipment not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_por_tipo(id_script_type)[source]¶
List all Script by Script Type.
Parameters: id_script_type – Identifier of the Script Type. Integer value and greater than zero. Returns: Dictionary with the following structure: {‘script’: [{‘id’: < id >, ‘tipo_roteiro': < id_tipo_roteiro >, ‘nome': < nome >, ‘descricao’: < descricao >}, ...more Script...]}
Raises: - InvalidParameterError – The identifier of Script Type is null and invalid.
- TipoRoteiroNaoExisteError – Script Type not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_script)[source]¶
Remove Script from by the identifier.
Parameters: id_script – Identifier of the Script. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Script is null and invalid.
- RoteiroNaoExisteError – Script not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.RoteiroEquipamento module¶
networkapiclient.TipoAcesso module¶
- class networkapiclient.TipoAcesso.TipoAcesso(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_tipo_acesso, protocolo)[source]¶
Edit access type by its identifier.
Parameters: - id_tipo_acesso – Access type identifier.
- protocolo – Protocol.
Returns: None
Raises: - ProtocoloTipoAcessoDuplicadoError – Protocol already exists.
- InvalidParameterError – Protocol value is invalid or none.
- TipoAcessoNaoExisteError – Access type doesn’t exist.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(protocolo)[source]¶
Insert new access type and returns its identifier.
Parameters: protocolo – Protocol.
Returns: Dictionary with structure: {‘tipo_acesso’: {‘id’: < id >}}
Raises: - ProtocoloTipoAcessoDuplicadoError – Protocol already exists.
- InvalidParameterError – Protocol value is invalid or none.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all access types.
Returns: Dictionary with structure: {‘tipo_acesso’: [{‘id’: < id >, ‘protocolo’: < protocolo >}, ... other access types ...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_tipo_acesso)[source]¶
Removes access type by its identifier.
Parameters: id_tipo_acesso – Access type identifier.
Returns: None
Raises: - TipoAcessoError – Access type associated with equipment, cannot be removed.
- InvalidParameterError – Protocol value is invalid or none.
- TipoAcessoNaoExisteError – Access type doesn’t exist.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.TipoEquipamento module¶
- class networkapiclient.TipoEquipamento.TipoEquipamento(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- inserir(name)[source]¶
Inserts a new Equipment Type and returns its identifier
Parameters: name – Equipment Type name. String with a minimum 3 and maximum of 100 characters Returns: Dictionary with the following structure: {'tipo_equipamento': {'id': < id_equipment_ype >}}
Raises: - InvalidParameterError – Name is null and invalid.
- EquipamentoError – There is already a registered Equipment Type with the value of name.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
- listar()[source]¶
List all Equipment Type.
Returns: Dictionary with the following structure: {‘equipment_type’ : [{‘id’: < id >, ‘nome’: < name >}, ... too Equipment Type ...] }
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response
networkapiclient.TipoRede module¶
- class networkapiclient.TipoRede.TipoRede(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_net_type, name)[source]¶
Edit network type by its identifier.
Parameters: - id_net_type – Network type identifier.
- name – Network type name.
Returns: None
Raises: - InvalidParameterError – Network type identifier and/or name is(are) none or invalid.
- TipoRedeNaoExisteError – Network type does not exist.
- NomeTipoRedeDuplicadoError – Network type name already exists.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(name)[source]¶
Insert new network type and return its identifier.
Parameters: name – Network type name.
Returns: Following dictionary: {‘net_type’: {‘id’: < id >}}
Raises: - InvalidParameterError – Network type is none or invalid.
- NomeTipoRedeDuplicadoError – A network type with this name already exists.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all network types.
Returns: Following dictionary: {'net_type': [{'id': < id_tipo_rede >, 'name': < nome_tipo_rede >}, ... other network types ...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_net_type)[source]¶
Remove network type by its identifier.
Parameters: id_net_type – Network type identifier.
Returns: None
Raises: - TipoRedeNaoExisteError – Network type does not exist.
- TipoRedeError – Network type is associated with network.
- InvalidParameterError – Network type is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.TipoRoteiro module¶
- class networkapiclient.TipoRoteiro.TipoRoteiro(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_script_type, type, description)[source]¶
Change Script Type from by the identifier.
Parameters: - id_script_type – Identifier of the Script Type. Integer value and greater than zero.
- type – Script Type type. String with a minimum 3 and maximum of 40 characters
- description – Script Type description. String with a minimum 3 and maximum of 100 characters
Returns: None
Raises: - InvalidParameterError – The identifier of Script Type, type or description is null and invalid.
- TipoRoteiroNaoExisteError – Script Type not registered.
- NomeTipoRoteiroDuplicadoError – Type script already registered with informed.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(type, description)[source]¶
Inserts a new Script Type and returns its identifier.
Parameters: - type – Script Type type. String with a minimum 3 and maximum of 40 characters
- description – Script Type description. String with a minimum 3 and maximum of 100 characters
Returns: Dictionary with the following structure:
{'script_type': {'id': < id_script_type >}}
Raises: - InvalidParameterError – Type or description is null and invalid.
- NomeTipoRoteiroDuplicadoError – Type script already registered with informed.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all Script Type.
Returns: Dictionary with the following structure: {‘script_type’: [{‘id’: < id >, ‘tipo’: < tipo >, ‘descricao’: < descricao >}, ...more Script Type...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_script_type)[source]¶
Remove Script Type from by the identifier.
Parameters: id_script_type – Identifier of the Script Type. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of Script Type is null and invalid.
- TipoRoteiroNaoExisteError – Script Type not registered.
- TipoRoteiroError – Script type is associated with a script.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Usuario module¶
- class networkapiclient.Usuario.Usuario(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- alterar(id_user, user, password, nome, ativo, email, user_ldap)[source]¶
Change User from by the identifier.
Parameters: - id_user – Identifier of the User. Integer value and greater than zero.
- user – Username. String with a minimum 3 and maximum of 45 characters
- password – User password. String with a minimum 3 and maximum of 45 characters
- nome – User name. String with a minimum 3 and maximum of 200 characters
- email – User Email. String with a minimum 3 and maximum of 300 characters
- ativo – Status. 0 or 1
- user_ldap – LDAP Username. String with a minimum 3 and maximum of 45 characters
Returns: None
Raises: - InvalidParameterError – The identifier of User, user, pwd, name, email or active is null and invalid.
- UserUsuarioDuplicadoError – There is already a registered user with the value of user.
- UsuarioNaoExisteError – User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- authenticate(username, password, is_ldap_user)[source]¶
Get user by username and password and their permissions.
Parameters: - username – Username. String with a minimum 3 and maximum of 45 characters
- password – User password. String with a minimum 3 and maximum of 45 characters
Returns: Following dictionary:
{'user': {'id': < id >} {'user': < user >} {'nome': < nome >} {'pwd': < pwd >} {'email': < email >} {'active': < active >} {'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
Raises: - InvalidParameterError – The value of username or password is invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- authenticate_ldap(username, password)[source]¶
Get user by username and password and their permissions.
Parameters: - username – Username. String with a minimum 3 and maximum of 45 characters
- password – User password. String with a minimum 3 and maximum of 45 characters
Returns: Following dictionary:
{'user': {'id': < id >} {'user': < user >} {'nome': < nome >} {'pwd': < pwd >} {'email': < email >} {'active': < active >} {'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
Raises: - InvalidParameterError – The value of username or password is invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- change_password(id_user, user_current_password, password)[source]¶
Change password of User from by the identifier.
Parameters: - id_user – Identifier of the User. Integer value and greater than zero.
- user_current_password – Senha atual do usuário.
- password – Nova Senha do usuário.
Returns: None
Raises: - UsuarioNaoExisteError – User not registered.
- InvalidParameterError – The identifier of User is null and invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_by_id(id_user)[source]¶
Get user by the identifier and their user groups. is_more -If more than 3 of groups of users or no, to control expansion Screen.
Returns: Dictionary with the following structure: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'grupos': [nome_grupo, ...more user groups...], 'user_ldap': < user_ldap >}}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get_by_user_ldap(user_name)[source]¶
Get user by the ldap name. is_more -If more than 3 of groups of users or no, to control expansion Screen.
Returns: Dictionary with the following structure: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'grupos': [nome_grupo, ...more user groups...], 'user_ldap': < user_ldap >}}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- inserir(user, pwd, name, email, user_ldap)[source]¶
Inserts a new User and returns its identifier.
The user will be created with active status.
Parameters: - user – Username. String with a minimum 3 and maximum of 45 characters
- pwd – User password. String with a minimum 3 and maximum of 45 characters
- name – User name. String with a minimum 3 and maximum of 200 characters
- email – User Email. String with a minimum 3 and maximum of 300 characters
- user_ldap – LDAP Username. String with a minimum 3 and maximum of 45 characters
Returns: Dictionary with the following structure:
{'usuario': {'id': < id_user >}}
Raises: - InvalidParameterError – The identifier of User, user, pwd, name or email is null and invalid.
- UserUsuarioDuplicadoError – There is already a registered user with the value of user.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_by_group(id_ugroup)[source]¶
Search Users by Group User by identifier.
Parameters: id_ugroup – Identifier of the Group User. Integer value and greater than zero. Returns: Dictionary with the following structure: {'users': [{'nome': < nome >, 'grupos': < grupos_id >, 'email': < email >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'id': < id >}, ... ] }
Raises: - InvalidParameterError – Group User is null and invalid.
- UGrupoNotFoundError – Group User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_by_group_out(id_ugroup)[source]¶
Search Users out group by Group User by identifier.
Parameters: id_ugroup – Identifier of the Group User. Integer value and greater than zero. Returns: Dictionary with the following structure: {'users': [{'nome': < nome >, 'grupos': < grupos_id >, 'email': < email >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'id': < id >}, ... ] }
Raises: - InvalidParameterError – Group User is null and invalid.
- UGrupoNotFoundError – Group User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_with_usergroup()[source]¶
List all users and their user groups. is_more -If more than 3 of groups of users or no, to control expansion Screen.
Returns: Dictionary with the following structure: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'is_more': <True ou False>, 'grupos': [nome_grupo, ...more user groups...]}, ...more user...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar()[source]¶
List all user.
Returns: Dictionary with the following structure: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'user_ldap': < ldap user >}, ...more user...]}
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_user)[source]¶
Remove User from by the identifier.
Parameters: id_user – Identifier of the User. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – The identifier of User is null and invalid.
- UsuarioNaoExisteError – User not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.UsuarioGrupo module¶
- class networkapiclient.UsuarioGrupo.UsuarioGrupo(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- inserir(id_user, id_group)[source]¶
Create a relationship between User and Group.
Parameters: - id_user – Identifier of the User. Integer value and greater than zero.
- id_group – Identifier of the Group. Integer value and greater than zero.
Returns: Dictionary with the following structure:
- ::
- {‘user_group’: {‘id’: < id_user_group >}}
Raises: - InvalidParameterError – The identifier of User or Group is null and invalid.
- GrupoUsuarioNaoExisteError – UserGroup not registered.
- UsuarioNaoExisteError – User not registered.
- UsuarioGrupoError – User already registered in the group.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover(id_user, id_group)[source]¶
Removes relationship between User and Group.
Parameters: - id_user – Identifier of the User. Integer value and greater than zero.
- id_group – Identifier of the Group. Integer value and greater than zero.
Returns: None
Raises: - UsuarioGrupoNaoExisteError – Association between user and group not registered.
- GrupoUsuarioNaoExisteError – UserGroup not registered.
- UsuarioNaoExisteError – User not registered.
- UsuarioGrupoError – User already registered in the group.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
networkapiclient.Vip module¶
- class networkapiclient.Vip.Vip(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- edit_reals(id_vip, method_bal, reals, reals_prioritys, reals_weights, alter_priority=0)[source]¶
Execute the script ‘gerador_vips’ several times with options -real, -add and -del to adjust vip request reals. :param id_vip: Identifier of the VIP. Integer value and greater than zero. :param method_bal: method_bal. :param reals: List of reals. Ex: [{‘real_name’:’Teste1’, ‘real_ip’:‘10.10.10.1’},{‘real_name’:’Teste2’, ‘real_ip’:‘10.10.10.2’}] :param reals_prioritys: List of reals_priority. Ex: [‘1’,‘5’,‘3’]. :param reals_weights: List of reals_weight. Ex: [‘1’,‘5’,‘3’]. :param alter_priority: 1 if priority has changed and 0 if hasn’t changed. :return: None :raise VipNaoExisteError: Request VIP not registered. :raise InvalidParameterError: Identifier of the request is invalid or null VIP. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. :raise EnvironmentVipError: The combination of finality, client and environment is invalid. :raise InvalidTimeoutValueError: The value of timeout is invalid. :raise InvalidBalMethodValueError: The value of method_bal is invalid. :raise InvalidCacheValueError: The value of cache is invalid. :raise InvalidPersistenceValueError: The value of persistence is invalid. :raise InvalidPriorityValueError: One of the priority values is invalid. :raise EquipamentoNaoExisteError: The equipment associated with this Vip Request doesn’t exist. :raise IpEquipmentError: Association between equipment and ip of this Vip Request doesn’t exist. :raise IpError: IP not registered. :raise RealServerPriorityError: Vip Request priority list has an error. :raise RealServerWeightError: Vip Request weight list has an error. :raise RealServerPortError: Vip Request port list has an error. :raise RealParameterValueError: Vip Request real server parameter list has an error. :raise RealServerScriptError: Vip Request real server script execution error.
networkapiclient.Vlan module¶
- class networkapiclient.Vlan.Vlan(networkapi_url, user, password, user_ldap=None)[source]¶
Bases: networkapiclient.GenericClient.GenericClient
- adicionar_permissao(id_vlan, nome_equipamento, nome_interface)[source]¶
Add communication permission for VLAN to trunk.
Run script ‘configurador’.
Parameters: - id_vlan – VLAN identifier.
- nome_equipamento – Equipment name.
- nome_interface – Interface name.
Returns: Following dictionary:
{‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - VlanNaoExisteError – VLAN does not exist.
- InvalidParameterError – Vlan id is invalid or none.
- InvalidParameterError – Equipment name and/or interface name is invalid or none.
- EquipamentoNaoExisteError – Equipment does not exist.
- LigacaoFrontInterfaceNaoExisteError – There is no interface on front link of informed interface.
- InterfaceNaoExisteError – Interface does not exist or is not associated to equipment.
- LigacaoFrontNaoTerminaSwitchError – Interface does not have switch connected.
- InterfaceSwitchProtegidaError – Switch interface is protected.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- allocate_IPv6(name, id_network_type, id_environment, description, id_environment_vip=None)[source]¶
Inserts a new VLAN.
Parameters: - name – Name of Vlan. String with a maximum of 50 characters.
- id_network_type – Identifier of the Netwok Type. Integer value and greater than zero.
- id_environment – Identifier of the Environment. Integer value and greater than zero.
- description – Description of Vlan. String with a maximum of 200 characters.
- id_environment_vip – Identifier of the Environment Vip. Integer value and greater than zero.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'bloco1': < bloco1 >, 'bloco2': < bloco2 >, 'bloco3': < bloco3 >, 'bloco4': < bloco4 >, 'bloco5': < bloco5 >, 'bloco6': < bloco6 >, 'bloco7': < bloco7 >, 'bloco8': < bloco8 >, 'bloco': < bloco >, 'mask_bloco1': < mask_bloco1 >, 'mask_bloco2': < mask_bloco2 >, 'mask_bloco3': < mask_bloco3 >, 'mask_bloco4': < mask_bloco4 >, 'mask_bloco5': < mask_bloco5 >, 'mask_bloco6': < mask_bloco6 >, 'mask_bloco7': < mask_bloco7 >, 'mask_bloco8': < mask_bloco8 >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada >}}
Raises: - VlanError – VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
- VlanNaoExisteError – VLAN not found.
- TipoRedeNaoExisteError – Network Type not registered.
- AmbienteNaoExisteError – Environment not registered.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – Name of Vlan and/or the identifier of the Environment is null or invalid.
- IPNaoDisponivelError – There is no network address is available to create the VLAN.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- allocate_without_network(environment_id, name, description, vrf=None)[source]¶
Create new VLAN without add NetworkIPv4.
Parameters: - environment_id – ID for Environment.
- name – The name of VLAN.
- description – Some description to VLAN.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada > } }
Raises: - VlanError – Duplicate name of VLAN, division DC of Environment not found/invalid or VLAN number not available.
- AmbienteNaoExisteError – Environment not found.
- InvalidParameterError – Some parameter was invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- alocar(nome, id_tipo_rede, id_ambiente, descricao, id_ambiente_vip=None, vrf=None)[source]¶
Inserts a new VLAN.
Parameters: - nome – Name of Vlan. String with a maximum of 50 characters.
- id_tipo_rede – Identifier of the Network Type. Integer value and greater than zero.
- id_ambiente – Identifier of the Environment. Integer value and greater than zero.
- descricao – Description of Vlan. String with a maximum of 200 characters.
- id_ambiente_vip – Identifier of the Environment Vip. Integer value and greater than zero.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >}}
Raises: - VlanError – VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
- VlanNaoExisteError – VLAN not found.
- TipoRedeNaoExisteError – Network Type not registered.
- AmbienteNaoExisteError – Environment not registered.
- EnvironmentVipNotFoundError – Environment VIP not registered.
- InvalidParameterError – Name of Vlan and/or the identifier of the Environment is null or invalid.
- IPNaoDisponivelError – There is no network address is available to create the VLAN.
- ConfigEnvironmentInvalidError – Invalid Environment Configuration or not registered
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- apply_acl(equipments, vlan, environment, network)[source]¶
Apply the file acl in equipments
Parameters: - equipments – list of equipments
- vlan – Vvlan
- environment – Environment
- network – v4 or v6
Raises Exception: Failed to apply acl
Returns: True case Apply and sysout of script
- buscar(id_vlan)[source]¶
Get VLAN by its identifier.
Parameters: id_vlan – VLAN identifier. Returns: Following dictionary: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'id_tipo_rede': < id_tipo_rede >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada >} OR {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_tipo_rede': < id_tipo_rede >, 'id_ambiente': < id_ambiente >, 'bloco1': < bloco1 >, 'bloco2': < bloco2 >, 'bloco3': < bloco3 >, 'bloco4': < bloco4 >, 'bloco5': < bloco5 >, 'bloco6': < bloco6 >, 'bloco7': < bloco7 >, 'bloco8': < bloco8 >, 'bloco': < bloco >, 'mask_bloco1': < mask_bloco1 >, 'mask_bloco2': < mask_bloco2 >, 'mask_bloco3': < mask_bloco3 >, 'mask_bloco4': < mask_bloco4 >, 'mask_bloco5': < mask_bloco5 >, 'mask_bloco6': < mask_bloco6 >, 'mask_bloco7': < mask_bloco7 >, 'mask_bloco8': < mask_bloco8 >, 'broadcast': < broadcast >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada >}}
Raises: - VlanNaoExisteError – VLAN does not exist.
- InvalidParameterError – VLAN id is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- check_number_available(id_environment, num_vlan, id_vlan)[source]¶
Checking if environment has a number vlan available
Parameters: - id_environment – Identifier of environment
- num_vlan – Vlan number
- id_vlan – Vlan indentifier (False if inserting a vlan)
Returns: True is has number available, False if hasn’t
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidParameterError – Invalid ID for VLAN.
- VlanNaoExisteError – VLAN not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- confirm_vlan(number_net, id_environment_vlan, ip_version=None)[source]¶
Checking if the vlan insert need to be confirmed
Parameters: - number_net – Filter by vlan number column
- id_environment_vlan – Filter by environment ID related
- ip_version – Ip version for checking
Returns: True is need confirmation, False if no need
Raises: - AmbienteNaoExisteError – Ambiente não cadastrado.
- InvalidParameterError – Invalid ID for VLAN.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- create_acl(id_vlan, network_type)[source]¶
Create the file acl
Parameters: - id_vlan – Vlan Id
- network_type – v4 or v6
Raises: - InvalidValueError – Attrs invalids.
- XMLError – Networkapi failed to generate the XML response.
- AclNotFoundError – ACL not created.
- VlanNotFoundError – Vlan not registered.
Returns: Following dictionary:
{'vlan': { 'acl_file_name': < acl_file_name >, 'ativada': < ativada >, 'acl_valida': < acl_valida >, 'nome': '< nome >', 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ambiente': < ambiente >, 'num_vlan': < num_vlan >, 'id': < id >, 'descricao': < descricao > }}
- create_ipv4(id_network_ipv4)[source]¶
Create VLAN in layer 2 using script ‘navlan’.
Parameters: id_network_ipv4 – NetworkIPv4 ID. Returns: Following dictionary: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - NetworkIPv4NaoExisteError – NetworkIPv4 not found.
- EquipamentoNaoExisteError – Equipament in list not found.
- VlanError – VLAN is active.
- InvalidParameterError – VLAN identifier is none or invalid.
- InvalidParameterError – Equipment list is none or empty.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- create_ipv6(id_network_ipv6)[source]¶
Create VLAN in layer 2 using script ‘navlan’.
Parameters: id_network_ipv6 – NetworkIPv6 ID. Returns: Following dictionary: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - NetworkIPv6NaoExisteError – NetworkIPv6 not found.
- EquipamentoNaoExisteError – Equipament in list not found.
- VlanError – VLAN is active.
- InvalidParameterError – VLAN identifier is none or invalid.
- InvalidParameterError – Equipment list is none or empty.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- create_script_acl(id_vlan, network_type)[source]¶
Generate the script acl
Parameters: - id_vlan – Vlan Id
- network_type – v4 or v6
Raises: - InvalidValueError – Attrs invalids.
- XMLError – Networkapi failed to generate the XML response.
- VlanACLDuplicatedError – ACL name duplicate.
- VlanNotFoundError – Vlan not registered.
Returns: Following dictionary:
{'vlan': { 'id': < id >, 'nome': '< nome >', 'num_vlan': < num_vlan >, 'descricao': < descricao > 'acl_file_name': < acl_file_name >, 'ativada': < ativada >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'redeipv6': < redeipv6 >, 'acl_valida_v6': < acl_valida_v6 >, 'redeipv4': < redeipv4 >, 'ambiente': < ambiente >, }}
- create_vlan(id_vlan)[source]¶
Set column ‘ativada = 1’.
Parameters: id_vlan – VLAN identifier. Returns: None
- criar(id_vlan)[source]¶
Create a VLAN with script ‘navlan’.
Parameters: id_vlan – VLAN identifier. Returns: Following dictionary: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - VlanNaoExisteError – VLAN does not exist.
- EquipamentoNaoExisteError – Equipment in list does not exist.
- VlanError – VLAN is active.
- InvalidParameterError – VLAN identifier is none or invalid.
- InvalidParameterError – Equipment list is none or empty.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- deallocate(id_vlan)[source]¶
Deallocate all relationships between Vlan.
Parameters: id_vlan – Identifier of the VLAN. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – VLAN identifier is null and invalid.
- VlanError – VLAN is active.
- VlanNaoExisteError – VLAN not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- edit_vlan(environment_id, name, number, description, acl_file, acl_file_v6, id_vlan)[source]¶
Edit a VLAN
Parameters: - id_vlan – ID for Vlan
- environment_id – ID for Environment.
- name – The name of VLAN.
- description – Some description to VLAN.
- number – Number of Vlan
- acl_file – Acl IPv4 File name to VLAN.
- acl_file_v6 – Acl IPv6 File name to VLAN.
Returns: None
Raises: - VlanError – VLAN name already exists, DC division of the environment invalid or there is no VLAN number available.
- VlanNaoExisteError – VLAN not found.
- AmbienteNaoExisteError – Environment not registered.
- InvalidParameterError – Name of Vlan and/or the identifier of the Environment is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- find_vlans(number, name, iexact, environment, net_type, network, ip_version, subnet, acl, pagination)[source]¶
Find vlans by all search parameters
Parameters: - number – Filter by vlan number column
- name – Filter by vlan name column
- iexact – Filter by name will be exact?
- environment – Filter by environment ID related
- net_type – Filter by network_type ID related
- network – Filter by each octs in network
- ip_version – Get only version (0:ipv4, 1:ipv6, 2:all)
- subnet – Filter by octs will search by subnets?
- acl – Filter by vlan acl column
- pagination – Class with all data needed to paginate
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada >, 'ambiente_name': < divisao_dc-ambiente_logico-grupo_l3 > 'redeipv4': [ { all networkipv4 related } ], 'redeipv6': [ { all networkipv6 related } ] }, 'total': {< total_registros >} }
Raises: - InvalidParameterError – Some parameter was invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- get(id_vlan)[source]¶
Get a VLAN by your primary key. Network IPv4/IPv6 related will also be fetched.
Parameters: id_vlan – ID for VLAN. Returns: Following dictionary: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada >, 'redeipv4': [ { all networkipv4 related } ], 'redeipv6': [ { all networkipv6 related } ] } }
Raises: - InvalidParameterError – Invalid ID for VLAN.
- VlanNaoExisteError – VLAN not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- insert_vlan(environment_id, name, number, description, acl_file, acl_file_v6, network_ipv4, network_ipv6, vrf=None)[source]¶
Create new VLAN
Parameters: - environment_id – ID for Environment.
- name – The name of VLAN.
- description – Some description to VLAN.
- number – Number of Vlan
- acl_file – Acl IPv4 File name to VLAN.
- acl_file_v6 – Acl IPv6 File name to VLAN.
- network_ipv4 – responsible for generating a network attribute ipv4 automatically.
- network_ipv6 – responsible for generating a network attribute ipv6 automatically.
Returns: Following dictionary:
{'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada > 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, } }
Raises: - VlanError – VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
- VlanNaoExisteError – VLAN not found.
- AmbienteNaoExisteError – Environment not registered.
- InvalidParameterError – Name of Vlan and/or the identifier of the Environment is null or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- invalidate(id_vlan)[source]¶
Invalidates ACL - IPv4 of VLAN from its identifier.
Assigns 0 to ‘acl_valida’ and null to ‘acl_file_name’.
Parameters: id_vlan – Identifier of the Vlan. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Vlan identifier is null and invalid.
- VlanNaoExisteError – Vlan not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- invalidate_ipv6(id_vlan)[source]¶
Invalidates ACL - IPv6 of VLAN from its identifier.
Assigns 0 to ‘acl_valida_v6’ and null to ‘acl_file_name_v6’.
Parameters: id_vlan – Identifier of the Vlan. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Vlan identifier is null and invalid.
- VlanNaoExisteError – Vlan not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- list_all()[source]¶
List all vlans
Returns: Following dictionary: {'vlan': [{'id': < id_vlan >, 'name': < nome_vlan >} {... demais vlans ...} ] }
Raises: - DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- listar_permissao(nome_equipamento, nome_interface)[source]¶
List all VLANS having communication permission to trunk from a port in switch.
Run script ‘configurador’.
The value of 'stdout' key of return dictionary can have a list of numbers or number intervals of VLAN´s, comma separated. Examples of possible returns of 'stdout' below: - 100,103,111,... - 100-110,... - 100-110,112,115,... - 100,103,105-111,113,115-118,...
Parameters: - nome_equipamento – Equipment name.
- nome_interface – Interface name.
Returns: Following dictionary:
{‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - InvalidParameterError – Equipment name and/or interface name is invalid or none.
- EquipamentoNaoExisteError – Equipment does not exist.
- LigacaoFrontInterfaceNaoExisteError – There is no interface on front link of informed interface.
- InterfaceNaoExisteError – Interface does not exist or is not associated to equipment.
- LigacaoFrontNaoTerminaSwitchError – Interface does not have switch connected.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- listar_por_ambiente(id_ambiente)[source]¶
List all VLANs from an environment. ** The itens returning from network is there to be compatible with other system ** :param id_ambiente: Environment identifier.
Returns: Following dictionary: {'vlan': [{'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, 'ativada': < ativada >, 'id_tipo_rede': < id_tipo_rede >, 'rede_oct1': < rede_oct1 >, 'rede_oct2': < rede_oct2 >, 'rede_oct3': < rede_oct3 >, 'rede_oct4': < rede_oct4 >, 'bloco': < bloco >, 'mascara_oct1': < mascara_oct1 >, 'mascara_oct2': < mascara_oct2 >, 'mascara_oct3': < mascara_oct3 >, 'mascara_oct4': < mascara_oct4 >, 'broadcast': < broadcast >,} , ... other vlans ... ]}
Raises: - InvalidParameterError – Environment id is none or invalid.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remove(id_vlan)[source]¶
Remove a VLAN by your primary key. Execute script to remove VLAN
Parameters: id_vlan – ID for VLAN. Returns: Following dictionary: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - InvalidParameterError – Identifier of the VLAN is invalid.
- VlanNaoExisteError – VLAN not found.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- remover_permissao(id_vlan, nome_equipamento, nome_interface)[source]¶
Remove communication permission for VLAN to trunk.
Run script ‘configurador’.
Parameters: - id_vlan – VLAN identifier.
- nome_equipamento – Equipment name.
- nome_interface – Interface name.
Returns: Following dictionary:
{‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - VlanNaoExisteError – VLAN does not exist.
- InvalidParameterError – VLAN id is none or invalid.
- InvalidParameterError – Equipment name and/or interface name is invalid or none.
- EquipamentoNaoExisteError – Equipment does not exist.
- LigacaoFrontInterfaceNaoExisteError – There is no interface on front link of informed interface.
- InterfaceNaoExisteError – Interface does not exist or is not associated to equipment.
- LigacaoFrontNaoTerminaSwitchError – Interface does not have switch connected.
- InterfaceSwitchProtegidaError – Switch interface is protected.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
- validar(id_vlan)[source]¶
Validates ACL - IPv4 of VLAN from its identifier.
Assigns 1 to ‘acl_valida’.
Parameters: id_vlan – Identifier of the Vlan. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Vlan identifier is null and invalid.
- VlanNaoExisteError – Vlan not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- validate_ipv6(id_vlan)[source]¶
Validates ACL - IPv6 of VLAN from its identifier.
Assigns 1 to ‘acl_valida_v6’.
Parameters: id_vlan – Identifier of the Vlan. Integer value and greater than zero.
Returns: None
Raises: - InvalidParameterError – Vlan identifier is null and invalid.
- VlanNaoExisteError – Vlan not registered.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- verificar_permissao(id_vlan, nome_equipamento, nome_interface)[source]¶
Check if there is communication permission for VLAN to trunk.
Run script ‘configurador’.
The “stdout” key value of response dictionary is 1(one) if VLAN has permission, or 0(zero), otherwise.
Parameters: - id_vlan – VLAN identifier.
- nome_equipamento – Equipment name.
- nome_interface – Interface name.
Returns: Following dictionary:
{‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
Raises: - VlanNaoExisteError – VLAN does not exist.
- InvalidParameterError – VLAN id is none or invalid.
- InvalidParameterError – Equipment name and/or interface name is invalid or none.
- EquipamentoNaoExisteError – Equipment does not exist.
- LigacaoFrontInterfaceNaoExisteError – There is no interface on front link of informed interface.
- InterfaceNaoExisteError – Interface does not exist or is not associated to equipment.
- LigacaoFrontNaoTerminaSwitchError – Interface does not have switch connected.
- DataBaseError – Networkapi failed to access the database.
- XMLError – Networkapi failed to generate the XML response.
- ScriptError – Failed to run the script.
networkapiclient.exception module¶
- exception networkapiclient.exception.CantDissociateError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception whey trying to dissociate filter and equipment type, and some environment is using the filter
- exception networkapiclient.exception.DetailedEnvironmentError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception to environment cant be removed because vlan has vip request association
- exception networkapiclient.exception.EnvironmentVipError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception to environment vip.
- exception networkapiclient.exception.EnvironmentVipNotFoundError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception to environment research by primary key.
- class networkapiclient.exception.ErrorHandler[source]¶
Bases: object
Classe que trata os códigos de erros retornados pela networkAPI e lança a exceção correspondente na networkAPI-Client.
- errors = {1: <class 'networkapiclient.exception.DataBaseError'>, 2: <class 'networkapiclient.exception.ScriptError'>, 3: <class 'networkapiclient.exception.XMLError'>, 4: <class 'networkapiclient.exception.XMLError'>, 100: <class 'networkapiclient.exception.TipoEquipamentoNaoExisteError'>, 101: <class 'networkapiclient.exception.ModeloEquipamentoNaoExisteError'>, 102: <class 'networkapiclient.exception.GrupoEquipamentoNaoExisteError'>, 103: <class 'networkapiclient.exception.InvalidParameterError'>, 104: <class 'networkapiclient.exception.InvalidParameterError'>, 105: <class 'networkapiclient.exception.InvalidParameterError'>, 106: <class 'networkapiclient.exception.InvalidParameterError'>, 107: <class 'networkapiclient.exception.EquipamentoError'>, 108: <class 'networkapiclient.exception.VlanError'>, 109: <class 'networkapiclient.exception.VlanError'>, 110: <class 'networkapiclient.exception.VlanError'>, 111: <class 'networkapiclient.exception.TipoRedeNaoExisteError'>, 112: <class 'networkapiclient.exception.AmbienteNaoExisteError'>, 113: <class 'networkapiclient.exception.InvalidParameterError'>, 114: <class 'networkapiclient.exception.InvalidParameterError'>, 115: <class 'networkapiclient.exception.InvalidParameterError'>, 116: <class 'networkapiclient.exception.VlanNaoExisteError'>, 117: <class 'networkapiclient.exception.EquipamentoNaoExisteError'>, 118: <class 'networkapiclient.exception.IpError'>, 119: <class 'networkapiclient.exception.IpNaoExisteError'>, 120: <class 'networkapiclient.exception.IpError'>, 121: <class 'networkapiclient.exception.VlanError'>, 122: <class 'networkapiclient.exception.VlanError'>, 123: <class 'networkapiclient.exception.InvalidParameterError'>, 124: <class 'networkapiclient.exception.HealthCheckExpectNaoExisteError'>, 125: <class 'networkapiclient.exception.InvalidFinalityValueError'>, 126: <class 'networkapiclient.exception.InvalidParameterError'>, 127: <class 'networkapiclient.exception.InvalidParameterError'>, 128: <class 'networkapiclient.exception.InvalidCacheValueError'>, 129: <class 'networkapiclient.exception.InvalidParameterError'>, 130: <class 'networkapiclient.exception.InvalidParameterError'>, 131: <class 'networkapiclient.exception.InvalidBalMethodValueError'>, 132: <class 'networkapiclient.exception.InvalidPersistenceValueError'>, 133: <class 'networkapiclient.exception.InvalidParameterError'>, 134: <class 'networkapiclient.exception.InvalidParameterError'>, 135: <class 'networkapiclient.exception.InvalidTimeoutValueError'>, 136: <class 'networkapiclient.exception.InvalidParameterError'>, 137: <class 'networkapiclient.exception.InvalidParameterError'>, 138: <class 'networkapiclient.exception.InvalidParameterError'>, 139: <class 'networkapiclient.exception.LigacaoFrontInterfaceNaoExisteError'>, 140: <class 'networkapiclient.exception.InvalidParameterError'>, 141: <class 'networkapiclient.exception.InterfaceNaoExisteError'>, 142: <class 'networkapiclient.exception.RelacionamentoInterfaceEquipamentoNaoExisteError'>, 143: <class 'networkapiclient.exception.InterfaceSwitchProtegidaError'>, 144: <class 'networkapiclient.exception.LigacaoFrontNaoTerminaSwitchError'>, 145: <class 'networkapiclient.exception.InvalidParameterError'>, 146: <class 'networkapiclient.exception.EquipamentoError'>, 147: <class 'networkapiclient.exception.InvalidParameterError'>, 148: <class 'networkapiclient.exception.EquipamentoError'>, 149: <class 'networkapiclient.exception.EquipamentoError'>, 150: <class 'networkapiclient.exception.IPNaoDisponivelError'>, 151: <class 'networkapiclient.exception.InvalidParameterError'>, 152: <class 'networkapiclient.exception.VipNaoExisteError'>, 153: <class 'networkapiclient.exception.IpNaoExisteError'>, 154: <class 'networkapiclient.exception.InvalidParameterError'>, 156: <class 'networkapiclient.exception.EquipamentoAmbienteError'>, 157: <class 'networkapiclient.exception.EquipamentoAmbienteNaoExisteError'>, 158: <class 'networkapiclient.exception.TipoRoteiroNaoExisteError'>, 159: <class 'networkapiclient.exception.InvalidParameterError'>, 160: <class 'networkapiclient.exception.GrupoL3NaoExisteError'>, 161: <class 'networkapiclient.exception.InvalidParameterError'>, 162: <class 'networkapiclient.exception.AmbienteLogicoNaoExisteError'>, 163: <class 'networkapiclient.exception.InvalidParameterError'>, 164: <class 'networkapiclient.exception.DivisaoDcNaoExisteError'>, 165: <class 'networkapiclient.exception.RoteiroNaoExisteError'>, 166: <class 'networkapiclient.exception.InvalidParameterError'>, 167: <class 'networkapiclient.exception.MarcaNaoExisteError'>, 168: <class 'networkapiclient.exception.InvalidParameterError'>, 169: <class 'networkapiclient.exception.NomeGrupoL3DuplicadoError'>, 170: <class 'networkapiclient.exception.InvalidParameterError'>, 171: <class 'networkapiclient.exception.TipoAcessoNaoExisteError'>, 172: <class 'networkapiclient.exception.InvalidParameterError'>, 173: <class 'networkapiclient.exception.NomeAmbienteLogicoDuplicadoError'>, 174: <class 'networkapiclient.exception.InvalidParameterError'>, 175: <class 'networkapiclient.exception.NomeDivisaoDcDuplicadoError'>, 176: <class 'networkapiclient.exception.InvalidParameterError'>, 177: <class 'networkapiclient.exception.UsuarioNaoExisteError'>, 178: <class 'networkapiclient.exception.InvalidParameterError'>, 179: <class 'networkapiclient.exception.UserUsuarioDuplicadoError'>, 180: <class 'networkapiclient.exception.GrupoUsuarioNaoExisteError'>, 181: <class 'networkapiclient.exception.InvalidParameterError'>, 182: <class 'networkapiclient.exception.NomeGrupoUsuarioDuplicadoError'>, 183: <class 'networkapiclient.exception.UsuarioGrupoError'>, 184: <class 'networkapiclient.exception.UsuarioGrupoNaoExisteError'>, 185: <class 'networkapiclient.exception.EquipamentoGrupoNaoExisteError'>, 186: <class 'networkapiclient.exception.VipError'>, 187: <class 'networkapiclient.exception.NomeInterfaceDuplicadoParaEquipamentoError'>, 189: <class 'networkapiclient.exception.PermissaoAdministrativaNaoExisteError'>, 190: <class 'networkapiclient.exception.EquipamentoRoteiroNaoExisteError'>, 191: <class 'networkapiclient.exception.VipError'>, 192: <class 'networkapiclient.exception.VipAllreadyCreateError'>, 193: <class 'networkapiclient.exception.NomeTipoRoteiroDuplicadoError'>, 194: <class 'networkapiclient.exception.InvalidParameterError'>, 195: <class 'networkapiclient.exception.InvalidParameterError'>, 196: <class 'networkapiclient.exception.TipoRoteiroError'>, 197: <class 'networkapiclient.exception.RoteiroError'>, 198: <class 'networkapiclient.exception.EquipamentoRoteiroError'>, 199: <class 'networkapiclient.exception.MarcarError'>, 200: <class 'networkapiclient.exception.InvalidParameterError'>, 201: <class 'networkapiclient.exception.InvalidParameterError'>, 202: <class 'networkapiclient.exception.ModeloEquipamentoError'>, 203: <class 'networkapiclient.exception.ProtocoloTipoAcessoDuplicadoError'>, 204: <class 'networkapiclient.exception.TipoAcessoError'>, 205: <class 'networkapiclient.exception.InvalidParameterError'>, 206: <class 'networkapiclient.exception.InvalidParameterError'>, 207: <class 'networkapiclient.exception.InvalidParameterError'>, 208: <class 'networkapiclient.exception.InvalidParameterError'>, 209: <class 'networkapiclient.exception.EquipamentoAcessoNaoExisteError'>, 210: <class 'networkapiclient.exception.InvalidParameterError'>, 211: <class 'networkapiclient.exception.InvalidParameterError'>, 212: <class 'networkapiclient.exception.InterfaceNaoExisteError'>, 213: <class 'networkapiclient.exception.InterfaceNaoExisteError'>, 214: <class 'networkapiclient.exception.InterfaceError'>, 215: <class 'networkapiclient.exception.TipoRedeError'>, 216: <class 'networkapiclient.exception.DivisaoDcError'>, 217: <class 'networkapiclient.exception.AmbienteLogicoError'>, 218: <class 'networkapiclient.exception.GrupoL3Error'>, 219: <class 'networkapiclient.exception.AmbienteDuplicadoError'>, 220: <class 'networkapiclient.exception.AmbienteError'>, 221: <class 'networkapiclient.exception.InvalidParameterError'>, 222: <class 'networkapiclient.exception.InvalidParameterError'>, 223: <class 'networkapiclient.exception.InvalidParameterError'>, 224: <class 'networkapiclient.exception.UsuarioError'>, 225: <class 'networkapiclient.exception.InvalidParameterError'>, 226: <class 'networkapiclient.exception.InvalidParameterError'>, 227: <class 'networkapiclient.exception.InvalidParameterError'>, 228: <class 'networkapiclient.exception.InvalidParameterError'>, 229: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 230: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 231: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 232: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 233: <class 'networkapiclient.exception.InvalidParameterError'>, 234: <class 'networkapiclient.exception.InvalidParameterError'>, 235: <class 'networkapiclient.exception.InvalidParameterError'>, 236: <class 'networkapiclient.exception.InvalidParameterError'>, 237: <class 'networkapiclient.exception.InvalidParameterError'>, 238: <class 'networkapiclient.exception.InvalidParameterError'>, 239: <class 'networkapiclient.exception.InvalidParameterError'>, 240: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 241: <class 'networkapiclient.exception.ValorIndicacaoPermissaoInvalidoError'>, 242: <class 'networkapiclient.exception.EquipamentoAcessoError'>, 243: <class 'networkapiclient.exception.InvalidParameterError'>, 244: <class 'networkapiclient.exception.InvalidParameterError'>, 245: <class 'networkapiclient.exception.InvalidParameterError'>, 246: <class 'networkapiclient.exception.InvalidParameterError'>, 247: <class 'networkapiclient.exception.InvalidParameterError'>, 248: <class 'networkapiclient.exception.InvalidParameterError'>, 249: <class 'networkapiclient.exception.InvalidParameterError'>, 250: <class 'networkapiclient.exception.NomeRoteiroDuplicadoError'>, 251: <class 'networkapiclient.exception.NomeMarcaDuplicadoError'>, 252: <class 'networkapiclient.exception.NomeMarcaModeloDuplicadoError'>, 253: <class 'networkapiclient.exception.NomeTipoRedeDuplicadoError'>, 254: <class 'networkapiclient.exception.NomeGrupoEquipamentoDuplicadoError'>, 255: <class 'networkapiclient.exception.InvalidParameterError'>, 256: <class 'networkapiclient.exception.InvalidParameterError'>, 257: <class 'networkapiclient.exception.PermissaoAdministrativaDuplicadaError'>, 258: <class 'networkapiclient.exception.DireitoGrupoEquipamentoNaoExisteError'>, 259: <class 'networkapiclient.exception.InvalidParameterError'>, 260: <class 'networkapiclient.exception.InvalidParameterError'>, 261: <class 'networkapiclient.exception.InvalidParameterError'>, 262: <class 'networkapiclient.exception.InvalidParameterError'>, 263: <class 'networkapiclient.exception.ValorIndicacaoDireitoInvalidoError'>, 264: <class 'networkapiclient.exception.ValorIndicacaoDireitoInvalidoError'>, 265: <class 'networkapiclient.exception.ValorIndicacaoDireitoInvalidoError'>, 266: <class 'networkapiclient.exception.ValorIndicacaoDireitoInvalidoError'>, 267: <class 'networkapiclient.exception.DireitoGrupoEquipamentoDuplicadoError'>, 268: <class 'networkapiclient.exception.InvalidParameterError'>, 269: <class 'networkapiclient.exception.InvalidParameterError'>, 270: <class 'networkapiclient.exception.InvalidParameterError'>, 271: <class 'networkapiclient.exception.InvalidParameterError'>, 272: <class 'networkapiclient.exception.InvalidParameterError'>, 273: <class 'networkapiclient.exception.DataBaseError'>, 274: <class 'networkapiclient.exception.InvalidParameterError'>, 275: <class 'networkapiclient.exception.InvalidParameterError'>, 276: <class 'networkapiclient.exception.InvalidParameterError'>, 277: <class 'networkapiclient.exception.InvalidParameterError'>, 278: <class 'networkapiclient.exception.InvalidParameterError'>, 279: <class 'networkapiclient.exception.InvalidParameterError'>, 280: <class 'networkapiclient.exception.InvalidParameterError'>, 281: <class 'networkapiclient.exception.InvalidParameterError'>, 282: <class 'networkapiclient.exception.InvalidParameterError'>, 283: <class 'networkapiclient.exception.EnvironmentVipNotFoundError'>, 284: <class 'networkapiclient.exception.EnvironmentVipError'>, 285: <class 'networkapiclient.exception.EnvironmentVipError'>, 286: <class 'networkapiclient.exception.InvalidParameterError'>, 287: <class 'networkapiclient.exception.InvalidParameterError'>, 288: <class 'networkapiclient.exception.IpError'>, 289: <class 'networkapiclient.exception.OptionVipNotFoundError'>, 290: <class 'networkapiclient.exception.OptionVipError'>, 291: <class 'networkapiclient.exception.OptionVipError'>, 292: <class 'networkapiclient.exception.IpNaoExisteError'>, 293: <class 'networkapiclient.exception.VlanError'>, 294: <class 'networkapiclient.exception.ConfigEnvironmentInvalidError'>, 295: <class 'networkapiclient.exception.IPNaoDisponivelError'>, 296: <class 'networkapiclient.exception.IPNaoDisponivelError'>, 297: <class 'networkapiclient.exception.VipError'>, 298: <class 'networkapiclient.exception.VipError'>, 307: <class 'networkapiclient.exception.InterfaceInvalidBackFrontError'>, 309: <class 'networkapiclient.exception.EquipmentDontRemoveError'>, 310: <class 'networkapiclient.exception.GroupDontRemoveError'>, 311: <class 'networkapiclient.exception.VlanAclExistenteError'>, 312: <class 'networkapiclient.exception.EquipamentoError'>, 313: <class 'networkapiclient.exception.HealthCheckExpectJaCadastradoError'>, 314: <class 'networkapiclient.exception.VlanError'>, 315: <class 'networkapiclient.exception.VlanError'>, 316: <class 'networkapiclient.exception.EnvironmentVipNotFoundError'>, 317: <class 'networkapiclient.exception.IpError'>, 318: <class 'networkapiclient.exception.VipError'>, 319: <class 'networkapiclient.exception.VipIpError'>, 320: <class 'networkapiclient.exception.EquipamentoAmbienteError'>, 321: <class 'networkapiclient.exception.EnvironmentVipError'>, 322: <class 'networkapiclient.exception.VipError'>, 323: <class 'networkapiclient.exception.DetailedEnvironmentError'>, 324: <class 'networkapiclient.exception.DetailedEnvironmentError'>, 325: <class 'networkapiclient.exception.InvalidPriorityValueError'>, 326: <class 'networkapiclient.exception.EquipamentoNaoExisteError'>, 327: <class 'networkapiclient.exception.IpEquipmentError'>, 328: <class 'networkapiclient.exception.IpError'>, 329: <class 'networkapiclient.exception.RealServerPriorityError'>, 330: <class 'networkapiclient.exception.RealServerWeightError'>, 331: <class 'networkapiclient.exception.RealServerPortError'>, 332: <class 'networkapiclient.exception.RealParameterValueError'>, 333: <class 'networkapiclient.exception.RealServerScriptError'>, 334: <class 'networkapiclient.exception.IpNotFoundByEquipAndVipError'>, 335: <class 'networkapiclient.exception.IPNaoDisponivelError'>, 336: <class 'networkapiclient.exception.VipIpError'>, 337: <class 'networkapiclient.exception.InvalidParameterError'>, 338: <class 'networkapiclient.exception.DataBaseError'>, 339: <class 'networkapiclient.exception.FilterNotFoundError'>, 340: <class 'networkapiclient.exception.DataBaseError'>, 341: <class 'networkapiclient.exception.DataBaseError'>, 342: <class 'networkapiclient.exception.TipoEquipamentoNaoExisteError'>, 343: <class 'networkapiclient.exception.FilterEqTypeAssociationError'>, 344: <class 'networkapiclient.exception.FilterDuplicateError'>, 345: <class 'networkapiclient.exception.VipError'>, 346: <class 'networkapiclient.exception.NetworkIPRangeEnvError'>, 347: <class 'networkapiclient.exception.IpRangeAlreadyAssociation'>, 348: <class 'networkapiclient.exception.CantDissociateError'>, 350: <class 'networkapiclient.exception.PermissionNotFoundError'>, 351: <class 'networkapiclient.exception.PermissaoAdministrativaDuplicadaError'>, 352: <class 'networkapiclient.exception.IpEquipCantDissociateFromVip'>, 354: <class 'networkapiclient.exception.VipIpError'>, 355: <class 'networkapiclient.exception.VipIpError'>, 356: <class 'networkapiclient.exception.VipIpError'>, 357: <class 'networkapiclient.exception.EnvironmentVipError'>, 358: <class 'networkapiclient.exception.InvalidParameterError'>, 376: <class 'networkapiclient.exception.NumeroRackDuplicadoError'>, 378: <class 'networkapiclient.exception.RacksError'>, 379: <class 'networkapiclient.exception.RackNaoExisteError'>, 380: <class 'networkapiclient.exception.RackAllreadyConfigError'>, 381: <class 'networkapiclient.exception.NomeRackDuplicadoError'>, 382: <class 'networkapiclient.exception.RackConfiguracaoError'>, 383: <class 'networkapiclient.exception.RackAplicarError'>, 400: <class 'networkapiclient.exception.InvalidRequestError'>, 401: <class 'networkapiclient.exception.UserNotAuthenticatedError'>, 402: <class 'networkapiclient.exception.UserNotAuthorizedError'>, 404: <class 'networkapiclient.exception.UrlNotFoundError'>, 407: <class 'networkapiclient.exception.VariableError'>, 501: <class 'networkapiclient.exception.NotImplementedError'>}¶
- exception networkapiclient.exception.FilterDuplicateError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of filter name already exist
- exception networkapiclient.exception.FilterEqTypeAssociationError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of filter and equip type already exist
- exception networkapiclient.exception.FilterNotFoundError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of filter search
- exception networkapiclient.exception.InvalidBalMethodValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid balancing method value
- exception networkapiclient.exception.InvalidCacheValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid cache value
- exception networkapiclient.exception.InvalidFinalityValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid finality value
- exception networkapiclient.exception.InvalidPersistenceValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid persistence value
- exception networkapiclient.exception.InvalidPriorityValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid priority value
- exception networkapiclient.exception.InvalidTimeoutValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid timeout value
- exception networkapiclient.exception.IpEquipCantDissociateFromVip(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
Returns exception when trying to dissociate ip and equipment, but equipment is the last balancer for Vip Request
- exception networkapiclient.exception.IpEquipmentError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of invalid ip and equipment association
- exception networkapiclient.exception.IpNotFoundByEquipAndVipError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of real server error
- exception networkapiclient.exception.IpRangeAlreadyAssociation(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception whey trying to associate ip and equipment, and equipment having another ip in the same ip range
- exception networkapiclient.exception.NetworkAPIClientError(error)[source]¶
Bases: exceptions.Exception
- exception networkapiclient.exception.NetworkIPRangeEnvError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of two environments having the same ip range
- exception networkapiclient.exception.OptionVipError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception to option vip.
- exception networkapiclient.exception.OptionVipNotFoundError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception to option research by primary key.
- exception networkapiclient.exception.PermissionNotFoundError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of filter search
- exception networkapiclient.exception.RealParameterValueError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid real server parameter
- exception networkapiclient.exception.RealServerPortError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid real server port list
- exception networkapiclient.exception.RealServerPriorityError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid real server priority list
- exception networkapiclient.exception.RealServerScriptError(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
returns exception of real server script error
- exception networkapiclient.exception.RealServerWeightError(error)[source]¶
Bases: networkapiclient.exception.InvalidParameterError
returns exception of invalid real server weight list
- exception networkapiclient.exception.RelacionamentoInterfaceEquipamentoNaoExisteError(error)[source]¶
- exception networkapiclient.exception.VipIpError(error)[source]¶
Bases: networkapiclient.exception.VlanError
returns exception to ip cant removed from vip.
- exception networkapiclient.exception.VipRequestBlockAlreadyInRule(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
Returns exception when trying to add a block that already exists in rule vip
- exception networkapiclient.exception.VipRequestNoBlockInRule(error)[source]¶
Bases: networkapiclient.exception.NetworkAPIClientError
Returns exception when trying to add a block in rule vip that doesn’t has any block
- exception networkapiclient.exception.VlanAclExistenteError(error)[source]¶
Bases: networkapiclient.exception.VlanError
returns exception to find a Vlan with a ACL-file that already exists.
networkapiclient.rest module¶
- exception networkapiclient.rest.ConnectionError(cause)[source]¶
Bases: networkapiclient.rest.RestError
Caso ocorra algum erro de conexão com a NetworkAPI.
- class networkapiclient.rest.Rest[source]¶
Classe utilitária para chamada de webservices REST.
Implementa métodos utilitários para realizações de chamadas a webservices REST.
- delete(url, request_data, content_type=None, auth_map=None)[source]¶
Envia uma requisição DELETE para a URL informada.
- Se auth_map é diferente de None, então deverá conter as
- chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
Parameters: - url – URL para enviar a requisição HTTP.
- request_data – Descrição para enviar no corpo da requisição HTTP.
- content_type – Tipo do conteúdo enviado em request_data. O valor deste parâmetro será adicionado no header “Content-Type” da requisição.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- delete_map(url, map=None, auth_map=None)[source]¶
Gera um XML a partir dos dados do dicionário e o envia através de uma requisição DELETE.
Parameters: - url – URL para enviar a requisição HTTP.
- map – Dicionário com os dados do corpo da requisição HTTP.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- get(url, auth_map=None)[source]¶
Envia uma requisição GET para a URL informada.
Se auth_map é diferente de None, então deverá conter as chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar a autenticação na networkAPI. As chaves e os seus valores são enviados no header da requisição.
Parameters: - url – URL para enviar a requisição HTTP.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- get_map(url, auth_map=None)[source]¶
Envia uma requisição GET.
Parameters: - url – URL para enviar a requisição HTTP.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- post(url, request_data, content_type=None, auth_map=None)[source]¶
Envia uma requisição POST para a URL informada.
- Se auth_map é diferente de None, então deverá conter as
- chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
Parameters: - url – URL para enviar a requisição HTTP.
- request_data – Descrição para enviar no corpo da requisição HTTP.
- content_type – Tipo do conteúdo enviado em request_data. O valor deste parâmetro será adicionado no header “Content-Type” da requisição.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- post_map(url, map, auth_map=None)[source]¶
Gera um XML a partir dos dados do dicionário e o envia através de uma requisição POST.
Parameters: - url – URL para enviar a requisição HTTP.
- map – Dicionário com os dados do corpo da requisição HTTP.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- put(url, request_data, content_type=None, auth_map=None)[source]¶
Envia uma requisição PUT para a URL informada.
- Se auth_map é diferente de None, então deverá conter as
- chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
Parameters: - url – URL para enviar a requisição HTTP.
- request_data – Descrição para enviar no corpo da requisição HTTP.
- content_type – Tipo do conteúdo enviado em request_data. O valor deste parâmetro será adicionado no header “Content-Type” da requisição.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- put_map(url, map, auth_map=None)[source]¶
Gera um XML a partir dos dados do dicionário e o envia através de uma requisição PUT.
Parameters: - url – URL para enviar a requisição HTTP.
- map – Dicionário com os dados do corpo da requisição HTTP.
- auth_map – Dicionário com as informações para autenticação na networkAPI.
Returns: Retorna uma tupla contendo: (< código de resposta http>, < corpo da resposta>).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
- exception networkapiclient.rest.RestError(cause, message)[source]¶
Bases: exceptions.Exception
Representa um erro ocorrido durante uma requisão REST.
- class networkapiclient.rest.RestRequest(url, method, user, password, user_ldap=None)[source]¶
Classe básica para requisições webservices REST à networkAPI
- submit(map)[source]¶
Envia a requisição HTTP de acordo com os parâmetros informados no construtor.
Parameters: map – Dicionário com os dados do corpo da requisição.
Returns: Retorna uma tupla contendo: (< código de resposta http >, < corpo da resposta >).
Raises: - ConnectionError – Falha na conexão com a networkAPI.
- RestError – Falha no acesso à networkAPI.
networkapiclient.utils module¶
- networkapiclient.utils.get_list_map(map, key)[source]¶
Se o mapa é diferente de None então retorna o mapa, caso contrário, cria o mapa {key:[]}.
O mapa criado terá o elemento ‘key’ com uma lista vazia.
Parameters: - map – Mapa onde o elemento tem como valor uma lista.
- key – Chave para criar o mapa {key:[]}
Returns: Retorna um mapa onde o elemento tem como valor uma lista.
- networkapiclient.utils.is_valid_int_param(param)[source]¶
Verifica se o parâmetro é um valor inteiro válido.
Parameters: param – Valor para ser validado. Returns: True se o parâmetro tem um valor inteiro válido, ou False, caso contrário.
networkapiclient.version_control module¶
networkapiclient.xml_utils module¶
- exception networkapiclient.xml_utils.InvalidNodeNameXMLError(cause, message)[source]¶
Bases: networkapiclient.xml_utils.XMLErrorUtils
Nome inválido para representá-lo como uma TAG de XML.
- exception networkapiclient.xml_utils.InvalidNodeTypeXMLError(cause, message)[source]¶
Bases: networkapiclient.xml_utils.XMLErrorUtils
Tipo inválido para o conteúdo de uma TAG de XML.
- exception networkapiclient.xml_utils.XMLErrorUtils(cause, message)[source]¶
Bases: exceptions.Exception
Representa um erro ocorrido durante o marshall ou unmarshall do XML.
- networkapiclient.xml_utils.dumps(map, root_name, root_attributes=None)[source]¶
Cria um string no formato XML a partir dos elementos do map.
Os elementos do mapa serão nós filhos do root_name.
Cada chave do map será um Nó no XML. E o valor da chave será o conteúdo do Nó.
Exemplos:
- Mapa: {'networkapi':1} XML: <?xml version="1.0" encoding="UTF-8"?><networkapi>1</networkapi> - Mapa: {'networkapi':{'teste':1}} XML: <?xml version="1.0" encoding="UTF-8"?> <networkapi> <teste>1</teste> </networkapi> - Mapa: {'networkapi':{'teste01':01, 'teste02':02}} XML: <?xml version="1.0" encoding="UTF-8"?> <networkapi> <teste01>01</teste01> <teste02>02</teste02> </networkapi> - Mapa: {'networkapi':{'teste01':01, 'teste02':[02,03,04]}} XML: <?xml version="1.0" encoding="UTF-8"?> <networkapi> <teste01>01</teste01> <teste02>02</teste02> <teste02>03</teste02> <teste02>04</teste02> </networkapi> - Mapa: {'networkapi':{'teste01':01, 'teste02':{'a':1, 'b':2}}} XML: <?xml version="1.0" encoding="UTF-8"?> <networkapi> <teste01>01</teste01> <teste02> <a>1</a> <b>2</b> </teste02> </networkapi>
Parameters: - map – Dicionário com os dados para serem convertidos em XML.
- root_name – Nome do nó root do XML.
- root_attributes – Dicionário com valores para serem adicionados como atributos para o nó root.
Returns: XML
Raises: - XMLErrorUtils – Representa um erro ocorrido durante o marshall ou unmarshall do XML.
- InvalidNodeNameXMLError – Nome inválido para representá-lo como uma TAG de XML.
- InvalidNodeTypeXMLError – “Tipo inválido para o conteúdo de uma TAG de XML.
- networkapiclient.xml_utils.dumps_networkapi(map, version='1.0')[source]¶
Idem ao método dump, porém, define que o nó root é o valor ‘networkapi’.
Parameters: - map – Dicionário com os dados para serem convertidos em XML.
- version – Versão do nó networkapi. A versão será adicionada como atributo do nó.
Returns: XML
Raises: - XMLErrorUtils – Representa um erro ocorrido durante o marshall ou unmarshall do XML.
- InvalidNodeNameXMLError – Nome inválido para representá-lo como uma TAG de XML.
- InvalidNodeTypeXMLError – “Tipo inválido para o conteúdo de uma TAG de XML.
- networkapiclient.xml_utils.loads(xml, force_list=None)[source]¶
Cria um dicionário com os dados do XML.
O dicionário terá como chave o nome do nó root e como valor o conteúdo do nó root. Quando o conteúdo de um nó é uma lista de nós então o valor do nó será um dicionário com uma chave para cada nó. Entretanto, se existir nós, de um mesmo pai, com o mesmo nome, então eles serão armazenados em uma mesma chave do dicionário que terá como valor uma lista.
O force_list deverá ter nomes de nós do XML que necessariamente terão seus valores armazenados em uma lista no dicionário de retorno.
- ::
Por exemplo: xml_1 = <?xml version=”1.0” encoding=”UTF-8”?> <networkapi versao=”1.0”> <testes> <teste>1<teste> <teste>2<teste> </testes> </networkapi>
A chamada loads(xml_1), irá gerar o dicionário: {‘networkapi’:{‘testes’:{‘teste’:[1,2]}}}
xml_2 = <?xml version=”1.0” encoding=”UTF-8”?> <networkapi versao=”1.0”> <testes> <teste>1<teste> </testes> </networkapi>
A chamada loads(xml_2), irá gerar o dicionário: {‘networkapi’:{‘testes’:{‘teste’:1}}}
A chamada loads(xml_2, [‘teste’]), irá gerar o dicionário: {‘networkapi’:{‘testes’:{‘teste’:[1]}}}
Ou seja, o XML_2 tem apenas um nó ‘teste’, porém, ao informar o parâmetro ‘force_list’ com o valor [‘teste’], a chave ‘teste’, no dicionário, terá o valor dentro de uma lista.
Parameters: - xml – XML
- force_list – Lista com os nomes dos nós do XML que deverão ter seus valores armazenados em lista dentro da chave do dicionário de retorno.
Returns: Dicionário com os nós do XML.
Raises XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.