Beispiel #1
0
    def _vserver_create_if_not_exists(self, network_info):
        """Creates vserver if not exists with given parameters."""
        vserver_name = self.configuration.netapp_vserver_name_template % \
                       network_info['server_id']
        vserver_client = driver.NetAppApiClient(
            self.api_version,
            vserver=vserver_name,
            configuration=self.configuration)
        if not self._vserver_exists(vserver_name):
            LOG.debug('Vserver %s does not exist, creating' % vserver_name)
            self._create_vserver(vserver_name)
        nodes = self._get_cluster_nodes()

        node_network_info = zip(nodes, network_info['network_allocations'])
        netmask = utils.cidr_to_netmask(network_info['cidr'])
        try:
            for node, net_info in node_network_info:
                port = self._get_node_data_port(node)
                ip = net_info['ip_address']
                self._create_lif_if_not_exists(vserver_name, net_info['id'],
                                               network_info['segmentation_id'],
                                               node, port, ip, netmask,
                                               vserver_client)
        except naapi.NaApiError:
            with excutils.save_and_reraise_exception():
                LOG.error(_("Failed to create network interface"))
                self._delete_vserver(vserver_name, vserver_client)

        self._enable_nfs(vserver_client)

        security_services = network_info.get('security_services')
        if security_services:
            self._setup_security_services(security_services, vserver_client,
                                          vserver_name)
        return vserver_name
Beispiel #2
0
    def _vserver_create_if_not_exists(self, network_info):
        """Creates vserver if not exists with given parameters."""
        vserver_name = (self.configuration.netapp_vserver_name_template %
                        network_info['server_id'])
        vserver_client = NetAppApiClient(
            self.api_version, vserver=vserver_name,
            configuration=self.configuration)
        if not self._vserver_exists(vserver_name):
            LOG.debug('Vserver %s does not exist, creating' % vserver_name)
            self._create_vserver(vserver_name)
        nodes = self._get_cluster_nodes()

        node_network_info = zip(nodes, network_info['network_allocations'])
        netmask = utils.cidr_to_netmask(network_info['cidr'])
        try:
            for node, net_info in node_network_info:
                port = self._get_node_data_port(node)
                ip = net_info['ip_address']
                self._create_lif_if_not_exists(
                    vserver_name, net_info['id'],
                    network_info['segmentation_id'], node, port,
                    ip, netmask, vserver_client)
        except naapi.NaApiError:
            with excutils.save_and_reraise_exception():
                LOG.error(_("Failed to create network interface"))
                self._delete_vserver(vserver_name, vserver_client)

        self._enable_nfs(vserver_client)

        security_services = network_info.get('security_services')
        if security_services:
            self._setup_security_services(security_services, vserver_client,
                                          vserver_name)
        return vserver_name
Beispiel #3
0
    def _create_share_server(self, network_info, request_host=None):
        """Is called to create/setup share server"""
        # Return pool name, vfs, IPs for a pool
        pool_name, vfs, ips = self._get_pool_location_from_share_host(
            request_host)

        ip = network_info['network_allocations'][0]['ip_address']
        if ip not in ips:
            # Besides DHSS, admin could have setup IP to VFS directly on array
            if len(ips) > (FPG.MAX_SUPPORTED_IP_PER_VFS - 1):
                message = (_("Pool %s has exceeded 3PAR's "
                             "max supported VFS IP address") % pool_name)
                LOG.error(message)
                raise exception.Invalid(message)

            subnet = utils.cidr_to_netmask(network_info['cidr'])
            vlantag = network_info['segmentation_id']

            self._hpe3par.create_fsip(ip, subnet, vlantag, pool_name, vfs)
            # Update in global saved config, self.fpgs[pool_name]
            ips.append(ip)

        return {'share_server_name': network_info['server_id'],
                'share_server_id': network_info['server_id'],
                'ip': ip,
                'subnet': subnet,
                'vlantag': vlantag if vlantag else 0,
                'fpg': pool_name,
                'vfs': vfs}
