diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-15 16:50:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-15 16:50:45 +0000 |
| commit | 6f924bbeb0dd66f3c5ba2465099f23069d2cacf2 (patch) | |
| tree | 0d103f3066904d97e9f6c307c10bfc2bfbcc38f9 /nova/api | |
| parent | 35c12feb8c9467b9b4a7eac7a3f3d63bd620a35b (diff) | |
| parent | 51ad3d4ee9f28184510a2802867535284c0f1b8b (diff) | |
Merge "Adding port attribute in network parameter of boot."
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 99d48d8a6..0c5a2e530 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -197,6 +197,8 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer): item["uuid"] = network_node.getAttribute("uuid") if network_node.hasAttribute("fixed_ip"): item["fixed_ip"] = network_node.getAttribute("fixed_ip") + if network_node.hasAttribute("port"): + item["port"] = network_node.getAttribute("port") networks.append(item) return networks else: @@ -498,14 +500,31 @@ class Controller(wsgi.Controller): injected_files.append((path, contents)) return injected_files + def _is_quantum_v2(self): + return FLAGS.network_api_class ==\ + "nova.network.quantumv2.api.API" + def _get_requested_networks(self, requested_networks): """Create a list of requested networks from the networks attribute.""" networks = [] for network in requested_networks: try: - network_uuid = network['uuid'] + port_id = network.get('port', None) + if port_id: + network_uuid = None + if not self._is_quantum_v2(): + # port parameter is only for qunatum v2.0 + msg = _("Unknown argment : port") + raise exc.HTTPBadRequest(explanation=msg) + if not utils.is_uuid_like(port_id): + msg = _("Bad port format: port uuid is " + "not in proper format " + "(%s)") % port_id + raise exc.HTTPBadRequest(explanation=msg) + else: + network_uuid = network['uuid'] - if not utils.is_uuid_like(network_uuid): + if not port_id and not utils.is_uuid_like(network_uuid): br_uuid = network_uuid.split('-', 1)[-1] if not utils.is_uuid_like(br_uuid): msg = _("Bad networks format: network uuid is " @@ -520,16 +539,22 @@ class Controller(wsgi.Controller): if address is not None and not utils.is_valid_ipv4(address): msg = _("Invalid fixed IP address (%s)") % address raise exc.HTTPBadRequest(explanation=msg) - # check if the network id is already present in the list, - # we don't want duplicate networks to be passed - # at the boot time - for id, ip in networks: - if id == network_uuid: - expl = (_("Duplicate networks (%s) are not allowed") % - network_uuid) - raise exc.HTTPBadRequest(explanation=expl) - - networks.append((network_uuid, address)) + + # For quantumv2, requestd_networks + # should be tuple of (network_uuid, fixed_ip, port_id) + if self._is_quantum_v2(): + networks.append((network_uuid, address, port_id)) + else: + # check if the network id is already present in the list, + # we don't want duplicate networks to be passed + # at the boot time + for id, ip in networks: + if id == network_uuid: + expl = (_("Duplicate networks" + " (%s) are not allowed") % + network_uuid) + raise exc.HTTPBadRequest(explanation=expl) + networks.append((network_uuid, address)) except KeyError as key: expl = _('Bad network format: missing %s') % key raise exc.HTTPBadRequest(explanation=expl) |
