Ejemplo n.º 1
0
    def follow_server_migrate(self, uuid, current_host, new_host):
        """Modify the host name associated with a share server and its shares.

        Particularly to reflect if a migration was performed at the back-end
        level without driver assistance.
        The network allocation (neutron port) will also be updated.
        """
        self._validate_hosts(current_host, new_host)
        ctxt = context.get_admin_context()
        server = db.share_server_get(ctxt, uuid)
        server_host = server['host']

        current_host_without_pool = current_host.split('#')[0]
        new_host_without_pool = new_host.split('#')[0]

        if current_host_without_pool in server_host:
            db.share_server_update(
                ctxt, uuid,
                self._update_host_values(server_host, current_host, new_host))

        for si in db.share_instances_get_all_by_share_server(ctxt, uuid):
            si_host = si['host']
            if current_host_without_pool in si_host:
                db.share_instance_update(
                    ctxt, si['id'],
                    self._update_host_values(si_host, current_host, new_host))

        ports = db.network_allocations_get_for_share_server(ctxt, uuid)
        port_new_host = new_host_without_pool.split('@')[0]
        for port in ports:
            self._update_port_host_id(port['id'], port_new_host)
Ejemplo n.º 2
0
 def test_share_server_get(self):
     values = {
         'share_network_id': 'fake-share-net-id',
         'host': 'hostname',
         'status': 'ACTIVE'
     }
     expected = self._create_share_server(values)
     server = db.share_server_get(self.ctxt, expected['id'])
     self.assertEqual(expected['id'], server['id'])
     self.assertEqual(server.share_network_id, expected.share_network_id)
     self.assertEqual(server.host, expected.host)
     self.assertEqual(server.status, expected.status)
Ejemplo n.º 3
0
 def _create_share_server(state='new', share_network_id=None, host=None):
     """Create a share server object."""
     srv = {}
     srv['host'] = host
     srv['share_network_id'] = share_network_id
     srv['status'] = state
     share_srv = db.share_server_create(context.get_admin_context(), srv)
     backend_details = {'fake': 'fake'}
     db.share_server_backend_details_set(context.get_admin_context(),
                                         share_srv['id'], backend_details)
     return db.share_server_get(context.get_admin_context(),
                                share_srv['id'])
Ejemplo n.º 4
0
 def test_share_server_get(self):
     values = {
         'share_network_id': 'fake-share-net-id',
         'host': 'hostname',
         'status': constants.STATUS_ACTIVE
     }
     expected = self._create_share_server(values)
     server = db.share_server_get(self.ctxt, expected['id'])
     self.assertEqual(expected['id'], server['id'])
     self.assertEqual(server.share_network_id, expected.share_network_id)
     self.assertEqual(server.host, expected.host)
     self.assertEqual(server.status, expected.status)
Ejemplo n.º 5
0
    def test_share_server_backend_details_set(self):
        details = {
            'value1': '1',
            'value2': '2',
        }
        server = self._create_share_server()
        db.share_server_backend_details_set(self.ctxt, server['id'], details)

        self.assertDictMatch(
            details,
            db.share_server_get(self.ctxt, server['id'])['backend_details']
        )
Ejemplo n.º 6
0
def create_share_server(**kwargs):
    """Create a share server object."""
    backend_details = kwargs.pop('backend_details', {})
    srv = {
        'host': 'host1',
        'share_network_id': 'fake_srv_id',
        'status': constants.STATUS_ACTIVE
    }
    share_srv = _create_db_row(db.share_server_create, srv, kwargs)
    if backend_details:
        db.share_server_backend_details_set(context.get_admin_context(),
                                            share_srv['id'], backend_details)
    return db.share_server_get(context.get_admin_context(), share_srv['id'])
Ejemplo n.º 7
0
 def _create_share_server(state='ACTIVE', share_network_id=None, host=None):
     """Create a share server object."""
     srv = {}
     srv['host'] = host
     srv['share_network_id'] = share_network_id
     srv['status'] = state
     share_srv = db.share_server_create(context.get_admin_context(), srv)
     backend_details = {'fake': 'fake'}
     db.share_server_backend_details_set(context.get_admin_context(),
                                         share_srv['id'],
                                         backend_details)
     return db.share_server_get(context.get_admin_context(),
                                share_srv['id'])
Ejemplo n.º 8
0
def create_share_server(**kwargs):
    """Create a share server object."""
    backend_details = kwargs.pop('backend_details', {})
    srv = {
        'host': 'host1',
        'share_network_id': 'fake_srv_id',
        'status': constants.STATUS_ACTIVE
    }
    share_srv = _create_db_row(db.share_server_create, srv, kwargs)
    if backend_details:
        db.share_server_backend_details_set(
            context.get_admin_context(), share_srv['id'], backend_details)
    return db.share_server_get(context.get_admin_context(),
                               share_srv['id'])
Ejemplo n.º 9
0
 def test_share_server_get_with_details(self):
     values = {
         'share_network_id': 'fake-share-net-id',
         'host': 'hostname',
         'status': 'ACTIVE'
     }
     details = {
         'value1': '1',
         'value2': '2',
     }
     srv_id = self._create_share_server(values)['id']
     db.share_server_backend_details_set(self.ctxt, srv_id, details)
     server = db.share_server_get(self.ctxt, srv_id)
     self.assertEqual(srv_id, server['id'])
     self.assertEqual(server.share_network_id, values['share_network_id'])
     self.assertEqual(server.host, values['host'])
     self.assertEqual(server.status, values['status'])
     self.assertDictMatch(details, server['backend_details'])
Ejemplo n.º 10
0
 def test_share_server_get_with_details(self):
     values = {
         'share_network_id': 'fake-share-net-id',
         'host': 'hostname',
         'status': 'ACTIVE'
     }
     details = {
         'value1': '1',
         'value2': '2',
     }
     srv_id = self._create_share_server(values)['id']
     db.share_server_backend_details_set(self.ctxt, srv_id, details)
     server = db.share_server_get(self.ctxt, srv_id)
     self.assertEqual(srv_id, server['id'])
     self.assertEqual(server.share_network_id, values['share_network_id'])
     self.assertEqual(server.host, values['host'])
     self.assertEqual(server.status, values['status'])
     self.assertDictMatch(details, server['backend_details'])