From d607bcceea464e722efe00035a31efd4fee0baa2 Mon Sep 17 00:00:00 2001 From: Sergio Maffioletti Date: Wed, 29 Aug 2018 15:23:01 +0200 Subject: [PATCH] Make `network_ids` truly optional in OpenStack resource (#644) Check that `network_ids` is defined before trying to use it for starting a VM; if it's not, just avoid setting the "nics" attribute in the OpenStack VM request. Fixes #643 . --- gc3libs/backends/openstack.py | 2 +- gc3libs/etc/gc3pie.conf.example | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gc3libs/backends/openstack.py b/gc3libs/backends/openstack.py index bb9b1134..cbfd0d9e 100755 --- a/gc3libs/backends/openstack.py +++ b/gc3libs/backends/openstack.py @@ -291,7 +291,7 @@ def _create_instance(self, image_id, name='gc3pie-instance', # groups nics = None - if self.network_ids: + if hasattr(self,'network_ids') and self.network_ids: nics=[{'net-id': netid.strip(), 'v4-fixed-ip': ''} for netid in self.network_ids.split(',')] gc3libs.log.debug("Specifying networks for vm %s: %s", diff --git a/gc3libs/etc/gc3pie.conf.example b/gc3libs/etc/gc3pie.conf.example index 43399eed..d2edbf7d 100644 --- a/gc3libs/etc/gc3pie.conf.example +++ b/gc3libs/etc/gc3pie.conf.example @@ -379,6 +379,15 @@ architecture=x64_64 # to_port is an integer (use -1 for icmp) # ipnetwork is a network specification in the form `IPaddr/netmask` (0.0.0.0/0 for any IP address) +# A comma separated list of network_ids to attach to the newly started +# instance. Network ids could be normally obtained through the openstack +# dashboard web interface or through the openstack CLI. +# The following entry is optional for openstack deployment with one default +# network. If multiple networks are available in the user's tenant, +# then `network_ids` must be specified otherwise GC3Pie will throw an +# UnrecoverableError and, therefore, won't be able to further proceed. +# +# network_ids = c86b320c-9542-4032-a951-c8a068894cc2 # 2) Start VMs using an EC2-compatible cloud infrastructure