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


Python Host.address方法代碼示例

本文整理匯總了Python中ansible.inventory.host.Host.address方法的典型用法代碼示例。如果您正苦於以下問題:Python Host.address方法的具體用法?Python Host.address怎麽用?Python Host.address使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ansible.inventory.host.Host的用法示例。


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

示例1: __init__

# 需要導入模塊: from ansible.inventory.host import Host [as 別名]
# 或者: from ansible.inventory.host.Host import address [as 別名]
    def __init__(self, play, inventory, variable_manager, loader):
        self._lookup = dict()
        self._loader = loader
        self._play = play
        self._variable_manager = variable_manager

        hosts = inventory.get_hosts(ignore_limits_and_restrictions=True)

        # check to see if localhost is in the hosts list, as we
        # may have it referenced via hostvars but if created implicitly
        # it doesn't sow up in the hosts list
        has_localhost = False
        for host in hosts:
            if host.name in C.LOCALHOST:
                has_localhost = True
                break

        if not has_localhost:
            new_host =  Host(name='localhost')
            new_host.set_variable("ansible_python_interpreter", sys.executable)
            new_host.set_variable("ansible_connection", "local")
            new_host.address = '127.0.0.1'
            hosts.append(new_host)

        for host in hosts:
            self._lookup[host.name] = host
開發者ID:source-foundry,項目名稱:code-corpora,代碼行數:28,代碼來源:hostvars.py

示例2: _create_implicit_localhost

# 需要導入模塊: from ansible.inventory.host import Host [as 別名]
# 或者: from ansible.inventory.host.Host import address [as 別名]
    def _create_implicit_localhost(self, pattern):

        if self.localhost:
            new_host = self.localhost
        else:
            new_host = Host(pattern)

            # use 'all' vars but not part of all group
            new_host.vars = self.groups['all'].get_vars()

            new_host.address = "127.0.0.1"
            new_host.implicit = True

            if "ansible_python_interpreter" not in new_host.vars:
                py_interp = sys.executable
                if not py_interp:
                    # sys.executable is not set in some cornercases.  #13585
                    py_interp = '/usr/bin/python'
                    display.warning('Unable to determine python interpreter from sys.executable. Using /usr/bin/python default. '
                                    'You can correct this by setting ansible_python_interpreter for localhost')
                new_host.set_variable("ansible_python_interpreter", py_interp)

            if "ansible_connection" not in new_host.vars:
                new_host.set_variable("ansible_connection", 'local')

            self.localhost = new_host

        return new_host
開發者ID:ernstp,項目名稱:ansible,代碼行數:30,代碼來源:data.py

示例3: _create_implicit_localhost

# 需要導入模塊: from ansible.inventory.host import Host [as 別名]
# 或者: from ansible.inventory.host.Host import address [as 別名]
 def _create_implicit_localhost(self, pattern):
     new_host = Host(pattern)
     new_host.address = "127.0.0.1"
     new_host.vars = self.get_host_vars(new_host)
     new_host.set_variable("ansible_connection", "local")
     if "ansible_python_interpreter" not in new_host.vars:
         new_host.set_variable("ansible_python_interpreter", sys.executable)
     self.get_group("ungrouped").add_host(new_host)
     return new_host
開發者ID:davismathew,項目名稱:stableansible,代碼行數:11,代碼來源:__init__.py

示例4: _create_implicit_localhost

# 需要導入模塊: from ansible.inventory.host import Host [as 別名]
# 或者: from ansible.inventory.host.Host import address [as 別名]
 def _create_implicit_localhost(self, pattern='localhost'):
     new_host = Host(pattern)
     new_host.address = "127.0.0.1"
     new_host.implicit = True
     new_host.vars = self.get_host_vars(new_host)
     new_host.set_variable("ansible_connection", "local")
     if "ansible_python_interpreter" not in new_host.vars:
         py_interp = sys.executable
         if not py_interp:
             # sys.executable is not set in some cornercases.  #13585
             display.warning('Unable to determine python interpreter from sys.executable. Using /usr/bin/python default. You can correct this by setting ansible_python_interpreter for localhost')
             py_interp = '/usr/bin/python'
         new_host.set_variable("ansible_python_interpreter", py_interp)
     self.get_group("ungrouped").add_host(new_host)
     return new_host
開發者ID:LukeInkster,項目名稱:PythonCorpus,代碼行數:17,代碼來源:__init__.py

示例5: _create_implicit_localhost

# 需要導入模塊: from ansible.inventory.host import Host [as 別名]
# 或者: from ansible.inventory.host.Host import address [as 別名]
    def _create_implicit_localhost(self, pattern):

        if self.localhost:
            new_host = self.localhost
        else:
            new_host = Host(pattern)

            new_host.address = "127.0.0.1"
            new_host.implicit = True

            # set localhost defaults
            py_interp = sys.executable
            if not py_interp:
                # sys.executable is not set in some cornercases. see issue #13585
                py_interp = '/usr/bin/python'
                display.warning('Unable to determine python interpreter from sys.executable. Using /usr/bin/python default. '
                                'You can correct this by setting ansible_python_interpreter for localhost')
            new_host.set_variable("ansible_python_interpreter", py_interp)
            new_host.set_variable("ansible_connection", 'local')

            self.localhost = new_host

        return new_host
開發者ID:awiddersheim,項目名稱:ansible,代碼行數:25,代碼來源:data.py


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