本文整理汇总了Python中euca2ools.commands.ec2.EC2Request.configure方法的典型用法代码示例。如果您正苦于以下问题:Python EC2Request.configure方法的具体用法?Python EC2Request.configure怎么用?Python EC2Request.configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类euca2ools.commands.ec2.EC2Request
的用法示例。
在下文中一共展示了EC2Request.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if not self.params.get('Storage.S3.AWSAccessKeyId'):
config_key_id = self.config.get_user_option('key-id')
if config_key_id:
self.log.info('Using access key ID %s from configuration',
config_key_id)
self.params['Storage.S3.AWSAccessKeyId'] = config_key_id
else:
raise ArgumentError('argument -o/--owner-akid is required')
if not self.params.get('Storage.S3.UploadPolicy'):
if not self.args.get('owner_sak'):
config_secret_key = self.config.get_user_option('secret-key')
if config_secret_key:
self.log.info('Using secret key from configuration')
self.args['owner_sak'] = config_secret_key
else:
raise ArgumentError('argument -w/--owner-sak is required '
'when -c/--policy is not used')
elif not self.args.get('Storage.S3.UploadPolicySignature'):
if not self.args.get('owner_sak'):
config_secret_key = self.config.get_user_option('secret-key')
if config_secret_key:
self.log.info('Using secret key from configuration')
self.args['owner_sak'] = config_secret_key
else:
raise ArgumentError('argument -w/--owner-sak is required '
'when -s/--policy-signature is not '
'used')
示例2: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
self.configure_s3_access()
if (self.params['DiskImage.1.Image.Format'].upper() in
('VMDK', 'VHD', 'RAW')):
self.params['DiskImage.1.Image.Format'] = \
self.params['DiskImage.1.Image.Format'].upper()
if not self.params.get('DiskImage.1.Image.Bytes'):
if self.params['DiskImage.1.Image.Format'] == 'RAW':
image_size = euca2ools.util.get_filesize(self.args['source'])
self.params['DiskImage.1.Image.Bytes'] = image_size
else:
raise ArgumentError(
'argument --image-size is required for {0} files'
.format(self.params['DiskImage.1.Image.Format']))
if not self.params.get('DiskImage.1.Volume.Size'):
vol_size = math.ceil(self.params['DiskImage.1.Image.Bytes'] /
2 ** 30)
self.params['DiskImage.1.Volume.Size'] = int(vol_size)
if not self.args.get('expires'):
self.args['expires'] = 30
if self.args['expires'] < 1:
raise ArgumentError(
'argument -x/--expires: value must be positive')
示例3: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('user_data'):
if os.path.isfile(self.args['user_data']):
raise ArgumentError(
'argument -d/--user-data: to pass the contents of a file '
'as user data, use -f/--user-data-file. To pass the '
"literal value '{0}' as user data even though it matches "
'the name of a file, use --user-data-force.')
else:
self.params['UserData'] = base64.b64encode(
self.args['user_data'])
elif self.args.get('user_data_force'):
self.params['UserData'] = base64.b64encode(
self.args['user_data_force'])
elif self.args.get('user_data_file'):
with open(self.args['user_data_file']) as user_data_file:
self.params['UserData'] = base64.b64encode(
user_data_file.read())
if self.args.get('KeyName') is None:
default_key_name = self.config.get_region_option(
'ec2-default-keypair')
if default_key_name:
self.log.info("using default key pair '%s'", default_key_name)
self.params['KeyName'] = default_key_name
示例4: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
gateway_id = self.args['gateway_id']
if gateway_id:
if gateway_id.startswith('nat-'):
self.params['NatGatewayId'] = gateway_id
else:
self.params['GatewayId'] = gateway_id
示例5: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
self.configure_s3_access()
if not self.args.get('expires'):
self.args['expires'] = 30
if self.args['expires'] < 1:
raise ArgumentError(
'argument -x/--expires: value must be positive')
示例6: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get("PublicIp") is not None and self.args.get("AllocationId") is not None:
# Can't be both EC2 and VPC
raise ArgumentError("argument -a/--allocation-id: not allowed with an IP address")
if self.args.get("PublicIp") is None and self.args.get("AllocationId") is None:
# ...but we still have to be one of them
raise ArgumentError("argument -a/--allocation-id or an IP address is required")
示例7: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if (self.args.get('Reset') and
any(self.args.get(attr) is not None for attr in
('Cpu', 'Disk', 'Memory'))):
# Basically, reset is mutually exclusive with everything else.
raise ArgumentError('argument --reset may not be used with '
'instance type attributes')
示例8: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('all'):
if self.args.get('Owner'):
raise ArgumentError('argument -a/--all: not allowed with '
'argument -o/--owner')
if self.args.get('RestorableBy'):
raise ArgumentError('argument -a/--all: not allowed with '
'argument -r/--restorable-by')
示例9: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get("positional_interface"):
if self.params.get("NetworkInterfaceId"):
# Shouldn't be supplied both positionally and optionally
raise ArgumentError("unrecognized arguments: {0}".format(self.args["positional_interface"]))
self.params["NetworkInterfaceId"] = self.args["positional_interface"]
if not self.params.get("NetworkInterfaceId"):
raise ArgumentError("argument -n/--network-interface is required")
示例10: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if (self.args.get('Attachment.DeleteOnTermination') is not None and
not self.args.get('Attachment.AttachmentId')):
raise ArgumentError('argument --delete-on-termination may only be '
'used with -a/--attachment')
if (self.args.get('Attachment.AttachmentId') and
self.args.get('Attachment.DeleteOnTermination') is None):
raise ArgumentError('argument -a/--attachment also requires '
'--delete-on-termination')
示例11: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('positional_vpc'):
if self.params.get('VpcId'):
# Shouldn't be supplied both positionally and optionally
raise ArgumentError('unrecognized arguments: {0}'.format(
self.args['positional_vpc']))
self.params['VpcId'] = self.args['positional_vpc']
if not self.params.get('VpcId'):
raise ArgumentError('argument -c/--vpc is required')
示例12: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if not self.args.get('Storage.S3.UploadPolicy'):
if not self.args.get('owner_sak'):
raise ArgumentError('argument -w/--owner-sak is required when '
'-c/--policy is not used')
elif not self.args.get('Storage.S3.UploadPolicySignature'):
if not self.args.get('owner_sak'):
raise ArgumentError('argument -w/--owner-sak is required when '
'-s/--policy-signature is not used')
示例13: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('positional_interface'):
if self.params.get('NetworkInterfaceId'):
# Shouldn't be supplied both positionally and optionally
raise ArgumentError('unrecognized arguments: {0}'.format(
self.args['positional_interface']))
self.params['NetworkInterfaceId'] = \
self.args['positional_interface']
if not self.params.get('NetworkInterfaceId'):
raise ArgumentError('argument -n/--network-interface is required')
示例14: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('PublicIp'):
if self.args.get('AssociationId'):
raise ArgumentError('argument -a/--association-id: not '
'allowed with an IP address')
elif self.args['PublicIp'].startswith('eipassoc'):
raise ArgumentError('VPC elastic IP association IDs must be '
'be specified with -a/--association-id')
elif not self.args.get('AssociationId'):
raise ArgumentError(
'argument -a/--association-id or an IP address is required')
示例15: configure
# 需要导入模块: from euca2ools.commands.ec2 import EC2Request [as 别名]
# 或者: from euca2ools.commands.ec2.EC2Request import configure [as 别名]
def configure(self):
EC2Request.configure(self)
if self.args.get('all', False):
if self.args.get('ImageId'):
raise ArgumentError('argument -a/--all: not allowed with '
'a list of images')
if self.args.get('ExecutableBy'):
raise ArgumentError('argument -a/--all: not allowed with '
'argument -x/--executable-by')
if self.args.get('Owner'):
raise ArgumentError('argument -a/--all: not allowed with '
'argument -o/--owner')