← Back to team overview

yahoo-eng-team team mailing list archive

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

 

Public bug reported:

nova supports creating vtpm instance,the create_secret and delete_secret
include 'vtpm', but find_secret not includes 'vypm'.

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

** Affects: nova
     Importance: Undecided
     Assignee: Qiu Fossen (fossen123)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => Qiu Fossen (fossen123)

** Project changed: neutron => nova

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1918863

Title:
  find secret not has usage_type='vtpm'

Status in OpenStack Compute (nova):
  New

Bug description:
  nova supports creating vtpm instance,the create_secret and
  delete_secret include 'vtpm', but find_secret not includes 'vypm'.

  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


Follow ups