Skip to content

Commit

Permalink
Fixed issue with ignore group
Browse files Browse the repository at this point in the history
  • Loading branch information
greyhoundforty committed Aug 2, 2024
1 parent d41d1ad commit 54de413
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions jobs/vpc-auto-stop-start/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def stop_vpc_instances():
instance_id = instance['id']
instance_name = instance['name']
if instance_name not in ignore_group:
print(f"Stopping instance {instance_id}")
print(f"Stopping instance {instance_name}")
response = client.create_instance_action(instance_id=instance_id, type='stop').get_result()
logging.info(response)
except ApiException as e:
Expand All @@ -88,19 +88,19 @@ def start_vpc_instances():
for instance in list_instances:
instance_id = instance['id']
instance_name = instance['name']
if instance_name not in ignore_group:
print(f"Starting instance {instance_id}")
response = client.create_instance_action(instance_id=instance_id, type='start').get_result()
logging.info(response)

print(f"Starting instance {instance_name}")
response = client.create_instance_action(instance_id=instance_id, type='start').get_result()
logging.info(response)

while True:
instance_status = client.get_instance(id=instance_id).get_result()['status']
if instance_status == 'running':
logging.info(f"Instance {instance_id} is now running")
break
else:
logging.info(f"Instance {instance_id} status: {instance_status}. Waiting...")
time.sleep(5)
while True:
instance_status = client.get_instance(id=instance_id).get_result()['status']
if instance_status == 'running':
logging.info(f"Instance {instance_id} is now running")
break
else:
logging.info(f"Instance {instance_id} status: {instance_status}. Waiting...")
time.sleep(5)
except ApiException as e:
print("Failed to start instances: %s\n" % e)

Expand Down

0 comments on commit 54de413

Please sign in to comment.