Пример #1
0
def enable_termination_protection(ec2, opts):
  instances = utils.get_instance_objs(ec2, opts)
  if instances == None:
    print 'No instance not found in this region'
    return None

  for instance in instances:
    if 'elasticbeanstalk:environment-name' in instance.tags:
      print 'Refusing to enable termination protection on an elastic beanstalk instance %s' % instance.id
    else:
      if not ec2.get_instance_attribute(instance.id, 'disableApiTermination')['disableApiTermination']:
        print 'Enabling termination protection on instance [%s]' % instance.id
        ec2.modify_instance_attribute(instance.id, 'disableApiTermination', True)
Пример #2
0
def pause_instance (ec2, opts):
  instances = utils.get_instance_objs(ec2, opts)

  if instances == None:
    print 'No instance not found in this region'
    return None

  instance_ids = []
  for instance in instances:
    instance_ids.append(instance.id)
  print 'Instance(s) found in this region, stopping...'
  ec2.stop_instances(instance_ids)
  print 'Instance(s) should now be in the process of stopping'
Пример #3
0
def unpause_instance (ec2, opts):
  instances = utils.get_instance_objs(ec2, opts)
  if instances == None:
    print 'Instance not found in this region'
    return None

  instance_ids = []
  for instance in instances:
    instance_ids.append(instance.id)
  print "Starting instances: %s" % instance_ids
  ec2.start_instances(instance_ids)
  print 'Sleeping for [%s] seconds to allow time for instance(s) to start... ' % opts['startup_sleep_seconds']
  time.sleep(opts['startup_sleep_seconds'])
  associate_eips(ec2)