Python django.db.models.get_model() Examples
The following are 30 code examples for showing how to use django.db.models.get_model(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
django.db.models
, or try the search function
.
Example 1
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 6 votes |
def update_v3(self, vlan, user): """Update vlan.""" try: env_model = get_model('ambiente', 'Ambiente') ogp_models = get_app('api_ogp', 'models') env = env_model.get_by_pk(vlan.get('environment')) self.ambiente = env self.nome = vlan.get('name') self.num_vlan = vlan.get('num_vlan') self.descricao = vlan.get('description') self.acl_file_name = vlan.get('acl_file_name') self.acl_valida = vlan.get('acl_valida', False) self.acl_file_name_v6 = vlan.get('acl_file_name_v6') self.acl_valida_v6 = vlan.get('acl_valida_v6', False) self.ativada = vlan.get('active', False) self.vrf = vlan.get('vrf') self.acl_draft = vlan.get('acl_draft') self.acl_draft_v6 = vlan.get('acl_draft_v6') old_vlan = self.get_by_pk(self.id) except Exception, e: raise VlanErrorV3(e)
Example 2
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 6 votes |
def _is_ipv6_in_use(self, ipv6, id_vip=None): id_vip = id_vip if id_vip else self.id spm_model = get_model('requisicaovips', 'ServerPoolMember') vp_model = get_model('api_vip_request', 'VipRequest') is_in_use = True pm_count = spm_model.objects.filter(ipv6=ipv6).exclude( server_pool__vipporttopool__requisicao_vip__ipv6=self.id ).count() vip_count = vp_model.objects.filter( ipv6=ipv6 ).exclude(pk=id_vip).count() if vip_count == 0 and pm_count == 0: is_in_use = False return is_in_use
Example 3
Project: luscan-devel Author: blackye File: xml_serializer.py License: GNU General Public License v2.0 | 6 votes |
def _get_model_from_node(self, node, attr): """ Helper to look up a model from a <object model=...> or a <field rel=... to=...> node. """ model_identifier = node.getAttribute(attr) if not model_identifier: raise base.DeserializationError( "<%s> node is missing the required '%s' attribute" \ % (node.nodeName, attr)) try: Model = models.get_model(*model_identifier.split(".")) except TypeError: Model = None if Model is None: raise base.DeserializationError( "<%s> node has invalid model identifier: '%s'" % \ (node.nodeName, model_identifier)) return Model
Example 4
Project: devops Author: madre File: dashboard.py License: MIT License | 6 votes |
def context(self, context): btns = [] for b in self.q_btns: btn = {} if 'model' in b: model = self.get_model(b['model']) if not self.user.has_perm("%s.view_%s" % (model._meta.app_label, model._meta.model_name)): continue btn['url'] = reverse("%s:%s_%s_%s" % (self.admin_site.app_name, model._meta.app_label, model._meta.model_name, b.get('view', 'changelist'))) btn['title'] = model._meta.verbose_name btn['icon'] = self.dashboard.get_model_icon(model) else: try: btn['url'] = reverse(b['url']) except NoReverseMatch: btn['url'] = b['url'] if 'title' in b: btn['title'] = b['title'] if 'icon' in b: btn['icon'] = b['icon'] btns.append(btn) context.update({'btns': btns})
Example 5
Project: django-sqlserver Author: denisenkom File: test_multidb.py License: MIT License | 6 votes |
def _test_run_sql(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) sql = """ INSERT INTO {0}_pony (pink, weight) VALUES (1, 3.55); INSERT INTO {0}_pony (pink, weight) VALUES (3, 5.0); """.format(app_label) operation = migrations.RunSQL(sql, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0)
Example 6
Project: django-sqlserver Author: denisenkom File: test_multidb.py License: MIT License | 6 votes |
def _test_run_python(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) # Create the operation def inner_method(models, schema_editor): Pony = models.get_model(app_label, "Pony") Pony.objects.create(pink=1, weight=3.55) Pony.objects.create(weight=5) operation = migrations.RunPython(inner_method, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0)
Example 7
Project: django-sqlserver Author: denisenkom File: test_operations.py License: MIT License | 6 votes |
def test_alter_field_m2m(self): project_state = self.set_up_test_model("test_alflmm", second_model=True) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AddField("Pony", "stables", models.ManyToManyField("Stable", related_name="ponies")) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") self.assertFalse(Pony._meta.get_field('stables').blank) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AlterField( "Pony", "stables", models.ManyToManyField(to="Stable", related_name="ponies", blank=True) ) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") self.assertTrue(Pony._meta.get_field('stables').blank)
Example 8
Project: django-sqlserver Author: denisenkom File: test_operations.py License: MIT License | 6 votes |
def test_repoint_field_m2m(self): project_state = self.set_up_test_model("test_alflmm", second_model=True, third_model=True) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AddField("Pony", "places", models.ManyToManyField("Stable", related_name="ponies")) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AlterField("Pony", "places", models.ManyToManyField(to="Van", related_name="ponies")) ]) # Ensure the new field actually works Pony = project_state.apps.get_model("test_alflmm", "Pony") p = Pony.objects.create(pink=False, weight=4.55) p.places.create() self.assertEqual(p.places.count(), 1) p.places.all().delete()
Example 9
Project: djongo Author: nesdis File: test_multidb.py License: GNU Affero General Public License v3.0 | 6 votes |
def _test_run_sql(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) sql = """ INSERT INTO {0}_pony (pink, weight) VALUES (1, 3.55); INSERT INTO {0}_pony (pink, weight) VALUES (3, 5.0); """.format(app_label) operation = migrations.RunSQL(sql, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0)
Example 10
Project: djongo Author: nesdis File: test_multidb.py License: GNU Affero General Public License v3.0 | 6 votes |
def _test_run_python(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) # Create the operation def inner_method(models, schema_editor): Pony = models.get_model(app_label, "Pony") Pony.objects.create(pink=1, weight=3.55) Pony.objects.create(weight=5) operation = migrations.RunPython(inner_method, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0)
Example 11
Project: djongo Author: nesdis File: test_operations.py License: GNU Affero General Public License v3.0 | 6 votes |
def test_alter_field_m2m(self): project_state = self.set_up_test_model("test_alflmm", second_model=True) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AddField("Pony", "stables", models.ManyToManyField("Stable", related_name="ponies")) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") self.assertFalse(Pony._meta.get_field('stables').blank) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AlterField( "Pony", "stables", models.ManyToManyField(to="Stable", related_name="ponies", blank=True) ) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") self.assertTrue(Pony._meta.get_field('stables').blank)
Example 12
Project: djongo Author: nesdis File: test_operations.py License: GNU Affero General Public License v3.0 | 6 votes |
def test_repoint_field_m2m(self): project_state = self.set_up_test_model("test_alflmm", second_model=True, third_model=True) project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AddField("Pony", "places", models.ManyToManyField("Stable", related_name="ponies")) ]) Pony = project_state.apps.get_model("test_alflmm", "Pony") project_state = self.apply_operations("test_alflmm", project_state, operations=[ migrations.AlterField("Pony", "places", models.ManyToManyField(to="Van", related_name="ponies")) ]) # Ensure the new field actually works Pony = project_state.apps.get_model("test_alflmm", "Pony") p = Pony.objects.create(pink=False, weight=4.55) p.places.create() self.assertEqual(p.places.count(), 1) p.places.all().delete()
Example 13
Project: DCRM Author: 82Flex File: compat.py License: GNU Affero General Public License v3.0 | 5 votes |
def get_django_model(app_label, model_name): return models.get_model(app_label, model_name)
Example 14
Project: DCRM Author: 82Flex File: compat.py License: GNU Affero General Public License v3.0 | 5 votes |
def get_django_model(app_label, model_name): return apps.get_model(app_label, model_name)
Example 15
Project: urbanfootprint Author: CalthorpeAnalytics File: utils.py License: GNU General Public License v3.0 | 5 votes |
def resolve_model(class_path): """ Resolves a class path to a Django model class :param class_path: a string model class path :return: """ return get_model(*class_path.split('.', 1))
Example 16
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create_v4(self, as_equipment): """Create AsnEquipment relationship.""" equipment = get_model('equipamento', 'Equipamento') self.equipment = equipment().get_by_pk( as_equipment.get('equipment')) self.asn = Asn().get_by_pk(as_equipment.get('asn')) self.save() return self
Example 17
Project: GloboNetworkAPI Author: globocom File: serializers.py License: Apache License 2.0 | 5 votes |
def get_model(self, obj): return self.extends_serializer(obj, 'model')
Example 18
Project: GloboNetworkAPI Author: globocom File: serializers.py License: Apache License 2.0 | 5 votes |
def get_model(self, obj): return self.extends_serializer(obj, 'model')
Example 19
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def update_v3(self, member): """ Creates pool member. @raise ServerPoolNotFoundError @raise PoolError @raise OperationalError @raise IpNotFoundError @raise IpError """ model_ip = get_model('ip', 'Ip') model_ipv6 = get_model('ip', 'Ipv6') pools_exceptions = get_app('api_pools', 'exceptions') # Ip self.ip = model_ip.get_by_pk(member['ip']['id']) \ if member['ip'] else None # Ipv6 self.ipv6 = model_ipv6.get_by_pk(member['ipv6']['id']) \ if member['ipv6'] else None self.weight = member['weight'] self.priority = member['priority'] self.port_real = member['port_real'] self.member_status = member['member_status'] self.limit = member['limit'] self.save() if self.server_pool.dscp: if self.port_real != self.server_pool.default_port: raise pools_exceptions.PoolError( 'DRSL3 Restriction: Pool Member {} cannot have different' ' port of Pool {}'.format( str(self), str(self.server_pool) ) )
Example 20
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create(self, ipv4_id, networkipv4_id): ipv4_model = get_model('ip', 'Ip') networkipv4_model = get_model('ip', 'NetworkIPv4') ipv4 = ipv4_model.get_by_pk(ipv4_id) networkipv4 = networkipv4_model.get_by_pk(networkipv4_id) if len(DHCPRelayIPv4.objects.filter(ipv4=ipv4, networkipv4=networkipv4)) > 0: raise exceptions.DHCPRelayAlreadyExistsError( ipv4_id, networkipv4_id) self.ipv4 = ipv4 self.networkipv4 = networkipv4
Example 21
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def validate_v3(self): """Validate networkIPv4.""" models = get_model("ambiente", "EnvCIDR") if not self.network_type: raise NetworkIPv4ErrorV3('Network type can not null') # validate if network if allow in environment env_id = self.vlan.ambiente.id configs = models().get(env_id=env_id) self.vlan.allow_networks_environment(configs, [self], [])
Example 22
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create(self, authenticated_user, equipment_id, id, new): """Persist an IPv4 and associate it to an equipment. If equipment was not related with VLAN environment, this makes the relationship @return: Nothing @raise NetworkIPv6NotFoundError: NetworkIPv6 does not exist. @raise NetworkIPv6Error: Error finding NetworkIPv6. @raise EquipamentoNotFoundError: Equipment does not exist. @raise EquipamentoError: Error finding Equipment. @raise IpNotAvailableError: No IP available to VLAN. @raise IpError: Error persisting in database. """ equipamentoambiente = get_model('equipamento', 'EquipamentoAmbiente') equipamento = get_model('equipamento', 'Equipamento') configuration = get_model('config', 'Configuration') vlan_model = get_model('vlan', 'Vlan') if new is False: # Search vlan by id vlan = vlan_model().get_by_pk(id) # Get first networkipv4 related to vlan try: self.networkipv4 = vlan.networkipv4_set.order_by('id')[0] except IndexError, e: self.log.error( u'Error finding the first networkipv4 from vlan.') raise NetworkIPv4NotFoundError( e, u'Error finding the first networkipv4 from vlan.')
Example 23
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def get_by_octs_and_environment_vip(cls, oct1, oct2, oct3, oct4, id_evip, valid=True): """Get IP by octs and environment vip. @return: IP. @raise IpNotFoundByEquipAndVipError: IP is not related with equipament. @raise IpNotFoundError: IP is not registered. @raise IpError: Failed to search for the IP. """ environmentvip = get_model('ambiente', 'EnvironmentVip') ambiente_model = get_model('ambiente', 'Ambiente') try: ips = Ip.objects.filter(oct1=oct1, oct2=oct2, oct3=oct3, oct4=oct4) if ips.count() == 0: raise IpNotFoundError(None) if valid is True: return Ip.objects.get(oct1=oct1, oct2=oct2, oct3=oct3, oct4=oct4, networkipv4__ambient_vip__id=id_evip) else: for ip in ips: if ip.networkipv4.ambient_vip: if ip.networkipv4.ambient_vip.id == id_evip: return ip else: environments = ambiente_model.objects.filter( vlan__networkipv4__ambient_vip__id=id_evip) for env in environments: if ip.networkipv4.vlan.ambiente.divisao_dc.id == env.divisao_dc.id \ and ip.networkipv4.vlan.ambiente.ambiente_logico.id == env.ambiente_logico.id: return ip raise ObjectDoesNotExist() except ObjectDoesNotExist, e: evip = environmentvip.get_by_pk(id_evip) msg = u'Ipv4 não está relacionado ao Ambiente Vip: %s.' % evip.show_environment_vip() cls.log.error(msg) raise IpNotFoundByEquipAndVipError(e, msg)
Example 24
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create_v3(self, ip_equipment): """Inserts a relationship between IP e Equipment. @return: Nothing. @raise IpError: Failure to insert. @raise EquipamentoNotFoundError: Equipment do not registered. @raise IpNotFoundError: Ip do not registered. @raise IpEquipamentoDuplicatedError: IP already registered for the equipment. @raise EquipamentoError: Failure to search equipment. """ equipamentoambiente = get_model('equipamento', 'EquipamentoAmbiente') equipamento = get_model('equipamento', 'Equipamento') self.equipamento = equipamento().get_by_pk(ip_equipment.get('equipment')) self.ip = Ip().get_by_pk(ip_equipment.get('ip')) # Validate the ip self.__validate_ip() try: try: equipment_environment = equipamentoambiente() equipment_environment.create_v3({ 'equipment': self.equipamento_id, 'environment': self.ip.networkipv4.vlan.ambiente_id }) except EquipamentoAmbienteDuplicatedError, e: # If already exists, OK ! pass self.save()
Example 25
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def validate_v3(self): """ Validate NetworkIPv6. """ if not self.network_type: raise NetworkIPv6ErrorV3('Network type can not null') # validate if network if allow in environment models = get_model("ambiente", "EnvCIDR") env_id = self.vlan.ambiente.id configs = models().get(env_id=env_id) self.vlan.allow_networks_environment(configs, [], [self])
Example 26
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def get_by_octs_and_environment_vip(cls, block1, block2, block3, block4, block5, block6, block7, block8, id_evip, valid=True): """ Get Ipv6 by blocks and environment vip. @return: Ipv6. @raise IpNotFoundError: Ipv6 is not registered. @raise IpError: Failed to search for the Ipv6. """ environmentvip = get_model('ambiente', 'EnvironmentVip') ambiente_model = get_model('ambiente', 'Ambiente') try: ips = Ipv6.objects.filter( block1=block1, block2=block2, block3=block3, block4=block4, block5=block5, block6=block6, block7=block7, block8=block8) if ips.count() == 0: raise IpNotFoundError(None) if valid is True: return Ipv6.objects.get( block1=block1, block2=block2, block3=block3, block4=block4, block5=block5, block6=block6, block7=block7, block8=block8, networkipv6__ambient_vip__id=id_evip) else: for ip in ips: if ip.networkipv6.ambient_vip: if ip.networkipv6.ambient_vip.id == id_evip: return ip else: environments = ambiente_model.objects.filter( vlan__networkipv6__ambient_vip__id=id_evip) for env in environments: if ip.networkipv6.vlan.ambiente.divisao_dc.id == env.divisao_dc.id \ and ip.networkipv6.vlan.ambiente.ambiente_logico.id == env.ambiente_logico.id: return ip raise ObjectDoesNotExist() except ObjectDoesNotExist, e: evip = environmentvip.get_by_pk(id_evip) msg = u'Ipv6 não está relacionado ao Ambiente Vip: %s.' % evip.show_environment_vip() cls.log.error(msg) raise IpNotFoundByEquipAndVipError(e, msg)
Example 27
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create_v3(self, ip_equipment): """Inserts a relationship between IP e Equipment. @return: Nothing. @raise IpError: Failure to insert. @raise EquipamentoNotFoundError: Equipment do not registered. @raise IpNotFoundError: Ip do not registered. @raise IpEquipamentoDuplicatedError: IP already registered for the equipment. @raise EquipamentoError: Failure to search equipment. """ equipamento = get_model('equipamento', 'Equipamento') equipamentoambiente = get_model('equipamento', 'EquipamentoAmbiente') self.equipamento = equipamento().get_by_pk(ip_equipment.get('equipment')) self.ip = Ipv6().get_by_pk(ip_equipment.get('ip')) # Validate the ip self.validate_ip() try: # All equipments related with environment of IP eqpts = self.ip.networkipv6.vlan.ambiente\ .equipamentoambiente_set.all()\ .values_list('equipamento', flat=True) if ip_equipment.get('equipment') not in eqpts: ea = equipamentoambiente( ambiente=self.ip.networkipv6.vlan.ambiente, equipamento=self.equipamento ) ea.save() self.save() except Exception, e: self.log.error(u'Failure to insert an ip_equipamento.') raise IpError(e, u'Failure to insert an ip_equipamento.')
Example 28
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def create_v3(self, env_map): optionvip_model = get_model('requisicaovips', 'OptionVip') optionvipenvvip_model = get_model( 'requisicaovips', 'OptionVipEnvironmentVip') self.conf = env_map.get('conf') optionsvip = env_map.get('optionsvip', None) environments = env_map.get('environments', None) self.finalidade_txt = env_map.get('finalidade_txt') self.cliente_txt = env_map.get('cliente_txt') self.ambiente_p44_txt = env_map.get('ambiente_p44_txt') self.description = env_map.get('description') self.save() if optionsvip is not None: optionsvip = [opt.get('option') for opt in optionsvip] for optionvip in optionsvip: option = optionvip_model.get_by_pk(optionvip) optenv_obj = optionvipenvvip_model() optenv_obj.option = option optenv_obj.environment = self optenv_obj.save() if environments is not None: environments = [opt.get('environment') for opt in environments] for environment in environments: env = Ambiente.get_by_pk(environment) envenv_obj = EnvironmentEnvironmentVip() envenv_obj.environment = env envenv_obj.environment_vip = self envenv_obj.validate() envenv_obj.save()
Example 29
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def update_v3(self, env_map): try: self.grupo_l3 = GrupoL3.get_by_pk(env_map.get('grupo_l3')) self.ambiente_logico = AmbienteLogico\ .get_by_pk(env_map.get('ambiente_logico')) self.divisao_dc = DivisaoDc.get_by_pk(env_map.get('divisao_dc')) if env_map.get('filter', None): self.filter = Filter.get_by_pk(env_map.get('filter')) else: self.filter = None if env_map.get('father_environment'): self.father_environment = Ambiente\ .get_by_pk(env_map.get('father_environment')) else: self.father_environment = None self.acl_path = env_map.get('acl_path') self.ipv4_template = env_map.get('ipv4_template') self.ipv6_template = env_map.get('ipv6_template') self.link = env_map.get('link') self.min_num_vlan_1 = env_map.get('min_num_vlan_1') self.max_num_vlan_1 = env_map.get('max_num_vlan_1') self.min_num_vlan_2 = env_map.get('min_num_vlan_2') self.max_num_vlan_2 = env_map.get('max_num_vlan_2') self.default_vrf = Vrf.get_by_pk(env_map.get('default_vrf')) self.vrf = self.default_vrf.internal_name self.vxlan = env_map.get('vxlan', self.vxlan) if env_map.get('aws_vpc'): aws_vpc = get_model('api_aws', 'VPC') self.aws_vpc = aws_vpc.get_by_pk(env_map.get('aws_vpc')) else: self.aws_vpc = None except Exception, e: raise EnvironmentErrorV3(e)
Example 30
Project: GloboNetworkAPI Author: globocom File: models.py License: Apache License 2.0 | 5 votes |
def get_vrf(self): # get vrf to filter vrf = get_model('api_vrf', 'Vrf') vrfs = vrf.objects.filter( Q( Q(vrfvlanequipment__equipment__in=self.get_eqpt()) & Q(vrfvlanequipment__vlan__id=self.id) ) | Q(id=self.ambiente.default_vrf_id) ) return vrfs