#!/usr/bin/python
#
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
from ganeti import compat
from ganeti import utils
from ganeti import errors
+from ganeti import netutils
_SHUTDOWN_CLUSTER = "cluster"
"snodes": "Secondary_Nodes", "admin_state": "Autostart",
"oper_state": "Running",
"oper_ram": "Memory", "disk_template": "Disk_template",
+ "oper_vcpus": "VCPUs",
"ip": "IP_address", "mac": "MAC_address",
"nic_mode": "NIC_Mode", "nic_link": "NIC_Link",
"bridge": "Bridge",
elif field == "oper_ram":
if val is None:
val = "(node down)"
+ elif field == "oper_vcpus":
+ if val is None:
+ val = "(node down)"
elif field == "sda_size" or field == "sdb_size":
if val is None:
val = "N/A"
op = opcodes.OpRenameInstance(instance_name=args[0],
new_name=args[1],
- ignore_ip=not opts.ip_check,
- check_name=opts.name_check)
- SubmitOrSend(op, opts)
+ ip_check=opts.ip_check,
+ name_check=opts.name_check)
+ result = SubmitOrSend(op, opts)
+
+ ToStdout("Instance '%s' renamed to '%s'", args[0], result)
+
return 0
if not AskUser(usertext):
return 1
- op = opcodes.OpMigrateInstance(instance_name=instance_name, live=opts.live,
+ # this should be removed once --non-live is deprecated
+ if not opts.live and opts.migration_mode is not None:
+ raise errors.OpPrereqError("Only one of the --non-live and "
+ "--migration-mode options can be passed",
+ errors.ECODE_INVAL)
+ if not opts.live: # --non-live passed
+ mode = constants.HT_MIGRATION_NONLIVE
+ else:
+ mode = opts.migration_mode
+
+ op = opcodes.OpMigrateInstance(instance_name=instance_name, mode=mode,
cleanup=opts.cleanup)
SubmitOpCode(op, cl=cl, opts=opts)
return 0
vnc_console_port = "%s:%s (display %s)" % (instance["pnode"],
port,
display)
- elif display > 0 and utils.IsValidIP4(vnc_bind_address):
+ elif display > 0 and netutils.IsValidIP4(vnc_bind_address):
vnc_console_port = ("%s:%s (node %s) (display %s)" %
(vnc_bind_address, port,
instance["pnode"], display))
" using the remote mirror (only for instances of type drbd)"),
'migrate': (
MigrateInstance, ARGS_ONE_INSTANCE,
- [FORCE_OPT, NONLIVE_OPT, CLEANUP_OPT],
+ [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT],
"[-f] <instance>", "Migrate instance to its secondary node"
" (only for instances of type drbd)"),
'move': (
"[<instance>...]",
"Lists the instances and their status. The available fields are"
" (see the man page for details): status, oper_state, oper_ram,"
- " name, os, pnode, snodes, admin_state, admin_ram, disk_template,"
- " ip, mac, nic_mode, nic_link, sda_size, sdb_size, vcpus, serial_no,"
+ " oper_vcpus, name, os, pnode, snodes, admin_state, admin_ram,"
+ " disk_template, ip, mac, nic_mode, nic_link, sda_size, sdb_size,"
+ " vcpus, serial_no,"
" nic.count, nic.mac/N, nic.ip/N, nic.mode/N, nic.link/N,"
" nic.macs, nic.ips, nic.modes, nic.links,"
" disk.count, disk.size/N, disk.sizes,"