def test_all_network_labels(self): CONF.network_label_regex = '.*' ip = get_ip_address(self.addresses) self.assertTrue(len(ip) == 3) self.assertTrue('10.123.123.123' in ip) self.assertTrue('123.123.123.123' in ip) self.assertTrue('15.123.123.123' in ip)
def data(self): result = super(KSC_InstanceDetailView, self).data() dns_support = CONF.trove_dns_support if dns_support: result['instance']['hostname'] = self.instance.hostname if CONF.add_addresses: ip = get_ip_address(self.instance.addresses) if ip is not None and len(ip) > 0: result['instance']['ip'] = ip if isinstance(self.instance, models.DetailInstance) and \ self.instance.volume_used: used = self.instance.volume_used binlog_used = self.instance.binlog_used result['instance']['storage_used'] = used result['instance']['binlog_used'] = binlog_used if self.instance.type == DBInstanceType.READ_REPLI: result['instance']['source_instance'] = self.instance.srouce_instance result['instance']["configuration_id"] = self.instance.db_info.configuration_id #result['instance']['admin_user']= self.instance.admin_user #result['instance']['port'] = self.instance.port #result['instance']['db_type'] = self.instance.service_type #result['instance']['security_group'] = self.instance.security_group #result['instance']['task_status'] = self.instance.task_status_ext #result['instance']['server_status'] = self.instance.server_status_ext #result['instance']['service_status'] = self.instance.service_status_ext return result
def _create_dns_entry(self): LOG.debug("%s: Creating dns entry for instance: %s" % (greenthread.getcurrent(), self.id)) dns_support = CONF.trove_dns_support LOG.debug(_("trove dns support = %s") % dns_support) if dns_support: dns_client = create_dns_client(self.context) def get_server(): c_id = self.db_info.compute_instance_id return self.nova_client.servers.get(c_id) def ip_is_available(server): LOG.info("Polling for ip addresses: $%s " % server.addresses) if server.addresses != {}: return True elif server.addresses == {} and server.status != InstanceStatus.ERROR: return False elif server.addresses == {} and server.status == InstanceStatus.ERROR: msg = _("Instance IP not available, instance (%s): " "server had status (%s).") LOG.error(msg % (self.id, server.status)) raise TroveError(status=server.status) poll_until(get_server, ip_is_available, sleep_time=1, time_out=DNS_TIME_OUT) server = self.nova_client.servers.get(self.db_info.compute_instance_id) LOG.info("Creating dns entry...") dns_client.create_instance_entry(self.id, get_ip_address(server.addresses)) else: LOG.debug("%s: DNS not enabled for instance: %s" % (greenthread.getcurrent(), self.id))
def test_filter_ips(self): CONF.network_label_regex = '.*' CONF.ip_regex = '^(15.|123.)' ip = get_ip_address(self.addresses) ip = filter_ips(ip, CONF.ip_regex) self.assertTrue(len(ip) == 2) self.assertTrue('123.123.123.123' in ip) self.assertTrue('15.123.123.123' in ip)
def _create_dns_entry(self): LOG.debug( _("%(gt)s: Creating dns entry for instance: %(id)s") % { 'gt': greenthread.getcurrent(), 'id': self.id }) dns_support = CONF.trove_dns_support LOG.debug(_("trove dns support = %s") % dns_support) if dns_support: dns_client = create_dns_client(self.context) def get_server(): c_id = self.db_info.compute_instance_id return self.nova_client.servers.get(c_id) def ip_is_available(server): LOG.info( _("Polling for ip addresses: $%s ") % server.addresses) if server.addresses != {}: return True elif (server.addresses == {} and server.status != InstanceStatus.ERROR): return False elif (server.addresses == {} and server.status == InstanceStatus.ERROR): LOG.error( _("Instance IP not available, " "instance (%(instance)s): " "server had status (%(status)s).") % { 'instance': self.id, 'status': server.status }) raise TroveError(status=server.status) utils.poll_until(get_server, ip_is_available, sleep_time=1, time_out=DNS_TIME_OUT) server = self.nova_client.servers.get( self.db_info.compute_instance_id) LOG.info(_("Creating dns entry...")) dns_client.create_instance_entry(self.id, get_ip_address(server.addresses)) else: LOG.debug( _("%(gt)s: DNS not enabled for instance: %(id)s") % { 'gt': greenthread.getcurrent(), 'id': self.id })
def _create_dns_entry(self): LOG.debug(_("%(gt)s: Creating dns entry for instance: %(id)s") % {'gt': greenthread.getcurrent(), 'id': self.id}) dns_support = CONF.trove_dns_support LOG.debug(_("trove dns support = %s") % dns_support) if dns_support: dns_client = create_dns_client(self.context) def get_server(): c_id = self.db_info.compute_instance_id return self.nova_client.servers.get(c_id) def ip_is_available(server): LOG.info(_("Polling for ip addresses: $%s ") % server.addresses) if server.addresses != {}: return True elif (server.addresses == {} and server.status != InstanceStatus.ERROR): return False elif (server.addresses == {} and server.status == InstanceStatus.ERROR): LOG.error(_("Instance IP not available, " "instance (%(instance)s): " "server had status (%(status)s).") % {'instance': self.id, 'status': server.status}) raise TroveError(status=server.status) utils.poll_until(get_server, ip_is_available, sleep_time=1, time_out=DNS_TIME_OUT) server = self.nova_client.servers.get( self.db_info.compute_instance_id) LOG.info(_("Creating dns entry...")) ip = get_ip_address(server.addresses) if not ip: raise TroveError('Error creating DNS. No IP available.') dns_client.create_instance_entry(self.id, ip.pop) else: LOG.debug(_("%(gt)s: DNS not enabled for instance: %(id)s") % {'gt': greenthread.getcurrent(), 'id': self.id})
def test_two_network_labels(self): CONF.network_label_regex = '^(private|public)$' ip = get_ip_address(self.addresses) self.assertTrue(len(ip) == 2) self.assertTrue('123.123.123.123' in ip) self.assertTrue('15.123.123.123' in ip)
def test_one_network_label(self): CONF.network_label_regex = 'public' ip = get_ip_address(self.addresses) self.assertEqual(['15.123.123.123'], ip)
def test_one_network_label_exact(self): CONF.network_label_regex = '^internal$' ip = get_ip_address(self.addresses) self.assertEqual(['10.123.123.123'], ip)