def get_container_object(req): ret = dict() ret[Definition.REST.Batch.get_str_batch_addr()] = req.params[ Definition.REST.Batch.get_str_batch_addr()].strip() ret[Definition.REST.Batch.get_str_batch_port()] = int( req.params[Definition.REST.Batch.get_str_batch_port()]) ret[Definition.REST.Batch.get_str_batch_status()] = int( req.params[Definition.REST.Batch.get_str_batch_status()]) ret[Definition.Container.get_str_con_image_name()] = req.params[ Definition.Container.get_str_con_image_name()].strip() ret[Definition.get_str_last_update( )] = Services.get_current_timestamp() return ret
def get_tuple_object(req): # parameters ret = dict() ret[Definition.Container.get_str_data_digest()] = req.params[ Definition.Container.get_str_data_digest()].strip() ret[Definition.Container.get_str_con_image_name()] = req.params[ Definition.Container.get_str_con_image_name()].strip() ret[Definition.Container.get_str_container_os()] = req.params[ Definition.Container.get_str_container_os()].strip() ret[Definition.Container.get_str_data_source()] = req.params[ Definition.Container.get_str_data_source()].strip() ret[Definition.Container.get_str_container_priority()] = 0 ret[Definition.REST.get_str_status()] = CTuple.SC ret[Definition.get_str_last_update( )] = Services.get_current_timestamp() return ret
def update_container(dict_input): def cont_in_table(dict_input): conts = LookUpTable.Containers.__containers[dict_input[ Definition.Container.get_str_con_image_name()]] for cont in conts: if dict_input.get(Definition.Container.Status.get_str_sid( )) == cont.get(Definition.Container.Status.get_str_sid()): return cont return None if dict_input[Definition.Container.get_str_con_image_name( )] not in LookUpTable.Containers.__containers: # no containers for this image exist new_cont = [dict_input] LookUpTable.Containers.__containers[dict_input[ Definition.Container.get_str_con_image_name()]] = new_cont else: cont = cont_in_table(dict_input) if not cont: # this specific container is not already in table LookUpTable.Containers.__containers[dict_input[ Definition.Container.get_str_con_image_name()]].append( dict_input) else: # container was already in table, update timestamp cont[Definition.get_str_last_update( )] = Services.get_current_timestamp()
def add_worker(dict_input): dict_input[Definition.get_str_last_update( )] = Services.get_current_timestamp() LookUpTable.Workers.__workers[dict_input[ Definition.get_str_node_addr()]] = dict_input
def get_tuple_id(tuple_info): return tuple_info[Definition.Container.get_str_data_digest( )][0:12] + ":" + str(tuple_info[Definition.get_str_last_update()])