+ if command == 'renumber':
+ connect()
+ machine = models.Machine.query.filter_by(name=machine_name).one()
+ renumber = 0
+ for n in machine.nics:
+ if n.other_action and n.other_action == 'renumber_dhcp':
+ n.other_action = 'renumber'
+ session.add(n)
+ session.flush()
+ renumber += 1
+ print "IP %s is set to be renumbered to %s with netmask %s and gateway %s the next time '%s' is powered on." % (n.ip, n.other_ip, n.other_netmask, n.other_gateway, machine_name)
+ else:
+ print 'IP %s is not currently slated to be renumbered.' % (n.ip)
+ if not renumber:
+ print >>sys.stderr, "machine '%s' is not currently slated to be renumbered" % (machine_name)
+ return 1
+ if not host:
+ print "'%s' does not appear to be running currently. You should" % (machine_name)
+ print "turn it on and ensure that it is either configured to use"
+ print "DHCP or statically configured with the new IP address(es),"
+ print "netmask(s), and gateway(s) above, and verify that it is"
+ print "working as expected."
+ return 0
+ run_control_remctl(host, [machine_name, 'shutdown'])
+ ret = count = 0
+ # 'xm list' returns 3 when the domain doesn't exist
+ while count < 6 and ret != 3:
+ time.sleep(5)
+ # No sense using an expensive call to probe the whole cluster
+ # when we're just waiting for it to shut down and know where it is.
+ ret = run_control_remctl(host, [machine_name, 'list'], quiet=1)
+ if ret != 3:
+ print >>sys.stderr, "Could not shut down machine '%s' - you must turn it completely off, then turn it back on." % (machine_name)
+ return 2
+ print "Machine '%s' has been turned off. It will now be turned back on." % (machine_name)
+ # Now we'll do the expensive call just to be sure the user didn't
+ # turn it on somewhere else while we were waiting, as the next step
+ # here would corrupt its disk.
+ if not find_vm(machine_name):
+ return run_control_remctl(host, [machine_name, 'create'])
+ # If the user turned it back on themselves, at this point, that's ok.
+ return 0