ctxt = context.get_admin_context()
svc_host = volume_utils.extract_host(host, 'backend')
- service = objects.Service.get_by_host_and_topic(
+ service = objects.Service.get_by_args(
ctxt, svc_host, CONF.volume_topic)
- expected = {'replication_status': fields.ReplicationStatus.ENABLED}
+ expected = {'replication_status': [fields.ReplicationStatus.ENABLED,
+ fields.ReplicationStatus.FAILED_OVER]}
result = service.conditional_update(
{'replication_status': fields.ReplicationStatus.FAILING_OVER},
expected)
secondary_backend_id})
return None
- service.replication_status = fields.ReplicationStatus.FAILED_OVER
- service.active_backend_id = active_backend_id
- service.disabled = True
- service.disabled_reason = "failed-over"
- service.save()
+ if secondary_backend_id == "default":
+ service.replication_status = fields.ReplicationStatus.ENABLED
+ service.active_backend_id = ""
+ service.disabled = False
+ service.disabled_reason = ""
+ service.save()
+
+ else:
+ service.replication_status = fields.ReplicationStatus.FAILED_OVER
+ service.active_backend_id = active_backend_id
+ service.disabled = True
+ service.disabled_reason = "failed-over"
+ service.save()
for update in volume_update_list:
# Response must include an id key: {volume_id: <cinder-uuid>}