Beispiel #1
0
    def detach(self, sr_uuid):
        keys = []
        pbdref = None
        try:
            pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass
        if self.dconf.has_key("SCSIid"):
            self.mpathmodule.reset(self.dconf["SCSIid"], True)  # explicitly unmap
            keys.append("mpath-" + self.dconf["SCSIid"])

        # Remove iscsi_sessions and multipathed keys
        if pbdref <> None:
            if self.cmd == "sr_detach":
                keys += ["multipathed", "iscsi_sessions", "MPPEnabled"]
            for key in keys:
                try:
                    self.session.xenapi.PBD.remove_from_other_config(pbdref, key)
                except:
                    pass

        if util._decr_iscsiSR_refcount(self.targetIQN, sr_uuid) != 0:
            return

        if self.direct and util._containsVDIinuse(self):
            return

        if iscsilib._checkTGT(self.targetIQN):
            try:
                iscsilib.logout(self.target, self.targetIQN, all=True)
            except util.CommandException, inst:
                raise xs_errors.XenError("ISCSIQueryDaemon", opterr="error is %d" % inst.code)
            if iscsilib._checkTGT(self.targetIQN):
                raise xs_errors.XenError("ISCSIQueryDaemon", opterr="Failed to logout from target")
Beispiel #2
0
    def detach(self, sr_uuid, delete=False):
        keys = []
        pbdref = None
        try:
            pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass
        if 'SCSIid' in self.dconf:
            self.mpathmodule.reset(self.dconf['SCSIid'], explicit_unmap=True)
            keys.append("mpath-" + self.dconf['SCSIid'])

        # Remove iscsi_sessions and multipathed keys
        if pbdref != None:
            if self.cmd == 'sr_detach':
                keys += ["multipathed", "iscsi_sessions", "MPPEnabled"]
            for key in keys:
                try:
                    self.session.xenapi.PBD.remove_from_other_config(
                        pbdref, key)
                except:
                    pass

        if util._decr_iscsiSR_refcount(self.targetIQN, sr_uuid) != 0:
            return

        if self.direct and util._containsVDIinuse(self):
            return

        if iscsilib._checkTGT(self.targetIQN):
            try:
                iscsilib.logout(self.target, self.targetIQN, all=True)
                if delete:
                    iscsilib.delete(self.targetIQN)
            except util.CommandException as inst:
                raise xs_errors.XenError('ISCSIQueryDaemon', \
                      opterr='error is %d' % inst.code)
            if iscsilib._checkTGT(self.targetIQN):
                raise xs_errors.XenError('ISCSIQueryDaemon', \
                    opterr='Failed to logout from target')

        self.attached = False
Beispiel #3
0
 def detach(self, sr_uuid):
     if util._containsVDIinuse(self):
         return
     return
Beispiel #4
0
 def detach(self, sr_uuid):
     if util._containsVDIinuse(self):
         return
     return