def run(self): attrs = dict(pool_id=self.parameters['Rbd.pool_id'], size=str(self.parameters['Rbd.size'])) Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Re-sizing rbd %s on pool %s to %s" % (self.parameters['Rbd.name'], self.parameters['Rbd.pool_id'], self.parameters['Rbd.size']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) crud = Crud() resp = crud.update("rbd", self.parameters['Rbd.name'], attrs) try: crud.sync_request_status(resp['request']) except RequestStateError as ex: Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Failed to resize rbd %s." " Error: %s" % (self.parameters['Rbd.name'], ex) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) return False Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Successfully re-sized rbd %s on pool-id %s to " "%s" % (self.parameters['Rbd.name'], self.parameters['Rbd.pool_id'], self.parameters['Rbd.size']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) return True
def run(self): attrs = dict(pool_id=self.parameters['Rbd.pool_id'], size=str(self.parameters['Rbd.size'])) Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Re-sizing rbd %s on pool %s to %s" % (self.parameters['Rbd.name'], self.parameters['Rbd.pool_id'], self.parameters['Rbd.size']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) crud = Crud() ret_val = crud.update("rbd", self.parameters['Rbd.name'], attrs) if ret_val['response'] is not None and \ ret_val['response']['error'] is True: Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Failed to resize rbd %s." " Error: %s" % (self.parameters['Rbd.name'], ret_val['error_status']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) return False Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Successfully re-sized rbd %s on pool-id %s to " "%s" % (self.parameters['Rbd.name'], self.parameters['Rbd.pool_id'], self.parameters['Rbd.size']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) return True
def run(self): pool_id = self.parameters['Pool.pool_id'] attrs = {} attrs['name'] = self.parameters.get('Pool.poolname') existing_name = NS._int.client.read( "clusters/%s/Pools/%s/pool_name" % \ ( NS.tendrl_context.integration_id, self.parameters['Pool.pool_id'] ) ).value Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Renaming the pool:%s with new name: %s" % (existing_name, self.parameters.get('Pool.poolname')) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) crud = Crud() resp = crud.update("pool", pool_id, attrs) try: crud.sync_request_status(resp['request']) except RequestStateError as ex: Event( Message( priority="error", publisher=NS.publisher_id, payload={ "message": "Failed to rename pool: %s with new name: %s" " Error: %s" % (existing_name, self.parameters.get('Pool.poolname'), ex) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) return False Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Pool: %s successfully renamed with new name: %s" % (existing_name, self.parameters.get('Pool.poolname')) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, ) ) return True
def run(self): pool_id = self.parameters['Pool.pool_id'] attrs = {} if 'Pool.pg_num' in self.parameters: fetched_obj = Pool(pool_id=self.parameters['Pool.pool_id']).load() attrs['pg_num'] = self.parameters.get('Pool.pg_num') if attrs['pg_num'] <= int(fetched_obj.pg_num): raise AtomExecutionFailedError( "New pg-num cannot be less than existing value") if 'Pool.size' in self.parameters: attrs['size'] = self.parameters.get('Pool.size') if 'Pool.min_size' in self.parameters: attrs['min_size'] = self.parameters.get('Pool.min_size') if 'Pool.quota_enabled' in self.parameters and \ self.parameters['Pool.quota_enabled'] is True: attrs['quota_max_objects'] = \ self.parameters.get('Pool.quota_max_objects') attrs['quota_max_bytes'] = \ self.parameters.get('Pool.quota_max_bytes') Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Updating details for pool-id %s." " Attributes: %s" % (self.parameters['Pool.pool_id'], str(attrs)) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) crud = Crud() resp = crud.update("pool", pool_id, attrs) try: crud.sync_request_status(resp['request']) except RequestStateError as ex: Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Failed to update pool %s." " Error: %s" % (self.parameters['Pool.pool_id'], ex) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) return False Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Pool %s successfully updated" % (self.parameters['Pool.pool_id']) }, job_id=self.parameters['job_id'], flow_id=self.parameters['flow_id'], cluster_id=NS.tendrl_context.integration_id, )) return True