def unregisterHost(self, _oHost): """ Unregister the given host resource (as running this resource) @param KiscResource_cluster_host _oHost Host resource (object) to unregister @return list Empty if resource is successfully unregistered, (ordered) error messages otherwise """ if self._iVerbose: self._INFO('Unregistering host (%s)' % _oHost.id()) lsErrors = list() # Unregister host try: sHost_id = _oHost.id() # ... registered hosts lsHosts = KiscRuntime.parseList(self._dsConfig.get('$HOSTS', None)) # ... check registration status if sHost_id not in lsHosts: return lsErrors # ... finalize lsHosts.remove(sHost_id) self._dsConfig['$HOSTS'] = ','.join(lsHosts) if not len(self._dsConfig['$HOSTS']): del self._dsConfig['$HOSTS'] if self._iVerbose: self._INFO('Host unregistered (%s)' % _oHost.id()) except RuntimeError as e: if self._iVerbose: self._ERROR(str(e)) lsErrors.append(str(e)) # Done return lsErrors
def getHostsIDs(self): """ Return hosts (IDs) running the resource @return list Resource running hosts IDs """ return KiscRuntime.parseList(self._dsConfig.get('$HOSTS', None))