aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/scripts
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2006-11-01 10:12:13 +0000
committerEwan Mellor <ewan@xensource.com>2006-11-01 10:12:13 +0000
commit4ed8357baa35d6a8c28b06e9fa1579bea1909448 (patch)
tree3e3038aa14ad44834eec4ad105af57752a06bba6 /tools/python/scripts
parentc09512317b7aafe6a02a313fbf484e1fea2a8d54 (diff)
downloadxen-4ed8357baa35d6a8c28b06e9fa1579bea1909448.tar.gz
xen-4ed8357baa35d6a8c28b06e9fa1579bea1909448.tar.bz2
xen-4ed8357baa35d6a8c28b06e9fa1579bea1909448.zip
Import 83:b569bb25a8f08a15381b022ee143d7f205976604 from xen-api.hg, minus the
Makefile patch. [XEND] Remove blank image file generation for QCOW images. There is no need for a blank backing store, although this means we have to find a new way to determine how much virtual disk space is free in the StorageRepository. Beginnings to attempt to supoprt HVM guests. Signed-off-by: Alastair Tse <atse@xensource.com>
Diffstat (limited to 'tools/python/scripts')
-rw-r--r--tools/python/scripts/xapi.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/tools/python/scripts/xapi.py b/tools/python/scripts/xapi.py
index f44d37e13b..7801030557 100644
--- a/tools/python/scripts/xapi.py
+++ b/tools/python/scripts/xapi.py
@@ -61,7 +61,7 @@ OPTIONS = {
'vm-shutdown': [(('-f', '--force'), {'help': 'Shutdown Forcefully',
'action': 'store_true'})],
- 'vdi-create': [(('--label',), {'help': 'Name for VDI'}),
+ 'vdi-create': [(('--name-label',), {'help': 'Name for VDI'}),
(('--description',), {'help': 'Description for VDI'}),
(('--sector-size',), {'type': 'int',
'help': 'Sector size'}),
@@ -279,13 +279,17 @@ def xapi_vbd_create(*args):
raise OptionError("Configuration file and domain not specified")
domname = args[0]
- filename = args[1]
- cfg = _read_python_cfg(filename)
+ if len(args) > 1:
+ filename = args[1]
+ cfg = _read_python_cfg(filename)
+ else:
+ cfg = {}
+
for opt, val in opts:
cfg[opt] = val
- print 'Creating VBD from %s ..' % filename
+ print 'Creating VBD ...',
server, session = _connect()
vm_uuid = resolve_vm(server, session, domname)
cfg['VM'] = vm_uuid
@@ -335,10 +339,11 @@ def xapi_sr_list(*args):
def xapi_vdi_create(*args):
opts, args = parse_args('vdi-create', args)
- if len(args) < 1:
- raise OptionError("Not enough arguments.")
-
- cfg = _read_python_cfg(args[0])
+ if len(args) > 0:
+ cfg = _read_python_cfg(args[0])
+ else:
+ cfg = {}
+
for opt, val in opts:
cfg[opt] = val
@@ -348,7 +353,7 @@ def xapi_vdi_create(*args):
cfg['SR'] = sr
size = (cfg['virtual_size'] * cfg['sector_size'])/MB
- print 'Creating VDI of size: %dMB' % size
+ print 'Creating VDI of size: %dMB ..' % size,
uuid = execute(server.VDI.create, session, cfg)
print 'Done. (%s)' % uuid
@@ -378,6 +383,8 @@ def xapi_vdi_rename(*args):
# Command Line Utils
#
import cmd
+import shlex
+
class XenAPICmd(cmd.Cmd):
def __init__(self, server, session):
cmd.Cmd.__init__(self)
@@ -386,7 +393,7 @@ class XenAPICmd(cmd.Cmd):
self.prompt = ">>> "
def default(self, line):
- words = line.split()
+ words = shlex.split(line)
if len(words) > 0:
cmd_name = words[0].replace('-', '_')
func_name = 'xapi_%s' % cmd_name
@@ -415,11 +422,14 @@ class XenAPICmd(cmd.Cmd):
def do_help(self, line):
usage(print_usage = False)
+ def emptyline(self):
+ pass
+
def postcmd(self, stop, line):
return False
def precmd(self, line):
- words = line.split()
+ words = shlex.split(line)
if len(words) > 0:
words0 = words[0].replace('-', '_')
return ' '.join([words0] + words[1:])