def test_version_strings(self): linux_dist = version_config.get_linux_dist() self.assertTrue(linux_dist == version_config.LINUX_CENTOS or linux_dist == version_config.LINUX_UBUNTU) test_list = [ (("2:5.0", "201509090010.2f5a1d9"), "2:5.0.0-201509090010.2f5a1d9"), (("05.02", "0.0.201509011045.80d8d50"), "5.2.0-201509011045.80d8d50"), (("1.9.5", "rc3"), "1.9.5-rc3"), (("5.0", "0.0.201509011045.80d8d50.el7"), "5.0.0-201509011045.80d8d50"), (("1.8.9", "0.1.rc0.el7"), "1.8.9-rc0"), (("1.9.4", "rc0"), "1.9.4-rc0"), ] for args, expected in test_list: mn_version = version_config.parse_midolman_version(*args) self.assertEqual(expected, str(mn_version))
def test_vars(self): print version_config.ConfigMap.get_configured_parameter("mn_version", config_json=CFG_FILE) print version_config.ConfigMap.get_configured_parameter("cmd_list_datapath", config_json=CFG_FILE) print version_config.ConfigMap.get_configured_parameter("option_config_mnconf", config_json=CFG_FILE) print version_config.ConfigMap.get_configured_parameter("option_use_v2_stack", config_json=CFG_FILE) print version_config.get_linux_dist()
def install_packages(self, repo, exact_version=None): if repo.get_type() == "rpm": raise ArgMismatchException("Not yet supported on Redhat!") # neutron_dep_packages = ['mysql', 'rabbitmq-server'] # neutron_packages = ['openstack-neutron', 'python-neutronclient', 'openstack-neutron-ml2'] cli = LinuxCLI(log_cmd=True) cli.cmd("sudo debconf-set-selections <<< 'mysql-server-5.1 mysql-server/root_password password 'cat''") cli.cmd("sudo debconf-set-selections <<< 'mysql-server-5.1 mysql-server/root_password_again password 'cat''") if not repo.is_installed("mysql-server-5.5"): repo.install_packages(["mysql-server-5.5", "mysql-client-5.5", "python-mysqldb"]) cli.cmd("mysqladmin -u root password cat") cli.regex_file("/etc/mysql/my.cnf", "s/.*bind-address.*/bind-address = 127.0.0.1/") cli.regex_file("/etc/mysql/my.cnf", "s/.*max_connections.*/max_connections = 1024/") cli.cmd("service mysql start") if not repo.is_installed("rabbitmq-server"): repo.install_packages(["rabbitmq-server"]) cli.cmd("rabbitmqctl change_password guest cat") cli.cmd("service rabbitmq-server restart") if not repo.is_installed("neutron-server"): repo.install_packages( [ "neutron-server", "neutron-dhcp-agent", "python-neutronclient", "python-neutron-lbaas", "python-mysql.connector", ] ) cli.cmd('mysql --user=root --password=cat -e "CREATE DATABASE IF NOT EXISTS neutron"') cli.cmd("mysql --user=root --password=cat -e \"CREATE USER neutron@localhost IDENTIFIED BY 'cat'\"") cli.cmd("mysql --user=root --password=cat -e \"CREATE USER neutron@'%' IDENTIFIED BY 'cat'\"") cli.cmd('mysql --user=root --password=cat -e "GRANT ALL PRIVILEGES ON neutron.* TO neutron@localhost"') cli.cmd("mysql --user=root --password=cat -e \"GRANT ALL PRIVILEGES ON neutron.* TO neutron@'%'\"") version_config.get_installed_midolman_version() mn_api_url = version_config.ConfigMap.get_configured_parameter("param_midonet_api_url") cfg_file_str = ( "[DEFAULT]\n" "core_plugin = midonet.neutron.plugin_v2.MidonetPluginV2\n" "auth_strategy = noauth\n" "rpc_backend = neutron.openstack.common.rpc.impl_kombu\n" "rabbit_host = localhost\n" "rabbit_userid = guest\n" "rabbit_password = cat\n" "service_plugins = lbaas\n" "allow_overlapping_ips = True\n" "router_scheduler_driver =\n" "\n" "[agent]\n" "root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf\n" "\n" "[database]\n" "connection = mysql://neutron:cat@localhost/neutron\n" "\n" "[oslo_concurrency]\n" "lock_path = $state_path/lock\n" ) cli.write_to_file("/etc/neutron/neutron.conf", cfg_file_str) dhcp_ini_str = ( "[DEFAULT]\n" "interface_driver = neutron.agent.linux.interface.MidonetInterfaceDriver\n" "dhcp_driver = midonet.neutron.agent.midonet_driver.DhcpNoOpDriver\n" "use_namespaces = True\n" "dnsmasq_config_file = /etc/neutron/dnsmasq-neutron.conf\n" "enable_isolated_metadata = True\n" "\n" "[MIDONET]\n" "midonet_uri = " + mn_api_url + "\n" "username = admin\n" "password = cat\n" "project_id = admin\n" "auth_url = http://localhost:5000/v2.0\n" ) cli.write_to_file("/etc/neutron/dhcp_agent.ini", dhcp_ini_str) lbaas_cfg_str = ( "[service_providers]\n" "service_provider = LOADBALANCER:Midonet:" "midonet.neutron.services.loadbalancer.driver.MidonetLoadbalancerDriver:default\n" ) cli.write_to_file("/etc/neutron/neutron_lbaas.conf", lbaas_cfg_str) mn_plugin_str = ( "[DATABASE]\n" "sql_connection = mysql+mysqlconnector://neutron:cat@localhost/neutron\n" "sql_max_retries = 100\n" "[MIDONET]\n" "midonet_uri = " + mn_api_url + "\n" "username = admin\n" "password = cat\n" "project_id = admin\n" "auth_url = http://localhost:5000/v2.0\n" "provider_router_id =\n" ) cli.mkdir("/etc/neutron/plugins/midonet") cli.write_to_file("/etc/neutron/plugins/midonet/midonet_plugin.ini", mn_plugin_str) cli.rm("/etc/neutron/plugin.ini") cli.cmd("ln -s /etc/neutron/plugins/midonet/midonet_plugin.ini /etc/neutron/plugin.ini") if exact_version == "kilo" or exact_version is None: cli.cmd( "neutron-db-manage --config-file /etc/neutron/neutron.conf " "--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" ) cli.cmd("midonet-db-manage upgrade head") else: cli.cmd( "neutron-db-manage --config-file /etc/neutron/neutron.conf " "--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade " + exact_version ) cli.cmd("midonet-db-manage upgrade " + exact_version) cli.write_to_file("/etc/default/neutron-server", 'NEUTRON_PLUGIN_CONFIG="/etc/neutron/plugin.ini"\n') cli.cmd("service neutron-server restart") cli.cmd("service neutron-dhcp-agent restart") repo.install_packages( [ "neutron-server", "neutron-dhcp-agent", "python-neutronclient", "python-neutron-lbaas", "python-mysql.connector", ] )
server = env.artifactory_server for arg, value in arg_map: if arg in ('-h', '--help'): usage(None) sys.exit(0) elif arg in ('-i', '--install'): command = 'install' component = value elif arg in ('-u', '--uninstall'): command = 'uninstall' component = value elif arg in ('-V', '--version'): if value != 'nightly': exact_version = value version = version_config.parse_midolman_version(value) elif arg in ('-D', '--dist', '--distribution'): distribution = value elif arg in ('-U', '--user'): username = value elif arg in ('-P', '--pass'): password = value elif arg in ('-S', '--server'): server = value elif arg in ('-d', '--debug'): debug = True else: raise ArgMismatchException('Invalid argument' + arg) if command == 'install': print('Installing ' + component + " " + distribution)