

def copy_key(self, ctxt, key_id):
    'Copies (i.e., clones) a key stored by barbican.\n\n        :param ctxt: contains information of the user and the environment for\n                     the request (nova/context.py)\n        :param key_id: the UUID of the key to copy\n        :return: the UUID of the key copy\n        :raises Exception: if key copying fails\n        '
    try:
        secret = self._get_secret(ctxt, key_id)
        con_type = secret.content_types['default']
        secret_data = self._get_secret_data(secret, payload_content_type=con_type)
        key = keymgr_key.SymmetricKey(secret.algorithm, secret_data)
        copy_uuid = self.store_key(ctxt, key, secret.expiration, secret.name, con_type, 'base64', secret.algorithm, secret.bit_length, secret.mode, True)
        return copy_uuid
    except Exception as e:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Error copying key: %s'), e)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/keymgr/barbican.py BarbicanKeyManager.copy_key/original