• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyrax.connect_to_cloudservers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyrax.connect_to_cloudservers函数的典型用法代码示例。如果您正苦于以下问题:Python connect_to_cloudservers函数的具体用法?Python connect_to_cloudservers怎么用?Python connect_to_cloudservers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了connect_to_cloudservers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: set_current_server_networks

	def set_current_server_networks(self):
		cs_dfw = pyrax.connect_to_cloudservers(region="ORD")
		cs_ord = pyrax.connect_to_cloudservers(region="DFW")
		dfw_servers = cs_dfw.servers.list()
		ord_servers = cs_ord.servers.list()
		self.servers = dfw_servers + ord_servers
		for server in self.servers:
			if server.name == self.server_name:
				self.network = server.networks	
开发者ID:lindseyanderson,项目名称:fpb_cloud_servers,代码行数:9,代码来源:cloudservers.py


示例2: get_servers

def get_servers(location = 'all'):
  region_list = {}
  if location == 'all':
    for temp_reg in pyrax.regions:
      for server in pyrax.connect_to_cloudservers(region=temp_reg).servers.list():
        region_list[server.name] = [ server.name, server.id, server.status, temp_reg ]
  else:
    for server in pyrax.connect_to_cloudservers(region=location).servers.list():
      region_list[server.name] = [ server.name, server.id, server.status, location ]
  return region_list
开发者ID:salalbr,项目名称:rackspace_cloud_lib,代码行数:10,代码来源:cloud_lib.py


示例3: build_server

def build_server(build_queue):
    # create list of server information to keep each build contained to it's own thread
    build_details = []
    try:
        print "Getting job from queue..."
        server_name = build_queue.get()
        if ssh_auth == "y":
            print "Connecting to cloud to build server %s" % server_name
            server = pyrax.connect_to_cloudservers(region=region).servers.create(server_name, server_id, server_flv_id, ssh_auth)
            print "%s has started building" % server_name
            #pass
        else:
            server = pyrax.connect_to_cloudservers(region=region).servers.create(server_name, server_id, server_flv_id)
            #pass

        build_details.append(breakpoint)
        build_details.append("Name: " + server.name)
        build_details.append("ID: " + server.id)
        build_details.append("Region: " + region)
        build_details.append("Admin Password: " + server.adminPass)


        if wait_for_build == True:

            try:
                #Pass tuple of server status, not list
                #pyrax.utils.wait_until(server, "status", ["ACTIVE", "ERROR"], interval=5, callback=None, attempts=0, verbose=False, verbose_atts="progress")
                pyrax.utils.wait_until(server, 'status', ('ACTIVE', 'ERROR'), interval=5, attempts=wait_timeout/5)
                build_details.append("Network information:")
                for i in server.networks.get(u'public'):
                    build_details.append("Public IP: " + i)
                #build_details.append("Public IP: " + server.networks.get(u'public')[0])
                build_details.append("Private IP: " + server.networks.get(u'private')[0])
                
            except:
                print "Pyrax wait for build unsuccessful. Please reference your cloud panel for server IP's"

        print breakpoint
        server_info.write(breakpoint)
        for info in build_details:
            print info
            server_info.write(info + "\n")
        print breakpoint
        server_info.write(breakpoint)

        #server_info.write(build_details)
        #print build_details

        build_queue.task_done()
        print "%s has finished, ending thread" % server_name
        

    except nexc.BadRequest as e:
        print "Bad image/flavor combination. Please try again. (wah wah wah)\n"
        exit()
开发者ID:jay13jay,项目名称:Cloud-Servers,代码行数:55,代码来源:create_servers.py


示例4: listservers

def listservers():
    '''Print out servers in account'''
    auth()
    fields = ['Name', 'DC', 'Status', 'Date Created', 'Server ID']
    servdata = []
    dfwservers = pyrax.connect_to_cloudservers(region='DFW')
    ordservers = pyrax.connect_to_cloudservers(region='ORD')
    for server in dfwservers.servers.list():
        servdata.append((server.name, 'DFW', server.status, server.created,
                server.id))
    for server in ordservers.servers.list():
        servdata.append((server.name, 'ORD', server.status, server.created,
                server.id))
    printhortable(fields, servdata)
