Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: add FC Support
......................................................................

packaging: setup: add FC Support

Add FC Support to Hosted Engine.
See feature page:
http://www.ovirt.org/Features/Self_Hosted_Engine_FC_Support
for documentation.

Change-Id: I344ee4cdc724a8499c451adbcd8860c3d1e20c27
Bug-Url: https://bugzilla.redhat.com/1153278
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/storage/__init__.py
R src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
4 files changed, 138 insertions(+), 85 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/30/37830/1

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 59620c0..70170ea 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -75,6 +75,7 @@
     NFS4 = 'nfs4'
     GLUSTERFS = 'glusterfs'
     ISCSI = 'iscsi'
+    FC = 'fc'
 
 
 @util.export
@@ -97,6 +98,7 @@
 @util.codegen
 class VDSMConstants(object):
     NFS_DOMAIN = 1
+    FC_DOMAIN = 2
     ISCSI_DOMAIN = 3
     GLUSTERFS_DOMAIN = 7
     DATA_DOMAIN = 1
@@ -762,7 +764,7 @@
     CONFIG_BOOT_DEVICE = 'ohosted.boot.configuration.available'
     CONFIG_STORAGE_EARLY = 'ohosted.storage.configuration.early'
     CONFIG_STORAGE_LATE = 'ohosted.storage.configuration.late'
-    CONFIG_STORAGE_ISCSI = 'ohosted.storage.iscsi.configuration.available'
+    CONFIG_STORAGE_BLOCKD = 'ohosted.storage.blockd.configuration.available'
     CONFIG_STORAGE_NFS = 'ohosted.storage.nfs.configuration.available'
     CONFIG_ADDITIONAL_HOST = 'ohosted.core.additional.host'
     REQUIRE_ANSWER_FILE = 'ohosted.core.require.answerfile'
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py
index 9f486bf..ff9b8fb 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py
@@ -24,14 +24,14 @@
 from otopi import util
 
 
-from . import iscsi
+from . import blockd
 from . import nfs
 from . import storage
 
 
 @util.export
 def createPlugins(context):
-    iscsi.Plugin(context=context)
+    blockd.Plugin(context=context)
     nfs.Plugin(context=context)
     storage.Plugin(context=context)
 
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
similarity index 76%
rename from src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py
rename to src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
index 2600116..36a59b4 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
@@ -42,7 +42,7 @@
 @util.export
 class Plugin(plugin.PluginBase):
     """
-    iSCSI storage domain plugin.
+    Block devices (iSCSI, FC) storage domain plugin.
     """
 
     _MAXRETRY = 2
@@ -53,6 +53,7 @@
         super(Plugin, self).__init__(context=context)
         self._interactive = False
         self.cli = None
+        self.storageType = None
 
     def _customize_ip_address(self):
         valid = False
@@ -170,14 +171,19 @@
             )
         return target
 
-    def _customize_lun(self, target):
-        available_luns = self._iscsi_get_lun_list(
-            ip=self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR],
-            port=self.environment[ohostedcons.StorageEnv.ISCSI_PORT],
-            user=self.environment[ohostedcons.StorageEnv.ISCSI_USER],
-            password=self.environment[ohostedcons.StorageEnv.ISCSI_PASSWORD],
-            iqn=target,
-        )
+    def _customize_lun(self, storageType, target):
+        if storageType == ohostedcons.VDSMConstants.ISCSI_DOMAIN:
+            available_luns = self._iscsi_get_lun_list(
+                ip=self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR],
+                port=self.environment[ohostedcons.StorageEnv.ISCSI_PORT],
+                user=self.environment[ohostedcons.StorageEnv.ISCSI_USER],
+                password=self.environment[
+                    ohostedcons.StorageEnv.ISCSI_PASSWORD
+                ],
+                iqn=target,
+            )
+        elif storageType == ohostedcons.VDSMConstants.FC_DOMAIN:
+            available_luns = self._fc_get_lun_list()
         if len(available_luns) == 0:
             self.logger.error(_('Cannot find any LUN on the selected target'))
             return None
