Skip to content

Commit

Permalink
Make network_ids truly optional in OpenStack resource (#644)
Browse files Browse the repository at this point in the history
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 .
  • Loading branch information
smaffiol authored and riccardomurri committed Aug 29, 2018
1 parent 86fd1cf commit d607bcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gc3libs/backends/openstack.py
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions gc3libs/etc/gc3pie.conf.example
Expand Up @@ -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

Expand Down

0 comments on commit d607bcc

Please sign in to comment.