Beispiel #4
0
    def _create_share_server(self, network_info, request_host=None):
        """Is called to create/setup share server"""
        # Return pool name, vfs, IPs for a pool
        pool_name, vfs, ips = self._get_pool_location_from_share_host(
            request_host)

        ip = network_info['network_allocations'][0]['ip_address']
        if ip not in ips:
            # Besides DHSS, admin could have setup IP to VFS directly on array
            if len(ips) > (FPG.MAX_SUPPORTED_IP_PER_VFS - 1):
                message = (_("Pool %s has exceeded 3PAR's "
                             "max supported VFS IP address") % pool_name)
                LOG.error(message)
                raise exception.Invalid(message)

            subnet = utils.cidr_to_netmask(network_info['cidr'])
            vlantag = network_info['segmentation_id']

            self._hpe3par.create_fsip(ip, subnet, vlantag, pool_name, vfs)
            # Update in global saved config, self.fpgs[pool_name]
            ips.append(ip)

        return {
            'share_server_name': network_info['server_id'],
            'share_server_id': network_info['server_id'],
            'ip': ip,
            'subnet': subnet,
            'vlantag': vlantag if vlantag else 0,
            'fpg': pool_name,
            'vfs': vfs
        }
Beispiel #5
0
 def _create_network_interface(self, nas_server, network, port_id):
     ip_addr = network['ip_address']
     netmask = utils.cidr_to_netmask(network['cidr'])
     gateway = network['gateway']
     vlan_id = network['segmentation_id']
     # Create the interfaces on NAS server
     self.client.create_interface(nas_server,
                                  ip_addr,
                                  netmask,
                                  gateway,
                                  port_id=port_id,
                                  vlan_id=vlan_id)
Beispiel #6
0
 def _create_network_interface(self, nas_server, network, port_id):
     ip_addr = network['ip_address']
     netmask = utils.cidr_to_netmask(network['cidr'])
     gateway = network['gateway']
     vlan_id = network['segmentation_id']
     # Create the interfaces on NAS server
     self.client.create_interface(nas_server,
                                  ip_addr,
                                  netmask,
                                  gateway,
                                  port_id=port_id,
                                  vlan_id=vlan_id)
Beispiel #7
0
    def setup_server(self, network_info, metadata=None):
        """Set up and configures share server with given network parameters."""
        # Only support single security service with type 'active_directory'
        vdm_name = network_info["server_id"]
        vlan_id = network_info["segmentation_id"]
        active_directory = None
        allocated_interfaces = []

        if network_info.get("security_services"):
            is_valid, active_directory = self._get_valid_security_service(network_info["security_services"])

            if not is_valid:
                raise exception.EMCVnxXMLAPIError(err=active_directory)

        try:
            if not self._vdm_exist(vdm_name):
                LOG.debug("Share server %s not found, creating " "share server...", vdm_name)
                self._get_context("VDM").create(vdm_name, self.mover_name)

            netmask = utils.cidr_to_netmask(network_info["cidr"])

            devices = self.get_managed_ports()

            for net_info in network_info["network_allocations"]:
                random.shuffle(devices)
                interface = {
                    "name": net_info["id"][-12:],
                    "device_name": devices[0],
                    "ip": net_info["ip_address"],
                    "mover_name": self.mover_name,
                    "net_mask": netmask,
                    "vlan_id": vlan_id if vlan_id else -1,
                }

                self._get_context("MoverInterface").create(interface)

                allocated_interfaces.append(interface)

            cifs_interface = allocated_interfaces[0]
            nfs_interface = allocated_interfaces[1]
            if active_directory:
                self._configure_active_directory(active_directory, vdm_name, cifs_interface)

            self._get_context("VDM").attach_nfs_interface(vdm_name, nfs_interface["name"])

            return {"share_server_name": vdm_name, "cifs_if": cifs_interface["ip"], "nfs_if": nfs_interface["ip"]}

        except Exception as ex:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE("Could not setup server. Reason: %s."), ex)
                server_details = self._construct_backend_details(vdm_name, allocated_interfaces)
                self.teardown_server(server_details, network_info["security_services"])
