def _get_wt_snapshot(self, description, fail_if_not_found=True): wt_snapshots = self._conn_wmi.WT_Snapshot(Description=description) if wt_snapshots: return wt_snapshots[0] elif fail_if_not_found: err_msg = _('Could not find WT Snapshot: %s') raise exceptions.ISCSITargetException(err_msg % description)
def _get_wt_disk(self, description, fail_if_not_found=True): # We can retrieve WT Disks only by description. wt_disks = self._conn_wmi.WT_Disk(Description=description) if wt_disks: return wt_disks[0] elif fail_if_not_found: err_msg = _('Could not find WT Disk: %s') raise exceptions.ISCSITargetException(err_msg % description)
def _get_wt_host(self, target_name, fail_if_not_found=True): hosts = self._conn_wmi.WT_Host(HostName=target_name) if hosts: return hosts[0] elif fail_if_not_found: err_msg = _('Could not find iSCSI target %s') raise exceptions.ISCSITargetException(err_msg % target_name)
def get_portal_locations(self, available_only=True, fail_if_none_found=True): wt_portals = self._conn_wmi.WT_Portal() if available_only: wt_portals = list(filter(lambda portal: portal.Listen, wt_portals)) if not wt_portals and fail_if_none_found: err_msg = _("No valid iSCSI portal was found.") raise exceptions.ISCSITargetException(err_msg) portal_locations = [self._get_portal_location(portal) for portal in wt_portals] return portal_locations
def _ensure_wt_provider_available(self): try: self._conn_wmi.WT_Portal except AttributeError: err_msg = _("The Windows iSCSI target provider is not available.") raise exceptions.ISCSITargetException(err_msg)