@@ -235,7 +241,7 @@
         if lunGUID is None:
             self._interactive = True
             slun = self.dialog.queryString(
-                name='OVEHOSTED_STORAGE_ISCSI_LUN',
+                name='OVEHOSTED_STORAGE_BLOCKD_LUN',
                 note=_(
                     'Please select the destination LUN '
                     '(@VALUES@) [@DEFAULT@]: '
@@ -312,6 +318,18 @@
                                "iscsi target")
         return iscsi_lun_list
 
+    def _fc_get_lun_list(self):
+        fc_lun_list = []
+        devices = self.cli.getDeviceList(
+            ohostedcons.VDSMConstants.FC_DOMAIN
+        )
+        self.logger.debug(devices)
+        if devices['status']['code'] != 0:
+            raise RuntimeError(devices['status']['message'])
+        for device in devices['devList']:
+            fc_lun_list.append(device)
+        return fc_lun_list
+
     def _iscsi_get_device(self, ip, port, user, password, iqn, lunGUID):
         available_luns = self._iscsi_get_lun_list(
             ip, port, user, password, iqn
@@ -321,15 +339,27 @@
                     return iscsi_device
         return None
 
-    def _validate_domain(self, target, lunGUID):
-        device = self._iscsi_get_device(
-            ip=self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR],
-            port=self.environment[ohostedcons.StorageEnv.ISCSI_PORT],
-            user=self.environment[ohostedcons.StorageEnv.ISCSI_USER],
-            password=self.environment[ohostedcons.StorageEnv.ISCSI_PASSWORD],
-            iqn=target,
-            lunGUID=lunGUID
-        )
+    def _fc_get_device(self, lunGUID):
+        available_luns = self._fc_get_lun_list()
+        for fc_device in available_luns:
+            if fc_device['GUID'] == lunGUID:
+                    return fc_device
+        return None
+
+    def _validate_domain(self, storageType, target, lunGUID):
+        if storageType == ohostedcons.VDSMConstants.ISCSI_DOMAIN:
+            device = self._iscsi_get_device(
+                ip=self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR],
+                port=self.environment[ohostedcons.StorageEnv.ISCSI_PORT],
+                user=self.environment[ohostedcons.StorageEnv.ISCSI_USER],
+                password=self.environment[
+                    ohostedcons.StorageEnv.ISCSI_PASSWORD
+                ],
+                iqn=target,
+                lunGUID=lunGUID
+            )
+        elif storageType == ohostedcons.VDSMConstants.FC_DOMAIN:
+            device = self._fc_get_device(lunGUID)
         if device is None:
             raise RuntimeError(
                 _('The requested device is not listed by VDSM')
@@ -423,7 +453,7 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
-        name=ohostedcons.Stages.CONFIG_STORAGE_ISCSI,
+        name=ohostedcons.Stages.CONFIG_STORAGE_BLOCKD,
         after=(
             ohostedcons.Stages.CONFIG_STORAGE_EARLY,
         ),
@@ -431,64 +461,74 @@
             ohostedcons.Stages.CONFIG_STORAGE_LATE,
         ),
         condition=(
-            lambda self: self.environment[
-                ohostedcons.StorageEnv.DOMAIN_TYPE
-            ] == ohostedcons.DomainTypes.ISCSI
+            lambda self: (
+                self.environment[
+                    ohostedcons.StorageEnv.DOMAIN_TYPE
+                ] == ohostedcons.DomainTypes.ISCSI or
+                self.environment[
+                    ohostedcons.StorageEnv.DOMAIN_TYPE
+                ] == ohostedcons.DomainTypes.FC
+            ),
         ),
     )
     def _customization(self):
         self.cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
-        valid_access = False
-        valid_lun = False
-        address = None
-        port = None
-        user = None
-        password = None
-        target = None
+        self.storageType = self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE]
         lunGUID = None
