Public bug reported:

When we create an instance, it's unable to pass the parameter hostname to 
nova-api.
Now, we use display_name as hostname[1], but obviously this is not a good 
practice because they are independent, In addition, hostname must conform to 
RFC 952, RFC 1123 specification, but the display name is not necessary.
So we need to pass hostname from the Rest API, and set it into the instance.

change method API.create()  [nova/compute/api.py]
    def create(self, context, instance_type,
               image_href, kernel_id=None, ramdisk_id=None,
               min_count=None, max_count=None,
               display_name=None, display_description=None,
               key_name=None, key_data=None, security_group=None,
               availability_zone=None, user_data=None, metadata=None,
               injected_files=None, admin_password=None,
               block_device_mapping=None, access_ip_v4=None,
               access_ip_v6=None, requested_networks=None, config_drive=None,
               auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
               shutdown_terminate=False, check_server_group_quota=False)
into:
    def create(self, context, instance_type,
               image_href, kernel_id=None, ramdisk_id=None,
               min_count=None, max_count=None,
               display_name=None, display_description=None,
               key_name=None, key_data=None, security_group=None,
               availability_zone=None, user_data=None, metadata=None,
               injected_files=None, admin_password=None,
               block_device_mapping=None, access_ip_v4=None,
               access_ip_v6=None, requested_networks=None, config_drive=None,
               auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
               shutdown_terminate=False, check_server_group_quota=False,
               hostname=None)

ps.
[1] nova/compute/api.py class API._populate_instance_for_create():
    def _populate_instance_names(self, instance, num_instances):
        """Populate instance display_name and hostname."""
        display_name = instance.get('display_name')
        if instance.obj_attr_is_set('hostname'):
            hostname = instance.get('hostname')
        else:
            hostname = None

        if display_name is None:
            display_name = self._default_display_name(instance.uuid)
            instance.display_name = display_name

        if hostname is None and num_instances == 1:
            # NOTE(russellb) In the multi-instance case, we're going to
            # overwrite the display_name using the
            # multi_instance_display_name_template.  We need the default
            # display_name set so that it can be used in the template, though.
            # Only set the hostname here if we're only creating one instance.
            # Otherwise, it will be built after the template based
            # display_name.
            hostname = display_name
            instance.hostname = utils.sanitize_hostname(hostname)

** Affects: nova
     Importance: Undecided
     Assignee: javeme (javaloveme)
         Status: New

** Description changed:

  When we create an instance, it's unable to pass the parameter hostname to 
nova-api.
  Now, we use display_name as hostname[1], but obviously this is not a good 
practice because they are independent, In addition, hostname must conform to 
RFC 952, RFC 1123 specification, but the display name is not necessary.
  So we need to pass hostname from the Rest API, and set it into the instance.
  
  change method API.create()  [nova/compute/api.py]
-     def create(self, context, instance_type,
-                image_href, kernel_id=None, ramdisk_id=None,
-                min_count=None, max_count=None,
-                display_name=None, display_description=None,
-                key_name=None, key_data=None, security_group=None,
-                availability_zone=None, user_data=None, metadata=None,
-                injected_files=None, admin_password=None,
-                block_device_mapping=None, access_ip_v4=None,
-                access_ip_v6=None, requested_networks=None, config_drive=None,
-                auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
-                shutdown_terminate=False, check_server_group_quota=False)
+     def create(self, context, instance_type,
+                image_href, kernel_id=None, ramdisk_id=None,
+                min_count=None, max_count=None,
+                display_name=None, display_description=None,
+                key_name=None, key_data=None, security_group=None,
+                availability_zone=None, user_data=None, metadata=None,
+                injected_files=None, admin_password=None,
+                block_device_mapping=None, access_ip_v4=None,
+                access_ip_v6=None, requested_networks=None, config_drive=None,
+                auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
+                shutdown_terminate=False, check_server_group_quota=False)
  into:
-     def create(self, context, instance_type,
-                image_href, kernel_id=None, ramdisk_id=None,
-                min_count=None, max_count=None,
-                display_name=None, display_description=None,
-                key_name=None, key_data=None, security_group=None,
-                availability_zone=None, user_data=None, metadata=None,
-                injected_files=None, admin_password=None,
-                block_device_mapping=None, access_ip_v4=None,
-                access_ip_v6=None, requested_networks=None, config_drive=None,
-                auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
-                shutdown_terminate=False, check_server_group_quota=False,
-                hostname=None)
+     def create(self, context, instance_type,
+                image_href, kernel_id=None, ramdisk_id=None,
+                min_count=None, max_count=None,
+                display_name=None, display_description=None,
+                key_name=None, key_data=None, security_group=None,
+                availability_zone=None, user_data=None, metadata=None,
+                injected_files=None, admin_password=None,
+                block_device_mapping=None, access_ip_v4=None,
+                access_ip_v6=None, requested_networks=None, config_drive=None,
+                auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
+                shutdown_terminate=False, check_server_group_quota=False,
+                hostname=None)
  
  ps.
