summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-06-24 04:11:54 +0100
committerandy <github@anarkystic.com>2010-06-24 04:11:54 +0100
commit34f4fa8495bca4d971872e59d358195263e72bf7 (patch)
tree9ccce3fb4c932e5c0b3628c31b42f84e9808cceb
parent426f5777cc65a6e7ec2a539bf5def80aaf21cd75 (diff)
downloadnova-34f4fa8495bca4d971872e59d358195263e72bf7.tar.gz
nova-34f4fa8495bca4d971872e59d358195263e72bf7.tar.xz
nova-34f4fa8495bca4d971872e59d358195263e72bf7.zip
Adding cloudpipe and vpn data back in to network.py
-rw-r--r--nova/compute/network.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/nova/compute/network.py b/nova/compute/network.py
index 3001b1375..4489f26d4 100644
--- a/nova/compute/network.py
+++ b/nova/compute/network.py
@@ -48,6 +48,10 @@ flags.DEFINE_integer('network_size', 256,
'Number of addresses in each private subnet')
flags.DEFINE_string('public_range', '4.4.4.0/24', 'Public IP address block')
flags.DEFINE_string('private_range', '10.0.0.0/8', 'Private IP address block')
+flags.DEFINE_integer('cnt_vpn_clients', 5,
+ 'Number of addresses reserved for vpn clients')
+flags.DEFINE_integer('cloudpipe_start_port', 12000,
+ 'Starting port for mapped CloudPipe external ports')
logging.getLogger().setLevel(logging.DEBUG)
@@ -135,7 +139,9 @@ class BaseNetwork(datastore.RedisModel):
@property
def available(self):
- for idx in range(3, len(self.network) - 1):
+ # the .2 address is always CloudPipe
+ # and the top <n> are for vpn clients
+ for idx in range(3, len(self.network)-(1 + FLAGS.cnt_vpn_clients)):
address = str(self.network[idx])
if not address in self.hosts.keys():
yield str(address)
@@ -210,7 +216,7 @@ class DHCPNetwork(BridgedNetwork):
logging.debug("Initing DHCPNetwork object...")
self.dhcp_listen_address = self.network[1]
self.dhcp_range_start = self.network[3]
- self.dhcp_range_end = self.network[-1]
+ self.dhcp_range_end = self.network[-(1 + FLAGS.cnt_vpn_clients)]
try:
os.makedirs(FLAGS.networks_path)
except Exception, err:
@@ -224,6 +230,20 @@ class DHCPNetwork(BridgedNetwork):
linux_net.start_dnsmasq(self)
else:
logging.debug("Not launching dnsmasq: no hosts.")
+ self.express_cloudpipe()
+
+ def allocate_vpn_ip(self, mac):
+ address = str(self.network[2])
+ self._add_host(self['user_id'], self['project_id'], address, mac)
+ self.express(address=address)
+ return address
+
+ def express_cloudpipe(self):
+ private_ip = self.network[2]
+ linux_net.confirm_rule("FORWARD -d %s -p udp --dport 1194 -j ACCEPT"
+ % (private_ip, ))
+ linux_net.confirm_rule("PREROUTING -t nat -d %s -p udp --dport %s -j DNAT --to %s:1194"
+ % (self.project.vpn_ip, self.project.vpn_port, private_ip))
def deexpress(self, address=None):
# if this is the last address, stop dns
@@ -394,6 +414,9 @@ def get_network_by_address(address):
return net
raise exception.AddressNotAllocated()
+def allocate_vpn_ip(user_id, project_id, mac):
+ return get_project_network(project_id).allocate_vpn_ip(mac)
+
def allocate_ip(user_id, project_id, mac):
return get_project_network(project_id).allocate_ip(user_id, project_id, mac)