-        valid_targets = []
-        while not valid_access:
-            address = self._customize_ip_address()
-            port = self._customize_port()
-            user = self._customize_user()
-            password = self._customize_password(user)
-            self.environment[otopicons.CoreEnv.LOG_FILTER].append(password)
-            # Validating access
-            try:
-                valid_targets = self._iscsi_discovery(
-                    address,
-                    port,
-                    user,
-                    password,
-                )
-                valid_access = True
-            except RuntimeError as e:
-                self.logger.debug('exception', exc_info=True)
-                self.logger.error(e)
-                if not self._interactive:
-                    raise RuntimeError(_('Cannot access iSCSI portal'))
-        self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR] = address
-        self.environment[ohostedcons.StorageEnv.ISCSI_PORT] = port
-        self.environment[ohostedcons.StorageEnv.ISCSI_USER] = user
-        self.environment[ohostedcons.StorageEnv.ISCSI_PASSWORD] = password
+        valid_lun = False
+        target = None
+        if self.storageType == ohostedcons.DomainTypes.ISCSI:
+            valid_access = False
+            address = None
+            port = None
+            user = None
+            password = None
+            valid_targets = []
+            while not valid_access:
+                address = self._customize_ip_address()
+                port = self._customize_port()
+                user = self._customize_user()
+                password = self._customize_password(user)
+                self.environment[otopicons.CoreEnv.LOG_FILTER].append(password)
+                # Validating access
+                try:
+                    valid_targets = self._iscsi_discovery(
+                        address,
+                        port,
+                        user,
+                        password,
+                    )
+                    valid_access = True
+                except RuntimeError as e:
+                    self.logger.debug('exception', exc_info=True)
+                    self.logger.error(e)
+                    if not self._interactive:
+                        raise RuntimeError(_('Cannot access iSCSI portal'))
+            self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR] = address
+            self.environment[ohostedcons.StorageEnv.ISCSI_PORT] = port
+            self.environment[ohostedcons.StorageEnv.ISCSI_USER] = user
+            self.environment[ohostedcons.StorageEnv.ISCSI_PASSWORD] = password
 
         while not valid_lun:
-            target = self._customize_target(
-                values=valid_targets,
-                default=valid_targets[0]
-            )
-            lunGUID = self._customize_lun(target)
+            if self.storageType == ohostedcons.DomainTypes.ISCSI:
+                target = self._customize_target(
+                    values=valid_targets,
+                    default=valid_targets[0]
+                )
+            else:
+                target = None
+            lunGUID = self._customize_lun(self.storageType, target)
             if lunGUID is not None:
                 try:
-                    self._validate_domain(target, lunGUID)
+                    self._validate_domain(self.storageType, target, lunGUID)
                     valid_lun = True
                 except Exception as e:
                     self.logger.debug('exception', exc_info=True)
                     self.logger.error(e)
                     if not self._interactive:
-                        raise RuntimeError(_('Cannot access iSCSI LUN'))
-
-        self.environment[ohostedcons.StorageEnv.ISCSI_TARGET] = target
+                        raise RuntimeError(_('Cannot access LUN'))
+        if self.storageType == ohostedcons.VDSMConstants.ISCSI_DOMAIN:
+            self.environment[ohostedcons.StorageEnv.ISCSI_TARGET] = target
         self.environment[ohostedcons.StorageEnv.LUN_ID] = lunGUID
 
     @plugin.event(
@@ -500,28 +540,24 @@
             ohostedcons.Stages.STORAGE_AVAILABLE,
         ),
         condition=(
-            lambda self: self.environment[
-                ohostedcons.StorageEnv.DOMAIN_TYPE
-            ] == ohostedcons.DomainTypes.ISCSI
+            lambda self: (
+                self.environment[
+                    ohostedcons.StorageEnv.DOMAIN_TYPE
+                ] == ohostedcons.DomainTypes.ISCSI or
+                self.environment[
+                    ohostedcons.StorageEnv.DOMAIN_TYPE
+                ] == ohostedcons.DomainTypes.FC
+            ),
         ),
     )
     def _misc(self):
-        iscsi_device = self._iscsi_get_device(
-            ip=self.environment[ohostedcons.StorageEnv.ISCSI_IP_ADDR],
-            port=self.environment[ohostedcons.StorageEnv.ISCSI_PORT],
-            user=self.environment[ohostedcons.StorageEnv.ISCSI_USER],
-            password=self.environment[ohostedcons.StorageEnv.ISCSI_PASSWORD],
-            iqn=self.environment[ohostedcons.StorageEnv.ISCSI_TARGET],
-            lunGUID=self.environment[ohostedcons.StorageEnv.LUN_ID],
-        )
-
         if self.environment[ohostedcons.StorageEnv.VG_UUID] is None:
             # If we don't have a volume group we must create it
             self.logger.info(_('Creating Volume Group'))
             dom = self.cli.createVG(
                 self.environment[ohostedcons.StorageEnv.SD_UUID],
                 [
-                    iscsi_device['GUID'],
+                    self.environment[ohostedcons.StorageEnv.LUN_ID],
                 ],
                 False,
             )
