def edit(self, request, id): """edit image online. this method is not very correct,change this if you can.""" """if HTTP_HOST is localhost,this will be failed,so use CONF.host instead. http_host=request.environ['HTTP_HOST'].rpartition(":")[0] """ http_host = CONF.host name = utils.random_str() port = 17698 image_instance = self.db.get_image(id) if image_instance: image_uuid = image_instance.uuid kwargs = {"Image": image_uuid} """this method should not be ina greenthread cause it is beatter to prepare edit before client to connect. TODO: change this if you can. self._manager.edit(kwargs, http_host, name, port) """ #eventlet.spawn_n(self._manager.edit, # kwargs, # http_host, # name, # port) self._process_task(self._manager.edit, kwargs, http_host, name, port) response = {"url":"http://%s:%s" % \ (http_host,port), "name": name} return ResponseObject(response)
def get_random_name(self): return utils.random_str(10)