From 75affe206e4c3f42197581533cbca42b16a40748 Mon Sep 17 00:00:00 2001 From: Dmitry Mescheryakov Date: Tue, 2 Apr 2013 16:35:02 +0400 Subject: [PATCH] Introduced new networking option for cluster Now Savanna can provision cluster without floating IPs. Also removed 'apt-get install xsltproc' crutch from the setup script Change-Id: I9240fe7402a398f5642823d87edc2408129eec2d Fixes: bug #1163226 --- doc/source/quickstart.rst | 43 ++------------------- etc/savanna/savanna.conf.sample | 11 ++++-- etc/savanna/savanna.conf.sample-full | 24 ++++++------ savanna/main.py | 5 +-- savanna/resources/setup-general.sh.template | 1 - savanna/service/cluster_ops.py | 33 +++++++++++----- 6 files changed, 46 insertions(+), 71 deletions(-) diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst index d9a36d32..37b5d35e 100644 --- a/doc/source/quickstart.rst +++ b/doc/source/quickstart.rst @@ -7,11 +7,9 @@ Savanna quickstart guide 1.1 OpenStack environment (Folsom+ version) installed. -1.2 OpenStack compute has to have floating IP autoassigment. You can read more here: http://docs.openstack.org/trunk/openstack-compute/admin/content/associating-public-ip.html +1.2 Git should be installed on the machine where Savanna_API will be deployed. -1.3 Git should be installed on the machine where Savanna_API will be deployed. - -1.4 Your OpenStack should have flavors with 'm1.small' and 'm1.medium' names defined because these flavors are referenced by Savanna's default Node Templates. +1.3 Your OpenStack should have flavors with 'm1.small' and 'm1.medium' names defined because these flavors are referenced by Savanna's default Node Templates. You can check which flavors you have by running .. sourcecode:: bash @@ -100,42 +98,7 @@ You should see the output similar to the following: cp ./etc/savanna/savanna.conf.sample ./etc/savanna/savanna.conf -3.6 In savanna.conf you should edit the following parameters: - -.. sourcecode:: bash - - [DEFAULT] - - # REST API config - #port=8080 - #allow_cluster_ops=false - - # Address and credentials that will be used to check auth tokens - #os_auth_host=openstack - #os_auth_port=35357 - #os_admin_username=admin - #os_admin_password=nova - #os_admin_tenant_name=admin - - # Nova network name that will be used to access VMs - #nova_internal_net_name=novanetwork - - # (Optional) Name of log file to output to. If not set, - # logging will go to stdout. (string value) - #log_file= - - [cluster_node] - - # An existing user on Hadoop image (string value) - #username=root - - # User's password (string value) - #password=swordfish - - [sqlalchemy] - - # URL for sqlalchemy database (string value) - #database_uri=sqlite:////tmp/savanna-server.db +3.6 Look through the savanna.conf and change parameters which default values do not suite you. **Note:** Config file could be specified for ``savanna-api`` and ``savanna-manage`` commands using ``--config-file`` flag. diff --git a/etc/savanna/savanna.conf.sample b/etc/savanna/savanna.conf.sample index 0a6d3ca1..0952f871 100644 --- a/etc/savanna/savanna.conf.sample +++ b/etc/savanna/savanna.conf.sample @@ -11,9 +11,6 @@ #os_admin_password=nova #os_admin_tenant_name=admin -# Nova network name that will be used to access VMs -#nova_internal_net_name=novanetwork - # (Optional) Name of log file to output to. If not set, # logging will go to stdout. (string value) #log_file= @@ -26,6 +23,14 @@ # User's password (string value) #password=swordfish +# When set to false, Savanna uses only internal IP of VMs. +# When set to true, Savanna expects OpenStack to auto-assign +# floating IPs to cluster nodes. Internal IPs will be used for +# inter-cluster communication, while floating ones will be +# used by Savanna to configure nodes. Also floating IPs will +# be exposed in service URLs (boolean value) +#use_floating_ips=true + [sqlalchemy] # URL for sqlalchemy database (string value) diff --git a/etc/savanna/savanna.conf.sample-full b/etc/savanna/savanna.conf.sample-full index 476640e1..bf37003e 100644 --- a/etc/savanna/savanna.conf.sample-full +++ b/etc/savanna/savanna.conf.sample-full @@ -10,12 +10,6 @@ # set port (integer value) #port=8080 -# resets DB (boolean value) -#reset_db=false - -# populates DB with stub data (boolean value) -#stub_data=false - # without that option the application operates in dry run mode # and does not send any requests to the OpenStack cluster # (boolean value) @@ -48,10 +42,6 @@ # Name of tenant where the user is admin (string value) #os_admin_tenant_name=admin -# Name of network which IPs are given to the VMs (string -# value) -#nova_internal_net_name=novanetwork - # # Options defined in savanna.openstack.common.log @@ -165,18 +155,26 @@ # User's password (string value) #password=swordfish +# When set to false, Savanna uses only internal IP of VMs. +# When set to true, Savanna expects OpenStack to auto-assign +# floating IPs to cluster nodes. Internal IPs will be used for +# inter-cluster communication, while floating ones will be +# used by Savanna to configure nodes. Also floating IPs will +# be exposed in service URLs (boolean value) +#use_floating_ips=true + [sqlalchemy] # -# Options defined in savanna.main +# Options defined in savanna.storage.db # # URL for sqlalchemy database (string value) -#database_uri=sqlite:////tmp/savanna-server.db +#database_uri=sqlite:////tmp/savanna.db # Sqlalchemy echo (boolean value) #echo=false -# Total option count: 40 +# Total option count: 37 diff --git a/savanna/main.py b/savanna/main.py index 3adff071..13c25998 100644 --- a/savanna/main.py +++ b/savanna/main.py @@ -53,10 +53,7 @@ opts = [ help='Password of the admin user'), cfg.StrOpt('os_admin_tenant_name', default='admin', - help='Name of tenant where the user is admin'), - cfg.StrOpt('nova_internal_net_name', - default='novanetwork', - help='Name of network which IPs are given to the VMs') + help='Name of tenant where the user is admin') ] CONF = cfg.CONF diff --git a/savanna/resources/setup-general.sh.template b/savanna/resources/setup-general.sh.template index 90729447..2ef7e50a 100644 --- a/savanna/resources/setup-general.sh.template +++ b/savanna/resources/setup-general.sh.template @@ -23,7 +23,6 @@ mv /tmp/hadoop-env.sh /etc/hadoop/hadoop-env.sh echo "----- Setting up Hadoop config through XSLT" -apt-get install -y xsltproc xsltproc /tmp/savanna-hadoop-cfg.xsl /etc/hadoop/core-site.xml | tee /tmp/core-site.xml mv /tmp/core-site.xml /etc/hadoop/core-site.xml xsltproc /tmp/savanna-hadoop-cfg.xsl /etc/hadoop/mapred-site.xml | tee /tmp/mapred-site.xml diff --git a/savanna/service/cluster_ops.py b/savanna/service/cluster_ops.py index fcc4f762..a201c7af 100644 --- a/savanna/service/cluster_ops.py +++ b/savanna/service/cluster_ops.py @@ -37,11 +37,18 @@ cluster_node_opts = [ help='An existing user on Hadoop image'), cfg.StrOpt('password', default='swordfish', - help='User\'s password') + help='User\'s password'), + cfg.BoolOpt('use_floating_ips', + default=True, + help='When set to false, Savanna uses only internal IP of VMs.' + ' When set to true, Savanna expects OpenStack to auto-' + 'assign floating IPs to cluster nodes. Internal IPs will ' + 'be used for inter-cluster communication, while floating ' + 'ones will be used by Savanna to configure nodes. Also ' + 'floating IPs will be exposed in service URLs') ] CONF.register_opts(cluster_node_opts, 'cluster_node') -#CONF.import_opt('nova_internal_net_name', 'savanna.main') def _find_by_id(lst, id): @@ -211,24 +218,30 @@ def _check_if_up(nova, node): srv = _find_by_id(nova.servers.list(), node['id']) nets = srv.networks - if CONF.nova_internal_net_name not in nets: + if len(nets) == 0: # VM's networking is not configured yet return - ips = nets[CONF.nova_internal_net_name] - if len(ips) < 2: - # public IP is not assigned yet - return + ips = nets.values()[0] - # we assume that public floating IP comes last in the list - node['ip'] = ips[-1] + if CONF.cluster_node.use_floating_ips: + if len(ips) < 2: + # floating IP is not assigned yet + return + + # we assume that floating IP comes last in the list + node['ip'] = ips[-1] + else: + if len(ips) < 1: + # private IP is not assigned yet + return + node['ip'] = ips[0] try: ret = _execute_command_on_node(node['ip'], 'ls -l /') _ensure_zero(ret) except Exception: # ssh is not up yet - # TODO(dmescheryakov) log error that takes > 5 minutes to start-up return node['is_up'] = True