Example #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)
Example #2
0
 def _migrate_share_set_error(self, context, ex, request_spec):
     instance = next((x for x in share_ref.instances
                      if x['status'] == constants.STATUS_MIGRATING),
                     None)
     if instance:
         db.share_instance_update(
             context, instance['id'],
             {'status': constants.STATUS_AVAILABLE})
     self._set_share_state_and_notify(
         'migrate_share_to_host',
         {'task_state': constants.TASK_STATE_MIGRATION_ERROR}, context,
         ex, request_spec)
Example #3
0
 def _migrate_share_set_error(self, context, ex, request_spec):
     instance = next((x for x in share_ref.instances
                      if x['status'] == constants.STATUS_MIGRATING),
                     None)
     if instance:
         db.share_instance_update(
             context, instance['id'],
             {'status': constants.STATUS_AVAILABLE})
     self._set_share_state_and_notify(
         'migrate_share_to_host',
         {'task_state': constants.TASK_STATE_MIGRATION_ERROR},
         context, ex, request_spec)
Example #4
0
 def _update(self, *args, **kwargs):
     db.share_instance_update(*args, **kwargs)