def _apply_backend_changes(op, sb_obj): if op == constants.SB_API_OP_CREATE: services = api_helper.getListFromServices(sb_obj.as_dict()) if constants.SB_SVC_CINDER in services: # Services are specified: Update backend + service actions api_helper.enable_backend( sb_obj, pecan.request.rpcapi.update_lvm_cinder_config) elif op == constants.SB_API_OP_MODIFY: if sb_obj.state == constants.SB_STATE_CONFIG_ERR: api_helper.enable_backend( sb_obj, pecan.request.rpcapi.update_lvm_cinder_config) elif op == constants.SB_API_OP_DELETE: pass
def _apply_backend_changes(op, sb_obj): if op in [constants.SB_API_OP_CREATE, constants.SB_API_OP_MODIFY]: services = api_helper.getListFromServices(sb_obj.as_dict()) if constants.SB_SVC_CINDER in services: # Services are specified: Update backend + service actions api_helper.enable_backend( sb_obj, pecan.request.rpcapi.update_external_cinder_config) else: # If no service is specified or glance or swift is the only service # this is a DB only change => Set the state to configured pecan.request.dbapi.storage_external_update( sb_obj.uuid, {'state': constants.SB_STATE_CONFIGURED}) # update shared_services s_s = utils.get_shared_services() shared_services = [] if s_s is None else ast.literal_eval(s_s) if services is not None: for s in services: if (s == constants.SB_SVC_CINDER and constants.SERVICE_TYPE_VOLUME not in shared_services): shared_services.append(constants.SERVICE_TYPE_VOLUME) if (s == constants.SB_SVC_GLANCE and constants.SERVICE_TYPE_IMAGE not in shared_services): shared_services.append(constants.SERVICE_TYPE_IMAGE) system = pecan.request.dbapi.isystem_get_one() system.capabilities['shared_services'] = str(shared_services) pecan.request.dbapi.isystem_update( system.uuid, {'capabilities': system.capabilities}) elif op == constants.SB_API_OP_DELETE: pass