def fix(self, status): if self.attributes['running'] is False: LOG.info(_("{node}:{bundle}:{item}: stopping...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) svc_stop(self.node, self.name) else: LOG.info(_("{node}:{bundle}:{item}: starting...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) svc_start(self.node, self.name)
def fix(self, status): if self.attributes['installed'] is False: LOG.info(_("{node}:{bundle}:{item}: removing...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) pkg_remove(self.node, self.name) else: LOG.info(_("{node}:{bundle}:{item}: installing...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) pkg_install(self.node, self.name)
def fix(self, status): for fix_type in ('type', 'content', 'mode', 'owner', 'group'): if fix_type in status.info['needs_fixing']: if fix_type == 'group' and \ 'owner' in status.info['needs_fixing']: # owner and group are fixed with a single chown continue if fix_type in ('mode', 'owner', 'group') and \ 'content' in status.info['needs_fixing']: # fixing content implies settings mode and owner/group continue if status.info['path_info'].exists: if self.attributes['delete']: LOG.info(_("{node}:{bundle}:{item}: deleting...").format( bundle=self.bundle.name, node=self.node.name, item=self.id)) else: LOG.info(_("{node}:{bundle}:{item}: fixing {type}...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, type=fix_type, )) else: LOG.info(_("{node}:{bundle}:{item}: creating...").format( bundle=self.bundle.name, item=self.id, node=self.node.name)) getattr(self, "_fix_" + fix_type)(status)
def fix(self, status): if 'type' in status.info['needs_fixing']: # fixing the type fixes everything if status.info['path_info'].exists: LOG.info(_("{node}:{bundle}:{item}: fixing type...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) else: LOG.info(_("{node}:{bundle}:{item}: creating...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) self._fix_type(status) return for fix_type in ('owner', 'group', 'target'): if fix_type in status.info['needs_fixing']: if fix_type == 'group' and \ 'owner' in status.info['needs_fixing']: # owner and group are fixed with a single chown continue LOG.info(_("{node}:{item}: fixing {type}...").format( item=self.id, node=self.node.name, type=fix_type, )) getattr(self, "_fix_" + fix_type)(status)
def fix(self, status): if not status.info['exists']: LOG.info(_("{node}:{bundle}:{item}: creating...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) if self.attributes['gid'] is None: command = "groupadd {}".format(self.name) else: command = "groupadd -g {gid} {groupname}".format( gid=self.attributes['gid'], groupname=self.name, ) self.node.run(command, may_fail=True) elif self.attributes['delete']: LOG.info(_("{node}:{bundle}:{item}: deleting...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) self.node.run("groupdel {}".format(self.name), may_fail=True) else: LOG.info(_("{node}:{bundle}:{item}: updating...").format( bundle=self.bundle.name, item=self.id, node=self.node.name, )) self.node.run( "groupmod -g {gid} {groupname}".format( gid=self.attributes['gid'], groupname=self.name, ), may_fail=True, )
def fix(self, status): if status.info['exists']: if self.attributes['delete']: msg = _("{node}:{bundle}:{item}: deleting...") else: msg = _("{node}:{bundle}:{item}: updating...") else: msg = _("{node}:{bundle}:{item}: creating...") LOG.info(msg.format(bundle=self.bundle.name, item=self.id, node=self.node.name)) if self.attributes['delete']: self.node.run("userdel {}".format(self.name), may_fail=True) else: command = "useradd " if not status.info['exists'] else "usermod " for attr, option in sorted(_ATTRIBUTE_OPTIONS.items()): if attr in status.info['needs_fixing'] and self.attributes[attr] is not None: if attr == 'groups': value = ",".join(self.attributes[attr]) else: value = str(self.attributes[attr]) command += "{} {} ".format(option, quote(value)) command += self.name self.node.run(command, may_fail=True)