Пример #1
0
    def _create_conf_tar(self):
        self._log.info(
            'Saving hosted-engine configuration '
            'on the shared storage domain'
        )
        dest = heconflib.get_volume_path(
            self._type,
            self._sdUUID,
            self._conf_imgUUID,
            self._conf_volUUID
        )

        heconflib.create_heconfimage(
            self._log,
            self._get_conffile_content(
                constants.HEConfFiles.HECONFD_ANSWERFILE
            ),
            self._get_conffile_content(
                constants.HEConfFiles.HECONFD_HECONF
            ),
            self._get_conffile_content(
                constants.HEConfFiles.HECONFD_BROKER_CONF
            ),
            self._get_conffile_content(
                constants.HEConfFiles.HECONFD_VM_CONF
            ),
            dest
        )
Пример #2
0
    def _closeup_create_tar(self):
        self.logger.info(_(
            'Saving hosted-engine configuration '
            'on the shared storage domain'
        ))

        dest = heconflib.get_volume_path(
            self.environment[
                ohostedcons.StorageEnv.DOMAIN_TYPE
            ],
            self.environment[ohostedcons.StorageEnv.SD_UUID],
            self.environment[ohostedcons.StorageEnv.CONF_IMG_UUID],
            self.environment[ohostedcons.StorageEnv.CONF_VOL_UUID]
        )

        heconflib.create_heconfimage(
            self.logger,
            self.environment[
                ohostedcons.StorageEnv.ANSWERFILE_CONTENT
            ],
            self.environment[
                ohostedcons.StorageEnv.HECONF_CONTENT
            ],
            self.environment[
                ohostedcons.StorageEnv.BROKER_CONF_CONTENT
            ],
            self.environment[
                ohostedcons.StorageEnv.VM_CONF_CONTENT
            ],
            dest
        )
    def _fetch_answer_file(self):
        self.logger.debug('_fetch_answer_file')

        source = heconflib.get_volume_path(
            self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE],
            self.environment[ohostedcons.StorageEnv.SD_UUID],
            self.environment[ohostedcons.StorageEnv.CONF_IMG_UUID],
            self.environment[ohostedcons.StorageEnv.CONF_VOL_UUID],
        )
        self.logger.debug('fetching from: ' + str(source))

        if not heconflib.validateConfImage(self.logger, source):
            msg = _('Unable to get the answer file from the shared storage')
            self.logger.error(msg)
            raise RuntimeError(msg)
        self._tmp_ans = heconflib.extractConfFile(
            self.logger,
            source,
            ohostedcons.FileLocations.HECONFD_ANSWERFILE,
        )
        self.logger.debug(
            'Answer file form the shared storage: {content}'.format(
                content=self._tmp_ans
            )
        )
        self.logger.info(_('Answer file successfully loaded'))
 def _get_volume_path(self):
     """
     Return path of the volume file inside the domain
     """
     return heconflib.get_volume_path(
         self._parent.environment[
             ohostedcons.StorageEnv.DOMAIN_TYPE
         ],
         self._parent.environment[ohostedcons.StorageEnv.SD_UUID],
         self._parent.environment[ohostedcons.StorageEnv.IMG_UUID],
         self._parent.environment[ohostedcons.StorageEnv.VOL_UUID]
     )
Пример #5
0
 def getEngineVMOVF(self):
     self._log.info('Extracting Engine VM OVF from the OVF_STORE')
     volumepath = heconflib.get_volume_path(
         self._type,
         self._sdUUID,
         self._ovf_store_imgUUID,
         self._ovf_store_volUUID
     )
     self._log.info('OVF_STORE volume path: %s ' % volumepath)
     filename = self._HEVMID + '.ovf'
     ovf = heconflib.extractConfFile(self._log, volumepath, filename)
     self._log.debug('HEVM OVF: \n%s\n' % ovf)
     if ovf is None:
         self._log.error('Unable to extract HEVM OVF')
     return ovf
