# R. Melton
# 9/25/15
####################################################################



from keystone_mgr import KeystoneMgr
from nova_mgr import NovaMgr
import os,json, sys
# we need to fix the python search path so that we can find crendentials.py 
sys.path.append(os.environ['HOME']+'/code/scripts/python_class_1')  
from credentials import get_neutron_creds,get_keystone_creds

print '\n\nexercise ',sys.argv[0]
#create the OpenStack objects we will need
my_nova = NovaMgr()
#my_nova.check_params()  # YOUR FIX HERE
my_keystone = KeystoneMgr() 

# list beginning info for the system
my_keystone.print_tenant()
my_nova.print_instances()
# YOUR FIX HERE, use sys.argv to get instance name and network UUID from comand line
vm_name = 'instance_1'
inst = my_nova.create_instance(vm_name,'e7160b18-f8ea-4a34-9146-b08fb4ecca96')
my_nova.print_instances()
# YOUR FIX HERE -  fix the problem of conflict with other users who may start VMs with the same name.
# change the parameter below.
my_nova.delete_instance(name=vm_name)
my_nova.print_instances()
# vm_exercise_3_1.py - script to  run/delete a VM.
#
# R. Melton
# 9/25/15
####################################################################


from keystone_mgr import KeystoneMgr
from nova_mgr import NovaMgr
import os, json, sys

# we need to fix the python search path so that we can find crendentials.py
sys.path.append(os.environ["HOME"] + "/code/scripts/class/python_class_1")
from credentials import get_neutron_creds, get_keystone_creds

print "\n\nexercise ", sys.argv[0]
# create the OpenStack objects we will need
my_nova = NovaMgr()
my_nova.check_params()
my_keystone = KeystoneMgr()

# list beginning info for the system
my_keystone.print_tenant()
my_nova.print_instances()
vm_name = sys.argv[1]
net_uuid = sys.argv[2]
inst = my_nova.create_instance(vm_name, net_uuid)
my_nova.print_instances()
my_nova.delete_instance(name=vm_name)
my_nova.print_instances()