Coverage for lib/ansible/inventory/host.py : 55%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
''' a single ansible host '''
# __slots__ = [ 'name', 'vars', 'groups' ]
return self.serialize()
return self.deserialize(data)
if not isinstance(other, Host): return False return self._uuid == other._uuid
return not self.__eq__(other)
return self.get_name()
groups = [] for group in self.groups: groups.append(group.serialize())
return dict( name=self.name, vars=self.vars.copy(), address=self.address, uuid=self._uuid, groups=groups, implicit=self.implicit, )
self.__init__(gen_uuid=False)
self.name = data.get('name') self.vars = data.get('vars', dict()) self.address = data.get('address', '') self._uuid = data.get('uuid', None) self.implicit = data.get('implicit', False)
groups = data.get('groups', []) for group_data in groups: g = Group() g.deserialize(group_data) self.groups.append(g)
self.set_variable('ansible_port', int(port))
# populate ancestors
# populate ancestors first
# actually add group
if group in self.groups: self.groups.remove(group)
# remove exclusive ancestors, xcept all! for oldg in group.get_ancestors(): if oldg.name != 'all': for childg in self.groups: if oldg in childg.get_ancestors(): break else: self.remove_group(oldg)
|