Example #1
0
    def __init__(self, driver_name, driver_protocol, **kwargs):

        na_utils.validate_instantiation(**kwargs)

        self.driver_name = driver_name
        self.driver_protocol = driver_protocol
        self.zapi_client = None
        self._stats = {}
        self.lun_table = {}
        self.lun_ostype = None
        self.host_type = None
        self.lun_space_reservation = 'true'
        self.lookup_service = fczm_utils.create_lookup_service()
        self.app_version = kwargs.get("app_version", "unknown")
        self.host = kwargs.get('host')
        self.backend_name = self.host.split('@')[1]

        self.configuration = kwargs['configuration']
        self.configuration.append_config_values(na_opts.netapp_connection_opts)
        self.configuration.append_config_values(na_opts.netapp_basicauth_opts)
        self.configuration.append_config_values(na_opts.netapp_transport_opts)
        self.configuration.append_config_values(
            na_opts.netapp_provisioning_opts)
        self.configuration.append_config_values(na_opts.netapp_san_opts)
        self.max_over_subscription_ratio = (
            volume_utils.get_max_over_subscription_ratio(
                self.configuration.max_over_subscription_ratio,
                supports_auto=True))
        self.reserved_percentage = self._get_reserved_percentage()
        self.loopingcalls = loopingcalls.LoopingCalls()
Example #2
0
    def __init__(self, execute=putils.execute, *args, **kwargs):
        self._remotefsclient = None
        super(NfsDriver, self).__init__(*args, **kwargs)
        self.configuration.append_config_values(nfs_opts)
        root_helper = utils.get_root_helper()
        # base bound to instance is used in RemoteFsConnector.
        self.base = getattr(self.configuration,
                            'nfs_mount_point_base')
        self.base = os.path.realpath(self.base)
        opts = getattr(self.configuration,
                       'nfs_mount_options')

        nas_mount_options = getattr(self.configuration,
                                    'nas_mount_options',
                                    None)
        if nas_mount_options is not None:
            LOG.debug('overriding nfs_mount_options with nas_mount_options')
            opts = nas_mount_options

        self._remotefsclient = remotefs_brick.RemoteFsClient(
            'nfs', root_helper, execute=execute,
            nfs_mount_point_base=self.base,
            nfs_mount_options=opts)

        supports_auto_mosr = kwargs.get('supports_auto_mosr', False)
        self._sparse_copy_volume_data = True
        self.reserved_percentage = self.configuration.reserved_percentage
        self.max_over_subscription_ratio = (
            volume_utils.get_max_over_subscription_ratio(
                self.configuration.max_over_subscription_ratio,
                supports_auto=supports_auto_mosr))

        self._supports_encryption = True
Example #3
0
 def update_volume_stats(self):
     """Update properties, capabilities and current states of the driver."""
     data = {}
     backend_name = (self.conf.safe_get('volume_backend_name') or
                     self.driver_info['volume_backend_name'])
     data = {
         'volume_backend_name': backend_name,
         'vendor_name': 'Hitachi',
         'driver_version': VERSION,
         'storage_protocol': self.storage_info['protocol'],
         'pools': [],
     }
     single_pool = {}
     single_pool.update(dict(
         pool_name=data['volume_backend_name'],
         reserved_percentage=self.conf.safe_get('reserved_percentage'),
         QoS_support=False,
         thick_provisioning_support=False,
         multiattach=True
     ))
     try:
         (total_capacity, free_capacity,
          provisioned_capacity) = self.get_pool_info()
     except utils.HBSDError:
         single_pool.update(dict(
             provisioned_capacity_gb=0,
             backend_state='down'))
         data["pools"].append(single_pool)
         LOG.debug("Updating volume status. (%s)", data)
         utils.output_log(
             MSG.POOL_INFO_RETRIEVAL_FAILED,
             pool=self.conf.hitachi_pool)
         return data
     single_pool.update(dict(
         total_capacity_gb=total_capacity,
         free_capacity_gb=free_capacity,
         provisioned_capacity_gb=provisioned_capacity,
         max_over_subscription_ratio=(
             volume_utils.get_max_over_subscription_ratio(
                 self.conf.safe_get('max_over_subscription_ratio'),
                 True)),
         thin_provisioning_support=True
     ))
     single_pool.update(dict(backend_state='up'))
     data["pools"].append(single_pool)
     LOG.debug("Updating volume status. (%s)", data)
     return data
