def _test_get_ea_for_forward_zone(self, template, skip_eas): network = {'id': mock.Mock(), 'name': mock.Mock(), 'provider:segmentation_id': mock.Mock(), 'provider:physical_network': mock.Mock(), 'provider:network_type': mock.Mock()} subnet = {'id': mock.Mock(), 'name': mock.Mock()} verified_ea = {'Subnet ID': subnet['id'], 'Subnet Name': subnet['name'], 'Network ID': network['id'], 'Network Name': network['name'], 'Network Encap': network['provider:network_type'], 'Segmentation ID': network['provider:segmentation_id'], 'Physical Network Name': ( network['provider:physical_network']), 'Tenant ID': self.tenant_id, 'Tenant Name': self.context.tenant_name, 'Account': self.user_id, 'CMP Type': 'OpenStack', 'Cloud API Owned': str(True)} ea = ea_manager.get_ea_for_forward_zone(self.user_id, self.tenant_id, self.tenant_name, network, subnet, template) expected_ea = {key: value for key, value in verified_ea.items() if key not in skip_eas} self.assertEqual(expected_ea, ea.ea_dict)
def _test_get_ea_for_forward_zone(self, template, skip_eas): network = { 'id': mock.Mock(), 'name': mock.Mock(), 'provider:segmentation_id': mock.Mock(), 'provider:physical_network': mock.Mock(), 'provider:network_type': mock.Mock() } subnet = {'id': mock.Mock(), 'name': mock.Mock()} verified_ea = { 'Subnet ID': subnet['id'], 'Subnet Name': subnet['name'], 'Network ID': network['id'], 'Network Name': network['name'], 'Network Encap': network['provider:network_type'], 'Segmentation ID': network['provider:segmentation_id'], 'Physical Network Name': (network['provider:physical_network']), 'Tenant ID': self.tenant_id, 'Tenant Name': self.context.tenant_name, 'Account': self.user_id, 'CMP Type': 'OpenStack', 'Cloud API Owned': str(True) } ea = ea_manager.get_ea_for_forward_zone(self.user_id, self.tenant_id, self.tenant_name, network, subnet, template) expected_ea = { key: value for key, value in list(verified_ea.items()) if key not in skip_eas } self.assertEqual(expected_ea, ea.ea_dict)
def test_get_ea_for_zones_without_net(self): # Test that None values is acceptable for network/subnet parameters expected_ea = {'Tenant ID': self.tenant_id, 'Tenant Name': self.context.tenant_name, 'Account': self.user_id, 'CMP Type': 'OpenStack', 'Cloud API Owned': str(True)} ea = ea_manager.get_ea_for_reverse_zone(self.user_id, self.tenant_id, self.tenant_name, None, None) self.assertEqual(expected_ea, ea.ea_dict) ea = ea_manager.get_ea_for_forward_zone(self.user_id, self.tenant_id, self.tenant_name, None, None, '{subnet_id}.infoblox.com') self.assertEqual(expected_ea, ea.ea_dict)
def test_get_ea_for_zones_without_net(self): # Test that None values is acceptable for network/subnet parameters expected_ea = { 'Tenant ID': self.tenant_id, 'Tenant Name': self.context.tenant_name, 'Account': self.user_id, 'CMP Type': 'OpenStack', 'Cloud API Owned': str(True) } ea = ea_manager.get_ea_for_reverse_zone(self.user_id, self.tenant_id, self.tenant_name, None, None) self.assertEqual(expected_ea, ea.ea_dict) ea = ea_manager.get_ea_for_forward_zone(self.user_id, self.tenant_id, self.tenant_name, None, None, '{subnet_id}.infoblox.com') self.assertEqual(expected_ea, ea.ea_dict)
def _update_strategy_and_eas(self): self.need_forward = (constants.ZONE_CREATION_STRATEGY_FORWARD in self.grid_config.zone_creation_strategy) if self.need_forward: self.forward_zone_eas = eam.get_ea_for_forward_zone( self.ib_cxt.user_id, self.ib_cxt.tenant_id, self.ib_cxt.tenant_name, self.ib_cxt.network, self.ib_cxt.subnet, self.pattern_builder.get_zone_name( is_external=self.ib_cxt.network_is_external)) self.need_reverse = (constants.ZONE_CREATION_STRATEGY_REVERSE in self.grid_config.zone_creation_strategy) if self.need_reverse: self.reverse_zone_eas = eam.get_ea_for_reverse_zone( self.ib_cxt.user_id, self.ib_cxt.tenant_id, self.ib_cxt.tenant_name, self.ib_cxt.network, self.ib_cxt.subnet)
def _ensure_dns_zone_availability(self, dns_view, port_tenant_id, tenant_name, is_external): if self.grid_config.dns_support is False: return forward_zone_eas = eam.get_ea_for_forward_zone( self.ib_cxt.user_id, port_tenant_id, tenant_name, self.ib_cxt.network, self.ib_cxt.subnet, self.pattern_builder.get_zone_name( is_external=self.ib_cxt.network_is_external)) dns_zone_name = self.pattern_builder.get_zone_name( port_tenant_id=port_tenant_id, tenant_name=tenant_name, is_external=is_external) ns_group = self.grid_config.ns_group if ns_group: ib_zone, obj_created = obj.DNSZone.create_check_exists( self.ib_cxt.connector, view=dns_view, ns_group=ns_group, fqdn=dns_zone_name, extattrs=forward_zone_eas) if ib_zone and obj_created: LOG.info("Created forward zone: %s with ns_group: %s" % ( dns_zone_name, ns_group)) else: self.ib_cxt.reserve_service_members() grid_primaries, grid_secondaries = self.ib_cxt.get_dns_members() ib_zone, obj_created = obj.DNSZone.create_check_exists( self.ib_cxt.connector, view=dns_view, fqdn=dns_zone_name, grid_primary=grid_primaries, grid_secondaries=grid_secondaries, extattrs=forward_zone_eas) if ib_zone and obj_created: LOG.info("Created forward zone: %s with " "grid_primaries: %s, grid_secondaries: %s" % ( dns_zone_name, grid_primaries, grid_secondaries))