def launch_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] version = argv[2] if len(argv) > 2 else "" stack = cloudformation.select_stack(stack_name) instance = opsmgr_launch_instance(stack, version, verbose=True) print "Waiting for Ops Manager to start ", opsmgr_wait(stack, verbose=True) print "Setting up initial Admin user" opsmgr_setup(stack) print "Configuring Ops Manager Director" bosh.bosh_config(stack) stack_section = "stack-" + stack["StackName"] password = config.get(stack_section, "opsmgr-password") opsmgr_dns = opsmgr_hostname(stack) pcfelb_dns = cloudformation.get_output(stack, "PcfElbDnsName") sshelb_dns = cloudformation.get_output(stack, "PcfElbSshDnsName") app_domain = config.get("cf", "apps-domain", stack=stack_name) sys_domain = config.get("cf", "system-domain", stack=stack_name) print print "Ops Manager started at", opsmgr_url(stack) print "Admin username is admin, password is", password print print "Before proceeding to install Elastic runtime, you must create" print "the following records through your DNS provider:" print print " CNAME", "opsmgr." + sys_domain, opsmgr_dns print " CNAME", "*." + app_domain, pcfelb_dns if app_domain != sys_domain: print " CNAME", "*." + sys_domain, pcfelb_dns if sshelb_dns is not None: print " CNAME", "ssh." + sys_domain, sshelb_dns print print "Failure to do so will lead to install failures later."
def list_releases(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None product_pattern = argv[1] release_pattern = argv[2] if len(argv) > 2 else "" product = pivnet_select_product(product_pattern) releases = pivnet_releases(product, release_pattern) print "\n".join([r["version"] for r in releases])
def config_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] version = argv[2] if len(argv) > 2 else "" stack = cloudformation.select_stack(stack_name) settings = cf_config(stack, version) print json.dumps(settings, indent=4)
def accept_eula(argv): cli.exit_with_usage(argv) if len(argv) < 3 else None product_pattern = argv[1] release_pattern = argv[2] product = pivnet_select_product(product_pattern) release = pivnet_select_release(product, release_pattern) pivnet_accept_eula(product, release)
def metadata_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 3 else None stack_name = argv[1] product_pattern = argv[2] stack = cloudformation.select_stack(stack_name) product = pivnet.pivnet_select_product(product_pattern) metadata = opsmgr_get_product_metadata(stack, product) print json.dumps(metadata, indent=4)
def settings_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) if stack is None: print "Stack", stack_name, "not found" sys.exit(1) bosh_config(stack)
def list_files(argv): cli.exit_with_usage(argv) if len(argv) < 3 else None product_pattern = argv[1] release_pattern = argv[2] file_pattern = argv[3] if len(argv) > 3 else "" product = pivnet_select_product(product_pattern) release = pivnet_select_release(product, release_pattern) files = pivnet_files(product, release, file_pattern) print "\n".join([product["slug"] + "/" + os.path.basename(f["aws_object_key"]) for f in files])
def import_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 4 else None stack_name = argv[1] product_pattern = argv[2] release_pattern = argv[3] stack = cloudformation.select_stack(stack_name) product = pivnet.pivnet_select_product(product_pattern) release = pivnet.pivnet_select_release(product, release_pattern) pivnet.pivnet_accept_eula(product, release) opsmgr_import_product(stack, product, release)
def products_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) available_products = opsmgr_available_products(stack) installed_products = opsmgr_installed_products(stack) for ap in available_products: installed = [ ip for ip in installed_products if ip["name"] == ap["name"]] if len(installed) > 0: if installed[0]["product_version"] == ap["product_version"]: ap["installed"] = "(installed)" else: ap["installed"] = "(" + installed[0]["product_version"] + " installed)" else: ap["installed"] = "" print ap["name"], ap["product_version"], ap["installed"]
def download(argv): cli.exit_with_usage(argv) if len(argv) < 3 else None product_pattern = argv[1] release_pattern = argv[2] file_pattern = argv[3] if len(argv) > 3 else "" product = pivnet_select_product(product_pattern) release = pivnet_select_release(product, release_pattern) files = pivnet_files(product, release, file_pattern) try: pivnet_download(product, release, files, True) except urllib2.HTTPError as error: if error.code == 451: print "You must accept-eula before downloading files" else: print error.reason, "(", error.code, ")" sys.exit(1)
def stemcells_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) available_stemcells = opsmgr_available_stemcells(stack) print json.dumps(available_stemcells, indent=4)
def delete_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 3 else None type_name = argv[1] item_id = argv[2] if argv[2] != "all" else None tree = get_tree(type_name, item_id) delete_tree(tree)
def uninstall_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) install_id = opsmgr_uninstall(stack) opsmgr_tail_logs(stack, install_id)
def settings_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) settings = json.load(opsmgr_get(stack, "/api/installation_settings")) print json.dumps(settings, indent=4)
def terminate_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) opsmgr_terminate_instances(stack)
def config_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) settings = bosh_config(stack) print json.dumps(settings, indent=4)
def logs_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None stack_name = argv[1] stack = cloudformation.select_stack(stack_name) opsmgr_tail_logs(stack)
def list_cmd(argv): cli.exit_with_usage(argv) if len(argv) < 2 else None type_name = argv[1] items = get_items(type_name) print "\n".join([item["id"] for item in items])