Example #4
0
    def do_setup(self, context):
        self.configuration.max_over_subscription_ratio = (
            volume_utils.get_max_over_subscription_ratio(
                self.configuration.max_over_subscription_ratio,
                supports_auto=False))

        if not self.configuration.max_over_subscription_ratio > 0:
            msg = _("Config 'max_over_subscription_ratio' invalid. Must be > "
                    "0: %s") % self.configuration.max_over_subscription_ratio
            LOG.error(msg)
            raise exception.NfsException(msg)

        packages = ('mount.nfs', '/usr/sbin/mount')
        for package in packages:
            try:
                self._execute(package, check_exit_code=False, run_as_root=True)
                break
            except OSError as exc:
                if exc.errno != errno.ENOENT:
                    raise
                LOG.error('%s is not installed.', package)
        else:
            msg = utils.build_or_str(packages, '%s needs to be installed.')
            raise exception.NfsException(msg)

        lcfg = self.configuration
        LOG.info('Connecting to host: %s.', lcfg.san_ip)

        host = lcfg.san_ip
        user = lcfg.san_login
        password = lcfg.san_password
        https_port = lcfg.zfssa_https_port

        credentials = ['san_ip', 'san_login', 'san_password', 'zfssa_data_ip']

        for cred in credentials:
            if not getattr(lcfg, cred, None):
                exception_msg = _('%s not set in cinder.conf') % cred
                LOG.error(exception_msg)
                raise exception.CinderException(exception_msg)

        self.zfssa = factory_zfssa()
        self.zfssa.set_host(host, timeout=lcfg.zfssa_rest_timeout)

        auth_str = base64.encode_as_text('%s:%s' % (user, password))
        self.zfssa.login(auth_str)

        self.zfssa.create_project(lcfg.zfssa_nfs_pool,
                                  lcfg.zfssa_nfs_project,
                                  compression=lcfg.zfssa_nfs_share_compression,
                                  logbias=lcfg.zfssa_nfs_share_logbias)

        share_args = {
            'sharedav': 'rw',
            'sharenfs': 'rw',
            'root_permissions': '777',
            'compression': lcfg.zfssa_nfs_share_compression,
            'logbias': lcfg.zfssa_nfs_share_logbias
        }

        self.zfssa.create_share(lcfg.zfssa_nfs_pool, lcfg.zfssa_nfs_project,
                                lcfg.zfssa_nfs_share, share_args)

        share_details = self.zfssa.get_share(lcfg.zfssa_nfs_pool,
                                             lcfg.zfssa_nfs_project,
                                             lcfg.zfssa_nfs_share)

        mountpoint = share_details['mountpoint']

        self.mount_path = lcfg.zfssa_data_ip + ':' + mountpoint
        https_path = 'https://' + lcfg.zfssa_data_ip + ':' + https_port + \
            '/shares' + mountpoint

        LOG.debug('NFS mount path: %s', self.mount_path)
        LOG.debug('WebDAV path to the share: %s', https_path)

        self.shares = {}
        mnt_opts = self.configuration.zfssa_nfs_mount_options
        self.shares[self.mount_path] = mnt_opts if len(mnt_opts) > 1 else None

        # Initialize the WebDAV client
        self.zfssa.set_webdav(https_path, auth_str)

        # Edit http service so that WebDAV requests are always authenticated
        args = {'https_port': https_port, 'require_login': True}

        self.zfssa.modify_service('http', args)
        self.zfssa.enable_service('http')

        if lcfg.zfssa_enable_local_cache:
            LOG.debug('Creating local cache directory %s.',
                      lcfg.zfssa_cache_directory)
            self.zfssa.create_directory(lcfg.zfssa_cache_directory)