def get_pool_by_search(search=dict()): pools = ServerPool.objects.filter() pool_map = build_query_to_datatable_v3(pools, search) return pool_map
def get_vip_request_by_search(search=dict()): vip_requests = models.VipRequest.objects.filter() vip_map = build_query_to_datatable_v3(vip_requests, search) return vip_map
def get_ipv6_by_search(search=dict()): """Get List of Ipv6 by Search.""" networks = Ipv6.objects.all() net_map = build_query_to_datatable_v3(networks, search) return net_map
def get_networkipv4_by_search(search=dict()): """Get List of NetworkIPv4 by Search.""" networks = ip_models.NetworkIPv4.objects.all() net_map = build_query_to_datatable_v3(networks, search) return net_map
def get_interfaces_environments_by_search(search=dict()): """Return a list of interface by dict.""" try: interfaces_envs = EnvironmentInterface.objects.filter() interfaces_envs_map = build_query_to_datatable_v3(interfaces_envs, search) except ObjectDoesNotExistException, e: raise ObjectDoesNotExistException(str(e))
def get_interface_type_by_search(search=dict()): """Return a list of interface by dict.""" try: interfaces = TipoInterface.objects.filter() interface_map = build_query_to_datatable_v3(interfaces, search) except ObjectDoesNotExistException, e: raise ObjectDoesNotExistException(str(e))
def get_vlan_by_search(search=dict()): """Get vlans by search""" vlans = Vlan.objects.filter() vlan_map = build_query_to_datatable_v3(vlans, search) return vlan_map
def get_pool_by_search(search=dict()): try: pools = ServerPool.objects.filter() pool_map = build_query_to_datatable_v3(pools, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return pool_map
def get_vip_request_by_search(search=dict()): try: vip_requests = VipRequest.objects.filter() vip_map = build_query_to_datatable_v3(vip_requests, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return vip_map
def get_as_by_search(search=dict()): """Return a list of AS's by dict.""" try: as_s = Asn.objects.filter() as_map = build_query_to_datatable_v3(as_s, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return as_map
def get_list_config_bgp_by_search(search=dict()): """Return a list of ListConfigBGP's by dict.""" try: objects = ListConfigBGP.objects.filter() object_map = build_query_to_datatable_v3(objects, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return object_map
def get_as_equipment_by_search(search=dict()): """Return a list of ASEquipment's by dict.""" try: as_equipment = AsnEquipment.get_by_pk() as_map = build_query_to_datatable_v3(as_equipment, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return as_map
def get_neighbor_by_search(search=dict()): """Return a list of Neighbor's by dict.""" try: neighbors = Neighbor.objects.filter() neighbor_map = build_query_to_datatable_v3(neighbors, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return neighbor_map
def get_interface_by_search(search=dict()): """Return a list of interface by dict.""" try: interfaces = Interface.objects.filter() interface_map = build_query_to_datatable_v3(interfaces, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return interface_map
def get_vrfs_by_search(search=dict()): """ Return a list of vrfs by dict :param search: dict """ vrfs = Vrf.objects.filter() vrf_map = build_query_to_datatable_v3(vrfs, search) return vrf_map
def get_ipv4_by_search(search=dict()): """Get List of Ipv4 by Search.""" try: networks = Ip.objects.all() net_map = build_query_to_datatable_v3(networks, search) except FieldError as e: raise ValidationAPIException(e.message) except Exception as e: raise NetworkAPIException(str(e)) else: return net_map
def get_logic_environment_by_search(search=dict()): """Return a list of dc environments by dict.""" try: environments = AmbienteLogico.objects.filter() env_map = build_query_to_datatable_v3(environments, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return env_map
def get_environment_by_search(search=dict()): """ Return a list of environments by dict :param search: dict """ environments = Ambiente.objects.filter() env_map = build_query_to_datatable_v3(environments, search) return env_map
def get_environment_by_search(search=dict()): """Return a list of environments by dict.""" try: environments = Ambiente.objects.filter() env_map = build_query_to_datatable_v3(environments, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return env_map
def get_as_by_search(search=dict()): """Return a list of AS's by dict.""" try: as_s = As.objects.filter() as_map = build_query_to_datatable_v3(as_s, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return as_map
def get_route_map_by_search(search=dict()): """Return a list of RouteMap's by dict.""" try: objects = RouteMap.objects.filter() object_map = build_query_to_datatable_v3(objects, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return object_map
def get_cidr_by_search(search=dict()): """Return a list of dc environments by dict.""" try: cidrs = EnvCIDR.objects.filter() cidrs_map = build_query_to_datatable_v3(cidrs, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return cidrs_map
def get_neighbor_v4_by_search(search=dict()): """Return a list of NeighborV4's by dict.""" try: objects = NeighborV4.objects.filter() object_map = build_query_to_datatable_v3(objects, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return object_map
def get_vlan_by_search(search=dict()): """Get vlans by search.""" try: vlans = Vlan.objects.filter() vlan_map = build_query_to_datatable_v3(vlans, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return vlan_map
def get_neighbor_v6_by_search(search=None): """Return a list of NeighborV6's by dict.""" try: objects = NeighborV6.objects.filter() search_dict = search if search else dict() object_map = build_query_to_datatable_v3(objects, search_dict) except FieldError as e: raise api_rest_exceptions.ValidationAPIException(str(e)) except Exception as e: raise api_rest_exceptions.NetworkAPIException(str(e)) else: return object_map
def get_environmentvip_by_search(search=dict()): """Return a list of environments vip by dict. :param search: dict """ try: env_vips = EnvironmentVip.objects.all() env_map = build_query_to_datatable_v3(env_vips, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return env_map
def get_networkipv6_by_search(search=dict()): """Get List of NetworkIPv6 by Search.""" try: networks = ip_models.NetworkIPv6.objects.all() net_map = build_query_to_datatable_v3(networks, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return net_map
def get_vrfs_by_search(search=dict()): """ Return a list of vrfs by dict :param search: dict """ try: vrfs = Vrf.objects.filter() vrf_map = build_query_to_datatable_v3(vrfs, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return vrf_map
def get_ogps_by_search(search=dict()): """ Return a list of Object Groups Permissions by dict :param search: dict """ try: ogps = ObjectGroupPermission.objects.filter() ogp_map = build_query_to_datatable_v3(ogps, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return ogp_map
def get_ogpgs_by_search(search=dict()): """ Return a list of Object Groups Permissions General by dict :param search: dict """ try: ogpgs = ObjectGroupPermissionGeneral.objects.filter() ogpg_map = build_query_to_datatable_v3(ogpgs, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return ogpg_map
def get_aws_vpc_by_search(search=dict()): """ Return a list of vpcs by dict :param search: dict """ try: vpcs = VPC.objects.filter() vpc_map = build_query_to_datatable_v3(vpcs, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return vpc_map
def get_equipments(**kwargs): """ Return a list of equipments :param user: Id user(optional) :param rights_write: Right of Write(optional) :param rights_read: Right of Read(optional) :param environment: Id of environment(optional) :param is_router: Boolean (True|False)(optional) """ try: eqpts = Equipamento.objects.all() q_filter = dict() if kwargs.get('user', None) is not None: q_filter.update(equipamentogrupo__egrupo__direitosgrupoequipamento__ugrupo__usuario=kwargs.get('user')) if kwargs.get('name', None) is not None: q_filter.update(nome=kwargs.get('name')) if kwargs.get('environment', None) is not None: q_filter.update(equipamentoambiente__ambiente=kwargs.get('environment')) if kwargs.get('rights_write', None) is not None: q_filter.update(equipamentogrupo__egrupo__direitosgrupoequipamento__escrita=1) if kwargs.get('rights_read', None) is not None: q_filter.update(equipamentogrupo__egrupo__direitosgrupoequipamento__leitura=1) if kwargs.get('is_router', None) is not None: q_filter.update(equipamentoambiente__is_router=kwargs.get('is_router')) if kwargs.get('environment_sdn_controller', None) is not None: q_filter.update(equipmentcontrollerenvironment=kwargs.get('environment_sdn_controller')) eqpts = eqpts.filter(Q(**q_filter)).distinct() eqpts = build_query_to_datatable_v3(eqpts, kwargs.get('search', {})) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return eqpts
def get_equipments(**kwargs): """ Return a list of equipments :param user: Id user(optional) :param rights_write: Right of Write(optional) :param rights_read: Right of Read(optional) :param environment: Id of environment(optional) :param is_router: Boolean (True|False)(optional) :param controller_of_environment: Id of controlled environment(optional) """ eqpts = Equipamento.objects.all() if kwargs.get('name', None) is not None: q_filter_name = { 'nome': kwargs.get('name') } eqpts = eqpts.filter(Q(**q_filter_name)) if kwargs.get('environment', None) is not None: q_filter_environment = { 'equipamentoambiente__ambiente': kwargs.get('environment') } eqpts = eqpts.filter(Q(**q_filter_environment)) if kwargs.get('user', None) is not None: q_filter_user = { 'equipamentogrupo__egrupo__direitosgrupoequipamento' '__ugrupo__usuario': kwargs.get('user') } eqpts = eqpts.filter(Q(**q_filter_user)) if kwargs.get('rights_write', None) is not None: q_filter_rights = { 'equipamentogrupo__egrupo__direitosgrupoequipamento__escrita': 1 } eqpts = eqpts.filter(Q(**q_filter_rights)) if kwargs.get('rights_read', None) is not None: q_filter_rights = { 'equipamentogrupo__egrupo__direitosgrupoequipamento__leitura': 1 } eqpts = eqpts.filter(Q(**q_filter_rights)) if kwargs.get('is_router', None) is not None: q_filter_router = { 'equipamentoambiente__is_router': kwargs.get('is_router') } eqpts = eqpts.filter(Q(**q_filter_router)) if kwargs.get('environment_sdn_controller', None) is not None: #q_filter_controller = { # 'ambientecontroller__ambiente__id': kwargs.get('controller_of_environment') #} #eqpts = eqpts.filter(Q(**q_filter_controller)) q_filter_controller = { 'equipamentoambiente__is_controller': kwargs.get('environment_sdn_controller') } eqpts = eqpts.filter(Q(**q_filter_controller)) eqpts = build_query_to_datatable_v3(eqpts, kwargs.get('search', {})) return eqpts
def get_equipments(**kwargs): """ Return a list of equipments :param user: Id user(optional) :param rights_write: Right of Write(optional) :param rights_read: Right of Read(optional) :param environment: Id of environment(optional) :param is_router: Boolean (True|False)(optional) """ eqpts = Equipamento.objects.all() if kwargs.get('user', None) is not None: q_filter_user = { 'equipamentogrupo__egrupo__direitosgrupoequipamento' '__ugrupo__usuario': kwargs.get('user') } eqpts = eqpts.filter(Q(**q_filter_user)) if kwargs.get('rights_write', None) is not None: q_filter_rights = { 'equipamentogrupo__egrupo__direitosgrupoequipamento__escrita': 1 } eqpts = eqpts.filter(Q(**q_filter_rights)) if kwargs.get('rights_read', None) is not None: q_filter_rights = { 'equipamentogrupo__egrupo__direitosgrupoequipamento__leitura': 1 } eqpts = eqpts.filter(Q(**q_filter_rights)) if kwargs.get('is_router', None) is not None: q_filter_router = { 'equipamentoambiente__is_router': kwargs.get('is_router') } eqpts = eqpts.filter(Q(**q_filter_router)) if kwargs.get('name', None) is not None: q_filter_router = {'nome': kwargs.get('name')} eqpts = eqpts.filter(Q(**q_filter_router)) if kwargs.get('environment', None) is not None: q_filters = [{ 'ipequipamento__ip__networkipv4__vlan__ambiente__environmentenvironmentvip' '__environment_vip__networkipv4__vlan__ambiente': kwargs.get('environment') }, { 'ipv6equipament__ip__networkipv6__vlan__ambiente__environmentenvironmentvip' '__environment_vip__networkipv6__vlan__ambiente': kwargs.get('environment') }] eqpts = eqpts.filter( reduce(lambda x, y: x | y, [Q(**q_filter) for q_filter in q_filters])) eqpts = build_query_to_datatable_v3(eqpts, kwargs.get('search', {})) return eqpts