def getConnection(user, password, project_name, project_id, main_ip):

    result = {}

    connector = ConnectionGetter(user, password, project_name, project_id, main_ip)

    keystone = UtilKeystone(connector.keystone())
    token_ref_id = keystone.getTokenRef(user, password, project_name).id

    sahara = UtilSahara(connector.sahara(token_ref_id))

    nova = UtilNova(connector.nova())

    result['keystone'] = keystone
    result['sahara'] = sahara
    result['nova'] = nova

    return result
MIN_NUM_ARGS = 4

def printUsage():
    print "python create_cluster.py <cluster_name> <key_pair> <config_file_path>"

if (len(sys.argv) < MIN_NUM_ARGS):
    print "Wrong number of arguments"
    printUsage()
    exit(1)

cluster_name = sys.argv[1]
key_pair = sys.argv[2]
config_file_path = sys.argv[3]

user = raw_input('OpenStack User: '******'OpenStack Password: '******'project_name')
project_id = json_parser.get('project_id')
main_ip = json_parser.get('main_ip')
connector = ConnectionGetter(user, key, project_name, project_id, main_ip)

keystone_util = UtilKeystone(connector.keystone())
token_ref_id = keystone_util.getTokenRef(user, key, project_name).id
sahara_util = UtilSahara(connector.sahara(token_ref_id))

cluster_id = sahara_util.createClusterHadoop(cluster_name, image_id, template_id, net_id,key_pair)
print cluster_id

output_container_name = json_parser.get('output_container_name')

exec_local_path = json_parser.get('exec_local_path')
public_keypair_path = json_parser.get('public_keypair_path')
private_keypair_path = json_parser.get('private_keypair_path')
private_keypair_name = json_parser.get('private_keypair_name')


net_id = json_parser.get('net_id')
image_id = json_parser.get('image_id')

#------------ GETTING CONNECTION WITH OPENSTACK -----------------
connector = ConnectionGetter(user, password, project_name, project_id, main_ip)

keystone_util = UtilKeystone(connector.keystone())
token_ref_id = keystone_util.getTokenRef(user, password, project_name).id
sahara_util = UtilSahara(connector.sahara(token_ref_id))

#----------------------- EXECUTING EXPERIMENT ------------------------------

for cluster_template in json_parser.get('cluster_templates'):
	
	cluster_template_id = cluster_template['id']
	cluster_size = cluster_template['n_slaves']
	cluster_name = DEF_CLUSTER_NAME + '-' +  str(cluster_size)

	######### CREATING CLUSTER #############
	try:
		cluster_id = sahara_util.createClusterHadoop(cluster_name, image_id, cluster_template_id, net_id, private_keypair_name)
		#cluster_id = "182afd54-e621-438c-977d-a7a543325714"