@@ -538,7 +574,10 @@
         self.logger.debug(vginfo)
         if vginfo['status']['code'] != 0:
             raise RuntimeError(vginfo['status']['message'])
-        if self.environment[ohostedcons.StorageEnv.ISCSI_PORTAL] is None:
+        if (
+            self.storageType == ohostedcons.DomainTypes.ISCSI and
+            self.environment[ohostedcons.StorageEnv.ISCSI_PORTAL] is None
+        ):
             try:
                 for pv in vginfo['info']['pvlist']:
                     for path in pv['pathlist']:
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index aa1ea48..c0303fc 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -186,6 +186,7 @@
         """
         if self.storageType in (
             ohostedcons.VDSMConstants.ISCSI_DOMAIN,
+            ohostedcons.VDSMConstants.FC_DOMAIN,
         ):
             # For iSCSI we need to connect the pool for
             # having /rhev populated.
@@ -287,6 +288,7 @@
     def _getExistingDomain(self):
         if self.storageType in (
             ohostedcons.VDSMConstants.ISCSI_DOMAIN,
+            ohostedcons.VDSMConstants.FC_DOMAIN,
         ):
             if self.environment[ohostedcons.StorageEnv.VG_UUID] is not None:
                 vginfo = self.cli.getVGInfo(
@@ -513,6 +515,7 @@
             ]
         elif self.storageType in (
             ohostedcons.VDSMConstants.ISCSI_DOMAIN,
+            ohostedcons.VDSMConstants.FC_DOMAIN,
         ):
             typeSpecificArgs = self.environment[
                 ohostedcons.StorageEnv.VG_UUID
@@ -854,7 +857,7 @@
         ),
         before=(
             ohostedcons.Stages.CONFIG_STORAGE_NFS,
-            ohostedcons.Stages.CONFIG_STORAGE_ISCSI,
+            ohostedcons.Stages.CONFIG_STORAGE_BLOCKD,
         ),
     )
     def _early_customization(self):
@@ -878,6 +881,7 @@
                 validValues=(
                     ohostedcons.DomainTypes.GLUSTERFS,
                     ohostedcons.DomainTypes.ISCSI,
+                    ohostedcons.DomainTypes.FC,
                     ohostedcons.DomainTypes.NFS3,
                     ohostedcons.DomainTypes.NFS4,
                 ),
@@ -894,6 +898,9 @@
             self.storageType = ohostedcons.VDSMConstants.GLUSTERFS_DOMAIN
         elif domain_type == ohostedcons.DomainTypes.ISCSI:
             self.storageType = ohostedcons.VDSMConstants.ISCSI_DOMAIN
+        elif domain_type == ohostedcons.DomainTypes.FC:
+            self.storageType = ohostedcons.VDSMConstants.FC_DOMAIN
+
         else:
             raise RuntimeError(
                 _(
@@ -914,7 +921,7 @@
         priority=plugin.Stages.PRIORITY_FIRST,
         after=(
             ohostedcons.Stages.CONFIG_STORAGE_NFS,
-            ohostedcons.Stages.CONFIG_STORAGE_ISCSI,
+            ohostedcons.Stages.CONFIG_STORAGE_BLOCKD,
         ),
         before=(
             ohostedcons.Stages.DIALOG_TITLES_E_STORAGE,
@@ -953,7 +960,7 @@
             ohostedcons.VDSMConstants.ISCSI_DOMAIN,
         ):
             devices = self.cli.getDeviceList(
-                ohostedcons.VDSMConstants.ISCSI_DOMAIN
+                self.storageType
             )
             self.logger.debug(devices)
             if devices['status']['code'] != 0:
@@ -966,13 +973,18 @@
                     ]:
                         iscsi_device = device
                         break
-
             if iscsi_device is None:
                 self.logger.info(_('Connecting Storage Domain'))
                 self._storageServerConnection()
             if not self.domain_exists:
                 self.logger.info(_('Creating Storage Domain'))
                 self._createStorageDomain()
+        if self.storageType in (
+            ohostedcons.VDSMConstants.FC_DOMAIN,
+        ):
+            if not self.domain_exists:
+                self.logger.info(_('Creating Storage Domain'))
+                self._createStorageDomain()
 
         if not self.pool_exists:
             self.logger.info(_('Creating Storage Pool'))


-- 
To view, visit http://gerrit.ovirt.org/37830
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I344ee4cdc724a8499c451adbcd8860c3d1e20c27
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to