def command(xenhost, xenpass, devstackpass): xen = Server(xenhost, 'root', xenpass) while True: devstack_ip = get_devstack_ip(xen) if devstack_ip: break time.sleep(1) devstack = Server(devstack_ip, 'stack', devstackpass) logger.info("Waiting for devstack machine") devstack.wait_for_ssh() logger.info("Checking run.sh results") if is_run_sh_succeeded(devstack): logger.info("run.sh succeeded") else: logger.info("run.sh failed, trying to fix it") if rabbit_is_failing(devstack): logger.info("rabbitmq is not running, restarting it") restart_rabbit(devstack) time.sleep(5) logger.info("Starting run.sh") start_run_sh(devstack) assert is_run_sh_succeeded(devstack) logger.info("Devstack is up and running, disconnecting") disconnect_all()
def command(host, user, password): server = Server(host, user, password) server.disable_known_hosts = True try: server.run("cd devstack && ./exercise.sh") finally: disconnect_all()
def main(): logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser( description='Install a centos vm in XenServer') parser.add_argument('xshost', help='XenServer host') parser.add_argument('vmname', help='Name for the virtual machine') parser.add_argument( 'install_repo', help='Distro url used by XenServer') parser.add_argument('rootpwd', help='Password for the root user on the new system') parser.add_argument('--xspass', help='Password for XenServer') parser.add_argument( '--xsuser', help='Username for XenServer (root)', default="root") parser.add_argument( '--hddsize', help='Disk size for vm in Gigabytes (8)', default="8") parser.add_argument( '--networklabel', help='name-label of the network to connect the server to', default="Pool-wide network associated with eth0") parser.add_argument( '--kickstart', help='Kickstart file to use', default=None) parser.add_argument( '--memsize', help='Memory size in MiB (2048)', default="2048") args = parser.parse_args() log.info("Parameters:%s", args) try: create_centos(args) finally: disconnect_all()
def remove_main(): parser = argparse.ArgumentParser(description='Remove a pxeboot config') parser.add_argument('user', help='User for PXE Server') parser.add_argument('host', help='PXE Server') parser.add_argument('mac', help='Mac address (xx:xx:xx:xx:xx:xx)') args = parser.parse_args() remove_pxeboot_config(args.user, args.host, args.mac) boxes.disconnect_all()
def connect_network(): params = get_params(sys.argv[1:]) command = ConnectNetwork(params) try: command() except CommandFailure as e: sys.stderr.write(e.message + '\n') sys.exit(1) finally: disconnect_all()
def install_main(): parser = argparse.ArgumentParser(description='Install a pxeboot config') parser.add_argument('user', help='User for PXE Server') parser.add_argument('host', help='PXE Server') parser.add_argument('mac', help='Mac address (xx:xx:xx:xx:xx:xx)') parser.add_argument( 'pxe_file', help='the pxe file you want to put on the server') args = parser.parse_args() install_pxeboot_config(args.user, args.host, args.mac, args.pxe_file) boxes.disconnect_all()
def command(host, service, user, password): server = Server(host, user, password) server.disable_known_hosts = True try: tempfile = server.run('tempfile') server.run('echo -ne "\\003\\x10\\015" > %s' % tempfile) server.run('screen -S stack -X bufferfile %s' % tempfile) server.run('screen -S stack -X readbuf') server.run('screen -S stack -p %s -X paste .' % service) finally: disconnect_all()
def command(xenhost, xenpass, devstackpass, tempest_params, tempest_repo, tempest_branch, no_clone, devstack_ip, suite): if not devstack_ip: xen = Server(xenhost, 'root', xenpass) xen.disable_known_hosts = True while True: devstack_ip = get_devstack_ip(xen) if devstack_ip: break time.sleep(1) devstack = Server(devstack_ip, 'stack', devstackpass) devstack.disable_known_hosts = True do_clone = not no_clone if do_clone: devstack.run( "rm -rf /opt/stack/tempest") devstack.run( "cd /opt/stack && git clone %s" % tempest_repo) else: devstack.run( "cd /opt/stack/tempest && git pull") devstack.run( "cd /opt/stack/tempest && git checkout %s" % tempest_branch) devstack.run( "/opt/stack/devstack/tools/configure_tempest.sh") devstack.run( "sudo pip install -U nose || true") temp_ini_file = tempfile.NamedTemporaryFile(delete=False) temp_ini_file.close() tempest_conf = "/opt/stack/tempest/etc/tempest.conf" devstack.get(tempest_conf, temp_ini_file.name) edit_ini_file(temp_ini_file.name) devstack.put(temp_ini_file.name, tempest_conf) devstack.run( "rm -f " "/opt/stack/tempest/tempest/tests/compute/test_console_output.py") devstack.run( """cd /opt/stack/tempest && nosetests %s %s -v -e "test_change_server_password" """ % (suite, tempest_params)) disconnect_all()
def command(host, filename, user, password): server = Server(host, user, password) server.disable_known_hosts = True extra_config = sys.stdin.readlines() tmp = tempfile.NamedTemporaryFile(delete=False) tmp.file.close() try: server.get(filename, tmp.name) set_extra_config(tmp.name, extra_config) server.put(tmp.name, filename) finally: disconnect_all()
def install_xcp_xapi(user, password, host): target = boxes.Server(host, user, password) target.disable_known_hosts = True def line_by_line(cmds): for command in cmds.strip().split('\n'): target.run(command) target.wait_for_ssh() line_by_line(install_commands) line_by_line(post_install_fixes_1) boxes.disconnect_all() # Make sure, that the server rebooted time.sleep(120) target.wait_for_ssh() line_by_line(post_install_fixes_2) target.run(add_sr) # And a final reboot target.run("reboot") boxes.disconnect_all()
def main(): logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser(description="Install a debian -like vm in XenServer") parser.add_argument("host", help="XenServer host") parser.add_argument("preseed_file", help="Preseed file to use") parser.add_argument("vmname", help="Name for the virtual machine") parser.add_argument("usrpwd", help="Password for the user on the new system") parser.add_argument("--hddsize", help="Disk size for vm in Gigabytes (8)", default="8") parser.add_argument("--mac", help="MAC address for vm", default="") parser.add_argument("--fstype", help="Type of filesystem (ext4)", default="ext4") parser.add_argument("--xsuser", help="Username for XenServer (root)", default="root") parser.add_argument("--xspass", help="Password for XenServer") parser.add_argument("--packages", help="Comma separated list of additional packages", default="") parser.add_argument("--timezone", help="Timezone for the new system (Europe/London)", default="Europe/London") parser.add_argument("--ntpserver", help="NTP server to use (0.us.pool.ntp.org)", default="0.us.pool.ntp.org") parser.add_argument("--username", help="Name for the user on the new system (ubuntu)", default="ubuntu") parser.add_argument("--suite", help="Suite to install (precise)", default="precise") parser.add_argument( "--install_repo", help="Distro url used by XenServer (http://archive.ubuntu.com/ubuntu)", default="http://archive.ubuntu.com/ubuntu", ) parser.add_argument( "--httpmirrorhost", help="http mirror host used during installation (archive.ubuntu.com)", default="archive.ubuntu.com", ) parser.add_argument( "--httpmirrordirectory", help="http mirror directory used during installation (/ubuntu)", default="/ubuntu" ) parser.add_argument( "--aptcachernghost", help="A host that runs apt-cacher-ng - to speed up installation. It will override httpmirrorhost, install_repo", default="", ) parser.add_argument("--memsize", help="Memory size in MiB (2048)", default="2048") parser.add_argument("--bootoptions", help="Additional boot options", default="") parser.add_argument("--httpmirrorproxy", help="HTTP proxy to be used by XenServer", default="") parser.add_argument( "--networklabel", help="name-label of the network to connect the server to", default="Pool-wide network associated with eth0", ) parser.add_argument("--domain", help="Domain name to use", default="somedomain") args = parser.parse_args() if args.aptcachernghost: httpmirrorhost = args.aptcachernghost + ":3142" install_repo = "http://" + httpmirrorhost + "/archive.ubuntu.com" + args.httpmirrordirectory else: httpmirrorhost = args.httpmirrorhost install_repo = args.install_repo try: command( args.xsuser, args.xspass, args.host, args.suite, install_repo, args.preseed_file, args.vmname, args.hddsize, args.mac, args.fstype, args.usrpwd, args.packages, args.timezone, args.ntpserver, args.username, httpmirrorhost, args.httpmirrordirectory, args.memsize, args.bootoptions, args.httpmirrorproxy, args.networklabel, args.domain, ) finally: disconnect_all()