From 95e7571a597abdafc638747e2d28c725df96bb17 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 2 Jul 2010 10:39:04 -0500 Subject: Simple Network avoids vlans --- nova/endpoint/cloud.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 931c6c6e1..50c087f2d 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -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() -- cgit From 45c192aee681eb684599ac2cacd9c38996ca2bb5 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 2 Jul 2010 10:39:04 -0500 Subject: Fixes and add interface template --- nova/endpoint/cloud.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 50c087f2d..960c1e9af 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -538,7 +538,7 @@ class CloudController(object): inst['ami_launch_index'] = num inst['bridge_name'] = bridge_name if FLAGS.simple_network: - network.allocate_simple_ip(mac=inst['mac_address']) + address = network.allocate_simple_ip() else: if inst['image_id'] == FLAGS.vpn_image_id: address = network.allocate_vpn_ip( @@ -579,10 +579,13 @@ class CloudController(object): pass if instance.get('private_dns_name', None): logging.debug("Deallocating address %s" % instance.get('private_dns_name', None)) - try: - self.network.deallocate_ip(instance.get('private_dns_name', None)) - except Exception, _err: - pass + if FLAGS.simple_network: + network.deallocate_simple_ip(instance.get('private_dns_name', None)) + else: + try: + self.network.deallocate_ip(instance.get('private_dns_name', None)) + except Exception, _err: + pass if instance.get('node_name', 'unassigned') != 'unassigned': #It's also internal default rpc.cast('%s.%s' % (FLAGS.compute_topic, instance['node_name']), {"method": "terminate_instance", -- cgit From 6e77201cbab22d0c4b383b245d5957946a229e4c Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Tue, 6 Jul 2010 17:35:33 +0200 Subject: If set, pass KernelId and RamdiskId from RunInstances call to the target compute node. --- nova/endpoint/cloud.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 39b3fd628..7b2d23e37 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -498,6 +498,10 @@ class CloudController(object): inst = self.instdir.new() # TODO(ja): add ari, aki inst['image_id'] = kwargs['image_id'] + if 'kernel_id' in kwargs: + inst['kernel_id'] = kwargs['kernel_id'] + if 'ramdisk_id' in kwargs: + inst['ramdisk_id'] = kwargs['ramdisk_id'] inst['user_data'] = kwargs.get('user_data', '') inst['instance_type'] = kwargs.get('instance_type', 'm1.small') inst['reservation_id'] = reservation_id -- cgit From dbe324f7254dd3e01de44bb908150fb8397fe118 Mon Sep 17 00:00:00 2001 From: Joshua McKenty Date: Wed, 7 Jul 2010 12:15:11 -0700 Subject: Got dhcpleasor working, with test ENV for testing, and rpc.cast for real world. --- nova/endpoint/cloud.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 931c6c6e1..269fb3950 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -498,6 +498,14 @@ class CloudController(object): # TODO - Strip the IP from the instance return defer.succeed({'disassociateResponse': ["Address disassociated."]}) + def release_ip(self, context, private_ip, **kwargs): + self.network.release_ip(private_ip) + return defer.succeed({'releaseResponse': ["Address released."]}) + + def lease_ip(self, context, private_ip, **kwargs): + self.network.lease_ip(private_ip) + return defer.succeed({'leaseResponse': ["Address lease."]}) + @rbac.allow('projectmanager', 'sysadmin') def run_instances(self, context, **kwargs): # make sure user can access the image -- cgit From b9a8bd2d55f016fba305a00c985c7f6769afddd2 Mon Sep 17 00:00:00 2001 From: Joshua McKenty Date: Wed, 7 Jul 2010 12:24:22 -0700 Subject: Fixes as per Vish review (whitespace, import statements) --- nova/endpoint/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 269fb3950..a2f60b47f 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -504,7 +504,7 @@ class CloudController(object): def lease_ip(self, context, private_ip, **kwargs): self.network.lease_ip(private_ip) - return defer.succeed({'leaseResponse': ["Address lease."]}) + return defer.succeed({'leaseResponse': ["Address leased."]}) @rbac.allow('projectmanager', 'sysadmin') def run_instances(self, context, **kwargs): -- cgit From ddc4a0970d9e98a45b820ed740f3ed8e696a4972 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 9 Jul 2010 16:17:45 -0700 Subject: move check for none before get mpi data --- nova/endpoint/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 931c6c6e1..f11faeb56 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -115,9 +115,9 @@ class CloudController(object): def get_metadata(self, ip): i = self.get_instance_by_ip(ip) - mpi = self._get_mpi_data(i['project_id']) if i is None: return None + mpi = self._get_mpi_data(i['project_id']) if i['key_name']: keys = { '0': { -- cgit From 69104d57f95b8d6609490af8ed981add3fc0a98b Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 14 Jul 2010 18:03:19 -0500 Subject: optimization to not load all instances when describe instances is called --- nova/endpoint/cloud.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nova/endpoint') diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index f11faeb56..19b6db91f 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -403,15 +403,17 @@ class CloudController(object): def _format_instances(self, context, reservation_id = None): reservations = {} - for instance in self.instdir.all: + if context.user.is_admin(): + instgenerator = self.instdir.all + else: + instgenerator = self.instdir.by_project(context.project.id) + for instance in instgenerator: res_id = instance.get('reservation_id', 'Unknown') if reservation_id != None and reservation_id != res_id: continue if not context.user.is_admin(): if instance['image_id'] == FLAGS.vpn_image_id: continue - if context.project.id != instance['project_id']: - continue i = {} i['instance_id'] = instance.get('instance_id', None) i['image_id'] = instance.get('image_id', None) -- cgit