From 582f71629d365b0d332ec38e05fb6fbf72acf07a Mon Sep 17 00:00:00 2001 From: Chris Donati Date: Thu, 21 Apr 2016 16:59:08 -0700 Subject: [PATCH] Reduce length of instance name --- lib/agents/gce_agent.py | 4 ++-- test/test_appscale_terminate_instances.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/agents/gce_agent.py b/lib/agents/gce_agent.py index d28b4a00..14b3bc75 100644 --- a/lib/agents/gce_agent.py +++ b/lib/agents/gce_agent.py @@ -657,7 +657,7 @@ def describe_instances(self, parameters, pending=False): auth_http = credentials.authorize(http) request = gce_service.instances().list( project=parameters[self.PARAM_PROJECT], - filter="name eq appscale-{0}-.*".format(parameters[self.PARAM_GROUP]), + filter="name eq {group}-.*".format(group=parameters[self.PARAM_GROUP]), zone=parameters[self.PARAM_ZONE] ) response = request.execute(http=auth_http) @@ -773,7 +773,7 @@ def run_instances(self, count, parameters, security_configured): instances = { # Truncate the name down to the first 62 characters, since GCE doesn't # let us use arbitrarily long instance names. - 'name': "appscale-{0}-{1}".format(group, uuid.uuid4())[:62], + 'name': '{group}-{uuid}'.format(group=group, uuid=uuid.uuid4())[:62], 'machineType': machine_type_url, 'disks':[{ 'source': disk_url, diff --git a/test/test_appscale_terminate_instances.py b/test/test_appscale_terminate_instances.py index 78b45240..fa4e93ae 100644 --- a/test/test_appscale_terminate_instances.py +++ b/test/test_appscale_terminate_instances.py @@ -400,7 +400,7 @@ def test_terminate_in_gce_and_succeeds(self): u'status': u'RUNNING', u'kind': u'compute#instance', u'machineType': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/global/machineTypes/n1-standard-1', - u'name': u'appscale-bazboogroup-one', + u'name': u'bazboogroup-one', u'zone': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b', u'tags': {u'fingerprint': u'42WmSpB8rSM='}, u'image': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/global/images/lucid64', @@ -421,7 +421,7 @@ def test_terminate_in_gce_and_succeeds(self): }, u'creationTimestamp': u'2013-05-22T11:52:33.254-07:00', u'id': u'8684033495853907982', - u'selfLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscale-bazboogroup-feb10b11-62bc-4536-ac25-9734f2267d6d', + u'selfLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/bazboogroup-feb10b11-62bc-4536-ac25-9734f2267d6d', u'networkInterfaces': [{ u'accessConfigs': [{ u'kind': u'compute#accessConfig', @@ -439,7 +439,7 @@ def test_terminate_in_gce_and_succeeds(self): u'status': u'RUNNING', u'kind': u'compute#instance', u'machineType': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/global/machineTypes/n1-standard-1', - u'name': u'appscale-bazboogroup-two', + u'name': u'bazboogroup-two', u'zone': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b', u'tags': {u'fingerprint': u'42WmSpB8rSM='}, u'image': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/global/images/lucid64', @@ -460,7 +460,7 @@ def test_terminate_in_gce_and_succeeds(self): }, u'creationTimestamp': u'2013-05-22T11:52:33.254-07:00', u'id': u'8684033495853907982', - u'selfLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscale-bazboogroup-feb10b11-62bc-4536-ac25-9734f2267d6d', + u'selfLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/bazboogroup-feb10b11-62bc-4536-ac25-9734f2267d6d', u'networkInterfaces': [{ u'accessConfigs': [{ u'kind': u'compute#accessConfig', @@ -487,7 +487,7 @@ def test_terminate_in_gce_and_succeeds(self): fake_instances = flexmock(name='fake_instances') fake_instances.should_receive('list').with_args(project=project_id, - filter="name eq appscale-bazboogroup-.*", zone=zone) \ + filter="name eq bazboogroup-.*", zone=zone) \ .and_return(fake_list_instance_request) fake_gce.should_receive('instances').and_return(fake_instances) @@ -501,7 +501,7 @@ def test_terminate_in_gce_and_succeeds(self): u'startTime': u'2013-05-27T10:44:51.849-07:00', u'insertTime': u'2013-05-27T10:44:51.806-07:00', u'targetId': u'12912855597472179535', - u'targetLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscale-appscalecgb20-0cf89267-5887-4048-b774-ca20de47a07f', + u'targetLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscalecgb20-0cf89267-5887-4048-b774-ca20de47a07f', u'operationType': u'delete', u'progress': 0, u'id': u'11114355109942058217', @@ -517,7 +517,7 @@ def test_terminate_in_gce_and_succeeds(self): u'startTime': u'2013-05-27T10:44:51.849-07:00', u'insertTime': u'2013-05-27T10:44:51.806-07:00', u'targetId': u'12912855597472179535', - u'targetLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscale-appscalecgb20-0cf89267-5887-4048-b774-ca20de47a07f', + u'targetLink': u'https://www.googleapis.com/compute/v1beta14/projects/appscale.com:appscale/zones/my-zone-1b/instances/appscalecgb20-0cf89267-5887-4048-b774-ca20de47a07f', u'operationType': u'delete', u'progress': 0, u'id': u'11114355109942058217', @@ -529,14 +529,14 @@ def test_terminate_in_gce_and_succeeds(self): fake_delete_instance_request_one.should_receive('execute').with_args( http=fake_authorized_http).and_return(delete_instance_info_one) fake_instances.should_receive('delete').with_args(project=project_id, - zone=zone, instance='appscale-bazboogroup-one').and_return( + zone=zone, instance='bazboogroup-one').and_return( fake_delete_instance_request_one) fake_delete_instance_request_two = flexmock(name='fake_delete_instance_request_two') fake_delete_instance_request_two.should_receive('execute').with_args( http=fake_authorized_http).and_return(delete_instance_info_two) fake_instances.should_receive('delete').with_args(project=project_id, - zone=zone, instance='appscale-bazboogroup-two').and_return( + zone=zone, instance='bazboogroup-two').and_return( fake_delete_instance_request_two) # mock out our waiting for the instances to be deleted