예제 #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
예제 #2
0
 def create_share(self, context, share, share_server=None):
     """Creates new share."""
     vserver = share_server['backend_details']['vserver_name']
     vserver_client = driver.NetAppApiClient(
         self.api_version,
         vserver=vserver,
         configuration=self.configuration)
     self._allocate_container(share, vserver, vserver_client)
     return self._create_export(share, vserver, vserver_client)
예제 #3
0
    def do_setup(self, context):
        """Prepare once the driver.

        Called once by the manager after the driver is loaded.
        Sets up clients, check licenses, sets up protocol
        specific helpers.
        """
        self._client = driver.NetAppApiClient(self.api_version,
                                              configuration=self.configuration)
        self._setup_helpers()
예제 #4
0
 def teardown_server(self, server_details, security_services=None):
     """Teardown share network."""
     vserver_name = server_details['vserver_name']
     vserver_client = driver.NetAppApiClient(
         self.api_version,
         vserver=vserver_name,
         configuration=self.configuration)
     self._delete_vserver(vserver_name,
                          vserver_client,
                          security_services=security_services)
예제 #5
0
 def deny_access(self, context, share, access, share_server=None):
     """Denies access to a given NAS storage for IPs in access."""
     vserver = share_server['backend_details']['vserver_name']
     vserver_client = driver.NetAppApiClient(
         self.api_version,
         vserver=vserver,
         configuration=self.configuration)
     helper = self._get_helper(share)
     helper.set_client(vserver_client)
     return helper.deny_access(context, share, access)
예제 #6
0
 def create_snapshot(self, context, snapshot, share_server=None):
     """Creates a snapshot of a share."""
     vserver = share_server['backend_details']['vserver_name']
     vserver_client = driver.NetAppApiClient(
         self.api_version,
         vserver=vserver,
         configuration=self.configuration)
     share_name = self._get_valid_share_name(snapshot['share_id'])
     snapshot_name = self._get_valid_snapshot_name(snapshot['id'])
     args = {'volume': share_name, 'snapshot': snapshot_name}
     LOG.debug('Creating snapshot %s' % snapshot_name)
     vserver_client.send_request('snapshot-create', args)
예제 #7
0
 def delete_share(self, context, share, share_server=None):
     """Deletes share."""
     share_name = self._get_valid_share_name(share['id'])
     vserver = share_server['backend_details']['vserver_name']
     vserver_client = driver.NetAppApiClient(
         self.api_version,
         vserver=vserver,
         configuration=self.configuration)
     if self._share_exists(share_name, vserver_client):
         self._remove_export(share, vserver_client)
         self._deallocate_container(share, vserver_client)
     else:
         LOG.info(_("Share %s does not exists") % share['id'])