def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = AgentResponse() try: dirname = os.path.dirname(cmd.installUrl) if not os.path.exists(dirname): os.makedirs(dirname) if cmd.backingFile: linux.qcow2_create_with_backing_file(cmd.backingFile, cmd.installUrl) else: linux.qcow2_create(cmd.installUrl, cmd.size) except Exception as e: logger.warn(linux.get_exception_stacktrace()) rsp.error = 'unable to create empty volume[uuid:%s, name:%s], %s' % ( cmd.uuid, cmd.name, str(e)) rsp.success = False return jsonobject.dumps(rsp) logger.debug( 'successfully create empty volume[uuid:%s, size:%s] at %s' % (cmd.volumeUuid, cmd.size, cmd.installUrl)) rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity() return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = CreateEmptyVolumeResponse() try: dirname = os.path.dirname(cmd.installUrl) if not os.path.exists(dirname): os.makedirs(dirname) linux.qcow2_create(cmd.installUrl, cmd.size) except Exception as e: logger.warn(linux.get_exception_stacktrace()) rsp.error = 'unable to create empty volume[uuid:%s, name:%s], %s' % ( cmd.uuid, cmd.name, str(e)) rsp.success = False return jsonobject.dumps(rsp) meta = VolumeMeta() meta.account_uuid = cmd.accountUuid meta.hypervisor_type = cmd.hypervisorType meta.name = cmd.name meta.uuid = cmd.volumeUuid meta.size = cmd.size meta_path = self._json_meta_file_name(cmd.installUrl) with open(meta_path, 'w') as fd: fd.write(jsonobject.dumps(meta, pretty=True)) self._set_capacity_to_response(cmd.uuid, rsp) logger.debug( 'successfully create empty volume[uuid:%s, name:%s, size:%s] at %s' % (cmd.uuid, cmd.name, cmd.size, cmd.installUrl)) return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = CreateEmptyVolumeResponse() try: dirname = os.path.dirname(cmd.installUrl) if not os.path.exists(dirname): os.makedirs(dirname) linux.qcow2_create(cmd.installUrl, cmd.size) except Exception as e: logger.warn(linux.get_exception_stacktrace()) rsp.error = 'unable to create empty volume[uuid:%s, name:%s], %s' % (cmd.uuid, cmd.name, str(e)) rsp.success = False return jsonobject.dumps(rsp) meta = VolumeMeta() meta.account_uuid = cmd.accountUuid meta.hypervisor_type = cmd.hypervisorType meta.name = cmd.name meta.uuid = cmd.volumeUuid meta.size = cmd.size meta_path = self._json_meta_file_name(cmd.installUrl) with open(meta_path, 'w') as fd: fd.write(jsonobject.dumps(meta, pretty=True)) self._set_capacity_to_response(cmd.uuid, rsp) logger.debug('successfully create empty volume[uuid:%s, name:%s, size:%s] at %s' % (cmd.uuid, cmd.name, cmd.size, cmd.installUrl)) return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = AgentRsp() dirname = os.path.dirname(cmd.installPath) if not os.path.exists(dirname): os.makedirs(dirname) if cmd.backingFile: linux.qcow2_create_with_backing_file(cmd.backingFile, cmd.installPath) else: linux.qcow2_create(cmd.installPath, cmd.size) logger.debug('successfully create empty volume[uuid:%s, size:%s] at %s' % (cmd.volumeUuid, cmd.size, cmd.installPath)) rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity() return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = AgentRsp() dirname = os.path.dirname(cmd.installPath) if not os.path.exists(dirname): os.makedirs(dirname) if cmd.backingFile: linux.qcow2_create_with_backing_file(cmd.backingFile, cmd.installPath) else: linux.qcow2_create(cmd.installPath, cmd.size) logger.debug('successfully create empty volume[uuid:%s, size:%s] at %s' % (cmd.volumeUuid, cmd.size, cmd.installPath)) rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity(cmd.mountPoint) return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = AgentResponse() try: dirname = os.path.dirname(cmd.installUrl) if not os.path.exists(dirname): os.makedirs(dirname) linux.qcow2_create(cmd.installUrl, cmd.size) except Exception as e: logger.warn(linux.get_exception_stacktrace()) rsp.error = 'unable to create empty volume[uuid:%s, name:%s], %s' % (cmd.uuid, cmd.name, str(e)) rsp.success = False return jsonobject.dumps(rsp) logger.debug('successfully create empty volume[uuid:%s, size:%s] at %s' % (cmd.volumeUuid, cmd.size, cmd.installUrl)) return jsonobject.dumps(rsp)
def create_empty_volume(self, req): cmd = jsonobject.loads(req[http.REQUEST_BODY]) rsp = AgentResponse() try: dirname = os.path.dirname(cmd.installUrl) if not os.path.exists(dirname): os.makedirs(dirname) if cmd.backingFile: linux.qcow2_create_with_backing_file(cmd.backingFile, cmd.installUrl) else: linux.qcow2_create(cmd.installUrl, cmd.size) except Exception as e: logger.warn(linux.get_exception_stacktrace()) rsp.error = "unable to create empty volume[uuid:%s, name:%s], %s" % (cmd.uuid, cmd.name, str(e)) rsp.success = False return jsonobject.dumps(rsp) logger.debug( "successfully create empty volume[uuid:%s, size:%s] at %s" % (cmd.volumeUuid, cmd.size, cmd.installUrl) ) rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity() return jsonobject.dumps(rsp)