- [1] :
-     def _populate_instance_names(self, instance, num_instances):
-         """Populate instance display_name and hostname."""
-         display_name = instance.get('display_name')
-         if instance.obj_attr_is_set('hostname'):
-             hostname = instance.get('hostname')
-         else:
-             hostname = None
+ [1] nova/compute/api.py class API._populate_instance_for_create():
+     def _populate_instance_names(self, instance, num_instances):
+         """Populate instance display_name and hostname."""
+         display_name = instance.get('display_name')
+         if instance.obj_attr_is_set('hostname'):
+             hostname = instance.get('hostname')
+         else:
+             hostname = None
  
-         if display_name is None:
-             display_name = self._default_display_name(instance.uuid)
-             instance.display_name = display_name
+         if display_name is None:
+             display_name = self._default_display_name(instance.uuid)
+             instance.display_name = display_name
  
-         if hostname is None and num_instances == 1:
-             # NOTE(russellb) In the multi-instance case, we're going to
-             # overwrite the display_name using the
-             # multi_instance_display_name_template.  We need the default
-             # display_name set so that it can be used in the template, though.
-             # Only set the hostname here if we're only creating one instance.
-             # Otherwise, it will be built after the template based
-             # display_name.
-             hostname = display_name
-             instance.hostname = utils.sanitize_hostname(hostname)
+         if hostname is None and num_instances == 1:
+             # NOTE(russellb) In the multi-instance case, we're going to
+             # overwrite the display_name using the
+             # multi_instance_display_name_template.  We need the default
+             # display_name set so that it can be used in the template, though.
+             # Only set the hostname here if we're only creating one instance.
+             # Otherwise, it will be built after the template based
+             # display_name.
+             hostname = display_name
+             instance.hostname = utils.sanitize_hostname(hostname)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1445863

Title:
  Unable to pass the parameter hostname to nova-api, when creating an
  instance.

Status in OpenStack Compute (Nova):
  New

Bug description:
  When we create an instance, it's unable to pass the parameter hostname to 
nova-api.
  Now, we use display_name as hostname[1], but obviously this is not a good 
practice because they are independent, In addition, hostname must conform to 
RFC 952, RFC 1123 specification, but the display name is not necessary.
  So we need to pass hostname from the Rest API, and set it into the instance.

  change method API.create()  [nova/compute/api.py]
      def create(self, context, instance_type,
                 image_href, kernel_id=None, ramdisk_id=None,
                 min_count=None, max_count=None,
                 display_name=None, display_description=None,
                 key_name=None, key_data=None, security_group=None,
                 availability_zone=None, user_data=None, metadata=None,
                 injected_files=None, admin_password=None,
                 block_device_mapping=None, access_ip_v4=None,
                 access_ip_v6=None, requested_networks=None, config_drive=None,
                 auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
                 shutdown_terminate=False, check_server_group_quota=False)
  into:
      def create(self, context, instance_type,
                 image_href, kernel_id=None, ramdisk_id=None,
                 min_count=None, max_count=None,
                 display_name=None, display_description=None,
                 key_name=None, key_data=None, security_group=None,
                 availability_zone=None, user_data=None, metadata=None,
                 injected_files=None, admin_password=None,
                 block_device_mapping=None, access_ip_v4=None,
                 access_ip_v6=None, requested_networks=None, config_drive=None,
                 auto_disk_config=None, scheduler_hints=None, legacy_bdm=True,
                 shutdown_terminate=False, check_server_group_quota=False,
                 hostname=None)

  ps.
  [1] nova/compute/api.py class API._populate_instance_for_create():
      def _populate_instance_names(self, instance, num_instances):
          """Populate instance display_name and hostname."""
          display_name = instance.get('display_name')
          if instance.obj_attr_is_set('hostname'):
              hostname = instance.get('hostname')
          else:
              hostname = None

          if display_name is None:
              display_name = self._default_display_name(instance.uuid)
              instance.display_name = display_name

          if hostname is None and num_instances == 1:
              # NOTE(russellb) In the multi-instance case, we're going to
              # overwrite the display_name using the
              # multi_instance_display_name_template.  We need the default
              # display_name set so that it can be used in the template, though.
              # Only set the hostname here if we're only creating one instance.
              # Otherwise, it will be built after the template based
              # display_name.
              hostname = display_name
              instance.hostname = utils.sanitize_hostname(hostname)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1445863/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to