update aws ec2 interface
for create_colume and for create_network_interface add client_token param Change-Id: Id9e575e9ab6d9da1e4029eeba19300292bef029c
This commit is contained in:
parent
8776ff585b
commit
08fd598064
|
@ -819,10 +819,10 @@ class CloudController(object):
|
||||||
|
|
||||||
@module_and_param_types(volume, 'str', 'int',
|
@module_and_param_types(volume, 'str', 'int',
|
||||||
'snap_id', 'str', 'int',
|
'snap_id', 'str', 'int',
|
||||||
'bool', 'str')
|
'bool', 'str', 'str')
|
||||||
def create_volume(self, context, availability_zone=None, size=None,
|
def create_volume(self, context, availability_zone=None, size=None,
|
||||||
snapshot_id=None, volume_type=None, iops=None,
|
snapshot_id=None, volume_type=None, iops=None,
|
||||||
encrypted=None, kms_key_id=None):
|
encrypted=None, kms_key_id=None, client_token=None):
|
||||||
"""Creates an EBS volume.
|
"""Creates an EBS volume.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -846,6 +846,8 @@ class CloudController(object):
|
||||||
kms_key_id (str): The full ARN of AWS KMS master key to use when
|
kms_key_id (str): The full ARN of AWS KMS master key to use when
|
||||||
creating the encrypted volume.
|
creating the encrypted volume.
|
||||||
Not used now.
|
Not used now.
|
||||||
|
client_token (str): Unique, case-sensitive identifier that you
|
||||||
|
provide to ensure the idempotency of the request.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Information about the volume.
|
Information about the volume.
|
||||||
|
@ -1691,13 +1693,15 @@ class VpcCloudController(CloudController):
|
||||||
'dummy',
|
'dummy',
|
||||||
'int',
|
'int',
|
||||||
'str',
|
'str',
|
||||||
'sg_ids')
|
'sg_ids',
|
||||||
|
'str')
|
||||||
def create_network_interface(self, context, subnet_id,
|
def create_network_interface(self, context, subnet_id,
|
||||||
private_ip_address=None,
|
private_ip_address=None,
|
||||||
private_ip_addresses=None,
|
private_ip_addresses=None,
|
||||||
secondary_private_ip_address_count=None,
|
secondary_private_ip_address_count=None,
|
||||||
description=None,
|
description=None,
|
||||||
security_group_id=None):
|
security_group_id=None,
|
||||||
|
client_token=None):
|
||||||
"""Creates a network interface in the specified subnet.
|
"""Creates a network interface in the specified subnet.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -1724,6 +1728,8 @@ class VpcCloudController(CloudController):
|
||||||
description (str): A description for the network interface.
|
description (str): A description for the network interface.
|
||||||
security_group_id (list of str): The list of security group IDs
|
security_group_id (list of str): The list of security group IDs
|
||||||
for the network interface.
|
for the network interface.
|
||||||
|
client_token (str): Unique, case-sensitive identifier that you
|
||||||
|
provide to ensure the idempotency of the request.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The network interface that was created.
|
The network interface that was created.
|
||||||
|
|
|
@ -156,13 +156,13 @@ def create_image(context, instance_id, name=None, description=None,
|
||||||
image['os_id'] = os_image_id
|
image['os_id'] = os_image_id
|
||||||
db_api.update_item(context, image)
|
db_api.update_item(context, image)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to complete image %s creation', image.id)
|
LOG.exception('Failed to complete image %s creation', image['id'])
|
||||||
try:
|
try:
|
||||||
image['state'] = 'failed'
|
image['state'] = 'failed'
|
||||||
db_api.update_item(context, image)
|
db_api.update_item(context, image)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warning("Couldn't set 'failed' state for db image %s",
|
LOG.warning("Couldn't set 'failed' state for db image %s",
|
||||||
image.id, exc_info=True)
|
image['id'], exc_info=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os_instance.start()
|
os_instance.start()
|
||||||
|
|
|
@ -47,7 +47,22 @@ def create_network_interface(context, subnet_id,
|
||||||
private_ip_addresses=None,
|
private_ip_addresses=None,
|
||||||
secondary_private_ip_address_count=None,
|
secondary_private_ip_address_count=None,
|
||||||
description=None,
|
description=None,
|
||||||
security_group_id=None):
|
security_group_id=None,
|
||||||
|
client_token=None):
|
||||||
|
|
||||||
|
if client_token:
|
||||||
|
result = describe_network_interfaces(context,
|
||||||
|
filter=[{'name': 'client-token',
|
||||||
|
'value': [client_token]}])
|
||||||
|
if result['networkInterfaceSet']:
|
||||||
|
if len(result['networkInterfaceSet']) > 1:
|
||||||
|
LOG.error('describe_network_interfaces returns %s '
|
||||||
|
'network_interfaces, but 1 is expected.',
|
||||||
|
len(result['networkInterfaceSet']))
|
||||||
|
LOG.error('Requested client token: %s', client_token)
|
||||||
|
LOG.error('Result: %s', result)
|
||||||
|
return result['networkInterfaceSet'][0]
|
||||||
|
|
||||||
subnet = ec2utils.get_db_item(context, subnet_id)
|
subnet = ec2utils.get_db_item(context, subnet_id)
|
||||||
if subnet is None:
|
if subnet is None:
|
||||||
raise exception.InvalidSubnetIDNotFound(id=subnet_id)
|
raise exception.InvalidSubnetIDNotFound(id=subnet_id)
|
||||||
|
@ -206,6 +221,7 @@ class NetworkInterfaceDescriber(common.TaggableItemsDescriber):
|
||||||
'attachment.attach.time': ('attachment', 'attachTime'),
|
'attachment.attach.time': ('attachment', 'attachTime'),
|
||||||
'attachment.delete-on-termination': ('attachment',
|
'attachment.delete-on-termination': ('attachment',
|
||||||
'deleteOnTermination'),
|
'deleteOnTermination'),
|
||||||
|
'client-token': 'clientToken',
|
||||||
'description': 'description',
|
'description': 'description',
|
||||||
'group-id': ['groupSet', 'groupId'],
|
'group-id': ['groupSet', 'groupId'],
|
||||||
'group-name': ['groupSet', 'groupName'],
|
'group-name': ['groupSet', 'groupName'],
|
||||||
|
|
|
@ -37,7 +37,21 @@ Validator = common.Validator
|
||||||
|
|
||||||
def create_volume(context, availability_zone=None, size=None,
|
def create_volume(context, availability_zone=None, size=None,
|
||||||
snapshot_id=None, volume_type=None, iops=None,
|
snapshot_id=None, volume_type=None, iops=None,
|
||||||
encrypted=None, kms_key_id=None):
|
encrypted=None, kms_key_id=None, client_token=None):
|
||||||
|
|
||||||
|
if client_token:
|
||||||
|
result = describe_volumes(context,
|
||||||
|
filter=[{'name': 'client-token',
|
||||||
|
'value': [client_token]}])
|
||||||
|
if result['volumeSet']:
|
||||||
|
if len(result['volumeSet']) > 1:
|
||||||
|
LOG.error('describe_volumes returns %s '
|
||||||
|
'volumes, but 1 is expected.',
|
||||||
|
len(result['volumeSet']))
|
||||||
|
LOG.error('Requested client token: %s', client_token)
|
||||||
|
LOG.error('Result: %s', result)
|
||||||
|
return result['volumeSet'][0]
|
||||||
|
|
||||||
if snapshot_id is not None:
|
if snapshot_id is not None:
|
||||||
snapshot = ec2utils.get_db_item(context, snapshot_id)
|
snapshot = ec2utils.get_db_item(context, snapshot_id)
|
||||||
os_snapshot_id = snapshot['os_id']
|
os_snapshot_id = snapshot['os_id']
|
||||||
|
@ -121,6 +135,7 @@ class VolumeDescriber(common.TaggableItemsDescriber):
|
||||||
SORT_KEY = 'volumeId'
|
SORT_KEY = 'volumeId'
|
||||||
FILTER_MAP = {
|
FILTER_MAP = {
|
||||||
'availability-zone': 'availabilityZone',
|
'availability-zone': 'availabilityZone',
|
||||||
|
'client-token': 'clientToken',
|
||||||
'create-time': 'createTime',
|
'create-time': 'createTime',
|
||||||
'encrypted': 'encrypted',
|
'encrypted': 'encrypted',
|
||||||
'size': 'size',
|
'size': 'size',
|
||||||
|
|
Loading…
Reference in New Issue