예제 #1
0
    def scan(self, sr_uuid):
        """Scan: see _loadvdis"""
        if not util.isdir(self.path):
            return

        self._loadvdis()
        self.physical_size = util.get_fs_size(self.path)
        self.physical_utilisation = util.get_fs_utilisation(self.path)
        self.virtual_allocation = self._sum_vdis()

        return super(LocalISOSR, self).scan(sr_uuid)
예제 #2
0
파일: FileSR.py 프로젝트: falaa/sm
 def _getsize(self):
     path = self.path
     if self.handles("cifs"):
         path = self.linkpath
     return util.get_fs_size(path)
예제 #3
0
 def _getsize(self):
     return util.get_fs_size(self.path)
예제 #4
0
파일: FileSR.py 프로젝트: maxcuttins/sm
 def _getsize(self):
     path = self.path
     if self.handles("smb"):
         path = self.linkpath
     return util.get_fs_size(path)
예제 #5
0
파일: FileSR.py 프로젝트: Zaitypola/sm
 def _getsize(self):
     return util.get_fs_size(self.path)
예제 #6
0
파일: ISOSR.py 프로젝트: xcp-ng/sm
    def scan(self, sr_uuid):
        """Scan: see _loadvdis"""
        if not util.isdir(self.path):
            raise xs_errors.XenError('SRUnavailable', \
                    opterr='no such directory %s' % self.path)

        if ('legacy_mode' not in self.dconf) and (not self._checkmount()):
            raise xs_errors.XenError('SRUnavailable', \
                    opterr='directory not mounted: %s' % self.path)

        #try:
        if not self.vdis:
            self._loadvdis()
        self.physical_size = util.get_fs_size(self.path)
        self.physical_utilisation = util.get_fs_utilisation(self.path)
        self.virtual_allocation = self.physical_size

        other_config = self.session.xenapi.SR.get_other_config(self.sr_ref)

        if 'xenserver_tools_sr' in other_config and \
                other_config['xenserver_tools_sr'] == "true":
            # Out of all the xs-tools ISOs which exist in this dom0, we mark
            # only one as the official one.

            # Pass 1: find the latest version
            latest_build_vdi = None
            latest_build_number = "0"
            for vdi_name in self.vdis:
                vdi = self.vdis[vdi_name]

                if latest_build_vdi is None:
                    latest_build_vdi = vdi.location
                    latest_build_number = "0"

                if 'xs-tools-build' in vdi.sm_config:
                    bld = vdi.sm_config['xs-tools-build']
                    if bld >= latest_build_number:
                        latest_build_vdi = vdi.location
                        latest_build_number = bld

            # Pass 2: mark all VDIs accordingly
            for vdi_name in self.vdis:
                vdi = self.vdis[vdi_name]
                if vdi.location == latest_build_vdi:
                    vdi.sm_config['xs-tools'] = "true"
                else:
                    if "xs-tools" in vdi.sm_config:
                        del vdi.sm_config['xs-tools']

            # Synchronise the VDIs: this will update the sm_config maps of current records
            scanrecord = SR.ScanRecord(self)
            scanrecord.synchronise_new()
            scanrecord.synchronise_existing()

            # Everything that looks like an xs-tools ISO but which isn't the
            # primary one will also be renamed "Old version of ..."
            sr = self.session.xenapi.SR.get_by_uuid(sr_uuid)
            all_vdis = self.session.xenapi.VDI.get_all_records_where(
                "field \"SR\" = \"%s\"" % sr)
            for vdi_ref in all_vdis.keys():
                vdi = all_vdis[vdi_ref]
                if 'xs-tools-version' in vdi['sm_config']:
                    name = tools_iso_name(vdi['location'])
                    if 'xs-tools' in vdi['sm_config']:
                        self.session.xenapi.VDI.set_name_label(vdi_ref, name)
                    else:
                        self.session.xenapi.VDI.set_name_label(
                            vdi_ref, "Old version of " + name)

            # never forget old VDI records to cope with rolling upgrade
            for location in scanrecord.gone:
                vdi = scanrecord.get_xenapi_vdi(location)
                util.SMlog(
                    "Marking previous version of tools ISO: location=%s uuid=%s"
                    % (vdi['location'], vdi['uuid']))
                vdi = self.session.xenapi.VDI.get_by_uuid(vdi['uuid'])
                name_label = self.session.xenapi.VDI.get_name_label(vdi)
                if not (name_label.startswith("Old version of ")):
                    self.session.xenapi.VDI.set_name_label(
                        vdi, "Old version of " + name_label)
                # Mark it as missing for informational purposes only
                self.session.xenapi.VDI.set_missing(vdi, True)
                self.session.xenapi.VDI.remove_from_sm_config(vdi, 'xs-tools')

        else:
            return super(ISOSR, self).scan(sr_uuid)