def download_server_certificate(cert_arn):
    f = FloppyCredential()
    host = config.get_clc_host()
    access_key_id = config.get_access_key_id()
    secret_access_key = config.get_secret_access_key()
    security_token = config.get_security_token()
    con = worker.ws.connect_euare(host_name=host, aws_access_key_id=access_key_id,
                                  aws_secret_access_key=secret_access_key, security_token=security_token)
    cert = con.download_server_certificate(f.get_instance_pub_key(), f.get_instance_pk(), f.get_iam_pub_key(),
                                           f.get_iam_token(), cert_arn)
    return cert 
Пример #2
0
def describe_volume(volume_id=None):
    if not volume_id:
        print 'volume id must be specified'
    try:
        access_key_id = config.get_access_key_id()
        secret_access_key = config.get_secret_access_key()
        security_token = config.get_security_token()
        con = worker.ws.connect_ec2(host_name='169.254.169.254', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
        volumes = con.describe_volumes([volume_id, 'verbose'])
        print 'describe-volumes: %s' % volumes
    except Exception, err:
        print 'failed to describe volumes: %s' % err
        return 
Пример #3
0
def detach_volume(volume_id=None):
    if not volume_id:
        print 'volume id must be specified'

    try:
        access_key_id = config.get_access_key_id()
        secret_access_key = config.get_secret_access_key()
        security_token = config.get_security_token()
        con = worker.ws.connect_ec2(host_name='169.254.169.254', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
        con.detach_volume(volume_id)
        print 'volume %s detached' % volume_id
    except Exception, err:
        print 'failed to detach volume: %s' % err
        return 
Пример #4
0
def attach_volume(instance_id=None, volume_id=None, device_name='/dev/vdc'):
    if not volume_id or not instance_id:
        print 'volume and instance id must be specified'

    try:
        access_key_id = config.get_access_key_id()
        secret_access_key = config.get_secret_access_key()
        security_token = config.get_security_token()
        con = worker.ws.connect_ec2(host_name='169.254.169.254', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
        con.attach_volume(volume_id, instance_id, device_name)
        print 'volume %s attached to instance %s at %s' % (volume_id, instance_id, device_name)
    except Exception, err:
        print 'failed to attach volume: %s' % err
        return 
Пример #5
0
def download_server_certificate(cert_arn, cert_file, pubkey_included=False):
    if os.path.exists(cert_file):
        return
    f = FloppyCredential() 
    host = config.get_clc_host()
    access_key_id = config.get_access_key_id()
    secret_access_key = config.get_secret_access_key()
    security_token = config.get_security_token()
    con = worker.ws.connect_euare(host_name=host, aws_access_key_id = access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
    cert= con.download_server_certificate(f.get_instance_pub_key(), f.get_instance_pk(), f.get_iam_pub_key(), f.get_iam_token(), cert_arn)
    if pubkey_included:
        cert_pem = '%s\n%s' % (cert.get_certificate(), cert_get_private_key())
    else:
        cert_pem = cert.get_private_key()
    write_certificate(cert_file, cert_pem) 
Пример #6
0
def download_server_cert(cert_arn=None):
    if not cert_arn:
        cert_arn = "arn:aws:iam::965529822009:server-certificate/ImagingCert-imgworker"
    try:
        f = FloppyCredential() 
        host = config.get_clc_host()
        access_key_id = config.get_access_key_id()
        secret_access_key = config.get_secret_access_key()
        security_token = config.get_security_token()
        con = worker.ws.connect_euare(host_name=host, aws_access_key_id = access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
        cert= con.download_server_certificate(f.get_instance_pub_key(), f.get_instance_pk(), f.get_iam_pub_key(), f.get_iam_token(), cert_arn)
        print '%s\n%s' % (cert.get_certificate(), cert.get_private_key())

        return cert;
    except Exception, err:
        print 'failed to download the server certificate: %s' % err
        return