コード例 #1
0
 def _destroy_lun(self, host_id, lun_path):
     """Destroy a LUN on the filer."""
     request = self.client.factory.create('Request')
     request.Name = 'lun-offline'
     path_xml = '<path>%s</path>'
     request.Args = text.Raw(path_xml % lun_path)
     response = self.client.service.ApiProxy(Target=host_id,
                                             Request=request)
     self._check_fail(request, response)
     request = self.client.factory.create('Request')
     request.Name = 'lun-destroy'
     request.Args = text.Raw(path_xml % lun_path)
     response = self.client.service.ApiProxy(Target=host_id,
                                             Request=request)
     self._check_fail(request, response)
コード例 #2
0
    def _clone_volume(self, volume_name, clone_name, volume_id):
        """Clones mounted volume with OnCommand proxy API."""
        host_id = self._get_host_id(volume_id)
        export_path = self._get_full_export_path(volume_id, host_id)

        request = self._client.factory.create('Request')
        request.Name = 'clone-start'

        clone_start_args = ('<source-path>%s/%s</source-path>'
                            '<destination-path>%s/%s</destination-path>')

        request.Args = text.Raw(clone_start_args % (export_path,
                                                    volume_name,
                                                    export_path,
                                                    clone_name))

        resp = self._client.service.ApiProxy(Target=host_id,
                                             Request=request)

        if (resp.Status == 'passed' and
                self.configuration.synchronous_snapshot_create):
            clone_id = resp.Results['clone-id'][0]
            clone_id_info = clone_id['clone-id-info'][0]
            clone_operation_id = int(clone_id_info['clone-op-id'][0])

            self._wait_for_clone_finished(clone_operation_id, host_id)
        elif resp.Status == 'failed':
            raise exception.CinderException(resp.Reason)
コード例 #3
0
 def _resize_volume(self, host_id, vol_name, new_size):
     """Resize the volume by the amount requested."""
     request = self.client.factory.create('Request')
     request.Name = 'volume-size'
     volume_size_xml = ('<volume>%s</volume><new-size>%s</new-size>')
     request.Args = text.Raw(volume_size_xml % (vol_name, new_size))
     response = self.client.service.ApiProxy(Target=host_id,
                                             Request=request)
     self._check_fail(request, response)
コード例 #4
0
 def _create_qtree(self, host_id, vol_name, qtree_name):
     """Create a qtree the filer."""
     request = self.client.factory.create('Request')
     request.Name = 'qtree-create'
     qtree_create_xml = (
         '<mode>0755</mode><volume>%s</volume><qtree>%s</qtree>')
     request.Args = text.Raw(qtree_create_xml % (vol_name, qtree_name))
     response = self.client.service.ApiProxy(Target=host_id,
                                             Request=request)
     self._check_fail(request, response)
コード例 #5
0
ファイル: netapp_nfs.py プロジェクト: tizzybec/cinder
    def _get_full_export_path(self, volume_id, host_id):
        """Returns full path to the NFS share, e.g. /vol/vol0/home"""
        export_path = self._get_export_path(volume_id)
        command_args = '<pathname>%s</pathname>'

        request = self._client.factory.create('Request')
        request.Name = 'nfs-exportfs-storage-path'
        request.Args = text.Raw(command_args % export_path)

        resp = self._client.service.ApiProxy(Target=host_id, Request=request)

        if resp.Status == 'passed':
            return resp.Results['actual-pathname'][0]
        elif resp.Status == 'failed':
            raise exception.CinderException(resp.Reason)
コード例 #6
0
    def _wait_for_clone_finished(self, clone_operation_id, host_id):
        """
        Polls ONTAP7 for clone status. Returns once clone is finished.
        :param clone_operation_id: Identifier of ONTAP clone operation
        """
        clone_list_options = ('<clone-id>'
                              '<clone-id-info>'
                              '<clone-op-id>%d</clone-op-id>'
                              '<volume-uuid></volume-uuid>'
                              '</clone-id>'
                              '</clone-id-info>')

        request = self._client.factory.create('Request')
        request.Name = 'clone-list-status'
        request.Args = text.Raw(clone_list_options % clone_operation_id)

        resp = self._client.service.ApiProxy(Target=host_id, Request=request)

        while resp.Status != 'passed':
            time.sleep(1)
            resp = self._client.service.ApiProxy(Target=host_id,
                                                 Request=request)
コード例 #7
0
    def _is_clone_done(self, host_id, clone_op_id, volume_uuid):
        """Check the status of a clone operation.

        Return True if done, False otherwise.
        """
        request = self.client.factory.create('Request')
        request.Name = 'clone-list-status'
        clone_list_status_xml = ('<clone-id><clone-id-info>'
                                 '<clone-op-id>%s</clone-op-id>'
                                 '<volume-uuid>%s</volume-uuid>'
                                 '</clone-id-info></clone-id>')
        request.Args = text.Raw(clone_list_status_xml %
                                (clone_op_id, volume_uuid))
        response = self.client.service.ApiProxy(Target=host_id,
                                                Request=request)
        self._check_fail(request, response)
        status = response.Results['status']
        if self._api_elem_is_empty(status):
            return False
        ops_info = status[0]['ops-info'][0]
        state = ops_info['clone-state'][0]
        return 'completed' == state
コード例 #8
0
    def _clone_lun(self, host_id, src_path, dest_path, snap):
        """Create a clone of a NetApp LUN.

        The clone initially consumes no space and is not space reserved.
        """
        request = self.client.factory.create('Request')
        request.Name = 'clone-start'
        clone_start_xml = ('<source-path>%s</source-path><no-snap>%s</no-snap>'
                           '<destination-path>%s</destination-path>')
        if snap:
            no_snap = 'false'
        else:
            no_snap = 'true'
        request.Args = text.Raw(clone_start_xml %
                                (src_path, no_snap, dest_path))
        response = self.client.service.ApiProxy(Target=host_id,
                                                Request=request)
        self._check_fail(request, response)
        clone_id = response.Results['clone-id'][0]
        clone_id_info = clone_id['clone-id-info'][0]
        clone_op_id = clone_id_info['clone-op-id'][0]
        volume_uuid = clone_id_info['volume-uuid'][0]
        while not self._is_clone_done(host_id, clone_op_id, volume_uuid):
            time.sleep(5)