Пример #6
0
 def _create_conf_tar(self, answer_c, heconf_c, brokerconf_c, vmconf_c):
     self._log.info(
         'Saving hosted-engine configuration '
         'on the shared storage domain'
     )
     dest = heconflib.get_volume_path(
         self._spUUID,
         self._sdUUID,
         self._conf_imgUUID,
         self._conf_volUUID
     )
     heconflib.create_heconfimage(
         self._log,
         answer_c,
         heconf_c,
         brokerconf_c,
         vmconf_c,
         dest
     )
    def _get_config_volume_path(self):
        sdUUID = self.sd.get(SD_UUID)
        spUUID = self.sd.get(SP_UUID)

        if sdUUID is None or spUUID is None:
            if self._logger:
                self._logger.debug("Configuration image not configured yet")
                return None

        try:
            conf_vol_uuid = self.sd.get(CONF_VOLUME_UUID)
            conf_img_uuid = self.sd.get(CONF_IMAGE_UUID)
        except (KeyError, ValueError):
            if self._logger:
                self._logger.debug("Configuration image doesn't exist")
            return None

        volumepath = heconflib.get_volume_path(spUUID, sdUUID, conf_img_uuid,
                                               conf_vol_uuid)
        return volumepath
Пример #8
0
    def _get_config_volume_path(self):
        sdUUID = self.sd.get(SD_UUID)
        spUUID = self.sd.get(SP_UUID)

        if sdUUID is None or spUUID is None:
            if self._logger:
                self._logger.debug("Configuration image not configured yet")
                return None

        try:
            conf_vol_uuid = self.sd.get(CONF_VOLUME_UUID)
            conf_img_uuid = self.sd.get(CONF_IMAGE_UUID)
        except (KeyError, ValueError):
            if self._logger:
                self._logger.debug("Configuration image doesn't exist")
            return None

        volumepath = heconflib.get_volume_path(
            spUUID,
            sdUUID,
            conf_img_uuid,
            conf_vol_uuid
        )
        return volumepath
Пример #9
0
    def refresh_local_conf_file(self, localcopy_filename, archive_fname):
        domain_type = self.get(ENGINE, DOMAIN_TYPE)
        sd_uuid = self.get(ENGINE, SD_UUID)
        conf_img_id = None
        conf_vol_id = None
        content = None
        try:
            conf_img_id = self.get(ENGINE, CONF_IMAGE_UUID)
            conf_vol_id = self.get(ENGINE, CONF_VOLUME_UUID)
        except (KeyError, ValueError):
            if self._logger:
                self._logger.debug("Configuration image doesn't exist")
            pass

        if not (conf_img_id and conf_vol_id):
            if self._logger:
                self._logger.debug(
                    "Failing back to conf file from a previous release"
                )
            return False

        if archive_fname == constants.HEConfFiles.HECONFD_VM_CONF:
            if self._logger:
                self._logger.info(
                    "Trying to get a fresher copy of vm configuration "
                    "from the OVF_STORE"
                )

            ovfs = ovf_store.OVFStore()
            conf = None
            scan = False

            try:
                scan = ovfs.scan()
            except (EnvironmentError, Exception) as err:
                self._logger.error(
                    "Failed scanning for OVF_STORE due to %s",
                    err
                )

            if scan:
                heovf = ovfs.getEngineVMOVF()
                if heovf is not None:
                    self._logger.info(
                        "Found an OVF for HE VM, "
                        "trying to convert"
                    )
                    conf = ovf2VmParams.confFromOvf(heovf)
            if conf is not None:
                self._logger.info('Got vm.conf from OVF_STORE')
                content = conf
            else:
                self._logger.error(
                    'Unable to get vm.conf from OVF_STORE, '
                    'falling back to initial vm.conf'
                )

        if not content:
            source = heconflib.get_volume_path(
                domain_type,
                sd_uuid,
                conf_img_id,
                conf_vol_id,
            )

            if self._logger:
                self._logger.debug(
                    "Reading '{archive_fname}' from '{source}'".format(
                        archive_fname=archive_fname,
                        source=source,

                    )
                )
            if heconflib.validateConfImage(self._logger, source):
                content = heconflib.extractConfFile(
                    self._logger,
                    source,
                    archive_fname,
                )

        if not content:
            if self._logger:
                self._logger.debug(
                    "unable to get a valid content"
                )
            return False
        if self._logger:
            self._logger.debug(
                "Writing to '{target}'".format(
                    target=localcopy_filename,
                )
            )
        with open(localcopy_filename, 'w') as target:
            target.write(content)
            if self._logger:
                self._logger.debug(
                    "local conf file was correctly written"
                )
            return True
        if self._logger:
            self._logger.error(
                "Unable to get conf file"
            )
            return False