Beispiel #8
0
    def _create_vserver_lifs(self, vserver_name, vserver_client, network_info):

        nodes = self._client.list_cluster_nodes()
        node_network_info = zip(nodes, network_info['network_allocations'])
        netmask = utils.cidr_to_netmask(network_info['cidr'])

        for node, net_info in node_network_info:
            net_id = net_info['id']
            port = self._get_node_data_port(node)
            ip = net_info['ip_address']
            self._create_lif_if_nonexistent(vserver_name, net_id,
                                            network_info['segmentation_id'],
                                            node, port, ip, netmask,
                                            vserver_client)
Beispiel #9
0
    def _create_network_interface(self, nas_server, network, port_id):
        kargs = {'ip_addr': network['ip_address'],
                 'gateway': network['gateway'],
                 'vlan_id': network['segmentation_id'],
                 'port_id': port_id}

        if netutils.is_valid_ipv6_cidr(kargs['ip_addr']):
            kargs['netmask'] = None
            kargs['prefix_length'] = str(utils.cidr_to_prefixlen(
                network['cidr']))
        else:
            kargs['netmask'] = utils.cidr_to_netmask(network['cidr'])

        # Create the interfaces on NAS server
        self.client.create_interface(nas_server, **kargs)
Beispiel #10
0
    def _create_lif(self, vserver_client, vserver_name, ipspace_name,
                    node_name, lif_name, network_allocation):
        """Creates LIF for Vserver."""

        port = self._get_node_data_port(node_name)
        ip_address = network_allocation['ip_address']
        netmask = utils.cidr_to_netmask(network_allocation['cidr'])
        vlan = network_allocation['segmentation_id']

        if not vserver_client.network_interface_exists(
                vserver_name, node_name, port, ip_address, netmask, vlan):

            self._client.create_network_interface(
                ip_address, netmask, vlan, node_name, port, vserver_name,
                lif_name, ipspace_name)
Beispiel #11
0
    def _create_network_interface(self, nas_server, network, port_id):
        kargs = {'ip_addr': network['ip_address'],
                 'gateway': network['gateway'],
                 'vlan_id': network['segmentation_id'],
                 'port_id': port_id}

        if netutils.is_valid_ipv6_cidr(kargs['ip_addr']):
            kargs['netmask'] = None
            kargs['prefix_length'] = str(utils.cidr_to_prefixlen(
                network['cidr']))
        else:
            kargs['netmask'] = utils.cidr_to_netmask(network['cidr'])

        # Create the interfaces on NAS server
        self.client.create_interface(nas_server, **kargs)
Beispiel #12
0
    def _create_lif(self, vserver_client, vserver_name, ipspace_name, node_name, lif_name, network_allocation):
        """Creates LIF for Vserver."""

        port = self._get_node_data_port(node_name)
        ip_address = network_allocation["ip_address"]
        netmask = utils.cidr_to_netmask(network_allocation["cidr"])
        vlan = network_allocation["segmentation_id"]
        network_mtu = network_allocation.get("mtu")
        mtu = network_mtu or DEFAULT_MTU

        if not vserver_client.network_interface_exists(vserver_name, node_name, port, ip_address, netmask, vlan):

            self._client.create_network_interface(
                ip_address, netmask, vlan, node_name, port, vserver_name, lif_name, ipspace_name, mtu
            )
