diff options
| author | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-06 11:25:40 -0800 |
|---|---|---|
| committer | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-21 17:09:29 -0800 |
| commit | 9c6bf7cf462346ed9379ff217774e2787e64f5f5 (patch) | |
| tree | cd1e9e432a70981d7ccddac4df30e6a9fdbd83aa /nova | |
| parent | adaf9049c8fb3652c0962909a3c835e1724d8a17 (diff) | |
Support fixed_ip range that is a subnet of the network block
This enables flat deployments where the instances live on the
'general' network. For example, a typical home router uses
192.168.0.0/16 for the private network. Cloud machines can be
assigned 192.168.100.0/24. An example network create command:
nova-manage network create private 192.168.0.0/16 1 65536 \
--fixed_cidr=192.168.100.0/24 --gateway=192.168.1.1
Change-Id: I17edd81e9bc21ca3320233b606c99e03e25201bc
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/network/manager.py | 14 | ||||
| -rw-r--r-- | nova/tests/fake_network.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_network.py | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py index d171b0489..493cdbe1b 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -1223,7 +1223,8 @@ class NetworkManager(manager.SchedulerDependentManager): def create_networks(self, context, label, cidr, multi_host, num_networks, network_size, cidr_v6, gateway, gateway_v6, bridge, - bridge_interface, dns1=None, dns2=None, **kwargs): + bridge_interface, dns1=None, dns2=None, + fixed_cidr=None, **kwargs): """Create networks based on parameters.""" # NOTE(jkoelker): these are dummy values to make sure iter works # TODO(tr3buchet): disallow carving up networks @@ -1353,7 +1354,7 @@ class NetworkManager(manager.SchedulerDependentManager): networks.append(network) if network and cidr and subnet_v4: - self._create_fixed_ips(context, network['id']) + self._create_fixed_ips(context, network['id'], fixed_cidr) return networks @wrap_check_policy @@ -1381,18 +1382,19 @@ class NetworkManager(manager.SchedulerDependentManager): """Number of reserved ips at the top of the range.""" return 1 # broadcast - def _create_fixed_ips(self, context, network_id): + def _create_fixed_ips(self, context, network_id, fixed_cidr=None): """Create all fixed ips for network.""" network = self._get_network_by_id(context, network_id) # NOTE(vish): Should these be properties of the network as opposed # to properties of the manager class? bottom_reserved = self._bottom_reserved_ips top_reserved = self._top_reserved_ips - project_net = netaddr.IPNetwork(network['cidr']) - num_ips = len(project_net) + if not fixed_cidr: + fixed_cidr = netaddr.IPNetwork(network['cidr']) + num_ips = len(fixed_cidr) ips = [] for index in range(num_ips): - address = str(project_net[index]) + address = str(fixed_cidr[index]) if index < bottom_reserved or num_ips - index <= top_reserved: reserved = True else: diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 3eccf9703..5ab4c74cb 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -150,7 +150,7 @@ class FakeNetworkManager(network_manager.NetworkManager): def deallocate_fixed_ip(self, context, address): self.deallocate_called = address - def _create_fixed_ips(self, context, network_id): + def _create_fixed_ips(self, context, network_id, fixed_cidr=None): pass diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 832aaca91..7b4269463 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -849,7 +849,7 @@ class CommonNetworkTestCase(test.TestCase): super(CommonNetworkTestCase, self).setUp() self.context = context.RequestContext('fake', 'fake') - def fake_create_fixed_ips(self, context, network_id): + def fake_create_fixed_ips(self, context, network_id, fixed_cidr=None): return None def test_remove_fixed_ip_from_instance(self): |
