def get_by_id(caller_id, farm_id): """ @cmview_admin_cm @param_post{farm_id,int} id of the requested farm @response{dict} Farm.dict property of the requested Farm """ return Farm.admin_get(farm_id).dict
def save_and_shutdown(caller_id, farm_id, name, description): """ Saves and shutdowns specified Farm's head. Worker nodes are destroyed. @cmview_admin_cm @param_post{farm_id,int} id of the Farm to save @param_post{name,string} name which Farm's head should saved to @param_post{description,string} description for newly saved Farm """ farm = Farm.admin_get(farm_id) return Farm.save_and_shutdown(farm, name, description)
def save_and_shutdown(caller_id, farm_id, name, description): """ Saves and shutdowns VM described by \c data. @decoratedby{src.cm.utils.decorators.admin_cm_log} @parameter{farm_id,int} id of the requested farm @parameter{data,dict} \n fields @asrequired{manager.cm.farm.utils.save_and_shutdown()} """ farm = Farm.admin_get(farm_id) return Farm.save_and_shutdown(farm, name, description)
def destroy(caller_id, farm_ids): """ @decoratedby{src.cm.utils.decorators.admin_cm_log} Admin method to destroy farms with ids listed in \c data. @parameter{data,list} list of destroyed farm's \c id's @response @asreturned{src.cm.manager.farm.utils.destroy()} """ farms = [] for farm_id in farm_ids: farms.append(Farm.admin_get(farm_id)) return Farm.destroy(farms)
def destroy(caller_id, farm_ids): """ Destroyes specified Farms. Neither Farm's head nor worker nodes are saved. Destroyed Farm cannot be recovered. @cmview_admin_cm @param_post{farm_ids,list(int)} ids of the Farms to destroy @response{list{HTTPResponse}} list of responses for each VM destruction """ farms = [] for farm_id in farm_ids: farms.append(Farm.admin_get(farm_id)) return Farm.destroy(farms)
def erase(caller_id, farm_ids): """ Cleanes up after failed Farm. Only admin may erase Farm so that he previously may perform some analytics. @cmview_admin_cm @param_post{farm_ids,list(int)} ids of the Farms to erase """ for fid in farm_ids: farm = Farm.admin_get(fid) for vm in farm.vms.all(): VM.erase(vm) farm.state = farm_states['closed'] try: farm.save() except Exception: log.exception('Cannot commit changes.')
def erase(caller_id, farm_ids): """ Method erases (removes from database) details about VMs that haven't ran properly. @decoratedby{src.cm.utils.decorators.admin_cm_log} @parameter{farm_ids,list(int)} ids of the farms to erase """ for fid in farm_ids: farm = Farm.admin_get(fid) for vm in farm.vms.all(): VM.erase(vm) farm.state = farm_states['closed'] try: farm.save() except Exception: log.exception('Cannot commit changes.')
def get_by_id(caller_id, farm_id): """ @decoratedby{src.cm.utils.decorators.admin_cm_log} @parameter{farm_id,int} id of the requested farm """ return Farm.admin_get(farm_id).dict