|
|
@ -19,6 +19,8 @@
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.inventory.group import Group
|
|
|
|
from ansible.inventory.group import Group
|
|
|
|
from ansible.utils.vars import combine_vars
|
|
|
|
from ansible.utils.vars import combine_vars
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +40,7 @@ class Host:
|
|
|
|
def __eq__(self, other):
|
|
|
|
def __eq__(self, other):
|
|
|
|
if not isinstance(other, Host):
|
|
|
|
if not isinstance(other, Host):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return id(self) == id(other)
|
|
|
|
return self._uuid == other._uuid
|
|
|
|
|
|
|
|
|
|
|
|
def __ne__(self, other):
|
|
|
|
def __ne__(self, other):
|
|
|
|
return not self.__eq__(other)
|
|
|
|
return not self.__eq__(other)
|
|
|
@ -55,6 +57,7 @@ class Host:
|
|
|
|
name=self.name,
|
|
|
|
name=self.name,
|
|
|
|
vars=self.vars.copy(),
|
|
|
|
vars=self.vars.copy(),
|
|
|
|
address=self.address,
|
|
|
|
address=self.address,
|
|
|
|
|
|
|
|
uuid=self._uuid,
|
|
|
|
gathered_facts=self._gathered_facts,
|
|
|
|
gathered_facts=self._gathered_facts,
|
|
|
|
groups=groups,
|
|
|
|
groups=groups,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -65,6 +68,7 @@ class Host:
|
|
|
|
self.name = data.get('name')
|
|
|
|
self.name = data.get('name')
|
|
|
|
self.vars = data.get('vars', dict())
|
|
|
|
self.vars = data.get('vars', dict())
|
|
|
|
self.address = data.get('address', '')
|
|
|
|
self.address = data.get('address', '')
|
|
|
|
|
|
|
|
self._uuid = data.get('uuid', uuid.uuid4())
|
|
|
|
|
|
|
|
|
|
|
|
groups = data.get('groups', [])
|
|
|
|
groups = data.get('groups', [])
|
|
|
|
for group_data in groups:
|
|
|
|
for group_data in groups:
|
|
|
@ -84,6 +88,7 @@ class Host:
|
|
|
|
self.set_variable('ansible_port', int(port))
|
|
|
|
self.set_variable('ansible_port', int(port))
|
|
|
|
|
|
|
|
|
|
|
|
self._gathered_facts = False
|
|
|
|
self._gathered_facts = False
|
|
|
|
|
|
|
|
self._uuid = uuid.uuid4()
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
def __repr__(self):
|
|
|
|
return self.get_name()
|
|
|
|
return self.get_name()
|
|
|
|