Beispiel #13
0
    def _vserver_create_if_not_exists(self, network_info):
        """Creates vserver if not exists with given parameters."""
        vserver_name = self._get_vserver_name(network_info['id'])
        vserver_client = driver.NetAppApiClient(
            self.api_version, vserver=vserver_name,
            configuration=self.configuration)
        args = {'query': {'vserver-info': {'vserver-name': vserver_name}}}

        LOG.debug(_('Checking if vserver is configured'))
        vserver_info = self._client.send_request('vserver-get-iter', args)
        if not int(vserver_info.get_child_content('num-records')):
            LOG.debug(_('Vserver %s does not exist, creating') % vserver_name)
            self._create_vserver(vserver_name)
        nodes = self._get_cluster_nodes()

        node_network_info = zip(nodes, network_info['network_allocations'])
        netmask = utils.cidr_to_netmask(network_info['cidr'])
        try:
            for node, net_info in node_network_info:
                port = self._get_node_data_port(node)
                ip = net_info['ip_address']
                self._create_lif_if_not_exists(
                    vserver_name, net_info['id'],
                    network_info['segmentation_id'], node, port,
                    ip, netmask, vserver_client)
        except naapi.NaApiError:
            with excutils.save_and_reraise_exception():
                LOG.error(_("Failed to create network interface"))
                self._delete_vserver(vserver_name, vserver_client)

        self._enable_nfs(vserver_client)
        if network_info.get('security_services'):
            for security_service in network_info['security_services']:
                if security_service['type'].lower() == "ldap":
                    self._configure_ldap(security_service, vserver_client)
                elif security_service['type'].lower() == "active_directory":
                    self._configure_active_directory(security_service,
                                                     vserver_client)
                elif security_service['type'].lower() == "kerberos":
                    self._configure_kerberos(vserver_name, security_service,
                                             vserver_client)
                else:
                    raise exception.NetAppException(
                        _('Unsupported protocol %s for NetApp driver')
                        % security_service['type'])
        return vserver_name
Beispiel #14
0
    def _create_network_interface(self, nas_server, network):
        ip_addr = network['ip_address']
        netmask = utils.cidr_to_netmask(network['cidr'])
        gateway = network['gateway']
        vlan_id = network['segmentation_id']
        if network['network_type'] not in SUPPORTED_NETWORK_TYPES:
            msg = _('The specified network type %s is unsupported by '
                    'the EMC Unity driver')
            raise exception.NetworkBadConfigurationException(
                reason=msg % network['network_type'])

        # Create the interfaces on NAS server
        self.client.create_interface(nas_server,
                                     ip_addr,
                                     netmask,
                                     gateway,
                                     ports=self.port_set,
                                     vlan_id=vlan_id)
Beispiel #15
0
    def _create_network_interface(self, nas_server, network):
        ip_addr = network['ip_address']
        netmask = utils.cidr_to_netmask(network['cidr'])
        gateway = network['gateway']
        vlan_id = network['segmentation_id']
        if network['network_type'] not in SUPPORTED_NETWORK_TYPES:
            msg = _('The specified network type %s is unsupported by '
                    'the EMC Unity driver')
            raise exception.NetworkBadConfigurationException(
                reason=msg % network['network_type'])

        # Create the interfaces on NAS server
        self.client.create_interface(nas_server,
                                     ip_addr,
                                     netmask,
                                     gateway,
                                     ports=self.port_set,
                                     vlan_id=vlan_id)
Beispiel #16
0
    def _create_vserver_lifs(self, vserver_name, vserver_client,
                             network_info):

        nodes = self._client.list_cluster_nodes()
        node_network_info = zip(nodes, network_info['network_allocations'])
        netmask = utils.cidr_to_netmask(network_info['cidr'])

        for node, net_info in node_network_info:
            net_id = net_info['id']
            port = self._get_node_data_port(node)
            ip = net_info['ip_address']
            self._create_lif_if_nonexistent(vserver_name,
                                            net_id,
                                            network_info['segmentation_id'],
                                            node,
                                            port,
                                            ip,
                                            netmask,
                                            vserver_client)
Beispiel #17
0
    def _setup_server(self, network_info, metadata=None):
        LOG.debug("begin _setup_server with %s", network_info)

        self._validate_network_type(network_info['network_type'])

        ip = network_info['network_allocations'][0]['ip_address']
        subnet = utils.cidr_to_netmask(network_info['cidr'])
        vlantag = network_info['segmentation_id']

        self._hpe3par.create_fsip(ip, subnet, vlantag, self.fpg, self.vfs)

        return {
            'share_server_name': network_info['server_id'],
            'share_server_id': network_info['server_id'],
            'ip': ip,
            'subnet': subnet,
            'vlantag': vlantag if vlantag else 0,
            'fpg': self.fpg,
            'vfs': self.vfs,
        }
