Exemple #1
0
 def delete_catalog(self, catalog_name):
     admin_url = None
     if not self.vcloud_session or not self.vcloud_session.organization: return False
     if 'ondemand' == self.service_type:
         refs = filter(lambda ref: ref.type_ == 'application/vnd.vmware.admin.organization+xml',
                              self.vcloud_session.organization.Link)
         if len(refs) == 1:
             admin_url = refs[0].href
     else:
         refs = filter(lambda ref: ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                              self.vcloud_session.organization.Link)
         if len(refs) == 1:
             admin_url = refs[0].href[:refs[0].href.rindex('/')]
     if admin_url:
         self.response = requests.get(admin_url, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify)
         if self.response.status_code == requests.codes.ok:
             adminOrg = vCloudEntities.parseString(self.response.content, True)
             if adminOrg and adminOrg.Catalogs and adminOrg.Catalogs.CatalogReference:
                 catRefs = filter(lambda ref: ref.name == catalog_name and ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                                         adminOrg.Catalogs.CatalogReference)
                 if len(catRefs) == 1:
                     self.response = requests.delete(catRefs[0].href, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify)
                     if self.response.status_code == requests.codes.no_content:
                         return True
     return False
Exemple #2
0
 def delete_catalog(self, catalog_name):
     admin_url = None
     if not self.vcloud_session or not self.vcloud_session.organization: return False
     if 'ondemand' == self.service_type:
         refs = filter(lambda ref: ref.type_ == 'application/vnd.vmware.admin.organization+xml',
                              self.vcloud_session.organization.Link)
         if len(refs) == 1:
             admin_url = refs[0].href
     else:
         refs = filter(lambda ref: ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                              self.vcloud_session.organization.Link)
         if len(refs) == 1:
             admin_url = refs[0].href[:refs[0].href.rindex('/')]
     if admin_url:
         self.response = requests.get(admin_url, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify)
         if self.response.status_code == requests.codes.ok:
             adminOrg = vCloudEntities.parseString(self.response.content, True)
             if adminOrg and adminOrg.Catalogs and adminOrg.Catalogs.CatalogReference:
                 catRefs = filter(lambda ref: ref.name == catalog_name and ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                                         adminOrg.Catalogs.CatalogReference)
                 if len(catRefs) == 1:
                     self.response = requests.delete(catRefs[0].href, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify)
                     if self.response.status_code == requests.codes.no_content:
                         return True
     return False
Exemple #3
0
 def create_catalog(self, catalog_name, description):
     refs = filter(lambda ref: ref.rel == 'add' and ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                          self.vcloud_session.organization.Link)
     if len(refs) == 1:
         data = """<?xml version="1.0" encoding="UTF-8"?>
         <AdminCatalog xmlns="http://www.vmware.com/vcloud/v1.5" name="%s">
         <Description>%s</Description>
         </AdminCatalog>
         """ % (catalog_name, description)
         self.response = requests.post(refs[0].href, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify, data=data)
         if self.response.status_code == requests.codes.created:
             task = vCloudEntities.parseString(self.response.content, True)
             return task.get_Tasks().get_Task()[0]
Exemple #4
0
 def create_catalog(self, catalog_name, description):
     refs = filter(lambda ref: ref.rel == 'add' and ref.type_ == 'application/vnd.vmware.admin.catalog+xml',
                          self.vcloud_session.organization.Link)
     if len(refs) == 1:
         data = """<?xml version="1.0" encoding="UTF-8"?>
         <AdminCatalog xmlns="http://www.vmware.com/vcloud/v1.5" name="%s">
         <Description>%s</Description>
         </AdminCatalog>
         """ % (catalog_name, description)
         self.response = requests.post(refs[0].href, headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify, data=data)
         if self.response.status_code == requests.codes.created:
             task = vCloudEntities.parseString(self.response.content, True)
             return task.get_Tasks().get_Task()[0]