示例#1
0
workspace_dir = '/var/lib/jenkins/workspace'
try:
	os.chdir(workspace_dir)
	# Run git command to print current commit hash
	subprocess.call(['git', 'log', '-1'])
except OSError:
	print "No Such Directory : %s" % (workspace_dir)

# Run Things
print "!!## -- Start Tearing Down Virtualized Infrastructure -- ##!!"

# gather account info
account_info = cloudaccount.generate_account_info(results.username, results.apikey)

# Create a dict of the URLS for the API for the account
urls = cloudaccount.urls(account_info['catalogs'])

## Gather the current servers
servers = cloudaccount.servers(urls[results.dc], account_info['authtoken'])

to_delete_servers = []
for server in servers:
	if results.server_name in server:
		to_delete_servers.append(servers[server]['id'])

# Run delete servers
deleted_servers = cloudservers.delete_servers(account_info['authtoken'], urls[results.dc], to_delete_servers)

# Print the result of delete_servers
print "The results of delete servers : "
print deleted_servers