當前位置: 首頁>>代碼示例>>Python>>正文


Python iobject.IObject類代碼示例

本文整理匯總了Python中boto.mashups.iobject.IObject的典型用法代碼示例。如果您正苦於以下問題:Python IObject類的具體用法?Python IObject怎麽用?Python IObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IObject類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_ssh_key_file

 def get_ssh_key_file(self):
     if not self.ssh_key_file:
         ssh_dir = os.path.expanduser('~/.ssh')
         if os.path.isdir(ssh_dir):
             ssh_file = os.path.join(ssh_dir, '%s.pem' % self.key_name)
             if os.path.isfile(ssh_file):
                 self.ssh_key_file = ssh_file
         if not self.ssh_key_file:
             iobject = IObject()
             self.ssh_key_file = iobject.get_filename('Path to OpenSSH Key file')
     return self.ssh_key_file
開發者ID:AlexanderNapierski,項目名稱:boto,代碼行數:11,代碼來源:server.py

示例2: get_ssh_client

    def get_ssh_client(self, key_file=None, host_key_file="~/.ssh/known_hosts", uname="root"):
        import paramiko

        if not self.instance:
            print "No instance yet!"
            return
        if not self._ssh_client:
            if not key_file:
                iobject = IObject()
                key_file = iobject.get_filename("Path to OpenSSH Key file")
            self._pkey = paramiko.RSAKey.from_private_key_file(key_file)
            self._ssh_client = paramiko.SSHClient()
            self._ssh_client.load_system_host_keys()
            self._ssh_client.load_host_keys(os.path.expanduser(host_key_file))
            self._ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            self._ssh_client.connect(self.instance.public_dns_name, username=uname, pkey=self._pkey)
        return self._ssh_client
開發者ID:kolencherry,項目名稱:dd-agent,代碼行數:17,代碼來源:server.py

示例3: bundle

 def bundle(self, bucket=None, prefix=None, key_file=None, cert_file=None, size=None, ssh_key=None):
     iobject = IObject()
     if not bucket:
         bucket = iobject.get_string('Name of S3 bucket')
     if not prefix:
         prefix = iobject.get_string('Prefix for AMI file')
     if not key_file:
         key_file = iobject.get_filename('Path to RSA private key file')
     if not cert_file:
         cert_file = iobject.get_filename('Path to RSA public cert file')
     if not size:
         size = iobject.get_int('Size (in MB) of bundled image')
     if not ssh_key:
         ssh_key = iobject.get_filename('Path to SSH Private Key')
     self.bundle_image(prefix, key_file, cert_file, size, ssh_key)
     self.upload_bundle(bucket, prefix, ssh_key)
     print 'registering image...'
     self.image_id = self.server.ec2.register_image('%s/%s.manifest.xml' % (bucket, prefix))
     return self.image_id
開發者ID:Noirad,項目名稱:Amazon-VOD.bundle,代碼行數:19,代碼來源:server.py

示例4: create_image

 def create_image(self, bucket=None, prefix=None, key_file=None, cert_file=None, size=None):
     iobject = IObject()
     if not bucket:
         bucket = iobject.get_string("Name of S3 bucket")
     if not prefix:
         prefix = iobject.get_string("Prefix for AMI file")
     if not key_file:
         key_file = iobject.get_filename("Path to RSA private key file")
     if not cert_file:
         cert_file = iobject.get_filename("Path to RSA public cert file")
     if not size:
         size = iobject.get_int("Size (in MB) of bundled image")
     self.bundle_image(prefix, key_file, cert_file, size)
     self.upload_bundle(bucket, prefix)
     print "registering image..."
     self.image_id = self.ec2.register_image("%s/%s.manifest.xml" % (bucket, prefix))
     return self.image_id
開發者ID:kolencherry,項目名稱:dd-agent,代碼行數:17,代碼來源:server.py

示例5: bundle

 def bundle(self, bucket=None, prefix=None, key_file=None, cert_file=None,
            size=None, ssh_key=None, fp=None, clear_history=True):
     iobject = IObject()
     if not bucket:
         bucket = iobject.get_string('Name of S3 bucket')
     if not prefix:
         prefix = iobject.get_string('Prefix for AMI file')
     if not key_file:
         key_file = iobject.get_filename('Path to RSA private key file')
     if not cert_file:
         cert_file = iobject.get_filename('Path to RSA public cert file')
     if not size:
         size = iobject.get_int('Size (in MB) of bundled image')
     if not ssh_key:
         ssh_key = self.server.get_ssh_key_file()
     self.copy_x509(key_file, cert_file)
     if not fp:
         fp = StringIO.StringIO()
     fp.write('sudo mv %s /mnt/boto.cfg; ' % BotoConfigPath)
     fp.write('mv ~/.ssh/authorized_keys /mnt/authorized_keys; ')
     if clear_history:
         fp.write('history -c; ')
     fp.write(self.bundle_image(prefix, size, ssh_key))
     fp.write('; ')
     fp.write(self.upload_bundle(bucket, prefix, ssh_key))
     fp.write('; ')
     fp.write('sudo mv /mnt/boto.cfg %s; ' % BotoConfigPath)
     fp.write('mv /mnt/authorized_keys ~/.ssh/authorized_keys')
     command = fp.getvalue()
     print 'running the following command on the remote server:'
     print command
     t = self.ssh_client.run(command)
     print '\t%s' % t[0]
     print '\t%s' % t[1]
     print '...complete!'
     print 'registering image...'
     self.image_id = self.server.ec2.register_image(name=prefix, image_location='%s/%s.manifest.xml' % (bucket, prefix))
     return self.image_id
開發者ID:AlexanderNapierski,項目名稱:boto,代碼行數:38,代碼來源:server.py

示例6: Config

    cfg = Config()
    cfg.add_config(file_url)

    for r in regions():
        if r.name == options.region:
            region = r
            break
    else:
        print("Region %s not found." % options.region)
        sys.exit(1)
    ec2 = boto.connect_ec2(region=region)
    if not options.nocred and not options.role:
        cfg.add_creds(ec2)

    iobj = IObject()
    if options.ami_id:
        ami = ec2.get_image(options.ami_id)
    else:
        ami_id = options.ami_id
        l = [(a, a.id, a.location) for a in ec2.get_all_images()]
        ami = iobj.choose_from_list(l, prompt='Choose AMI')

    if options.key_name:
        key_name = options.key_name
    else:
        l = [(k, k.name, '') for k in ec2.get_all_key_pairs()]
        key_name = iobj.choose_from_list(l, prompt='Choose Keypair').name

    if options.groups:
        groups = options.groups
開發者ID:Mayfifth,項目名稱:Scripts,代碼行數:30,代碼來源:launch_instance-script.py


注:本文中的boto.mashups.iobject.IObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。