当前位置: 首页>>代码示例>>Python>>正文


Python Utils.get_ipv4方法代码示例

本文整理汇总了Python中utils.Utils.get_ipv4方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.get_ipv4方法的具体用法?Python Utils.get_ipv4怎么用?Python Utils.get_ipv4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Utils的用法示例。


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

示例1: launch_oc_agent

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
    def launch_oc_agent(cls, oc_server, nova_client, network):
        name = Utils.generate_unique_name("bac-opencenter-agent")

        ipv4 = Utils.get_ipv4(oc_server.addresses["public"])
        
        fp = "vm_scripts/install_oc_agent.sh"
        data = Utils.read_data(fp)
        data = data.replace("SERVER_IP", ipv4)
        data = data.replace("PASSWORD", oc_server.oc_password)
            
        oc_agent = cls.create_server(nova_client, name, network.id, data)
        
        return oc_agent
开发者ID:metral,项目名称:build_a_cloud,代码行数:15,代码来源:rackspace.py

示例2: wait_for_oc_service

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
 def wait_for_oc_service(cls, server):
     oc_port = 443
     
     try:
         ipv4 = Utils.get_ipv4(server.addresses["public"])
         msg = "Waiting for OpenCenter service to be up: %s" % server.name
         logger.info(msg)
         
         while (not Utils.port_is_open(ipv4, oc_port)):
             msg = "Still waiting for OpenCenter service to be up: %s" \
                     % server.name
             logger.debug(msg)
             sleep(10)
         msg = "OpenCenter Service Ready on: %s" % server.name
         logger.info(msg)
     except Exception,e:
         logger.error(msg)
开发者ID:metral,项目名称:build_a_cloud,代码行数:19,代码来源:rackspace.py

示例3: wait_for_oc_server

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
    def wait_for_oc_server(cls, nova_client, oc_server, 
            network):

        updated_oc_server = oc_server
        oc_port = 443
        
        # Check server status until active
        status = cls.check_status(nova_client, updated_oc_server)
        while not status:
            if status == False:
                sleep(10)
                updated_oc_server = \
                        cls.update_server(nova_client, updated_oc_server)
            elif status is None:
                msg = "Server Error (OC Server - Booting Issue): Deleting %s" \
                        % updated_oc_server.name
                return cls.oc_server_recover(\
                        msg, updated_oc_server, nova_client, network)
            status = cls.check_status(nova_client, updated_oc_server)
                
        ipv4 = Utils.get_ipv4(updated_oc_server.addresses["public"])
        active_port = 22    # SSH
        
        # If active, do post setup
        if Utils.port_is_open(ipv4, active_port):
            updated_oc_server = cls.post_setup(nova_client, oc_server, oc_port)
            if not updated_oc_server:
                msg = "Server Error (OC Server - Setup Issue): Deleting %s" \
                        % updated_oc_server.name
                return cls.oc_server_recover(\
                        msg, updated_oc_server, nova_client, network)

        # If for some reason network is not working even when active, try again
        else: 
            msg = "Server Error (OC Server - Routing Issue): Deleting %s" \
                    % updated_oc_server.name
            return cls.oc_server_recover(\
                    msg, updated_oc_server, nova_client, network)
        
        return updated_oc_server
开发者ID:metral,项目名称:build_a_cloud,代码行数:42,代码来源:rackspace.py

示例4: wait_for_oc_agents

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
 def wait_for_oc_agents(cls, oc_agents, nova_client, oc_server, network):
     updated_oc_agents = []
     
     active_port = 22    # SSH
     while len(updated_oc_agents) != len(oc_agents):
         for index, oc_agent in enumerate(oc_agents):
             status = cls.check_status(nova_client, oc_agent)
             
             if status == True:
                 updated_oc_agent = cls.update_server(nova_client, oc_agent)
                 ipv4 = Utils.get_ipv4(updated_oc_agent.addresses["public"])
                 if updated_oc_agent not in updated_oc_agents:
                     if Utils.port_is_open(ipv4, active_port):
                         updated_oc_agent = \
                                 cls.post_setup(nova_client, oc_agent)
                         updated_oc_agents.append(updated_oc_agent)
                     else:
                         msg = "Server Error (OC Agent - " + \
                                 "Booting Issue): Deleting %s" \
                                 % oc_agent.name
                         logger.error(msg)
                         cls.delete_server(oc_agent)
                         sleep(10)
                         oc_agent = cls.launch_oc_agent(\
                                 oc_server, nova_client, network)
                         oc_agents[index] = oc_agent    
             elif status == False:
                 sleep(10)
             elif status is None:
                 msg = "Server Error (OC Agent - " + \
                         "Routing Issue): Deleting %s" % oc_agent.name
                 logger.error(msg)
                 cls.delete_server(oc_agent)
                 sleep(10)
                 oc_agent = cls.launch_oc_agent(\
                         oc_server, nova_client, network)
                 oc_agents[index] = oc_agent    
     
     return updated_oc_agents
开发者ID:metral,项目名称:build_a_cloud,代码行数:41,代码来源:rackspace.py

示例5: post_setup

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
    def post_setup(cls, nova_client, oc_server, oc_port = None):
        # Update server to have latest info
        updated_oc_server = cls.update_server(nova_client, oc_server)

        # Set passwords
        updated_oc_server = cls.update_root_password(\
                oc_server, updated_oc_server)
        updated_oc_server = cls.update_oc_password(oc_server, updated_oc_server)
        
        # Print server info
        Utils.print_server_info(updated_oc_server)

        # Run payloads via SSH
        ipv4 = Utils.get_ipv4(updated_oc_server.addresses["public"])
        command = "ssh -q -o StrictHostKeyChecking=no %s " % ipv4 + \
                "'chmod +x /etc/prep.sh ; /etc/prep.sh'"
        Utils.do_subprocess(command)

        # Wait for opencenter services to be ready, if required
        if oc_port: cls.wait_for_oc_service(updated_oc_server)
        
        return updated_oc_server
开发者ID:metral,项目名称:build_a_cloud,代码行数:24,代码来源:rackspace.py

示例6: build_a_cloud

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import get_ipv4 [as 别名]
    def build_a_cloud(cls, nova_client):
        logger.info("Build A Cloud Started")

        # Dev Cleanup
        cls.remove_user_networks(nova_client)

        # Check RAM & CloudNetwork Quotas
        cls.check_quotas(nova_client)

        # Create new network
        cidr = "192.168.3.0/24"
        network = cls.create_network(nova_client, "bac", cidr)

        ## Launch opencenter cluster
        num_of_oc_agents = 4
        oc_server, oc_agents = \
                cls.launch_cluster(nova_client, network, num_of_oc_agents)
                
        logger.info("Vanilla Cluster Launched")
        Utils.print_server_info(oc_server)
        for oc_agent in oc_agents:
            Utils.print_server_info(oc_agent)

        logger.info("Provisioning Cluster")
        oc_user = "admin"
        oc_password = oc_server.oc_password
        oc_server_ipv4 = Utils.get_ipv4(oc_server.addresses["public"])
        oc_url ="https://%s:8443" % oc_server_ipv4
         
        oc.provision_cluster(nova_client, oc_server, oc_url, oc_user, \
            oc_password, num_of_oc_agents, cidr)

        logger.info("Checking & Deleting any Servers that had a Booting Error")
        cls.delete_errored_servers(nova_client)

        logger.info("Build A Cloud Finished")
开发者ID:metral,项目名称:build_a_cloud,代码行数:38,代码来源:rackspace.py


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