开发者ID:ExtremeSitting,项目名称:python-fogtools,代码行数:14,代码来源:fogcloner.py


示例5: minions_up

def minions_up(key_name, credential_file="~/.rackspace_cloud_credentials",
               layout=default_layout, region="IAD"):
    '''
    Creates a specific build of machines and bootstraps salt.

    The credential file can be set via keyword credential_file, and defaults
    to ~/.rackspace_cloud_credentials
    '''

    # Authenticate with Rackspace, use credential file
    pyrax.set_setting("identity_type", "rackspace")
    pyrax.set_credential_file(os.path.expanduser(credential_file))

    # Shorthand
    cs = pyrax.connect_to_cloudservers(region=region)

    minions = []

    for minion in layout["minions"]:
        minions.append(cs.servers.create(minion["hostname"],
                                         minion["image"],
                                         minion["flavor"],
                                         key_name=key_name))

    # Make sure all the minions are done before we move on to fabric runs
    minions = [pyrax.utils.wait_for_build(minion, verbose=True)
               for minion in minions]

    env.hosts = [str(minion.accessIPv4) for minion in minions]
    print(env.hosts)
开发者ID:rgbkrk,项目名称:bootstrap-salt-nbviewer,代码行数:30,代码来源:fabfile.py


示例6: __init__

    def __init__(self, task_kwargs=None, json_config_file=None):
        json_config_file = json_config_file or './deploy_settings.json'
        self.cloudservers = None
        self.settings = AttributeDict({})
        self.fabric_env_servers = []
        self.created_servers = []

        task_kwargs = task_kwargs or {}

        settings = self.read_settings_file(json_config_file)

        for key in self.SETTINGS_KEYS:
            try:
                self.settings[key] = task_kwargs[key]
            except KeyError:
                try:
                    self.settings[key] = environ[key]
                except KeyError:
                    try:
                        self.settings[key] = settings[key]
                    except KeyError:
                        pass

        self.settings.server_count = int(self.settings.server_count)
        self.settings.setdefault('ssh_user', 'root')
        self.settings.setdefault('git_branch', 'master')
        self.ensure_settings('rackspace_username', 'rackspace_apikey')

        pyrax.set_setting('identity_type', 'rackspace')
        pyrax.set_credentials(
            self.settings.rackspace_username,
            self.settings.rackspace_apikey)
        self.cloudservers = pyrax.connect_to_cloudservers()
        self.loadbalancers = pyrax.connect_to_cloud_loadbalancers()
开发者ID:mobilerider,项目名称:medusa-for-rack,代码行数:34,代码来源:tasks.py


示例7: flv_selection

def flv_selection():
    #Displays a list of all available flavors, allows the user to select one, and performs input validation.
    flvs = pyrax.connect_to_cloudservers(region=region).list_flavors()
    count = 1
    for flv in flvs:
        print count, ")", flv.name
        count += 1
    total_count = len(flvs)
    while True:
        server_flv = raw_input("\nSelect the server that you want to create by entering a number between 1 and %s.%s" % (total_count, prompt))
        try:
            server_flv = int(server_flv)
            if server_flv < 1 or server_flv > total_count:
                print "Selection out of range."
            else:
                break
        except ValueError:
            print "Not a valid selection."
    count = 1
    for flv in flvs:
        if count != server_flv:
            count += 1
        else:
            server_flv_type = flv.name
            server_flv_id = flv.id
            break
    return (server_flv_type, server_flv_id)
开发者ID:necrux,项目名称:Cloud-Servers,代码行数:27,代码来源:create_servers.py


示例8: server_selection

