示例#1
0
 def _upload_source_ova(self):
     """Upload the base OS ova to catalog."""
     if vcd_utils.catalog_item_exists(org=self.org,
                                      catalog_name=self.catalog_name,
                                      catalog_item_name=self.ova_name):
         msg = f"Found ova file '{self.ova_name}' in catalog " \
               f"'{self.catalog_name}'"
         self.msg_update_callback.general(msg)
         self.logger.info(msg)
     else:
         ova_filepath = f"cse_cache/{self.ova_name}"
         download_file(url=self.ova_href,
                       filepath=ova_filepath,
                       sha256=self.ova_sha256,
                       logger=self.logger,
                       msg_update_callback=self.msg_update_callback)
         catalog_item_name = pathlib.Path(ova_filepath).name
         vcd_utils.upload_ova_to_catalog(
             client=self.client,
             source_filepath=ova_filepath,
             catalog_name=self.catalog_name,
             catalog_item_name=catalog_item_name,
             org=self.org,
             logger=self.logger,
             msg_update_callback=self.msg_update_callback)
示例#2
0
    def download_template_scripts(self, template_name, revision,
                                  force_overwrite=False):
        """Download all scripts of a template to local scripts folder.

        :param str template_name:
        "param str revision:
        :param bool force_overwrite: if True, will download the script even if
            it already exists.
        """
        # Multiple codepaths enter into this. Hence all scripts are downloaded.
        # When vcdbroker.py id deprecated, the scripts should loop through
        # TemplateScriptFile to download scripts.
        for script_file in ScriptFile:
            remote_script_url = \
                self._get_remote_script_url(template_name, revision,
                                            script_file)

            local_script_filepath = ltm.get_script_filepath(
                template_name, revision, script_file)
            download_file(url=remote_script_url,
                          filepath=local_script_filepath,
                          force_overwrite=force_overwrite,
                          logger=self.logger,
                          msg_update_callback=self.msg_update_callback)

            # Set Read,Write permission only for the owner
            if os.name != 'nt':
                os.chmod(local_script_filepath, stat.S_IRUSR | stat.S_IWUSR)
    def download_template_scripts(self, template_name, revision,
                                  force_overwrite=False):
        """Download all scripts of a template to local scripts folder.

        :param str template_name:
        :param str revision:
        :param bool force_overwrite: if True, will download the script even if
            it already exists.
        """
        if not self.cookbook_version:
            raise ValueError('Invalid value for cookbook_version')
        # Multiple code paths enter into this. Hence all scripts are
        # downloaded. When vcdbroker.py id deprecated, the scripts should
        # loop through TemplateScriptFile to download scripts.
        scripts_to_download = TemplateScriptFile
        if self.legacy_mode:
            # if server configuration is indicating legacy_mode,
            # download cluster-scripts from template repository.
            scripts_to_download = ScriptFile
        for script_file in scripts_to_download:
            remote_script_url = \
                self._get_remote_script_url(
                    template_name, revision,
                    script_file)

            local_script_filepath = ltm.get_script_filepath(
                self.cookbook_version, template_name, revision, script_file)
            utils.download_file(
                url=remote_script_url,
                filepath=local_script_filepath,
                force_overwrite=force_overwrite,
                logger=self.logger,
                msg_update_callback=self.msg_update_callback
            )

            # Set Read,Write permission only for the owner
            if os.name != 'nt':
                os.chmod(local_script_filepath, stat.S_IRUSR | stat.S_IWUSR)