def install_devstack(fab_settings, string_descriptor, hostname, download_conf=False, ipversion="4", patch="", proxy="", quiet=False): verbose = [] if quiet: verbose = ['output', 'running', 'warnings'] with settings(**fab_settings), hide(*verbose): if exists("/etc/gai.conf"): append("/etc/gai.conf", "precedence ::ffff:0:0/96 100", use_sudo=True) if proxy: warn_if_fail(put(StringIO('Acquire::http::proxy "http://proxy.esl.cisco.com:8080/";'), "/etc/apt/apt.conf.d/00proxy", use_sudo=True)) warn_if_fail(put(StringIO('Acquire::http::Pipeline-Depth "0";'), "/etc/apt/apt.conf.d/00no_pipelining", use_sudo=True)) update_time(sudo) if ipversion != "4": sudo("/sbin/sysctl -w net.ipv6.conf.all.forwarding=1") append("/etc/sysctl.conf", "net.ipv6.conf.all.forwarding=1", use_sudo=True) warn_if_fail(sudo("apt-get update")) warn_if_fail(sudo("apt-get install -y git python-pip")) warn_if_fail(run("git config --global user.email '*****@*****.**';" "git config --global user.name 'Test Node'")) run("rm -rf ~/devstack") quit_if_fail(run("git clone https://github.com/openstack-dev/devstack.git")) if patch: warn_if_fail(run("git fetch https://review.openstack.org/openstack-dev/devstack {patch} " "&& git cherry-pick FETCH_HEAD".format(patch))) warn_if_fail(put(string_descriptor, "devstack/local.conf", use_sudo=False)) with cd("devstack"): warn_if_fail(run("./stack.sh")) if download_conf: get('~/devstack/openrc', "./openrc") get('/opt/stack/tempest/etc/tempest.conf', "./tempest.conf") collect_logs(run, hostname)
def install_devstack(settings_dict, envs=None, verbose=None, proxy=None, patch=False, opts=None): envs = envs or {} verbose = verbose or [] with settings(**settings_dict), hide(*verbose), shell_env(**envs): if exists("/etc/gai.conf"): append("/etc/gai.conf", "precedence ::ffff:0:0/96 100", use_sudo=True) if proxy: warn_if_fail(put(StringIO('Acquire::http::proxy "http://proxy.esl.cisco.com:8080/";'), "/etc/apt/apt.conf.d/00proxy", use_sudo=True)) warn_if_fail(put(StringIO('Acquire::http::Pipeline-Depth "0";'), "/etc/apt/apt.conf.d/00no_pipelining", use_sudo=True)) update_time(sudo) if opts.ipversion != 4: sudo("/sbin/sysctl -w net.ipv6.conf.all.forwarding=1") append("/etc/sysctl.conf", "net.ipv6.conf.all.forwarding=1", use_sudo=True) warn_if_fail(sudo("apt-get update")) warn_if_fail(sudo("apt-get install -y git python-pip")) warn_if_fail(run("git config --global user.email '*****@*****.**';" "git config --global user.name 'Test Node'")) run("rm -rf ~/devstack") quit_if_fail(run("git clone https://github.com/openstack-dev/devstack.git")) make_local("devstack/local.conf", sudo_flag=False, opts=opts) with cd("devstack"): warn_if_fail(run("./stack.sh")) if patch: apply_changes() if exists('~/devstack/openrc'): get('~/devstack/openrc', "./openrc") else: print (red("No openrc file, something went wrong! :(")) if exists('/opt/stack/tempest/etc/tempest.conf'): get('/opt/stack/tempest/etc/tempest.conf', "./tempest.conf") else: print (red("No openrc file, something went wrong! :(")) print (green("Finished!")) return True
def install(aggregated_configs, apt_cacher_proxy=None, patch="", proxy="", devstack_repo="", devstack_br="", quiet=False): verbose = [] fab_settings = aggregated_configs[env.host]["fab_settings"] local_conf = aggregated_configs[env.host]["devstack_config"] config_files = aggregated_configs[env.host]["config_files"] hostname = aggregated_configs[env.host]["hostname"] exec_command_before = aggregated_configs[env.host]["exec_commands_before"] exec_command_after = aggregated_configs[env.host]["exec_commands_after"] if quiet: verbose = ['output', 'running', 'warnings'] with settings(**fab_settings), hide(*verbose): if exists("/etc/gai.conf"): append("/etc/gai.conf", "precedence ::ffff:0:0/96 100", use_sudo=True) if proxy: warn_if_fail(put(StringIO( 'Acquire::http::proxy "http://proxy.esl.cisco.com:8080/";'), "/etc/apt/apt.conf.d/00proxy", use_sudo=True)) warn_if_fail(put(StringIO('Acquire::http::Pipeline-Depth "0";'), "/etc/apt/apt.conf.d/00no_pipelining", use_sudo=True)) if apt_cacher_proxy: warn_if_fail( put(StringIO('Acquire::http { Proxy "{url}"; };'.format( url=apt_cacher_proxy)), "/etc/apt/apt.conf.d/02proxy", use_sudo=True)) update_time(sudo) warn_if_fail(sudo("apt-get update")) warn_if_fail(sudo("apt-get install -y git python-pip")) warn_if_fail( run("git config --global user.email '*****@*****.**';" "git config --global user.name 'Test Node'")) if exists("devstack"): with cd("devstack"): warn_if_fail(run("./unstack.sh")) run("rm -rf ~/devstack") quit_if_fail(run( "git clone -b {branch} {devstack}".format(devstack=devstack_repo, branch=devstack_br))) if patch: with cd("devstack"): warn_if_fail( run( "git fetch https://review.openstack.org/openstack-dev/devstack {patch} " "&& git cherry-pick FETCH_HEAD".format(patch=patch))) warn_if_fail(put(StringIO(local_conf), "devstack/local.conf")) if exec_command_before: run(exec_command_before) if config_files: for path, conf_file in config_files.iteritems(): warn_if_fail(put(StringIO(conf_file), path)) with cd("devstack"): warn_if_fail(run("./stack.sh")) path = os.environ.get("WORKSPACE", os.getcwd()) if os.path.exists( "{path}/id_rsa_{key}".format(path=path, key=hostname)): path = os.environ.get("WORKSPACE", os.getcwd()) put("{path}/id_rsa_{key}".format(path=path, key=hostname), "~/.ssh/id_rsa") put("{path}/id_rsa_{key}.pub".format(path=path, key=hostname), "~/.ssh/id_rsa.pub") put("{0}/id_rsa_all.pub".format(path), "/tmp/all_authorized") warn_if_fail(run("chmod 500 ~/.ssh/id_rsa")) warn_if_fail( run("cat /tmp/all_authorized >> ~/.ssh/authorized_keys")) append("/etc/ssh/ssh_config", "\nStrictHostKeyChecking no\nUserKnownHostsFile=/dev/null", use_sudo=True) if exec_command_after: run(exec_command_after) collect_logs(run, hostname) collect_logs_devstack("install_{host}".format(host=hostname))