← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1918863] Re: find secret not has usage_type='vtpm'

 

@Brin: thanks. I assume that it is a new feature not a bug so I mark
this Invalid. Let's continue the work in the bp.

** Changed in: nova
       Status: Confirmed => Invalid

-- 
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/1918863

Title:
  find secret not has usage_type='vtpm'

Status in OpenStack Compute (nova):
  Invalid

Bug description:
  Currently, nova supports creating a vtpm instance,but in the implement
  code logical, the create_secret and delete_secret interface can deal
  'vtpm' type, but when we want to use delete_secret() to delete the
  vtpm device, it cannot find the 'vypm', see below.

  Use case: we want to live migrate the vtpm instance to another
  instance, and there need to be clean the vtpm in the old host, so we
  should fix this bug, and we would like to register a blueprint to
  support live migratge vtpm instance.

  like this:

      def create_secret(self, usage_type, usage_id, password=None, uuid=None):
          """Create a secret.

          :param usage_type: one of 'iscsi', 'ceph', 'rbd', 'volume', 'vtpm'.
                             'rbd' will be converted to 'ceph'. 'vtpm' secrets
                             are private and ephemeral; others are not.
          :param usage_id: name of resource in secret
          :param password: optional secret value to set
          :param uuid: optional UUID of the secret; else one is generated by
              libvirt
          """
          secret_conf = vconfig.LibvirtConfigSecret()
          secret_conf.ephemeral = usage_type == 'vtpm'
          secret_conf.private = usage_type == 'vtpm'
          secret_conf.usage_id = usage_id
          secret_conf.uuid = uuid
          if usage_type in ('rbd', 'ceph'):
              secret_conf.usage_type = 'ceph'
          elif usage_type == 'iscsi':
              secret_conf.usage_type = 'iscsi'
          elif usage_type == 'volume':
              secret_conf.usage_type = 'volume'
          elif usage_type == 'vtpm':
              secret_conf.usage_type = 'vtpm'
          else:
              msg = _("Invalid usage_type: %s")
              raise exception.InternalError(msg % usage_type)

          xml = secret_conf.to_xml()
          try:
              LOG.debug('Secret XML: %s', xml)
              conn = self.get_connection()
              secret = conn.secretDefineXML(xml)
              if password is not None:
                  secret.setValue(password)
              return secret
          except libvirt.libvirtError:
              with excutils.save_and_reraise_exception():
                  LOG.error('Error defining a secret with XML: %s', xml)

      def delete_secret(self, usage_type, usage_id):
          """Delete a secret.

          :param usage_type: one of 'iscsi', 'ceph', 'rbd', 'volume' or 'vtpm'
          :param usage_id: name of resource in secret
          """
          secret = self.find_secret(usage_type, usage_id)
          if secret is not None:
              secret.undefine()

      def find_secret(self, usage_type, usage_id):
          """Find a secret.

          usage_type: one of 'iscsi', 'ceph', 'rbd' or 'volume'
          usage_id: name of resource in secret
          """
          if usage_type == 'iscsi':
              usage_type_const = libvirt.VIR_SECRET_USAGE_TYPE_ISCSI
          elif usage_type in ('rbd', 'ceph'):
              usage_type_const = libvirt.VIR_SECRET_USAGE_TYPE_CEPH
          elif usage_type == 'volume':
              usage_type_const = libvirt.VIR_SECRET_USAGE_TYPE_VOLUME
          else:
              msg = _("Invalid usage_type: %s")
              raise exception.InternalError(msg % usage_type)

          try:
              conn = self.get_connection()
              return conn.secretLookupByUsage(usage_type_const, usage_id)
          except libvirt.libvirtError as e:
              if e.get_error_code() == libvirt.VIR_ERR_NO_SECRET:
                  return None

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


References