def add(self, **kwargs): """ Adds default StorageDomain/s according to the default configuration/s (default configuration can be overridden with custom config via keyword args) @param kwargs: keyword args @return: StorageDomain """ storagedomain = self.getOnly() if not storagedomain: # wait for host to become ready StatusUtils.wait(self.getHost, "up") # create storage domain self.injectExpectParam(kwargs) created_storagedomains = self._doAdd(self.getResourceManager().getSdk().storagedomains, **kwargs) if created_storagedomains: if isinstance(created_storagedomains, types.ListType): attach_responses = [] for item in created_storagedomains: attach_responses.append(self._attach(item)) return attach_responses[0] else: return self._attach(created_storagedomains) else: self.raiseNotCreatedError() return storagedomain
def remove(self, **kwargs): """ Removes default DataCenter according to keyword args @param kwargs: keyword args @return: Response """ resource = self.get() if not resource: self.raiseNotFoundError() # delete response = resource.delete() # wait till gone StatusUtils.waitRemoved(self.get) return response
def remove(self, **kwargs): """ Removes default Cluster according to keyword args @param kwargs: keyword args @return: Response """ cluster = self.get() if not cluster: self.raiseNotFoundError() # delete response = cluster.delete() # wait till gone StatusUtils.waitRemoved(self.get) return response
def _attach(self, storagedomain): """ Attaches StorageDomain to DC @param storagedomain: The StorageDomain to attach """ if storagedomain: # wait till ready StatusUtils.waitBrutal(self.get, "unattached", name=storagedomain.name) # attach storage domain datacenter = self.getDataCenter() attached_storagedomain = datacenter.storagedomains.add(storagedomain) # wait till it got active try: StatusUtils.wait(self.getAttachedStorageDomain, "active") except: pass # if it's not went up, try activate manually if attached_storagedomain.status.state != "active": # activate SD attached_storagedomain.activate() # wait till ready StatusUtils.wait(self.getAttachedStorageDomain, "active") return attached_storagedomain
def remove(self, **kwargs): """ Removes default host according to keyword args @param kwargs: keyword args @return: Response """ host = self.get() if not host: self.raiseNotFoundError() if host.status.state != 'maintenance': host.deactivate() StatusUtils.wait(self.get, 'maintenance') # delete response = host.delete() # wait till gone StatusUtils.waitRemoved(self.get) return response
def remove(self, **kwargs): """ Removes default StorageDomain according to keyword args @param kwargs: keyword args @return: Response """ storagedomain = self.getOnly() if not storagedomain: return # get attached storage domain attached_storagedomain = self.getAttachedStorageDomain() if ( attached_storagedomain and attached_storagedomain.status and attached_storagedomain.status.state and attached_storagedomain.status.state != "maintenance" ): # move to maintenance attached_storagedomain.deactivate() # wait till ready StatusUtils.wait(self.getAttachedStorageDomain, "maintenance") # delete DC datacenter = self.getDataCenter() datacenter.delete() # wait till gone StatusUtils.waitRemoved(self.getDataCenter) # delete response = storagedomain.delete(storagedomain=params.StorageDomain(host=self.hostResourceManager.get())) # wait till gone StatusUtils.waitRemoved(self.get) return response