Beispiel #18
0
    def _setup_server(self, network_info, metadata=None):
        LOG.debug("begin _setup_server with %s", network_info)

        self._validate_network_type(network_info['network_type'])

        ip = network_info['network_allocations'][0]['ip_address']
        subnet = utils.cidr_to_netmask(network_info['cidr'])
        vlantag = network_info['segmentation_id']

        self._hpe3par.create_fsip(ip, subnet, vlantag, self.fpg, self.vfs)

        return {
            'share_server_name': network_info['server_id'],
            'share_server_id': network_info['server_id'],
            'ip': ip,
            'subnet': subnet,
            'vlantag': vlantag if vlantag else 0,
            'fpg': self.fpg,
            'vfs': self.vfs,
        }
Beispiel #19
0
 def test_cidr_to_netmask_05(self):
     cidr = '10.0.0.1'
     expected_netmask = '255.255.255.255'
     result = utils.cidr_to_netmask(cidr)
     self.assertEqual(expected_netmask, result)
Beispiel #20
0
 def test_cidr_to_netmask_03(self):
     cidr = '10.0.0.0/5'
     expected_netmask = '248.0.0.0'
     result = utils.cidr_to_netmask(cidr)
     self.assertEqual(expected_netmask, result)
Beispiel #21
0
 def test_cidr_to_netmask_05(self):
     cidr = '10.0.0.1'
     expected_netmask = '255.255.255.255'
     result = utils.cidr_to_netmask(cidr)
     self.assertEqual(expected_netmask, result)
Beispiel #22
0
 def test_cidr_to_netmask_03(self):
     cidr = '10.0.0.0/5'
     expected_netmask = '248.0.0.0'
     result = utils.cidr_to_netmask(cidr)
     self.assertEqual(expected_netmask, result)
Beispiel #23
0
    def setup_server(self, network_info, metadata=None):
        """Set up and configures share server with given network parameters."""
        # Only support single security service with type 'active_directory'
        vdm_name = network_info['server_id']
        vlan_id = network_info['segmentation_id']
        active_directory = None
        allocated_interfaces = []

        if network_info.get('security_services'):
            is_valid, active_directory = self._get_valid_security_service(
                network_info['security_services'])

            if not is_valid:
                raise exception.EMCVnxXMLAPIError(err=active_directory)

        try:
            if not self._vdm_exist(vdm_name):
                LOG.debug('Share server %s not found, creating '
                          'share server...', vdm_name)
                self._get_context('VDM').create(vdm_name, self.mover_name)

            netmask = utils.cidr_to_netmask(network_info['cidr'])

            devices = self.get_managed_ports()

            for net_info in network_info['network_allocations']:
                random.shuffle(devices)
                interface = {
                    'name': net_info['id'][-12:],
                    'device_name': devices[0],
                    'ip': net_info['ip_address'],
                    'mover_name': self.mover_name,
                    'net_mask': netmask,
                    'vlan_id': vlan_id if vlan_id else -1,
                }

                self._get_context('MoverInterface').create(interface)

                allocated_interfaces.append(interface)

            cifs_interface = allocated_interfaces[0]
            nfs_interface = allocated_interfaces[1]
            if active_directory:
                self._configure_active_directory(
                    active_directory, vdm_name, cifs_interface)

            self._get_context('VDM').attach_nfs_interface(
                vdm_name, nfs_interface['name'])

            return {
                'share_server_name': vdm_name,
                'cifs_if': cifs_interface['ip'],
                'nfs_if': nfs_interface['ip'],
            }

        except Exception as ex:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Could not setup server. Reason: %s.'), ex)
                server_details = self._construct_backend_details(
                    vdm_name, allocated_interfaces)
                self.teardown_server(
                    server_details, network_info['security_services'])
Beispiel #24
0
 def _get_parsed_access_to(self, access_to):
     netmask = utils.cidr_to_netmask(access_to)
     if netmask == '255.255.255.255':
         return access_to.split('/')[0]
     return access_to.split('/')[0] + '/' + netmask
