Fixing DNS hostname code to save info to DB in taskmanager.
* Got rid of update_hostname method. * Return the entry.name in the create_instance_entry method, and now use that value to update the DB in the taskmanager code. * Fixed hostname bug in the views.
This commit is contained in:
parent
04110bd7ea
commit
4f27a733c7
@ -71,18 +71,15 @@ class DnsManager(object):
|
||||
if entry:
|
||||
self.driver.delete_entry(entry.name, entry.type)
|
||||
|
||||
def update_hostname(self, instance):
|
||||
def determine_hostname(self, instance_id):
|
||||
"""
|
||||
Create the hostname field based on the instance id.
|
||||
Use instance by default
|
||||
Use instance by default.
|
||||
"""
|
||||
dns_support = config.Config.get('reddwarf_dns_support', 'False')
|
||||
LOG.debug(_("reddwarf dns support = %s") % dns_support)
|
||||
if utils.bool_from_string(dns_support):
|
||||
entry = self.entry_factory.create_entry(instance.id)
|
||||
instance.hostname = entry.name
|
||||
instance.save()
|
||||
LOG.debug("Saved the hostname as %s " % instance.hostname)
|
||||
entry = self.entry_factory.create_entry(instance_id)
|
||||
if entry:
|
||||
return entry.name
|
||||
else:
|
||||
instance.hostname = instance.name
|
||||
instance.save()
|
||||
return None
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ import netaddr
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from reddwarf.common import config
|
||||
from reddwarf.common import exception
|
||||
from reddwarf.common import utils
|
||||
from reddwarf.common.remote import create_dns_client
|
||||
from reddwarf.common.remote import create_guest_client
|
||||
from reddwarf.common.remote import create_nova_client
|
||||
@ -366,11 +367,17 @@ class Instance(BuiltInstance):
|
||||
service_status = InstanceServiceStatus.create(instance_id=db_info.id,
|
||||
status=ServiceStatuses.NEW)
|
||||
|
||||
dns_client = create_dns_client(context)
|
||||
dns_client.update_hostname(db_info)
|
||||
dns_support = config.Config.get("reddwarf_dns_support", 'False')
|
||||
if utils.bool_from_string(dns_support):
|
||||
dns_client = create_dns_client(context)
|
||||
hostname = dns_client.determine_hostname(db_info.id)
|
||||
db_info.hostname=hostname
|
||||
db_info.save()
|
||||
|
||||
task_api.API(context).create_instance(db_info.id, name, flavor_id,
|
||||
flavor.ram, image_id, databases, users, service_type, volume_size)
|
||||
|
||||
|
||||
return SimpleInstance(context, db_info, service_status)
|
||||
|
||||
def _validate_can_perform_action(self):
|
||||
|
@ -93,7 +93,7 @@ class InstanceDetailView(InstanceView):
|
||||
|
||||
dns_support = config.Config.get("reddwarf_dns_support", 'False')
|
||||
if utils.bool_from_string(dns_support):
|
||||
result['hostname'] = self.instance.hostname
|
||||
result['instance']['hostname'] = self.instance.hostname
|
||||
|
||||
if self.add_addresses:
|
||||
ip = get_ip_address(self.instance.addresses)
|
||||
|
Loading…
Reference in New Issue
Block a user