Skip to content

Instantly share code, notes, and snippets.



Created May 17, 2010
What would you like to do?
import sys
from org.apache.commons.httpclient.protocol import Protocol
from com.vmware.vcloud.sdk import VcloudClient, Organization, Vdc
from com.vmware.vcloud.sdk.samples import FakeSSLSocketFactory
class VcloudLogin(object):
VcloudLogin: Login to vcloud class
vcloudClient = None
api_version = None
vcloud_url = None
def __init__(self, vcloud_url, api_version):
# This is needed if you have a self certified certificate
# remove it if you have a proper SSL certs.
self.vcloud_url = vcloud_url
self.api_version = api_version
def setup_fake_ssl(self):
https = Protocol("https", FakeSSLSocketFactory(), 443)
Protocol.registerProtocol("https", https)
def login(self, username, password):
versions = VcloudClient.getSupportedVersions(self.vcloud_url + "/api/versions")
self.vcloudClient = VcloudClient(versions.get(self.api_version))
return self.vcloudClient.login(username, password)
if __name__ == '__main__':
vcl = VcloudLogin(URL, API_VERSION)
organizations_list = vcl.login(USERNAME, PASSWORD)
for org in organizations_list.values():
for vdcLink in \
Organization.getOrganizationByReference(vcl.vcloudClient, org).getVdcLinks():
vdc = Vdc.getVdc(vcl.vcloudClient, vdcLink)
print "VDC Href: %s\n" % (vdcLink.getHref())
for vapps in vdc.getVappRefs():
print "Name: %s URL: %s" % (vapps.getName(), vapps.getHref())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment