Exemplo n.º 1
0
    def connect(self, emc_share_driver, context):
        """Connect to Unity storage."""
        config = emc_share_driver.configuration
        storage_ip = enas_utils.convert_ipv6_format_if_needed(
            config.emc_nas_server)
        username = config.emc_nas_login
        password = config.emc_nas_password
        self.client = client.UnityClient(storage_ip, username, password)

        pool_conf = config.safe_get('unity_share_data_pools')
        self.pool_set = self._get_managed_pools(pool_conf)

        self.reserved_percentage = config.safe_get('reserved_share_percentage')
        if self.reserved_percentage is None:
            self.reserved_percentage = 0

        self.max_over_subscription_ratio = config.safe_get(
            'max_over_subscription_ratio')
        self.port_ids_conf = config.safe_get('unity_ethernet_ports')
        self.unity_share_server = config.safe_get('unity_share_server')
        self.driver_handles_share_servers = config.safe_get(
            'driver_handles_share_servers')
        if (not self.driver_handles_share_servers) and (
                not self.unity_share_server):
            msg = ("Make sure there is NAS server name "
                   "configured for share creation when driver "
                   "is in DHSS=False mode.")
            raise exception.BadConfigurationException(reason=msg)
        self.validate_port_configuration(self.port_ids_conf)
        pool_name = config.unity_server_meta_pool
        self._config_pool(pool_name)
Exemplo n.º 2
0
 def nfs_allow_access(self, share_name, host_ip, access_level):
     share = self.system.get_nfs_share(name=share_name)
     host_ip = enas_utils.convert_ipv6_format_if_needed(host_ip)
     if access_level == const.ACCESS_LEVEL_RW:
         share.allow_read_write_access(host_ip, force_create_host=True)
         share.allow_root_access(host_ip, force_create_host=True)
     else:
         share.allow_read_only_access(host_ip, force_create_host=True)
Exemplo n.º 3
0
 def nfs_allow_access(self, share_name, host_ip, access_level):
     share = self.system.get_nfs_share(name=share_name)
     host_ip = enas_utils.convert_ipv6_format_if_needed(host_ip)
     if access_level == const.ACCESS_LEVEL_RW:
         share.allow_read_write_access(host_ip, force_create_host=True)
         share.allow_root_access(host_ip, force_create_host=True)
     else:
         share.allow_read_only_access(host_ip, force_create_host=True)
Exemplo n.º 4
0
 def _get_nfs_location(file_interfaces, share_name):
     return [{
         'path': '%(interface)s:/%(share_name)s' % {
             'interface':
             enas_utils.convert_ipv6_format_if_needed(interface.ip_address),
             'share_name':
             share_name
         }
     } for interface in file_interfaces]
Exemplo n.º 5
0
 def _get_nfs_location(file_interfaces, share_name):
     return [
         {'path': '%(interface)s:/%(share_name)s' % {
             'interface': enas_utils.convert_ipv6_format_if_needed(
                 interface.ip_address),
             'share_name': share_name}
          }
         for interface in file_interfaces
     ]
Exemplo n.º 6
0
    def _create_nfs_share(self, share_name, share_server):
        """Create NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        self._get_context('NFSShare').create(share_name, vdm_name)

        nfs_if = enas_utils.convert_ipv6_format_if_needed(
            share_server['backend_details']['nfs_if'])

        return ('%(nfs_if)s:/%(share_name)s'
                % {'nfs_if': nfs_if,
                   'share_name': share_name})
Exemplo n.º 7
0
    def _create_nfs_share(self, share_name, share_server):
        """Create NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        self._get_context('NFSShare').create(share_name, vdm_name)

        nfs_if = enas_utils.convert_ipv6_format_if_needed(
            share_server['backend_details']['nfs_if'])

        return ('%(nfs_if)s:/%(share_name)s'
                % {'nfs_if': nfs_if,
                   'share_name': share_name})
Exemplo n.º 8
0
    def _nfs_deny_access(self, share, access, share_server):
        """Deny access to NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        access_type = access['access_type']
        if access_type != 'ip':
            reason = _('Only ip access type allowed.')
            raise exception.InvalidShareAccess(reason=reason)

        host_ip = enas_utils.convert_ipv6_format_if_needed(access['access_to'])

        self._get_context('NFSShare').deny_share_access(
            share['id'], host_ip, vdm_name)
Exemplo n.º 9
0
    def _nfs_deny_access(self, share, access, share_server):
        """Deny access to NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        access_type = access['access_type']
        if access_type != 'ip':
            LOG.warning("Only ip access type allowed.")
            return

        host_ip = enas_utils.convert_ipv6_format_if_needed(access['access_to'])

        self._get_context('NFSShare').deny_share_access(share['id'], host_ip,
                                                        vdm_name)
Exemplo n.º 10
0
    def _nfs_deny_access(self, share, access, share_server):
        """Deny access to NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        access_type = access['access_type']
        if access_type != 'ip':
            LOG.warning("Only ip access type allowed.")
            return

        host_ip = enas_utils.convert_ipv6_format_if_needed(access['access_to'])

        self._get_context('NFSShare').deny_share_access(
            share['id'], host_ip, vdm_name)
Exemplo n.º 11
0
    def _nfs_deny_access(self, share, access, share_server):
        """Deny access to NFS share."""
        vdm_name = self._get_share_server_name(share_server)

        access_type = access['access_type']
        if access_type != 'ip':
            reason = _('Only ip access type allowed.')
            raise exception.InvalidShareAccess(reason=reason)

        host_ip = enas_utils.convert_ipv6_format_if_needed(access['access_to'])

        self._get_context('NFSShare').deny_share_access(share['id'], host_ip,
                                                        vdm_name)
Exemplo n.º 12
0
    def update_access(self, context, share, access_rules, add_rules,
                      delete_rules, share_server=None):
        # deleting rules
        for rule in delete_rules:
            self.deny_access(context, share, rule, share_server)

        # adding rules
        for rule in add_rules:
            self.allow_access(context, share, rule, share_server)

        # recovery mode
        if not (add_rules or delete_rules):
            white_list = []
            for rule in access_rules:
                self.allow_access(context, share, rule, share_server)
                white_list.append(
                    enas_utils.convert_ipv6_format_if_needed(
                        rule['access_to']))
            self.clear_access(share, share_server, white_list)
Exemplo n.º 13
0
    def update_access(self, context, share, access_rules, add_rules,
                      delete_rules, share_server=None):
        # deleting rules
        for rule in delete_rules:
            self.deny_access(context, share, rule, share_server)

        # adding rules
        for rule in add_rules:
            self.allow_access(context, share, rule, share_server)

        # recovery mode
        if not (add_rules or delete_rules):
            white_list = []
            for rule in access_rules:
                self.allow_access(context, share, rule, share_server)
                white_list.append(
                    enas_utils.convert_ipv6_format_if_needed(
                        rule['access_to']))
            self.clear_access(share, share_server, white_list)
Exemplo n.º 14
0
 def __init__(self, configuration, debug=True):
     super(XMLAPIConnector, self).__init__()
     self.storage_ip = enas_utils.convert_ipv6_format_if_needed(
         configuration.emc_nas_server)
     self.username = configuration.emc_nas_login
     self.password = configuration.emc_nas_password
     self.debug = debug
     self.auth_url = 'https://' + self.storage_ip + '/Login'
     self._url = 'https://{}/servlets/CelerraManagementServices'.format(
         self.storage_ip)
     context = enas_utils.create_ssl_context(configuration)
     if context:
         https_handler = url_request.HTTPSHandler(context=context)
     else:
         https_handler = url_request.HTTPSHandler()
     cookie_handler = url_request.HTTPCookieProcessor(
         http_cookiejar.CookieJar())
     self.url_opener = url_request.build_opener(https_handler,
                                                cookie_handler)
     self._do_setup()
Exemplo n.º 15
0
 def __init__(self, configuration, debug=True):
     super(XMLAPIConnector, self).__init__()
     self.storage_ip = enas_utils.convert_ipv6_format_if_needed(
         configuration.emc_nas_server)
     self.username = configuration.emc_nas_login
     self.password = configuration.emc_nas_password
     self.debug = debug
     self.auth_url = 'https://' + self.storage_ip + '/Login'
     self._url = 'https://{}/servlets/CelerraManagementServices'.format(
         self.storage_ip)
     context = enas_utils.create_ssl_context(configuration)
     if context:
         https_handler = url_request.HTTPSHandler(context=context)
     else:
         https_handler = url_request.HTTPSHandler()
     cookie_handler = url_request.HTTPCookieProcessor(
         http_cookiejar.CookieJar())
     self.url_opener = url_request.build_opener(https_handler,
                                                cookie_handler)
     self._do_setup()
Exemplo n.º 16
0
    def create_share_from_snapshot(self,
                                   context,
                                   share,
                                   snapshot,
                                   share_server=None,
                                   parent_share=None):
        """Create a share from a snapshot - clone a snapshot."""
        share_name = share['id']

        share_proto = share['share_proto'].upper()

        # Validate the share protocol
        if share_proto not in ('NFS', 'CIFS'):
            raise exception.InvalidShare(
                reason=(_('Invalid NAS protocol supplied: %s.') % share_proto))

        # Get the pool name from share host field
        pool_name = share_utils.extract_host(share['host'], level='pool')
        if not pool_name:
            message = (_("Pool is not available in the share host %s.") %
                       share['host'])
            raise exception.InvalidHost(reason=message)

        self._share_server_validation(share_server)

        self._allocate_container_from_snapshot(share, snapshot, share_server,
                                               pool_name)

        nfs_if = enas_utils.convert_ipv6_format_if_needed(
            share_server['backend_details']['nfs_if'])

        if share_proto == 'NFS':
            self._create_nfs_share(share_name, share_server)
            location = ('%(nfs_if)s:/%(share_name)s' % {
                'nfs_if': nfs_if,
                'share_name': share_name
            })
        elif share_proto == 'CIFS':
            location = self._create_cifs_share(share_name, share_server)

        return location
Exemplo n.º 17
0
    def connect(self, emc_share_driver, context):
        """Connect to Unity storage."""
        config = emc_share_driver.configuration
        storage_ip = enas_utils.convert_ipv6_format_if_needed(
            config.emc_nas_server)
        username = config.emc_nas_login
        password = config.emc_nas_password
        self.client = client.UnityClient(storage_ip, username, password)

        pool_conf = config.safe_get('unity_share_data_pools')
        self.pool_set = self._get_managed_pools(pool_conf)

        self.reserved_percentage = config.safe_get('reserved_share_percentage')
        if self.reserved_percentage is None:
            self.reserved_percentage = 0

        self.max_over_subscription_ratio = config.safe_get(
            'max_over_subscription_ratio')
        self.port_ids_conf = config.safe_get('unity_ethernet_ports')
        self.validate_port_configuration(self.port_ids_conf)
        pool_name = config.unity_server_meta_pool
        self._config_pool(pool_name)
Exemplo n.º 18
0
    def create_share_from_snapshot(self, context, share, snapshot,
                                   share_server=None):
        """Create a share from a snapshot - clone a snapshot."""
        share_name = share['id']

        share_proto = share['share_proto']

        # Validate the share protocol
        if share_proto.upper() not in ('NFS', 'CIFS'):
            raise exception.InvalidShare(
                reason=(_('Invalid NAS protocol supplied: %s.')
                        % share_proto))

        # Get the pool name from share host field
        pool_name = share_utils.extract_host(share['host'], level='pool')
        if not pool_name:
            message = (_("Pool is not available in the share host %s.") %
                       share['host'])
            raise exception.InvalidHost(reason=message)

        self._share_server_validation(share_server)

        self._allocate_container_from_snapshot(
            share, snapshot, share_server, pool_name)

        nfs_if = enas_utils.convert_ipv6_format_if_needed(
            share_server['backend_details']['nfs_if'])

        if share_proto == 'NFS':
            self._create_nfs_share(share_name, share_server)
            location = ('%(nfs_if)s:/%(share_name)s'
                        % {'nfs_if': nfs_if,
                           'share_name': share_name})
        elif share_proto == 'CIFS':
            location = self._create_cifs_share(share_name, share_server)

        return location
Exemplo n.º 19
0
 def test_invalid_ipv6_addr(self, ip_addr):
     self.assertEqual(ip_addr, utils.convert_ipv6_format_if_needed(ip_addr))
Exemplo n.º 20
0
 def test_ipv6_addr(self, ip_addr):
     expected_ip_addr = '[%s]' % ip_addr
     self.assertEqual(expected_ip_addr,
                      utils.convert_ipv6_format_if_needed(ip_addr))
Exemplo n.º 21
0
 def test_ipv6_addr(self, ip_addr):
     expected_ip_addr = '[%s]' % ip_addr
     self.assertEqual(expected_ip_addr,
                      utils.convert_ipv6_format_if_needed(ip_addr))
Exemplo n.º 22
0
 def test_invalid_ipv6_addr(self, ip_addr):
     self.assertEqual(ip_addr, utils.convert_ipv6_format_if_needed(ip_addr))