Пример #1
0
class DescribeKeyPairs(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2010-08-31'
    Description = 'Shows information about keypairs.'
    Args = [
        Param(name='keypair', ptype='string', cardinality='+', optional=True)
    ]
    Filters = [
        Param(name='fingerprint',
              ptype='string',
              doc='Fingerprint of the key pair.'),
        Param(name='key-name', ptype='string', doc='Name of the keypair.')
    ]

    def display_keypairs(self, keypairs):
        for keypair in keypairs:
            keypair_string = '%s\t%s' % (keypair.name, keypair.fingerprint)
            print('KEYPAIR\t%s' % keypair_string)

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'get_all_key_pairs',
                                     keynames=self.keypair)

    def main_cli(self):
        keypairs = self.main()
        self.display_keypairs(keypairs)
Пример #2
0
class CreateAccountAlias(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Name = 'CreateAccountAlias'
    Description = 'Create an alias for your account'
    Params = [
        Param(name='AccountAlias',
              short_name='a',
              long_name='account-alias',
              ptype='string',
              optional=False,
              doc="""The new alias for the account."""),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Use the parameter only as the system admin to act as the account admin of the specified account without changing to account admin's role. """
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #3
0
class ConfirmProductInstance(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Confirm if instance is running with product code attached.'
    Options = [
        Param(name='instance_id',
              short_name='i',
              long_name='instance',
              optional=False,
              ptype='string',
              doc='Unique identifier for a running instance')
    ]
    Args = [
        Param(name='product_code',
              ptype='string',
              doc='The product code to verify',
              cardinality=1,
              optional=False)
    ]

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'confirm_product_instance',
                                     product_code=self.product_code,
                                     instance_id=self.instance_id)

    def main_cli(self):
        rs = self.main()
        product_string = '%s\t%s\t' % (self.product_code, self.instance_id)
        if rs and rs[0] is True:
            product_string += 'true'
        else:
            product_string += 'false'
        print product_string
Пример #4
0
class DownloadBundle(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Downloads a bundled image from a bucket.'
    Options = [Param(name='bucket', short_name='b', long_name='bucket',
                     optional=False, ptype='string',
                     doc='Name of the bucket to upload to.'),
               Param(name='manifest_path',
                     short_name='m', long_name='manifest',
                     optional=True, ptype='string',
                     doc='Path to the manifest file for bundled image.'),
               Param(name='prefix', short_name='p', long_name='prefix',
                     optional=True, ptype='string',
                     doc='Prefix used to identify the image in the bucket'),
               Param(name='directory',
                     short_name='d', long_name='directory',
                     optional=True, ptype='dir', default='/tmp',
                     doc='The directory to download the parts to.')]

    def ensure_bucket(self, bucket):
        bucket_instance = None
        s3conn = self.make_connection_cli('s3')
        try:
            bucket_instance = s3conn.get_bucket(bucket)
        except S3ResponseError, s3error:
            print 'Unable to get bucket %s' % bucket
            sys.exit()
        return bucket_instance
class DescribeAvailabilityZones(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2010-08-31'
    Description = 'Shows information about availability zones.'
    Args = [Param(name='zone', ptype='string',
                  cardinality='+', optional=True)]
    Filters = [Param(name='message', ptype='string',
                     doc='Message giving information about the Availability Zone.'),
               Param(name='region-name', ptype='string',
                     doc='Region the Availability Zone is in (e.g., us-east-1).'),
               Param(name='state', ptype='string',
                     doc='State of the Availability Zone'),
               Param(name='zone-name', ptype='string',
                     doc='Name of the zone.')]
    
    def display_zones(self, zones):
        for zone in zones:
            zone_string = '%s\t%s' % (zone.name, zone.state)
            print 'AVAILABILITYZONE\t%s' % zone_string

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn, 'get_all_zones',
                                      zones=self.zone)

    def main_cli(self):
        zones = self.main()
        self.display_zones(zones)
Пример #6
0
class CreateAccountAlias(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Name = 'CreateAccountAlias'
    Description = 'Create an alias for your account'
    Params = [
        Param(name='AccountAlias',
              short_name='a',
              long_name='account-alias',
              ptype='string',
              optional=False,
              doc="""The new alias for the account."""),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #7
0
class DescribeAddresses(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2011-01-01'
    Description = 'Shows information about addresses.'
    Args = [Param(name='ip', ptype='string',
                  cardinality='+', optional=True)]
    Filters = [Param(name='instance-id', ptype='string',
                     doc='Instance the address is associated with (if any).'),
               Param(name='public-ip', ptype='string',
                     doc='The elastic IP address.')]

    def display_addresses(self, addresses):
        for address in addresses:
            domain = getattr(address, 'domain', 'standard') or 'standard'
            address_string = '%s\t%s\t%s' % (address.public_ip,
                                             address.instance_id or '',
                                             domain)
            print 'ADDRESS\t%s' % address_string

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn, 'get_all_addresses',
                                     addresses=self.ip)

    def main_cli(self):
        addresses = self.main()
        self.display_addresses(addresses)
Пример #8
0
class DeleteAccount(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Name = 'DeleteAccount'
    Description = 'Delete an account'
    Params = [
        Param(name='AccountName',
              short_name='a',
              long_name='account-name',
              ptype='string',
              optional=False,
              doc="""The name of the account to delete."""),
        Param(name='Recursive',
              short_name='r',
              long_name='recursive',
              ptype='boolean',
              optional=True,
              doc="""True if to delete the account recursively."""),
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #9
0
class StopInstances(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Stops the specified EBS-based instances.'
    Options = [
        Param(name='force',
              short_name='f',
              long_name='force',
              optional=True,
              ptype='boolean',
              default=False,
              doc='Forces the instance to stop.')
    ]
    Args = [
        Param(name='instance_id',
              ptype='string',
              optional=False,
              cardinality='+',
              doc='unique identifier for instance to stop')
    ]

    def display_instances(self, instances):
        for instance in instances:
            print 'INSTANCE\t%s' % instance.id

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'stop_instances',
                                     instance_ids=self.instance_id,
                                     force=self.force)

    def main_cli(self):
        instances = self.main()
        self.display_instances(instances)
Пример #10
0
class DescribeTags(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2010-08-31'
    Description = 'List tags associated with your account.'
    Filters = [
        Param(name='key', ptype='string', doc='Tag key.'),
        Param(name='resource-id', ptype='string', doc='Resource ID.'),
        Param(name='resource-type',
              ptype='string',
              doc="""Resource type.
                     Valid Values: customer-gateway | dhcp-options | image |
                     instance | reserved-instances | snapshot |
                     spot-instances-request | subnet | volume |
                     vpc | vpn-connection | vpn-gateway"""),
        Param(name='value', ptype='string', doc='Tag value.')
    ]

    def display_tags(self, tags):
        for tag in tags:
            tag_string = '%s\t%s\t%s\t%s' % (tag.res_id, tag.res_type,
                                             tag.name, tag.value)
            print 'TAG\t%s' % tag_string

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn, 'get_all_tags')

    def main_cli(self):
        tags = self.main()
        self.display_tags(tags)
Пример #11
0
class CreateAccessKey(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """CreateAccessKey"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=True,
            doc=""" The User name that the new key will belong to. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """,
        )
    ]

    def cli_formatter(self, data):
        print data.AccessKey['AccessKeyId']
        print data.AccessKey['SecretAccessKey']

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #12
0
class CreateSigningCertificate(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """CreateSigningCertificate"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=True,
            doc=""" Name of the User the signing certificate is for. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Use the parameter only as the system admin to act as the account admin of the specified account without changing to account admin's role. """,
        )
    ]

    def cli_formatter(self, data):
        print data.Certificate['CertificateId']
        print data.Certificate['CertificateBody']
        print data.Certificate['PrivateKey']

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #13
0
class DeactivateMFADevice(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """DeactivateMFADevice"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=False,
            doc=
            """ Name of the User whose MFA device you want to deactivate. """,
        ),
        Param(
            name='SerialNumber',
            short_name='s',
            long_name='serial-number',
            ptype='string',
            optional=False,
            doc=
            """ The serial number that uniquely identifies the MFA device. """,
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #14
0
class UploadServerCertificate(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """UploadServerCertificate"""
    Params = [
        Param(
            name='Path',
            short_name='p',
            long_name='path',
            ptype='string',
            optional=True,
            doc=
            """ The path for the server certificate. For more information about paths, see Identifiers for IAM Entities in Using AWS Identity and Access Management.  This parameter is optional. If it is not included, it defaults to a slash (/). """,
        ),
        Param(
            name='ServerCertificateName',
            short_name='s',
            long_name='server-certificate-name',
            ptype='string',
            optional=False,
            doc=
            """ The name for the server certificate. Do not include the path in this value. """,
        ),
        Param(
            name='CertificateBody',
            short_name='c',
            long_name='certificate-body',
            ptype='string',
            optional=False,
            doc=
            """ The contents of the public key certificate in PEM-encoded format. """,
        ),
        Param(
            name='PrivateKey',
            short_name=None,
            long_name='private-key',
            ptype='string',
            optional=False,
            doc=""" The contents of the private key in PEM-encoded format. """,
        ),
        Param(
            name='CertificateChain',
            short_name=None,
            long_name='certificate-chain',
            ptype='string',
            optional=True,
            doc=
            """ The contents of the certificate chain. This is typically a concatenation of the PEM-encoded public key certificates of the chain. """,
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #15
0
class GetPassword(euca2ools.commands.eucacommand.EucaCommand):

    Description = """Retrieves decrypts the administrator password
    for a Windows instance."""
    Options = [
        Param(name='privatekey',
              short_name='k',
              long_name='priv-launch-key',
              ptype='file',
              optional=False,
              doc="""The file that contains the private key
                     used to launch the instance.""")
    ]
    Args = [
        Param(name='instance_id',
              ptype='string',
              optional=False,
              doc='unique identifier for the Windows instance')
    ]

    def main(self):
        conn = self.make_connection_cli()
        pd = self.make_request_cli(conn,
                                   'get_password_data',
                                   instance_id=self.instance_id)
        if pd:
            # TODO - this is actually in the bundler
            # TODO validate file?
            return euca2ools.bundler.Bundler(self).decrypt_string(
                pd, self.privatekey, encoded=True)

    def main_cli(self):
        pw = self.main()
        print pw
Пример #16
0
class DescribeRegions(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2010-08-31'
    Description = 'Shows information about regions.'
    Args = [
        Param(name='described_region_name',
              ptype='string',
              doc='name of the region to describe',
              cardinality='+',
              optional=True)
    ]
    Filters = [
        Param(name='endpoint', ptype='string', doc='Endpoint of the region.'),
        Param(name='region-name', ptype='string', doc='Name of the region.')
    ]

    def display_regions(self, regions):
        for region in regions:
            region_string = '%s\t%s' % (region.name, region.endpoint)
            print 'REGION\t%s' % region_string

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'get_all_regions',
                                     region_names=self.described_region_name)

    def main_cli(self):
        regions = self.main()
        self.display_regions(regions)
Пример #17
0
class DeleteAccountPolicy(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """DeleteAccountPolicy"""
    Params = [
        Param(
            name='AccountName',
            short_name='a',
            long_name='account-name',
            ptype='string',
            optional=False,
            doc=""" Name of the account the policy is associated with. """,
        ),
        Param(
            name='PolicyName',
            short_name='p',
            long_name='policy-name',
            ptype='string',
            optional=False,
            doc=""" Name of the policy document to delete. """,
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
class CreateSigningCertificate(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """CreateSigningCertificate"""
    Params = [Param(
        name='UserName',
        short_name='u',
        long_name='user-name',
        ptype='string',
        optional=True,
        doc=""" Name of the User the signing certificate is for. """,
        ), Param(
        name='DelegateAccount',
        short_name=None,
        long_name='delegate',
        ptype='string',
        optional=True,
        doc=""" [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """,
        )]

    def cli_formatter(self, data):
        print(data.Certificate['CertificateId'])
        print(data.Certificate['CertificateBody'])
        print(data.Certificate['PrivateKey'])

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #19
0
class CreateAccessKey(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """CreateAccessKey"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=True,
            doc=""" The User name that the new key will belong to. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Use the parameter only as the system admin to act as the account admin of the specified account without changing to account admin's role. """,
        )
    ]

    def cli_formatter(self, data):
        print data.AccessKey['AccessKeyId']
        print data.AccessKey['SecretAccessKey']

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #20
0
class GetLoginProfile(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """GetLoginProfile"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=False,
            doc=
            """ Name of the User whose login profile you want to retrieve. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """,
        )
    ]

    def cli_formatter(self, data):
        print(data.LoginProfile['UserName'])

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #21
0
class GetUser(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """GetUser"""
    Params = [Param(
        name='UserName',
        short_name='u',
        long_name='user-name',
        ptype='string',
        optional=True,
        doc=""" Name of the User to get information about.  This parameter is optional. If it is not included, it defaults to the User making the request. """ ,
        ), Param(
        name='DelegateAccount',
        short_name=None,
        long_name='delegate',
        ptype='string',
        optional=True,
        doc=""" [Eucalyptus extension] Use the parameter only as the system admin to act as the account admin of the specified account without changing to account admin's role. """,
        )]

    def cli_formatter(self, data):
        print data.User['Arn']
        print data.User['UserId']

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #22
0
class GetAccountPolicy(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """GetAccountPolicy"""
    Params = [Param(
        name='AccountName',
        short_name='a',
        long_name='account-name',
        ptype='string',
        optional=False,
        doc=""" Name of the account the policy is associated with. """,
        ), Param(
        name='PolicyName',
        short_name='p',
        long_name='policy-name',
        ptype='string',
        optional=False,
        doc=""" Name of the policy document to get. """,
        )]

    def cli_formatter(self, data):
        print(data.PolicyDocument)

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #23
0
class DetachVolume(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Detaches a volume from an instance.'
    Options = [Param(name='instance_id', short_name='i', long_name='instance',
                     optional=True, ptype='string',
                     doc="""unique id of a running instance to detach
                     the volume from."""),
               Param(name='device', short_name='d', long_name='device',
                     optional=True, ptype='string',
                     doc='local device name (inside the guest VM) to use.'),
               Param(name='force', short_name='f', long_name='force',
                     optional=True, ptype='boolean', default=False,
                     doc="""Forces detachment if the previous detachment
                     attempt did not occur cleanly""")]
    Args = [Param(name='volume_id', ptype='string',
                  doc='unique id for the volume to be detached',
                  cardinality=1, optional=False)]

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn, 'detach_volume',
                                     volume_id=self.volume_id,
                                     instance_id=self.instance_id,
                                     device=self.device,
                                     force=self.force)

    def main_cli(self):
        status = self.main()
        if status:
            print('VOLUME\t%s' % self.volume_id)
        else:
            self.error_exit()
Пример #24
0
class ImportKeyPair(euca2ools.commands.eucacommand.EucaCommand):

    APIVersion = '2010-08-31'
    Description = 'Import a public key created with 3rd party tool'
    Options = [
        Param(name='file_name',
              short_name='f',
              long_name='public-key-file',
              optional=False,
              ptype='file',
              doc='Path to file containing the public key.')
    ]
    Args = [
        Param(name='key_name',
              ptype='string',
              doc='A unique name for the key pair.',
              optional=False)
    ]

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'import_key_pair',
                                     key_name=self.key_name,
                                     public_key_material=self.file_name)

    def main_cli(self):
        keypair = self.main()
        if keypair:
            print 'KEYPAIR\t%s\t%s' % (keypair.name, keypair.fingerprint)
Пример #25
0
class CreateSecurityGroup(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Creates a new security group.'
    Options = [
        Param(name='group_description',
              short_name='d',
              long_name='description',
              optional=False,
              ptype='string',
              doc='Description for the group to be created')
    ]
    Args = [
        Param(name='group_name',
              ptype='string',
              doc='unique name for the group to be created',
              cardinality=1,
              optional=False)
    ]

    def display_group(self, group):
        print('GROUP\t%s\t%s' % (group.name, group.description))

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'create_security_group',
                                     name=self.group_name,
                                     description=self.group_description)

    def main_cli(self):
        group = self.main()
        self.display_group(group)
Пример #26
0
class DeleteLoginProfile(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """DeleteLoginProfile"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=False,
            doc=
            """ Name of the User whose login profile you want to delete. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Use the parameter only as the system admin to act as the account admin of the specified account without changing to account admin's role. """,
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        self.do_cli()
Пример #27
0
class AssociateAddress(euca2ools.commands.eucacommand.EucaCommand):

    Description = 'Associate an instance with a public IP address.'
    Options = [
        Param(name='instance_id',
              short_name='i',
              long_name='instance',
              optional=False,
              ptype='string',
              doc="""unique identifier for a running instance
                     to associate the address with.""")
    ]
    Args = [
        Param(name='ip',
              ptype='string',
              doc='IP address to associate',
              cardinality=1,
              optional=False)
    ]

    def main(self):
        conn = self.make_connection_cli()
        return self.make_request_cli(conn,
                                     'associate_address',
                                     instance_id=self.instance_id,
                                     public_ip=self.ip)

    def main_cli(self):
        status = self.main()
        if status:
            print 'ADDRESS\t%s\t%s' % (self.ip, self.instance_id)
        else:
            self.error_exit()
Пример #28
0
class GetPassword(euca2ools.commands.eucacommand.EucaCommand):

    Description = """Retrieves decrypts the administrator password
    for a Windows instance."""
    Options = [Param(name='privatekey',
                     short_name='k', long_name='priv-launch-key',
                     ptype='file', optional=False,
                     doc="""The file that contains the private key
                     used to launch the instance.""")]
    Args = [Param(name='instance_id', ptype='string', optional=False,
                     doc='unique identifier for the Windows instance')]

    def main(self):
        conn = self.make_connection_cli()
        try:
            pd = self.make_request_cli(conn, 'get_password_data',
                                       instance_id=self.instance_id)
        except AttributeError:
            # The reply didn't contain a passwordData element.  Boto doesn't
            # handle this since EC2 always includes one, even if it is empty.
            return None
        if pd:
            # TODO - this is actually in the bundler
            # TODO validate file?
            return euca2ools.bundler.Bundler(self).decrypt_string(
                    pd, self.privatekey, encoded=True)
        else:
            return None

    def main_cli(self):
        pw = self.main()
        if pw:
            print(pw)
        else:
            sys.exit('no password found for this instance')
Пример #29
0
class ListSigningCertificates(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """ListSigningCertificates"""
    Params = [Param(
        name='UserName',
        short_name='u',
        long_name='user-name',
        ptype='string',
        optional=True,
        doc=""" The name of the User. """,
        ), Param(
        name='_verbose',
        short_name='v',
        long_name='verbose',
        ptype='boolean',
        optional=True,
        request_param=False,
        doc='Causes output to include the certificate body',
        ), Param(
        name='Marker',
        short_name='m',
        long_name='marker',
        ptype='string',
        optional=True,
        doc=""" Use this only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the Marker element in the response you just received. """ ,
        ), Param(
        name='MaxItems',
        short_name=None,
        long_name='max-items',
        ptype='integer',
        optional=True,
        doc=""" Use this only when paginating results to indicate the maximum number of certificate IDs you want in the response. If there are additional certificate IDs beyond the maximum you specify, the IsTruncated response element is true. """ ,
        ), Param(
        name='DelegateAccount',
        short_name=None,
        long_name='delegate',
        ptype='string',
        optional=True,
        doc=""" [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """,
        )]

    def cli_formatter(self, data):
        for cert in data.Certificates:
            print(cert['CertificateId'])
            if self.cli_options.verbose:
                print(cert['CertificateBody'])
            print(cert['Status'])
            
    def main(self, **args):
        self.list_markers.append('Certificates')
        self.item_markers.append('member')
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()
Пример #30
0
class PutUserPolicy(AWSQueryRequest):

    ServiceClass = euca2ools.commands.euare.Euare

    Description = """PutUserPolicy"""
    Params = [
        Param(
            name='UserName',
            short_name='u',
            long_name='user-name',
            ptype='string',
            optional=False,
            doc=""" Name of the User to associate the policy with. """,
        ),
        Param(
            name='PolicyName',
            short_name='p',
            long_name='policy-name',
            ptype='string',
            optional=False,
            doc=""" Name of the policy document. """,
        ),
        Param(
            name='PolicyDocument',
            short_name='o',
            long_name='policy-content',
            ptype='string',
            optional=True,
            doc=""" The content of policy document. """,
        ),
        Param(
            name='PolicyDocument',
            short_name='f',
            long_name='policy-document',
            ptype='file',
            optional=True,
            doc=""" The policy document as a file. """,
        ),
        Param(
            name='DelegateAccount',
            short_name=None,
            long_name='delegate',
            ptype='string',
            optional=True,
            doc=
            """ [Eucalyptus extension] Process this command as if the administrator of the specified account had run it. This option is only usable by cloud administrators. """,
        )
    ]

    def cli_formatter(self, data):
        pass

    def main(self, **args):
        return self.send(**args)

    def main_cli(self):
        euca2ools.utils.print_version_if_necessary()
        self.do_cli()