Beispiel #25
0
    def setup_server(self, emc_share_driver, network_info, metadata=None):
        """Set up and configures share server with given network parameters."""
        # Only support single security service with type 'active_directory'
        interface_info = []
        vdm_name = 'vdm-' + network_info['server_id']
        vlan_id = network_info['segmentation_id']
        active_directory = None
        sec_services = []

        if network_info.get('security_services'):
            sec_services = network_info['security_services']
            is_valid, data = self._get_valid_security_service(
                sec_services)
            if is_valid:
                active_directory = data
            else:
                LOG.error(data)
                raise exception.EMCVnxXMLAPIError(err=data)

        try:
            # Refresh DataMover/VDM by the configuration
            moverRef = self.get_mover_ref_by_name(self._mover_name)
            if not self._vdm_exist(vdm_name):
                LOG.debug('Share Server %s not found. Creating', vdm_name)
                self._create_vdm(vdm_name, moverRef)

            status, vdmRef = self._XMLAPI_helper.get_vdm_by_name(vdm_name)
            if constants.STATUS_OK != status:
                message = (_('Could not get Share Server by name %(name)s. '
                             'Reason: %(err)s.')
                           % {'name': vdm_name,
                              'err': vdmRef})
                LOG.error(message)
                raise exception.EMCVnxXMLAPIError(err=message)

            netmask = utils.cidr_to_netmask(network_info['cidr'])

            allocated_interfaces = []
            device_port = self._get_device_port(moverRef)

            for net_info in network_info['network_allocations']:
                ip = net_info['ip_address']
                if_name = 'if-' + net_info['id'][-12:]
                if_info = {'ip': ip, 'if_name': if_name}
                interface_info.append(if_info)
                status, interface = self._XMLAPI_helper.create_mover_interface(
                    if_name,
                    device_port['name'],
                    ip,
                    moverRef['id'],
                    netmask,
                    vlan_id)

                if constants.STATUS_OK != status:
                    message = (_('Interface creation failed. Reason: %s.')
                               % interface)
                    LOG.error(message)
                    raise exception.EMCVnxXMLAPIError(err=message)
                allocated_interfaces.append(interface)

            if active_directory:
                self._configure_active_directory(
                    active_directory, vdmRef,
                    allocated_interfaces[0])

            self._enable_nfs_service(vdmRef, allocated_interfaces[1])

            return {
                'share_server_name': vdm_name,
                'share_server_id': vdmRef['id'],
                'cifs_if': allocated_interfaces[0]['ip'],
                'nfs_if': allocated_interfaces[1]['ip'],
            }

        except Exception as ex:
            with excutils.save_and_reraise_exception():
                message = _('Could not setup server. Reason: %s.') % ex
                LOG.error(message)
                server_details = self._contruct_backend_details(
                    vdm_name, vdmRef, interface_info)
                self.teardown_server(None, server_details, sec_services)
