class AWSResourceManager_test(unittest.TestCase):
	
    def setUp(self):
	set_debug(True)
	self.mgr = AWSResourceManager('us-east-1') # east coast

    def tearDown(self):
        pass

    def test_get_instance_list(self):
	vm_list = self.mgr.get_instance_list()
	print "%d instances" % len(vm_list)
	for inst in vm_list :
		if inst:
			msg("\tinst: " + inst)
		else:
			msg("\tinst: <null>")

    def test_stop_instance(self):
	self.mgr.stop_instance(aws_id)
	pass

    def test_start_instance(self):
	self.mgr.start_instance(aws_id)
	pass

    def test_get_instance_list_key_name(self):
	vm_list = self.mgr.get_instance_list(key_name='bogus')
	assert len(vm_list) == 0
Exemplo n.º 2
0
ip_address = instance.ip_address

while True:

    (s,o) = os_cmd("checkport.py " + ip_address + " 12345")
    if s == 0 :
        break
    BaseUtil.sleep(20)

if s > 0 :
	msg("The amazon VM is not reachable - please make sure AWS instances are running and "
            + "'amazonhost' is configured properly.")
        msg("Skipping this part of testing")
	sys.exit(0)

(s, pubKey) = os_cmd("cat ~/.ssh/id_rsa.pub")
pubKey.rstrip('\n')

#print "pubKey: " + pubKey
if s == 0:
    #addSudoer("54.80.11.60", "sudoer", "ALL", pubKey = pubKey )
    add_sudoer( 'ssh -i ' + os.environ['BS_HOME'] + '/info/vault/TheGreatKeyPair_East.pem.unlocked ubuntu@amazonhost',
               "amazonhost", "sudoer",
               remove_user = True,
               root_services = "ALL",
               pub_key = pubKey )

mgr.stop_instance('i-ba73ff54')