def call_volume_command(): """Parse the arguments and call the required command""" log.log_call_argv() nfs = importlib.import_module("nfs-ng") cmd = xapi.storage.api.v5.volume.Volume_commandline( Implementation(nfs.Callbacks())) base = os.path.basename(sys.argv[0]) if base == "Volume.clone": cmd.clone() elif base == "Volume.create": cmd.create() elif base == "Volume.destroy": cmd.destroy() elif base == "Volume.resize": cmd.resize() elif base == "Volume.set": cmd.set() elif base == "Volume.set_description": cmd.set_description() elif base == "Volume.set_name": cmd.set_name() elif base == "Volume.snapshot": cmd.snapshot() elif base == "Volume.stat": cmd.stat() elif base == "Volume.unset": cmd.unset() else: raise xapi.storage.api.v5.volume.Unimplemented(base)
psize = current_size >> 2 # TODO(rck) hostname = socket.gethostname() stat = SRHelper.get_volume(sr, key) controller = cfg.controller[len('linstor://'):] stat['uri'] = [ '{}://{}/{};controller={}'.format(SCHEME, hostname, key, controller) ] stat['virtual_size'] = current_size stat['physical_utilisation'] = psize return stat if __name__ == "__main__": log.log_call_argv() cmd = xapi.storage.api.v5.volume.Volume_commandline(Implementation()) base = os.path.basename(sys.argv[0]) if base == "Volume.clone": cmd.clone() elif base == "Volume.create": cmd.create() elif base == "Volume.destroy": cmd.destroy() elif base == "Volume.resize": cmd.resize() elif base == "Volume.set": cmd.set() elif base == "Volume.set_description": cmd.set_description() elif base == "Volume.set_name":
fd.write("\n") return def destroy(self, dbg, sr): # no need to destroy anything return def detach(self, dbg, sr): u = urlparse.urlparse(sr) code = subprocess.call(["umount", u.path]) if code != 0: raise xapi.XenAPIException("DAVE", ["IS", "COOL"]) return if __name__ == "__main__": log.log_call_argv() cmd = xapi.storage.api.volume.SR_commandline(Implementation()) base = os.path.basename(sys.argv[0]) try: if base == "SR.probe": cmd.probe() elif base == "SR.stat": cmd.stat() elif base == "SR.attach": cmd.attach() elif base == "SR.create": cmd.create() elif base == "SR.set_name": cmd.set_name() elif base == "SR.set_description": cmd.set_description()