def init_host_with_rpc(self):
    LOG.info(_LI('Initializing RPC dependent components of volume driver %(driver_name)s (%(version)s)'), {'driver_name': self.driver.__class__.__name__, 'version': self.driver.get_version()})
    stats = self.driver.get_volume_stats(refresh=True)
    svc_host = vol_utils.extract_host(self.host, 'backend')
    try:
        service = objects.Service.get_by_args(context.get_admin_context(), svc_host, 'cinder-volume')
    except exception.ServiceNotFound:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Service not found for updating replication_status.'))
    if (service.replication_status != fields.ReplicationStatus.FAILED_OVER):
        if (stats and stats.get('replication_enabled', False)):
            service.replication_status = fields.ReplicationStatus.ENABLED
        else:
            service.replication_status = fields.ReplicationStatus.DISABLED
    service.save()
    LOG.info(_LI('Driver post RPC initialization completed successfully.'), resource={'type': 'driver', 'id': self.driver.__class__.__name__})
def init_host_with_rpc(self):
    LOG.info(_LI('Initializing RPC dependent components of volume driver %(driver_name)s (%(version)s)'), {'driver_name': self.driver.__class__.__name__, 'version': self.driver.get_version()})
    stats = self.driver.get_volume_stats(refresh=True)
    svc_host = vol_utils.extract_host(self.host, 'backend')
    try:
        service = objects.Service.get_by_args(context.get_admin_context(), svc_host, 'cinder-volume')
    except exception.ServiceNotFound:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Service not found for updating replication_status.'))
    if (service.replication_status != fields.ReplicationStatus.FAILED_OVER):
        if (stats and stats.get('replication_enabled', False)):
            service.replication_status = fields.ReplicationStatus.ENABLED
        else:
            service.replication_status = fields.ReplicationStatus.DISABLED
    service.save()
    LOG.info(_LI('Driver post RPC initialization completed successfully.'), resource={'type': 'driver', 'id': self.driver.__class__.__name__})