예제 #1
0
def create_app(app, options, check_app = False):

	openshift_app = None

	if check_app:
		openshift_app = appinfo(options)

	#create openshift application
	if openshift_app == None:

		start = time.time()

		create_cmd = ['rhc', 'app', 'create', '--type', 'diy-0.1', '--nogit']

		if options.debug == True: create_cmd.append("-d")

		for item in ["app", "rhlogin", "password", "timeout"]:
			if hasattr(options, item) and eval('options.%s' % item) != None and eval('options.%s' % item) != '':
				create_cmd.append("--%s=%s" % (item, eval('options.%s' % item)))

		shellexecute( create_cmd, location=app.path, debug=options.debug, output=True,
			msg="Creating %s application at openshift using do-it-yourself cartridge" % options.app, exit_on_error=True )

		openshift_app = appinfo(options)
		if openshift_app == None: error_message("Failed to create app, check that rhc tools are correctly installed.")

		message( "Application %s successfully created at %s in %s" % (options.app, app.path, elapsed(start)) )

	return openshift_app
예제 #2
0
def openshift_open(options, openshift_app=None):
	if openshift_app == None: openshift_app = appinfo(options)
	if openshift_app == None:
		error_message("the application '%s' does not exist for login '%s' in openshift" % (options.app, options.rhlogin))

	url = openshift_app.url
	if options.subdomain != '': url = url.rstrip('/') + '/' + options.subdomain.strip('/')
	webbrowser.open(url, new=2)
예제 #3
0
def openshift_app(options):

	openshift_app = appinfo(options)

	if openshift_app == None:
		error_message("The application '%s' does not exist for login '%s' in openshift" % (options.app, options.rhlogin))

	for key in openshift_app.__dict__:
		print '%s: %s' % (key, openshift_app.__dict__[key])
예제 #4
0
def openshift_destroy(app, options):
	start = time.time()

	if not options.bypass:
		message( [
			"!!!! WARNING !!!! WARNING !!!! WARNING !!!!", 
			"You are about to destroy the '%s' application." % options.app, 
			"", 
			"This is NOT reversible, all remote data for this application will be removed."
		] )

		answer = raw_input("~ Do you want to destroy this application (y/n): [%s] " % "no")

		answer = answer.strip().lower()
		if answer not in ['yes', 'y']:
			error_message("the application '%s' was not destroyed" % options.app)

	app_folder = app.path

	openshift_app = appinfo(options)

	if openshift_app != None:

		destroy_cmd = ['rhc', 'app', 'destroy']

		if options.debug == True: destroy_cmd.append("--debug")

		destroy_cmd.append('--bypass')

		for item in ["app", "rhlogin", "password", "timeout"]:
			if hasattr(options, item) and eval('options.%s' % item) != None and eval('options.%s' % item) != '':
				destroy_cmd.append("--%s=%s" % (item, eval('options.%s' % item)))

		shellexecute( destroy_cmd, output=True, debug=options.debug, 
			msg="Destroying application %s" % options.app, exit_on_error=True)

	else:
		message( "application %s does not exist on openshift. skipping destroy." % options.app )

	silent = not (options.verbose or options.debug)

	#delete local files
	if not silent: message("deleting .git, .openshift folders and .gitignore file at %s" % app_folder)
	remove_folder(os.path.join(app_folder, '.git'), silent=silent)
	remove_folder(os.path.join(app_folder, '.openshift'), silent=silent)
	remove_file(os.path.join(app_folder, '.gitignore'), silent=silent)

	message([
		"app successfully removed from openshift in %s" % elapsed(start),
		"don't forget to remove openshift configuration from application.conf file"
	])
예제 #5
0
def check_app(app, options):
	openshift_app = appinfo(options)

	if openshift_app == None:

		if options.bypass == True:
			answer = 'yes'
		else:
			message("the application '%s' does not exist for login '%s' in openshift" % (options.app, options.rhlogin))
			answer = raw_input("~ Do you want to create it? [%s] " % "yes")

		answer = answer.strip().lower()
		if answer in ['yes', 'y', '']:
			openshift_app = create_app(app, options)
		else:
			error_message("the application '%s' does not exist for login '%s' in openshift" % (options.app, options.rhlogin))

	if options.verbose or options.debug:
		message("OK! - checked application: %s at %s for user %s!" % (openshift_app.name, openshift_app.url, options.rhlogin))

	return openshift_app