Neutron support

Added configurations:
* use_neutron

If Neutron is enabled, management network id is
passed as a parameter, when instances are being
launched.

Instance's internal and management IPs are equal and
point to the first IP in a list of a specified
management network.

Model classes for Cluster and Cluster Template updated.

Implements blueprint add-neutron-support

Change-Id: If6e79327ab14bbc813175396cd7287c2a29149b0
This commit is contained in:
Nikita Konovalov 2013-08-27 19:58:31 +04:00
parent 843e563fc1
commit 89ea1a3515
7 changed files with 76 additions and 12 deletions

View File

@ -15,13 +15,17 @@
# 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.
# floating IPs will be exposed in service URLs. This option
# is ignored when "use_neutron" is set to True (boolean value)
#use_floating_ips=True
# The suffix of the node's FQDN. In nova-network that is
# dhcp_domain config parameter (string value)
#node_domain=novalocal
# Use Neutron or Nova Network (boolean value)
#use_neutron=false
# List of plugins to be loaded. Savanna preserves the order of
# the list when returning it. (list value)
plugins=vanilla,hdp

View File

@ -11,6 +11,21 @@
#port=8386
# 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
# The suffix of the node's FQDN. In nova-network that is
# dhcp_domain config parameter (string value)
#node_domain=novalocal
# Use Neutron or Nova Network (boolean value)
#use_neutron=false
#
# Options defined in savanna.main
#
@ -177,7 +192,8 @@
# 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)
# be exposed in service URLs. This option is ignored when
# "use_neutron" is set to True (boolean value)
#use_floating_ips=true
# The suffix of the node's FQDN. In nova-network that is
@ -256,4 +272,4 @@
#pool_timeout=<None>
# Total option count: 51
# Total option count: 53

View File

@ -33,11 +33,15 @@ cluster_node_opts = [
'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.'),
'floating IPs will be exposed in service URLs. This '
'option is ignored when "use_neutron" is set to True'),
cfg.StrOpt('node_domain',
default='novalocal',
help="The suffix of the node's FQDN. In nova-network that is "
"dhcp_domain config parameter")
"dhcp_domain config parameter"),
cfg.BoolOpt('use_neutron',
default=False,
help="Use Neutron or Nova Network")
]

View File

@ -53,6 +53,7 @@ class Cluster(mb.SavannaBase):
hadoop_version = sa.Column(sa.String(80), nullable=False)
cluster_configs = sa.Column(st.JsonDictType())
default_image_id = sa.Column(sa.String(36))
neutron_management_network = sa.Column(sa.String(36))
anti_affinity = sa.Column(st.JsonListType())
private_key = sa.Column(sa.Text, default=crypto.generate_private_key())
user_keypair_id = sa.Column(sa.String(80))
@ -144,6 +145,7 @@ class ClusterTemplate(mb.SavannaBase):
default_image_id = sa.Column(sa.String(36))
anti_affinity = sa.Column(st.JsonListType())
tenant_id = sa.Column(sa.String(36))
neutron_management_network = sa.Column(sa.String(36))
plugin_name = sa.Column(sa.String(80), nullable=False)
hadoop_version = sa.Column(sa.String(80), nullable=False)
node_groups = relationship('TemplatesRelation', cascade="all,delete",

View File

@ -14,6 +14,7 @@
# limitations under the License.
from novaclient import exceptions as nova_exceptions
from oslo.config import cfg
from savanna import conductor as c
from savanna import context
@ -27,6 +28,7 @@ from savanna.utils.openstack import nova
conductor = c.API
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -208,6 +210,16 @@ def _run_instance(cluster, node_group, idx, aa_groups, userdata):
# create instances only at hosts w/ no instances w/ aa-enabled processes
hints = {'different_host': list(set(aa_ids))} if aa_ids else None
if CONF.use_neutron:
net_id = cluster.neutron_management_network
nics = [{"net-id": net_id, "v4-fixed-ip": ""}]
nova_instance = nova.client().servers.create(
name, node_group.get_image_id(), node_group.flavor_id,
scheduler_hints=hints, userdata=userdata,
key_name=cluster.user_keypair_id,
nics=nics)
else:
nova_instance = nova.client().servers.create(
name, node_group.get_image_id(), node_group.flavor_id,
scheduler_hints=hints, userdata=userdata,

View File

@ -28,6 +28,31 @@ CONF = cfg.CONF
# NOTE(slukjanov): https://blueprints.launchpad.net/savanna?searchtext=ip
def init_instances_ips(instance, server):
if instance.internal_ip and instance.management_ip:
return True
if CONF.use_neutron:
return init_neutron_ips(instance, server)
else:
return init_nova_network_ips(instance, server)
def init_neutron_ips(instance, server):
ctx = context.ctx()
net_id = instance.node_group.cluster.neutron_management_network
net_name = nova.client().networks.get(net_id).label
internal_ip = server.networks.get(net_name, [None])[0]
management_ip = internal_ip
conductor.instance_update(ctx, instance, {"management_ip": management_ip,
"internal_ip": internal_ip})
return internal_ip
def init_nova_network_ips(instance, server):
"""Extracts internal and management ips.
As internal ip will be used the first ip from the nova networks CIDRs.
@ -36,9 +61,6 @@ def init_instances_ips(instance, server):
"""
ctx = context.ctx()
if instance.internal_ip and instance.management_ip:
return True
management_ip = instance.management_ip
internal_ip = instance.internal_ip

View File

@ -88,6 +88,10 @@ CLUSTER_TEMPLATE_SCHEMA = {
"description": {
"type": "string",
},
"neutron_management_network": {
"type": "string",
"format": "uuid"
},
},
"additionalProperties": False,
"required": [