[MGM] Support nova_net_id option when there are n+ Neutron networks

Change-Id: I99b6b9b8ff386ca77ce24e23ff1fa07b96546472
This commit is contained in:
Endre Karlson
2013-09-23 11:10:20 +02:00
parent 32022c6ac0
commit c48e51a155
3 changed files with 15 additions and 1 deletions

View File

@@ -78,6 +78,10 @@ Command Line Options
The image ID or name to use on new nodes spun up in the Nova API
.. option:: --nova_net_id <Neutron Network ID>
Specify which Neutron Network ID workers should be started with.
.. option:: --nova_image_size <NOVA_IMAGE_SIZE>
The flavor ID (image size ID) or name to use for new nodes spun up in

View File

@@ -114,6 +114,10 @@ def main():
'--nova_bypass_url',
help='use a different URL to the one supplied by the service'
)
options.parser.add_argument(
'--nova_net_id',
help="The ID of the network to put loadbalancer on"
"(Required if multiple Neutron networks)")
options.parser.add_argument(
'--gearman', action='append', metavar='HOST:PORT', default=[],
help='Gearman job servers'

View File

@@ -52,6 +52,7 @@ class Node(object):
self.secgroup = args.nova_secgroup
self.node_basename = args.node_basename
self.az = args.nova_az_name
self.net_id = args.nova_net_id
self.rm_fip_ignore_500 = args.rm_fip_ignore_500
# Replace '_' with '-' in basename
@@ -144,6 +145,11 @@ class Node(object):
node_name = '{0}-{1}'.format(self.node_basename, node_id)
else:
node_name = '{0}'.format(node_id)
networks = []
if self.net_id:
networks.append({"uuid": self.net_id})
body = {"server": {
"name": node_name,
"imageRef": self.image,
@@ -152,7 +158,7 @@ class Node(object):
"max_count": 1,
"min_count": 1,
"availability_zone": self.az,
"networks": [],
"networks": networks,
"security_groups": [{"name": self.secgroup}]
}}
resp, body = self.nova.post(url, body=body)