Skip to content

Commit

Permalink
Reduce length of instance name
Browse files Browse the repository at this point in the history
  • Loading branch information
cdonati committed Apr 21, 2016
1 parent 6882530 commit 582f716
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/agents/gce_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions test/test_appscale_terminate_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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)

Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 582f716

Please sign in to comment.