Simple Network avoids vlans
This commit is contained in:
@@ -58,6 +58,13 @@ flags.DEFINE_integer('cnt_vpn_clients', 5,
|
||||
flags.DEFINE_integer('cloudpipe_start_port', 12000,
|
||||
'Starting port for mapped CloudPipe external ports')
|
||||
|
||||
flags.DEFINE_boolean('simple_network', False,
|
||||
'Use simple networking instead of vlans')
|
||||
flags.DEFINE_string('simple_network_bridge', 'br100',
|
||||
'Bridge for instances')
|
||||
flags.DEFINE_list('simple_network_ips', ['192.168.1.1'],
|
||||
'Available ips for network')
|
||||
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
# CLEANUP:
|
||||
@@ -418,6 +425,20 @@ def get_network_by_address(address):
|
||||
return net
|
||||
raise exception.AddressNotAllocated()
|
||||
|
||||
def allocate_simple_ip():
|
||||
redis = datastore.Redis.instance()
|
||||
if not redis.exists('ips') and not len(redis.keys('instances:*')):
|
||||
for address in FLAGS.simple_network_ips:
|
||||
redis.sadd('ips', address)
|
||||
address = redis.spop('ips')
|
||||
if not address:
|
||||
raise exception.NoMoreAddresses()
|
||||
return address
|
||||
|
||||
def deallocate_simple_ip(address):
|
||||
datastore.Redis.instance().sadd('ips', address)
|
||||
|
||||
|
||||
def allocate_vpn_ip(user_id, project_id, mac):
|
||||
return get_project_network(project_id).allocate_vpn_ip(mac)
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ from nova.objectstore import image # for image_path flag
|
||||
FLAGS = flags.FLAGS
|
||||
flags.DEFINE_string('libvirt_xml_template',
|
||||
utils.abspath('compute/libvirt.xml.template'),
|
||||
'Network XML Template')
|
||||
'Libvirt XML Template')
|
||||
flags.DEFINE_bool('use_s3', True,
|
||||
'whether to get images from s3 or use local copy')
|
||||
flags.DEFINE_string('instances_path', utils.abspath('../instances'),
|
||||
@@ -151,9 +151,10 @@ class Node(object, service.Service):
|
||||
""" launch a new instance with specified options """
|
||||
logging.debug("Starting instance %s..." % (instance_id))
|
||||
inst = self.instdir.get(instance_id)
|
||||
# TODO: Get the real security group of launch in here
|
||||
security_group = "default"
|
||||
net = network.BridgedNetwork.get_network_for_project(inst['user_id'],
|
||||
if not FLAGS.simple_network:
|
||||
# TODO: Get the real security group of launch in here
|
||||
security_group = "default"
|
||||
net = network.BridgedNetwork.get_network_for_project(inst['user_id'],
|
||||
inst['project_id'],
|
||||
security_group).express()
|
||||
inst['node_name'] = FLAGS.node_name
|
||||
|
||||
+18
-6
@@ -516,7 +516,12 @@ class CloudController(object):
|
||||
key_data = key_pair.public_key
|
||||
# TODO: Get the real security group of launch in here
|
||||
security_group = "default"
|
||||
bridge_name = network.BridgedNetwork.get_network_for_project(context.user.id, context.project.id, security_group)['bridge_name']
|
||||
if FLAGS.simple_network:
|
||||
bridge_name = FLAGS.simple_network_bridge
|
||||
else:
|
||||
net = network.BridgedNetwork.get_network_for_project(
|
||||
context.user.id, context.project.id, security_group)
|
||||
bridge_name = net['bridge_name']
|
||||
for num in range(int(kwargs['max_count'])):
|
||||
inst = self.instdir.new()
|
||||
# TODO(ja): add ari, aki
|
||||
@@ -532,12 +537,19 @@ class CloudController(object):
|
||||
inst['mac_address'] = utils.generate_mac()
|
||||
inst['ami_launch_index'] = num
|
||||
inst['bridge_name'] = bridge_name
|
||||
if inst['image_id'] == FLAGS.vpn_image_id:
|
||||
address = network.allocate_vpn_ip(
|
||||
inst['user_id'], inst['project_id'], mac=inst['mac_address'])
|
||||
if FLAGS.simple_network:
|
||||
network.allocate_simple_ip(mac=inst['mac_address'])
|
||||
else:
|
||||
address = network.allocate_ip(
|
||||
inst['user_id'], inst['project_id'], mac=inst['mac_address'])
|
||||
if inst['image_id'] == FLAGS.vpn_image_id:
|
||||
address = network.allocate_vpn_ip(
|
||||
inst['user_id'],
|
||||
inst['project_id'],
|
||||
mac=inst['mac_address'])
|
||||
else:
|
||||
address = network.allocate_ip(
|
||||
inst['user_id'],
|
||||
inst['project_id'],
|
||||
mac=inst['mac_address'])
|
||||
inst['private_dns_name'] = str(address)
|
||||
# TODO: allocate expresses on the router node
|
||||
inst.save()
|
||||
|
||||
Reference in New Issue
Block a user