Esempio n. 1
0
 def test_get_snapshot_id(self):
     snapshot = {
         'provider_location': '23047-ef2344-4563cvw-r4323cwed',
         'id': 'test_id'
     }
     result = utils.get_snapshot_id(snapshot)
     expected = '23047-ef2344-4563cvw-r4323cwed'
     self.assertEqual(expected, result)
Esempio n. 2
0
 def revert_to_snapshot(self,
                        context,
                        snapshot,
                        share_access_rules,
                        snapshot_access_rules,
                        share_server=None):
     """Reverts a share (in place) to the specified snapshot."""
     snapshot_id = unity_utils.get_snapshot_id(snapshot)
     return self.client.restore_snapshot(snapshot_id)
Esempio n. 3
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']

        # Check share's protocol.
        # Throw an exception immediately if it is an invalid protocol.
        share_proto = share['share_proto'].upper()
        self._validate_share_protocol(share_proto)

        # Get share server name from share server
        server_name = self.get_server_name(share_server)

        try:
            nas_server = self.client.get_nas_server(server_name)
        except storops_ex.UnityResourceNotFoundError:
            message = (_("Failed to get NAS server %(server)s when "
                         "creating the share %(share)s.") % {
                             'server': server_name,
                             'share': share_name
                         })
            LOG.exception(message)
            raise exception.EMCUnityError(err=message)
        snapshot_id = unity_utils.get_snapshot_id(snapshot)
        backend_snap = self.client.create_snap_of_snap(snapshot_id, share_name)

        locations = None
        if share_proto == 'CIFS':
            self.client.create_cifs_share(backend_snap, share_name)

            locations = self._get_cifs_location(nas_server.file_interface,
                                                share_name)
        elif share_proto == 'NFS':
            self.client.create_nfs_share(backend_snap, share_name)

            locations = self._get_nfs_location(nas_server.file_interface,
                                               share_name)

        return locations
Esempio n. 4
0
 def delete_snapshot(self, context, snapshot, share_server=None):
     """Delete a snapshot."""
     snapshot_id = unity_utils.get_snapshot_id(snapshot)
     snap = self.client.get_snapshot(snapshot_id)
     self.client.delete_snapshot(snap)
Esempio n. 5
0
 def test_get_snapshot_id_without_pl(self):
     snapshot = {'provider_location': '', 'id': 'test_id'}
     result = utils.get_snapshot_id(snapshot)
     expected = 'test_id'
     self.assertEqual(expected, result)