Пример #1
0
    def capture_vapp(self,
                     catalog_resource,
                     vapp_href,
                     catalog_item_name,
                     description,
                     customize_on_instantiate=False,
                     overwrite=False):
        """Capture vApp as a catalog item template.

        :param catalog_resource: (`lxml.objectify.StringElement`): The
            catalog.
        :param vapp_href: (str): The href of the vApp to capture.
        :param catalog_item_name: (str): The name of the target catalog item.
        :param description: (str): The description of the catalog item.
        :param customize_on_instantiate: (bool): A flag indicating if the
            vApp to be instantiated from this vApp template can be customized.
        :param overwrite: (bool): A flag indicating if the item in the catalog
            has to be overwritten if it already exists. If it doesn't exists,
            this flag is not used.
        :return:  A :class:`lxml.objectify.StringElement` object describing
            the updated catalog item.
        """
        contents = E.CaptureVAppParams(
            E.Description(description),
            E.Source(href=vapp_href),
            name=catalog_item_name)
        if customize_on_instantiate:
            contents.append(
                E.CustomizationSection(
                    E_OVF.Info('VApp template customization section'),
                    E.CustomizeOnInstantiate('true')))
        if overwrite:
            try:
                item = self.get_catalog_item(
                    catalog_resource.get('name'), catalog_item_name)
                contents.append(
                    E.TargetCatalogItem(
                        href=item.get('href'),
                        id=item.get('id'),
                        type=item.get('type'),
                        name=item.get('name')))
            except Exception:
                pass
        return self.client.post_linked_resource(
            catalog_resource,
            rel=RelationType.ADD,
            media_type=EntityType.CAPTURE_VAPP_PARAMS.value,
            contents=contents)
Пример #2
0
 def capture_vapp(self,
                  catalog_resource,
                  vapp_href,
                  catalog_item_name,
                  description,
                  customize_on_instantiate=False):
     contents = E.CaptureVAppParams(E.Description(description),
                                    E.Source(href=vapp_href),
                                    name=catalog_item_name)
     if customize_on_instantiate:
         contents.append(
             E.CustomizationSection(
                 E_OVF.Info('VApp template customization section'),
                 E.CustomizeOnInstantiate('true')))
     return self.client.post_linked_resource(
         catalog_resource,
         rel=RelationType.ADD,
         media_type=EntityType.CAPTURE_VAPP_PARAMS.value,
         contents=contents)