def main():
	# the configuration will be read into the cfg.CONF global data structure
	args = ['--config-file']
	if len(sys.argv) > 2 and sys.argv[1] == '--config-file':
		args.append(sys.argv[2])
	    	config.parse(args)
	    	config.setup_logging()
		if not cfg.CONF.config_file:
			sys.exit("ERROR: Unable to find configuration file via the '--config-file' option!")
		
		#Interaction with database and store cloud credentials into source cloud database
		while True:
			passwd = getpass.getpass('The source cloud credentials will be stored into mysql database, please type in source cloud mysql database password. If password is equal to admin password, type in Enter directly!\nPassword:\n')
			if passwd is not '':
				password = passwd
			else:
				password = cfg.CONF.SOURCE.os_password
			print password
			ip = re.search('http://(.+?):', cfg.CONF.SOURCE.os_auth_url)

			DNScredentials = {'host': ip.group(1),
			  		  'user': '******',
			  		  'passwd':password,
			  		  'db': 'keystone'}
			db = None
			try:				
				db = connect(**DNScredentials)
				cursor = getCursor(db)
				createDNS(db, cursor)
				insertTargetDNS(db, cursor)
				insertSourceDNS(db, cursor)
				db.close()	
				break
			except:
				print 'Unable to connect to mysql database!'
				continue
		
	elif len(sys.argv) > 4 and sys.argv[1] == '-src' and sys.argv[3] == '-dst':
		db = connect(**DNScredentials)
		cursor = getCursor(db)
		srcConfig = readDNS(db, cursor, sys.argv[2])
		if not srcConfig:
			print "Cloud " + sys.argv[2] + ' does not exist in the database, please configure flyway.conf!'
	
		dstConfig = readDNS(db, cursor, sys.argv[4])
		if not dstConfig:
			sys.exit("Cloud " + sys.argv[4] + ' does not exist in the database, please configure flyway.conf!')
	
		writeToFile('etc/flyway.conf', configContent(srcConfig, dstConfig))
		args.append('./etc/flyway.conf')
		config.parse(args)
	    	config.setup_logging()
		db.close()
    	
	try:
		flow.execute()
	except RuntimeError, e:
		sys.exit("ERROR: %s" % e)
def main():
    config.init(sys.argv[1:])
    config.setup_logging()
    try:
        daemon = MlxEswitchDaemon()
        daemon.start()
    except Exception as e:
        LOG.exception("Failed to start EswitchDaemon - Daemon terminated! %s",
                      e)
        sys.exit(1)

    daemon.daemon_loop()
Exemplo n.º 3
0
def main():
    # the configuration will be read into the cfg.CONF global data structure
    args = ['--config-file']
    if len(sys.argv) > 2:
        args.append(sys.argv[2])
    config.parse(args)
    config.setup_logging()
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via the "
                 "'--config-file' option!")

    try:
        flow.execute()
    except RuntimeError, e:
        sys.exit("ERROR: %s" % e)
from flow.flavortask import FlavorMigrationTask
from flow.imagetask import ImageMigrationTask
from flow.keypairtask import KeypairMigrationTask
from flow.roletask import RoleMigrationTask
from flow.tenanttask import TenantMigrationTask
from flow.instancetask import InstanceMigrationTask
from utils.db_handlers.keypairs import *

from flow import flow

from django.shortcuts import render
from flow.usertask import UserMigrationTask
from common import config as cfg

cfg.parse(['--config-file', '../flyway/etc/flyway.conf'])
cfg.setup_logging()
initialize_environment()
update_environment()


def index(request):
    latest_poll_list = [1, 2, 3, 4, 5]
    context = {'latest_poll_list': latest_poll_list}
    return render(request, 'flyway_test/index.html', context)


def find_users(request):
    migration_task = UserMigrationTask()
    users = migration_task.ks_source.users.list()
    context = {'users': users}
    return render(request, 'flyway_test/index.html', context)