Beispiel #26
0
    def setup_server(self, emc_share_driver, network_info, metadata=None):
        """Set up and configures share server with given network parameters."""
        # Only support single security service with type 'active_directory'
        interface_info = []
        vdm_name = 'vdm-' + network_info['server_id']
        vlan_id = network_info['segmentation_id']
        active_directory = None
        sec_services = []

        if network_info.get('security_services'):
            sec_services = network_info['security_services']
            is_valid, data = self._get_valid_security_service(sec_services)
            if is_valid:
                active_directory = data
            else:
                LOG.error(data)
                raise exception.EMCVnxXMLAPIError(err=data)

        try:
            # Refresh DataMover/VDM by the configuration
            moverRef = self.get_mover_ref_by_name(self._mover_name)
            if not self._vdm_exist(vdm_name):
                LOG.debug('Share Server %s not found. Creating', vdm_name)
                self._create_vdm(vdm_name, moverRef)

            status, vdmRef = self._XMLAPI_helper.get_vdm_by_name(vdm_name)
            if constants.STATUS_OK != status:
                message = (_('Could not get Share Server by name %(name)s. '
                             'Reason: %(err)s.') % {
                                 'name': vdm_name,
                                 'err': vdmRef
                             })
                LOG.error(message)
                raise exception.EMCVnxXMLAPIError(err=message)

            netmask = utils.cidr_to_netmask(network_info['cidr'])

            allocated_interfaces = []
            device_port = self._get_device_port(moverRef)

            for net_info in network_info['network_allocations']:
                ip = net_info['ip_address']
                if_name = 'if-' + net_info['id'][-12:]
                if_info = {'ip': ip, 'if_name': if_name}
                interface_info.append(if_info)
                status, interface = self._XMLAPI_helper.create_mover_interface(
                    if_name, device_port['name'], ip, moverRef['id'], netmask,
                    vlan_id)

                if constants.STATUS_OK != status:
                    message = (_('Interface creation failed. Reason: %s.') %
                               interface)
                    LOG.error(message)
                    raise exception.EMCVnxXMLAPIError(err=message)
                allocated_interfaces.append(interface)

            if active_directory:
                self._configure_active_directory(active_directory, vdmRef,
                                                 allocated_interfaces[0])

            self._enable_nfs_service(vdmRef, allocated_interfaces[1])

            return {
                'share_server_name': vdm_name,
                'share_server_id': vdmRef['id'],
                'cifs_if': allocated_interfaces[0]['ip'],
                'nfs_if': allocated_interfaces[1]['ip'],
            }

        except Exception as ex:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Could not setup server. Reason: %s.'), ex)
                server_details = self._contruct_backend_details(
                    vdm_name, vdmRef, interface_info)
                self.teardown_server(None, server_details, sec_services)
Beispiel #27
0
 def _get_parsed_access_to(self, access_to):
     netmask = utils.cidr_to_netmask(access_to)
     if netmask == '255.255.255.255':
         return access_to.split('/')[0]
     return access_to.split('/')[0] + '/' + netmask
Beispiel #28
0
    def setup_server(self, network_info, metadata=None):
        """Set up and configures share server with given network parameters."""
        # Only support single security service with type 'active_directory'
        vdm_name = network_info['server_id']
        vlan_id = network_info['segmentation_id']
        active_directory = None
        allocated_interfaces = []

        if network_info.get('security_services'):
            is_valid, active_directory = self._get_valid_security_service(
                network_info['security_services'])

            if not is_valid:
                raise exception.EMCVnxXMLAPIError(err=active_directory)

        try:
            if not self._vdm_exist(vdm_name):
                LOG.debug(
                    'Share server %s not found, creating '
                    'share server...', vdm_name)
                self._get_context('VDM').create(vdm_name, self.mover_name)

            netmask = utils.cidr_to_netmask(network_info['cidr'])

            devices = self.get_managed_ports()

            for net_info in network_info['network_allocations']:
                random.shuffle(devices)
                interface = {
                    'name': net_info['id'][-12:],
                    'device_name': devices[0],
                    'ip': net_info['ip_address'],
                    'mover_name': self.mover_name,
                    'net_mask': netmask,
                    'vlan_id': vlan_id if vlan_id else -1,
                }

                self._get_context('MoverInterface').create(interface)

                allocated_interfaces.append(interface)

            cifs_interface = allocated_interfaces[0]
            nfs_interface = allocated_interfaces[1]
            if active_directory:
                self._configure_active_directory(active_directory, vdm_name,
                                                 cifs_interface)

            self._get_context('VDM').attach_nfs_interface(
                vdm_name, nfs_interface['name'])

            return {
                'share_server_name': vdm_name,
                'cifs_if': cifs_interface['ip'],
                'nfs_if': nfs_interface['ip'],
            }

        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.exception('Could not setup server.')
                server_details = self._construct_backend_details(
                    vdm_name, allocated_interfaces)
                self.teardown_server(server_details,
                                     network_info['security_services'])
Beispiel #29
0
 def test_cidr_to_netmask(self, cidr, expected_netmask):
     result = utils.cidr_to_netmask(cidr)
     self.assertEqual(expected_netmask, result)