Exemplo n.º 1
0
def main():
  connection = common.connect()

  prefix = raw_input(
    "Do you want the section of {} to have a prefix? (default '')".format(
      _HOSTS_PATH))
  if prefix:
    prefix = prefix + " "
  region = common.prompt_region(connection)
  type_ = common.prompt_choice("Type", ["private", "public"], "public")

  begin_marker = "# {}{} begin".format(prefix, region.name)
  end_marker = "# {}{} end".format(prefix, region.name)

  with open(_HOSTS_PATH) as hosts_file:
    content = hosts_file.read()

  content = re.sub("\s*{}.*{}".format(begin_marker, end_marker), "", content,
                   flags=re.DOTALL)

  connection = common.connect(region)
  mapping = sorted(_get_mapping(connection, type_ == "public"))
  content += _generate_mapping_content(begin_marker, end_marker, mapping)

  with tempfile.NamedTemporaryFile(delete=False) as temporary_file:
    temporary_file.write(content)

  subprocess.check_call([
    "sudo",
    "cp",
    temporary_file.name,
    _HOSTS_PATH
  ])
def main():
  connection = common.connect()
  region = common.prompt_region(connection)
  connection = common.connect(region)
  zone = common.prompt_zone(connection)
  security_group = common.prompt_security_group(connection)
  prefix = "{}-{}-".format(security_group, zone.split("-")[-1])
  name = _prompt_name(connection, prefix)
  instance_type = _prompt_instance_type()
  key_path = common.prompt_key_path()
  key_name = os.path.basename(key_path).split(".")[0]

  arguments = _LaunchArguments(instance_type=instance_type,
                               key_name=key_name,
                               name=name,
                               security_group=security_group,
                               zone=zone)

  env.host_string = _launch(connection, arguments, region)
  env.key_filename = key_path
  env.user = _USERNAME
  common.wait_until_remote_reachable()
  sudo("hostname {}".format(name))
  _update_system_files(name)
  _install()
  _update_installed_files()
  reboot()

  if instance_type.ephemeral_disk_count > 1:
    _create_ephemeral_raid(instance_type.ephemeral_disk_count)
  
  if _GIT_REPO:
    _clone()
Exemplo n.º 3
0
def main():
  ec2_connection = common.connect()
  region = common.prompt_region(ec2_connection)
  elb_connection = common.connect_elb_region(region.name)
  elb = common.prompt_elb(elb_connection, _DEFAULT_ELB_NAME)

  if not elb:
    print("No ELBs exist for region {}".format(region.name))
    return

  choice = common.prompt_choice("Choice", _ELB_ACTIONS, _DEFAULT_ELB_ACTION)
  while (choice != "Exit"):
    elb_info = _get_elb_info(ec2_connection, elb)
    _handle_user_choice(choice, elb, elb_info.zones,
                        elb_info.registered_instances,
                        elb_info.unregistered_instances)
    choice = common.prompt_choice("Choice", _ELB_ACTIONS, _DEFAULT_ELB_ACTION)
  return