def server_selection():
    #Displays a list of all available images, allows the user to select one, and performs input validation.
    imgs = pyrax.connect_to_cloudservers(region=region).images.list()
    count = 1
    for img in imgs:
        print count, ")", img.name
        count += 1
    total_count = len(imgs)
    while True:
        server = raw_input("\nSelect the server that you want to create by entering a number between 1 and %s.%s" % (total_count, prompt))
        try:
            server = int(server)
            if server < 1 or server > total_count:
                print "Selection out of range."
            else:
                break
        except ValueError:
            print "Not a valid selection."
    count = 1
    for img in imgs:
        if count != server:
            count += 1
        else:
            server_type = img.name
            server_id = img.id
            break
    return (server_type, server_id)
开发者ID:necrux,项目名称:Cloud-Servers,代码行数:27,代码来源:create_servers.py


示例9: server_info

def server_info(id, dc):
    cs = pyrax.connect_to_cloudservers(region=dc)
    server = cs.servers.get(id)
    print "Server Name: ", server.name
    print "Server ID: ", server.id
    print "Public IP: ", server.accessIPv4
    print "Private IP :", server.addresses['private'][0]['addr']
开发者ID:chris-mendoza,项目名称:cloud-examples,代码行数:7,代码来源:cloud_servers.py


示例10: sync_vagrant_rackspace_environment

def sync_vagrant_rackspace_environment():
    pyrax_login()

    # iterate over all of the cloud servers to identify those that are
    # already running.
    # https://github.com/rackspace/pyrax/blob/master/docs/cloud_servers.md
    cs = pyrax.connect_to_cloudservers(region="ORD")
    for server in cs.servers.list():

        # if the cloud server is already running and managed by
        # vagrant (in env.hosts), then let's make sure the id file is
        # set correctly
        server_configured = False
        filename = vagrant_id_filename(server.name, "rackspace")
        if server.name in env.hosts:
            if os.path.exists(filename):
                with open(filename, 'r') as stream:
                    if server.id == stream.read():
                        server_configured = True
        
        # if the server is not configured on the local machine, just
        # need to create the file with the server.id in it
        if server.name in env.hosts and not server_configured:
            if not os.path.exists(os.path.dirname(filename)):
                local("mkdir -p %s" % os.path.dirname(filename))
            with open(filename, 'w') as stream:
                stream.write(server.id)
开发者ID:frrmack,项目名称:MovievsMovie,代码行数:27,代码来源:utils.py


示例11: main

def main():

	pyrax.set_setting("identity_type", "rackspace")
	creds_file = os.path.expanduser('~/.rackspace_cloud_credentials')
	pyrax.set_credential_file(creds_file)
	available_regions = pyrax.regions

	print "Regions Available:", " ".join(list(available_regions))
	region = ""
	while region not in pyrax.regions:
		region = raw_input("Select region: ")
	cs = pyrax.connect_to_cloudservers(region)
	servers = cs.servers.list()
	srv_dict = {}

	print "Select a server from which an image will be created."
	for pos, srv in enumerate(servers):
	    print "%s: %s" % (pos, srv.name)
	    srv_dict[str(pos)] = srv.id
	selection = None
	while selection not in srv_dict:
	    if selection is not None:
	        print " -- Invalid choice"
	    selection = raw_input("Enter the number for your choice: ")

	server_id = srv_dict[selection]
	print
	nm = raw_input("Enter a name for the image: ")

	img_id = cs.servers.create_image(server_id, nm)

	print "Image '%s' is being created. Its ID is: %s" % (nm, img_id)
开发者ID:r3d91ll,项目名称:RAX-CloudAPI,代码行数:32,代码来源:test.py


示例12: test_connect_to_cloudservers

 def test_connect_to_cloudservers(self):
     pyrax.cloudservers = None
     sav = pyrax.connect_to_cloudservers
     pyrax.connect_to_cloudservers = self.orig_connect_to_cloudservers
     pyrax.cloudservers = pyrax.connect_to_cloudservers()
     self.assertIsNotNone(pyrax.cloudservers)
     pyrax.connect_to_cloudservers = sav
