本文整理汇总了Python中boto.ec2.blockdevicemapping.BlockDeviceType.no_device方法的典型用法代码示例。如果您正苦于以下问题:Python BlockDeviceType.no_device方法的具体用法?Python BlockDeviceType.no_device怎么用?Python BlockDeviceType.no_device使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ec2.blockdevicemapping.BlockDeviceType
的用法示例。
在下文中一共展示了BlockDeviceType.no_device方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleImages
# 需要导入模块: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
# 或者: from boto.ec2.blockdevicemapping.BlockDeviceType import no_device [as 别名]
def handleImages(self, action, clc, callback=None):
if action == "DescribeImages":
owner = self.get_argument("Owner", None)
if not owner:
owners = None
else:
owners = [owner]
filters = self.get_filter_args()
return clc.get_all_images(owners, filters, callback)
elif action == "DescribeImageAttribute":
imageid = self.get_argument("ImageId")
attribute = self.get_argument("Attribute")
return clc.get_image_attribute(imageid, attribute, callback)
elif action == "ModifyImageAttribute":
imageid = self.get_argument("ImageId")
attribute = self.get_argument("Attribute")
operation = self.get_argument("OperationType")
users = self.get_argument_list("UserId")
groups = self.get_argument_list("UserGroup")
return clc.modify_image_attribute(imageid, attribute, operation, users, groups, callback)
elif action == "ResetImageAttribute":
imageid = self.get_argument("ImageId")
attribute = self.get_argument("Attribute")
return clc.reset_image_attribute(imageid, attribute, callback)
elif action == "DeregisterImage":
image_id = self.get_argument("ImageId")
return clc.deregister_image(image_id, callback)
elif action == "RegisterImage":
image_location = self.get_argument("ImageLocation", None)
name = self.get_argument("Name")
description = self.get_argument("Description", None)
if description != None:
description = base64.b64decode(description)
architecture = self.get_argument("Architecture", None)
kernel_id = self.get_argument("KernelId", None)
ramdisk_id = self.get_argument("RamdiskId", None)
root_dev_name = self.get_argument("RootDeviceName", None)
snapshot_id = self.get_argument("SnapshotId", None)
# get block device mappings
bdm = BlockDeviceMapping()
mapping = self.get_argument("BlockDeviceMapping.1.DeviceName", None)
idx = 1
while mapping:
pre = "BlockDeviceMapping.%d" % idx
dev_name = mapping
block_dev_type = BlockDeviceType()
block_dev_type.ephemeral_name = self.get_argument("%s.VirtualName" % pre, None)
if not (block_dev_type.ephemeral_name):
block_dev_type.no_device = self.get_argument("%s.NoDevice" % pre, "") == "true"
block_dev_type.snapshot_id = self.get_argument("%s.Ebs.SnapshotId" % pre, None)
block_dev_type.size = self.get_argument("%s.Ebs.VolumeSize" % pre, None)
block_dev_type.delete_on_termination = (
self.get_argument("%s.Ebs.DeleteOnTermination" % pre, "") == "true"
)
bdm[dev_name] = block_dev_type
idx += 1
mapping = self.get_argument("BlockDeviceMapping.%d.DeviceName" % idx, None)
if snapshot_id:
rootbdm = BlockDeviceType()
rootbdm.snapshot_id = snapshot_id
bdm["/dev/sda1"] = rootbdm
if len(bdm) == 0:
bdm = None
return clc.register_image(
name, image_location, description, architecture, kernel_id, ramdisk_id, root_dev_name, bdm, callback
)
示例2: handleImages
# 需要导入模块: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
# 或者: from boto.ec2.blockdevicemapping.BlockDeviceType import no_device [as 别名]
def handleImages(self, action, clc, callback=None):
if action == 'DescribeImages':
owner = self.get_argument('Owner', None);
if not owner:
owners = None
else:
owners = [owner]
filters = self.get_filter_args()
return clc.get_all_images(owners, filters, callback)
elif action == 'DescribeImageAttribute':
imageid = self.get_argument('ImageId')
attribute = self.get_argument('Attribute')
return clc.get_image_attribute(imageid, attribute, callback)
elif action == 'ModifyImageAttribute':
imageid = self.get_argument('ImageId')
attribute = self.get_argument('Attribute')
operation = self.get_argument('OperationType')
users = self.get_argument_list('UserId')
groups = self.get_argument_list('UserGroup')
return clc.modify_image_attribute(imageid, attribute, operation, users, groups, callback)
elif action == 'ResetImageAttribute':
imageid = self.get_argument('ImageId')
attribute = self.get_argument('Attribute')
return clc.reset_image_attribute(imageid, attribute, callback)
elif action == 'DeregisterImage':
image_id = self.get_argument('ImageId')
return clc.deregister_image(image_id, callback)
elif action == 'RegisterImage':
image_location = self.get_argument('ImageLocation', None)
name = self.get_argument('Name')
description = self.get_argument('Description', None)
if description != None:
description = base64.b64decode(description);
architecture = self.get_argument('Architecture', None)
kernel_id = self.get_argument('KernelId', None)
ramdisk_id = self.get_argument('RamdiskId', None)
root_dev_name = self.get_argument('RootDeviceName', None)
snapshot_id = self.get_argument('SnapshotId', None)
# get block device mappings
bdm = BlockDeviceMapping()
mapping = self.get_argument('BlockDeviceMapping.1.DeviceName', None)
idx = 1
while mapping:
pre = 'BlockDeviceMapping.%d' % idx
dev_name = mapping
block_dev_type = BlockDeviceType()
block_dev_type.ephemeral_name = self.get_argument('%s.VirtualName' % pre, None)
if not(block_dev_type.ephemeral_name):
block_dev_type.no_device = \
(self.get_argument('%s.NoDevice' % pre, '') == 'true')
block_dev_type.snapshot_id = \
self.get_argument('%s.Ebs.SnapshotId' % pre, None)
block_dev_type.size = \
self.get_argument('%s.Ebs.VolumeSize' % pre, None)
block_dev_type.delete_on_termination = \
(self.get_argument('%s.Ebs.DeleteOnTermination' % pre, '') == 'true')
bdm[dev_name] = block_dev_type
idx += 1
mapping = self.get_argument('BlockDeviceMapping.%d.DeviceName' % idx, None)
if snapshot_id:
rootbdm = BlockDeviceType()
rootbdm.snapshot_id = snapshot_id
bdm['/dev/sda1'] = rootbdm
if len(bdm) == 0:
bdm = None
return clc.register_image(name, image_location, description, architecture, kernel_id, ramdisk_id, root_dev_name, bdm, callback)
示例3: handleRunInstances
# 需要导入模块: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
# 或者: from boto.ec2.blockdevicemapping.BlockDeviceType import no_device [as 别名]
def handleRunInstances(self, action, clc, user_data_file, callback):
image_id = self.get_argument("ImageId")
min = self.get_argument("MinCount", "1")
max = self.get_argument("MaxCount", "1")
key = self.get_argument("KeyName", None)
groups = self.get_argument_list("SecurityGroup")
sec_group_ids = self.get_argument_list("SecurityGroupId")
if user_data_file:
user_data = user_data_file
else:
user_data = self.get_argument("UserData", "")
user_data = base64.b64decode(user_data)
addr_type = self.get_argument("AddressingType", None)
vm_type = self.get_argument("InstanceType", None)
placement = self.get_argument("Placement.AvailabilityZone", None)
placement_group = self.get_argument("Placement.GroupName", None)
tenancy = self.get_argument("Placement.Tenancy", None)
kernel = self.get_argument("KernelId", None)
ramdisk = self.get_argument("RamdiskId", None)
monitoring = False
if self.get_argument("Monitoring.Enabled", "") == "true":
monitoring = True
subnet = self.get_argument("SubnetId", None)
private_ip = self.get_argument("PrivateIpAddress", None)
# get block device mappings
bdm = BlockDeviceMapping()
mapping = self.get_argument("BlockDeviceMapping.1.DeviceName", None)
idx = 1
while mapping:
pre = "BlockDeviceMapping.%d" % idx
dev_name = mapping
block_dev_type = BlockDeviceType()
block_dev_type.ephemeral_name = self.get_argument("%s.VirtualName" % pre, None)
if not (block_dev_type.ephemeral_name):
block_dev_type.no_device = self.get_argument("%s.NoDevice" % pre, "") == "true"
block_dev_type.snapshot_id = self.get_argument("%s.Ebs.SnapshotId" % pre, None)
block_dev_type.size = self.get_argument("%s.Ebs.VolumeSize" % pre, None)
block_dev_type.delete_on_termination = (
self.get_argument("%s.Ebs.DeleteOnTermination" % pre, "") == "true"
)
bdm[dev_name] = block_dev_type
idx += 1
mapping = self.get_argument("BlockDeviceMapping.%d.DeviceName" % idx, None)
if len(bdm) == 0:
bdm = None
api_termination = False
if self.get_argument("DisableApiTermination", "") == "true":
api_termination = True
instance_shutdown = False
if self.get_argument("InstanceInitiatedShutdownBehavior", "") == "true":
instance_shutdown = True
token = self.get_argument("ClientToken", None)
addition_info = self.get_argument("AdditionInfo", None)
instance_profile_name = self.get_argument("IamInstanceProfile.Name", None)
instance_profile_arn = self.get_argument("IamInstanceProfile.Arn", None)
return clc.run_instances(
image_id,
min_count=min,
max_count=max,
key_name=key,
security_groups=groups,
user_data=user_data,
addressing_type=addr_type,
instance_type=vm_type,
placement=placement,
kernel_id=kernel,
ramdisk_id=ramdisk,
monitoring_enabled=monitoring,
subnet_id=subnet,
block_device_map=bdm,
disable_api_termination=api_termination,
instance_initiated_shutdown_behavior=instance_shutdown,
private_ip_address=private_ip,
placement_group=placement_group,
client_token=token,
security_group_ids=sec_group_ids,
additional_info=addition_info,
instance_profile_name=instance_profile_name,
instance_profile_arn=instance_profile_arn,
tenancy=tenancy,
callback=callback,
)
示例4: handleRunInstances
# 需要导入模块: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
# 或者: from boto.ec2.blockdevicemapping.BlockDeviceType import no_device [as 别名]
def handleRunInstances(self, action, clc, user_data_file, callback):
image_id = self.get_argument('ImageId')
min = self.get_argument('MinCount', '1')
max = self.get_argument('MaxCount', '1')
key = self.get_argument('KeyName', None)
groups = self.get_argument_list('SecurityGroup')
sec_group_ids = self.get_argument_list('SecurityGroupId')
if user_data_file:
user_data = user_data_file
else:
user_data = self.get_argument('UserData', "")
user_data = base64.b64decode(user_data)
addr_type = self.get_argument('AddressingType', None)
vm_type = self.get_argument('InstanceType', None)
placement = self.get_argument('Placement.AvailabilityZone', None)
placement_group = self.get_argument('Placement.GroupName', None)
tenancy = self.get_argument('Placement.Tenancy', None)
kernel = self.get_argument('KernelId', None)
ramdisk = self.get_argument('RamdiskId', None)
monitoring=False
if self.get_argument('Monitoring.Enabled', '') == 'true':
monitoring=True
subnet = self.get_argument('SubnetId', None);
private_ip = self.get_argument('PrivateIpAddress', None);
# get block device mappings
bdm = BlockDeviceMapping()
mapping = self.get_argument('BlockDeviceMapping.1.DeviceName', None)
idx = 1
while mapping:
pre = 'BlockDeviceMapping.%d' % idx
dev_name = mapping
block_dev_type = BlockDeviceType()
block_dev_type.ephemeral_name = self.get_argument('%s.VirtualName' % pre, None)
if not(block_dev_type.ephemeral_name):
block_dev_type.no_device = \
(self.get_argument('%s.NoDevice' % pre, '') == 'true')
block_dev_type.snapshot_id = \
self.get_argument('%s.Ebs.SnapshotId' % pre, None)
block_dev_type.size = \
self.get_argument('%s.Ebs.VolumeSize' % pre, None)
block_dev_type.delete_on_termination = \
(self.get_argument('%s.Ebs.DeleteOnTermination' % pre, '') == 'true')
bdm[dev_name] = block_dev_type
idx += 1
mapping = self.get_argument('BlockDeviceMapping.%d.DeviceName' % idx, None)
if len(bdm) == 0:
bdm = None
api_termination=False
if self.get_argument('DisableApiTermination', '') == 'true':
api_termination=True
instance_shutdown=False
if self.get_argument('InstanceInitiatedShutdownBehavior', '') == 'true':
instance_shutdown=True
token = self.get_argument('ClientToken', None);
addition_info = self.get_argument('AdditionInfo', None);
instance_profile_name = self.get_argument('IamInstanceProfile.Name', None);
instance_profile_arn = self.get_argument('IamInstanceProfile.Arn', None);
return clc.run_instances(image_id, min_count=min, max_count=max,
key_name=key, security_groups=groups,
user_data=user_data, addressing_type=addr_type,
instance_type=vm_type, placement=placement,
kernel_id=kernel, ramdisk_id=ramdisk,
monitoring_enabled=monitoring, subnet_id=subnet,
block_device_map=bdm,
disable_api_termination=api_termination,
instance_initiated_shutdown_behavior=instance_shutdown,
private_ip_address=private_ip,
placement_group=placement_group, client_token=token,
security_group_ids=sec_group_ids,
additional_info=addition_info,
instance_profile_name=instance_profile_name,
instance_profile_arn=instance_profile_arn,
tenancy=tenancy, callback=callback)