Exemplo n.º 1
0
 def get_vdc_references(self, serviceId):
     serviceReferences = filter(lambda serviceReference: serviceReference.get_serviceId() == serviceId, self.services.get_Service())
     if len(serviceReferences) == 0:
         return []
     self.response = requests.get(serviceReferences[0].get_href(), headers=self._get_vcloud_headers(), verify=self.verify)
     vdcs = vchsType.parseString(self.response.content, True)
     return vdcs.get_VdcRef()
Exemplo n.º 2
0
 def get_vdc_references(self, serviceId):
     serviceReferences = filter(lambda serviceReference: serviceReference.get_serviceId() == serviceId, self.services.get_Service())
     if len(serviceReferences) == 0:
         return []
     self.response = requests.get(serviceReferences[0].get_href(), headers=self._get_vcloud_headers(), verify=self.verify)
     vdcs = vchsType.parseString(self.response.content, True)
     return vdcs.get_VdcRef()
Exemplo n.º 3
0
 def login_to_org(self, service, org_name):
     vdcReference = self.get_vdc_reference(service, org_name)
     if vdcReference:
         link = filter(lambda link: link.get_type() == "application/xml;class=vnd.vmware.vchs.vcloudsession", vdcReference.get_Link())[0]
         self.response = requests.post(link.get_href(), headers=self._get_vcloud_headers(), verify=self.verify)
         if self.response.status_code == requests.codes.created:
             vchs = vchsType.parseString(self.response.content, True)
             vdcLink = vchs.get_VdcLink()
             headers = {}
             headers[vdcLink.authorizationHeader] = vdcLink.authorizationToken
             headers["Accept"] = "application/*+xml;version=" + self.version
             self.response = requests.get(vdcLink.href, headers=headers, verify=self.verify)
             if self.response.status_code == requests.codes.ok:
                 self.vdc = vdcType.parseString(self.response.content, True)
                 self.org = self.vdc.name
                 org_url = filter(lambda link: link.get_type() == "application/vnd.vmware.vcloud.org+xml", self.vdc.get_Link())[0].href
                 vcloud_session = VCS(org_url, self.username, self.org, None, org_url, org_url, version=self.version, verify=self.verify)
                 if vcloud_session.login(password=None, token=vdcLink.authorizationToken):
                     self.vcloud_session = vcloud_session
                     return True
     return False
Exemplo n.º 4
0
 def login_to_org(self, service, org_name):
     vdcReference = self.get_vdc_reference(service, org_name)
     if vdcReference:
         link = filter(lambda link: link.get_type() == "application/xml;class=vnd.vmware.vchs.vcloudsession", vdcReference.get_Link())[0]
         self.response = requests.post(link.get_href(), headers=self._get_vcloud_headers(), verify=self.verify)
         if self.response.status_code == requests.codes.created:
             vchs = vchsType.parseString(self.response.content, True)
             vdcLink = vchs.get_VdcLink()
             headers = {}
             headers[vdcLink.authorizationHeader] = vdcLink.authorizationToken
             headers["Accept"] = "application/*+xml;version=" + self.version
             self.response = requests.get(vdcLink.href, headers=headers, verify=self.verify)
             if self.response.status_code == requests.codes.ok:
                 self.vdc = vdcType.parseString(self.response.content, True)
                 self.org = self.vdc.name
                 org_url = filter(lambda link: link.get_type() == "application/vnd.vmware.vcloud.org+xml", self.vdc.get_Link())[0].href
                 vcloud_session = VCS(org_url, self.username, self.org, None, org_url, org_url, version=self.version, verify=self.verify)
                 if vcloud_session.login(password=None, token=vdcLink.authorizationToken):
                     self.vcloud_session = vcloud_session
                     return True
     return False