Esempio n. 1
0
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)
Esempio n. 2
0
def opsmgr_install_if_needed(stack, slug, product_pattern, release_pattern=None):
	available_matches = opsmgr_available_products(stack, slug, release_pattern)
	if len(available_matches) < 1:
		product = pivnet.pivnet_select_product(product_pattern)
		release = pivnet.pivnet_select_release(product, release_pattern)
		opsmgr_import_product(stack, product, release)
		available_matches = opsmgr_available_products(stack, slug, release_pattern)

	installed_matches = opsmgr_installed_products(stack, slug)
	if len(installed_matches) < 1:
		params = {
			"name": slug,
			"product_version": available_matches[0]["product_version"]
		}
		opsmgr_post(stack, "/api/installation_settings/products", urllib.urlencode(params))
	elif installed_matches[0]["product_version"] != available_matches[0]["product_version"]:
		print "Upgrade not yet implemented. If you want to change the installed version,"
		print "first remove the old tile, then retry this operation."
		sys.exit(1)
Esempio n. 3
0
def opsmgr_import_stemcell(stack, stemcell):
	folder = "stemcells"
	print "Creating folder for", folder
	command = [
		'mkdir', '-p', folder
	]
	opsmgr_exec(stack, command)
	product = pivnet.pivnet_select_product("Stemcells")
	release = pivnet.pivnet_select_release(product, stemcell["version"])
	pivnet.pivnet_accept_eula(product, release)
	files = pivnet.pivnet_files(product, release)
	os_pattern = '-' + stemcell["os"] + '-'
	is_pattern = '-' + stemcell["infrastructure"] + '-'
	for file in files:
		download_filename = os.path.basename(file["aws_object_key"])
		if not os_pattern in download_filename:
			continue
		if not is_pattern in download_filename:
			continue
		download_filename = folder + "/" + download_filename
		download_url = file["_links"]["download"]["href"]
		print "Downloading stemcell", download_filename
		command = [
			'wget', '-q',
			'-O', download_filename,
			'--post-data=""',
			'--header="Authorization: Token ' + config.get('pivotal-network', 'token') + '"',
			download_url
		]
		opsmgr_exec(stack, command)
		print "Importing stemcell", download_filename
		username = config.get("stack-" + stack["StackName"], "opsmgr-username")
		password = config.get("stack-" + stack["StackName"], "opsmgr-password")
		command = [
			'curl', '-k', 'https://localhost/api/stemcells',
			'-F', 'stemcell[file]=@' + download_filename,
			'-X', 'POST',
			'-u', username + ':' + password
		]
		opsmgr_exec(stack, command)