Beispiel #1
0
    def load(self, location):
        self.path = self.location
        self.size = 0
        self.utilisation = 0
        self.label = self.path
        self.sm_config = {}
        try:
            s = os.stat(self.path)
            self.deleted = False

            # Use the CTIME of the symlink to mean "time it was hotplugged"
            iso8601 = time.strftime("%Y-%m-%dT%H:%M:%SZ",
                                    time.gmtime(s[stat.ST_CTIME]))
            self.sm_config['hotplugged_at'] = iso8601

            dev = os.path.basename(self.path)
            info = sysdevice.stat(dev)
            if "size" in info.keys():
                self.size = info["size"]
                self.utilisation = self.size

            self.label = "%s %s" % (info["bus"], info["bus_path"])
            self.description = info["hwinfo"]

            # XXX: what other information can we recover?
            if self.sr.sm_config.has_key('type'):
                self.read_only = self.sr.sm_config['type'] == "cd"

        except OSError, e:
            self.deleted = True
Beispiel #2
0
Datei: udevSR.py Projekt: ESDS/sm
    def load(self, location):
        self.path = self.location
        self.size = 0
        self.utilisation = 0
        self.label = self.path
        self.sm_config = {}
        try:
            s = os.stat(self.path)
            self.deleted = False

            # Use the CTIME of the symlink to mean "time it was hotplugged"
            iso8601 = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(s[stat.ST_CTIME]))
            self.sm_config['hotplugged_at'] = iso8601

            dev = os.path.basename(self.path)
	    info = sysdevice.stat(dev)
	    if "size" in info.keys():
	        self.size = info["size"]
                self.utilisation = self.size

            self.label = "%s %s" % (info["bus"], info["bus_path"])
            self.description = info["hwinfo"]
            
            # XXX: what other information can we recover?
            if self.sr.sm_config.has_key('type'):
                self.read_only = self.sr.sm_config['type'] == "cd"
                
        except OSError, e:
            self.deleted = True
Beispiel #3
0
    def load(self, location):
        self.path = self.location
        self.size = 0
        self.utilisation = 0
        self.label = self.path
        self.sm_config = {}
        try:
            s = os.stat(self.path)
            self.deleted = False

            # Use the CTIME of the symlink to mean "time it was hotplugged"
            iso8601 = time.strftime("%Y-%m-%dT%H:%M:%SZ",
                                    time.gmtime(s[stat.ST_CTIME]))
            self.sm_config['hotplugged_at'] = iso8601

            dev = os.path.basename(self.path)
            info = sysdevice.stat(dev)
            if "size" in info.keys():
                self.size = info["size"]
                self.utilisation = self.size

            self.label = "%s %s" % (info["bus"], info["bus_path"])
            self.description = info["hwinfo"]

            # XXX: what other information can we recover?
            if 'type' in self.sr.sm_config:
                self.read_only = self.sr.sm_config['type'] == "cd"

            usb_path = info.get("usb_path")
            if usb_path:
                self.sm_config["usb_path"] = info["usb_path"]
                pusbs = self.session.xenapi.PUSB.get_all_records()
                for pusb in pusbs.itervalues():
                    if usb_path == pusb.get("path"):
                        if pusb.get("passthrough_enabled"):
                            raise xs_errors.XenError('VDIUnavailable')
                        break

        except OSError as e:
            self.deleted = True