开发者ID:Gu1,项目名称:pyrax,代码行数:7,代码来源:test_module.py


示例13: master_up

def master_up(key_name, credential_file="~/.rackspace_cloud_credentials",
              image=default_layout["master"]["image"],
              flavor=default_layout["master"]["flavor"],
              name=default_layout["master"]["hostname"],
              region="IAD"):
    '''
    Create a salt-master on Rackspace

    Alternatively create the master using nova
    '''

    # Authenticate with Rackspace, use credential file
    pyrax.set_setting("identity_type", "rackspace")
    pyrax.set_credential_file(os.path.expanduser(credential_file))

    # Shorthand
    cs = pyrax.connect_to_cloudservers(region=region)

    master = cs.servers.create(name, image, flavor, key_name=key_name)

    master = pyrax.utils.wait_for_build(master, verbose=True)

    env.hosts = [master.accessIPv4]

    print(master.networks)

    print("Master IP: {}".format(master.accessIPv4))

    return master.accessIPv4
开发者ID:rgbkrk,项目名称:bootstrap-salt-nbviewer,代码行数:29,代码来源:fabfile.py


示例14: main

def main():

	pyrax.set_setting("identity_type", "rackspace")
	creds_file = os.path.expanduser('~/.rackspace_cloud_credentials')
	pyrax.set_credential_file(creds_file)

	available_regions = pyrax.regions

	print "Regions Available:", " ".join(list(available_regions))
	region = ""
	while region not in available_regions:
		region = raw_input("Select Region: ")

	cs = pyrax.connect_to_cloudservers(region)
	available_images = cs.images.list()
	available_flavors = cs.flavors.list()

	image = make_choice(images, "Select an image: ")
	flavor = make_choice(flavors, "Select a flavor: ")

	base_name = raw_input('Base server name': )
	server_count = int(raw_input('Number of servers to build: '))

	print "Building {} servers with base name '{}', flavor '{}', and image " 
		"'{}'.".format(server_count, base_name, flavor.name, image.name)
开发者ID:ddremund,项目名称:rs-devops,代码行数:25,代码来源:server_build.py


示例15: list_servers

def list_servers(dc):
    cs = pyrax.connect_to_cloudservers(region=dc)
    for server in cs.servers.list():
        print "Server Name: ", server.name
        print "Server Status: ", server.status
        print "Server ID: ", server.id
        print "Public IP: ", server.accessIPv4
        print "Private IP: ", server.addresses['private'][0]['addr']
开发者ID:chris-mendoza,项目名称:cloud-examples,代码行数:8,代码来源:cloud_servers.py


示例16: _connect_to_rackspace

 def _connect_to_rackspace(self):
     """ returns a connection object to Rackspace  """
     pyrax.set_setting('identity_type', 'rackspace')
     pyrax.set_default_region(self.state.region)
     pyrax.set_credentials(self.config.access_key_id,
                           self.config.secret_access_key)
     nova = pyrax.connect_to_cloudservers(region=self.state.region)
     return nova
开发者ID:ClusterHQ,项目名称:bookshelf,代码行数:8,代码来源:rackspace.py


示例17: raxCreateServer

