def update(self, resource_id, owner=None): # resource object if self._resource_type == ResourceType.VICTIMS: resource_obj = VictimObject() elif self._resource_type == ResourceType.BATCH_JOBS: resource_obj = BatchJobObject() else: resource_obj = GroupObject(self._resource_type) resource_obj.set_id(int(resource_id)) if owner is not None: resource_obj.set_owner_name(owner) resource_obj.set_phase(2) # set resource api phase (1 = add) # return object for modification return self._method_wrapper(resource_obj)
def delete(self, resource_id, owner=None): # resource object if self._resource_type == ResourceType.VICTIMS: resource_obj = VictimObject() else: resource_obj = GroupObject(self._resource_type) resource_obj.set_id(resource_id) resource_obj.set_owner_name(owner) resource_obj.set_phase(3) # set resource api phase (3 = delete) # call delete to queue call wrapper = self._method_wrapper(resource_obj) wrapper.delete()
def add(self, resource_name, owner=None): """ add resource to resource container """ # generate unique temporary id resource_id = uuid.uuid4().int if self._resource_type == ResourceType.VICTIMS: resource_object = VictimObject() elif self._resource_type == ResourceType.BATCH_JOBS: resource_object = BatchJobObject() else: resource_object = GroupObject(self._resource_type) resource_object.set_id(resource_id, False) # set resource id if owner is not None: resource_object.set_owner_name(owner) # set resource name if resource_name is not None: resource_object.set_name(resource_name, False) # set resource name resource_object.set_phase(1) # set resource api action # return resource object return self._method_wrapper(resource_object)