

def create_key(self, ctxt, expiration=None, name='Nova Compute Key', payload_content_type='application/octet-stream', mode='CBC', algorithm='AES', length=256):
    'Creates a key.\n\n        :param ctxt: contains information of the user and the environment\n                     for the request (nova/context.py)\n        :param expiration: the date the key will expire\n        :param name: a friendly name for the secret\n        :param payload_content_type: the format/type of the secret data\n        :param mode: the algorithm mode (e.g. CBC or CTR mode)\n        :param algorithm: the algorithm associated with the secret\n        :param length: the bit length of the secret\n\n        :return: the UUID of the new key\n        :raises Exception: if key creation fails\n        '
    barbican_client = self._get_barbican_client(ctxt)
    try:
        key_order = barbican_client.orders.create_key(name, algorithm, length, mode, payload_content_type, expiration)
        order_ref = key_order.submit()
        order = barbican_client.orders.get(order_ref)
        return self._retrieve_secret_uuid(order.secret_ref)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Error creating key: %s'), e)

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