def raxCreateServer(dc, imgIDToUse, flvrIDToUse, svrBaseName, numServers):
    raxCldSvr = pyrax.connect_to_cloudservers(region=dc)
    serverImgs = raxCldSvr.images.list()
    svrsCreated = {}  # Dictionary to hold info on the servers that get created
    completed = []  # Array to hold the servers that complete creation
    if raxArgs.interactive:
        for img in sorted(serverImgs, key=lambda serverImgs: serverImgs.name):
            print img.name, " || ID:", img.id
        imgIDToUse = raw_input('ID of image to use: ')
        imgNameToUse = [img.name for img in serverImgs if img.id == imgIDToUse][0]
        #print str(imgToUse)
        serverFlvrs = raxCldSvr.flavors.list()
        for flvr in serverFlvrs:
            print "Name: " + flvr.name + " || ID:" + flvr.id
        flvrIDToUse = raw_input('ID of flavor to use: ')
        print 'Using ' + bcolors.OKBLUE + imgNameToUse + bcolors.ENDC
        try:
            numServers = int(raxArgs.numServers)
        except (ValueError, TypeError):
            numServers = 3
        if (raxArgs.svrBaseName is None):
            svrBaseName = raw_input('What is the server base name to use: ')
        else:
            svrBaseName = raxArgs.svrBaseName
    print 'Creating a new server from image' \
        ' ' + bcolors.OKBLUE + imgIDToUse + bcolors.ENDC + ' in ' + \
        bcolors.WARNING + dc + bcolors.ENDC + '.'
    print 'Creating ' + str(numServers) + ' servers.'
    print 'Server name will begin with ' + svrBaseName

    for i in xrange(0, numServers):
        svrName = '%s%s' % (svrBaseName, i)
        svrsCreated[svrName] = raxCldSvr.servers.create(svrName, imgIDToUse,
                                                        flvrIDToUse)
        print "Created server: %s" % svrName
    sys.stdout.write("Waiting for builds to complete")
    sys.stdout.flush()
    while len(completed) < numServers:
        sys.stdout.write('.')
        sys.stdout.flush()
        time.sleep(30)
        for name, server in svrsCreated.iteritems():
            if name in completed:
                continue
            server.get()
            if server.status in ['ACTIVE', 'ERROR', 'UNKNOWN']:
                sys.stdout.write("\n")
                print '======================================='
                print 'Name: %s' % server.name
                if (server.status == 'ERROR'):
                    print 'Status: %s %s %s' % bcolors.FAIL, server.status, \
                        bcolors.ENDC
                else:
                    print 'Status: %s' % server.status
                print 'ID: %s' % server.id
                print 'Networks: %s' % server.networks
                print 'Password: %s' % server.adminPass
                completed.append(name)
开发者ID:javiergayala,项目名称:RAX-API-Challenge,代码行数:58,代码来源:challenge1.py


示例18: connect_to_rackspace

def connect_to_rackspace(region,
                         access_key_id,
                         secret_access_key):
    """ returns a connection object to Rackspace  """
    pyrax.set_setting('identity_type', 'rackspace')
    pyrax.set_default_region(region)
    pyrax.set_credentials(access_key_id, secret_access_key)
    nova = pyrax.connect_to_cloudservers(region=region)
    return nova
开发者ID:ClusterHQ,项目名称:bookshelf,代码行数:9,代码来源:rackspace.py


示例19: home

def home(request):
    pyrax.set_credentials(request.user.rax_username, request.user.rax_api_key)

    cs_dfw = pyrax.connect_to_cloudservers(region="DFW")
    cs_ord = pyrax.connect_to_cloudservers(region="ORD")

    dfw_servers = cs_dfw.servers.list()
    ord_servers = cs_ord.servers.list()
    all_servers = dfw_servers + ord_servers

    html = "<html><body>"

    for server in all_servers:
        html += "Server: %s <br/>" % server.name

    html += "</body></html>"

    return HttpResponse(html)
开发者ID:jmvrbanac,项目名称:ChaosCowboy,代码行数:18,代码来源:views.py


示例20: connect_to_rackspace

def connect_to_rackspace():
    """ returns a connection object to Rackspace  """
    import pyrax

    pyrax.set_setting('identity_type', env.os_auth_system)
    pyrax.set_default_region(env.os_region_name)
    pyrax.set_credentials(env.os_username, env.os_password)
    nova = pyrax.connect_to_cloudservers(region=env.os_region_name)
    return nova
开发者ID:Azulinho,项目名称:fabric-collections,代码行数:9,代码来源:api.py



注:本文中的pyrax.connect_to_cloudservers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyrax.get_setting函数代码示例发布时间:2022-05-27
下一篇:
Python pyrax.connect_to_cloudfiles函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap