def deploy_cluster_config(bridge_id, do_vlan=True, phydev="bond0"): script_path = os.path.realpath(sys.argv[0]) for node in vmcConfig().cluster_nodes: print("") pinfo("Create on %s" % node) if do_vlan: call(["ssh", "-l", "root", node, "%s -b %d -i %s -c" % (script_path, bridge_id, phydev)]) else: call(["ssh", "-l", "root", node, "%s -b %d" % (script_path, bridge_id)])
def main(): if os.getuid() != 0: die("You have to run this script as root.") conf = vmcConfig() vm = vmcVM() # Configure VM object vm.set_default(conf) if len(sys.argv) <= 1: usage(vm) sys.exit(2) try: opts, args = getopt.getopt(sys.argv[1:], "a:b:d:n:m:c:s:r:f:l:ph") except getopt.GetoptError, e: print (str(e)) usage(vm) sys.exit(2)
print ("""Usage : %s LIBVIRT_DOMAIN Undefine libvirt domain on all cluster nodes -h, --help Display help information """ % os.path.basename(sys.argv[0])) try: toundefine = sys.argv[1] if toundefine == "--help" or toundefine == "-h": usage() except: usage() sys.exit(1) conf = vmcConfig() if conf.do_cluster: # Check if the domain is running somewhere # And undefine everywhere for h in conf.cluster_nodes: conn = libvirt.open("qemu+ssh://" + h + "/system") try: dom = conn.lookupByName(toundefine) except: perror("\"%s\" domain isn't defined on %s" % (toundefine, h)) dom = None pass if not dom == None: if dom.isActive():
OPTIONS -h, --help Display help information -f, --fqdn Print FQDN cluster name -n, --no-nl Print all names on the same line """ % os.path.basename(sys.argv[0])) try: for arg in sys.argv: if arg == "--help" or arg == "-h": usage() sys.exit(0) if arg == "--fqdn" or arg == "-f": print_fqdn = True if arg == "--no-nl" or arg == "-n": print_nl = False except: pass vm = vmcConfig() if print_fqdn == True: nodes = ['%s.accelance.net' % (x,) for x in vm.cluster_nodes] else: nodes = vm.cluster_nodes if print_nl == True: print('\n'.join(nodes)) else: print(' '.join(nodes))