Skip to content

Commit 687f459

Browse files
Use coriolis-writer v2 API
The v1 coriolis-writer API only accepts device names such as /dev/vdb. Device names are unreliable and can change depending on the order in which the devices are identified. For this reason, most Coriolis providers attach one device at a time and then check the device name that was identified by the VM. This is unnecessary for providers that can predentermine the SCSI ID or address of the device and use that instead of device names. As such, we'll use the v2 API of the Coriolis writer, which also accepts udev links such as /dev/disk/by-id/<disk-id>. The Coriolis writer will still resolve those links to ensure that there aren't multiple lock owners of the same device. The main difference is that the disk path is passed as a b64 encoded string. Also, the lock acquire/release now became POST requests, which are more appropriate than using GET for this purpose.
1 parent a9b70ff commit 687f459

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

coriolis/providers/backup_writers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# All Rights Reserved.
33

44
import abc
5+
import base64
56
import contextlib
67
import copy
78
import datetime
@@ -574,16 +575,17 @@ def _set_info(self, info):
574575

575576
@property
576577
def _uri(self):
577-
return "https://%s:%s/api/v1/%s" % (
578-
self._ip, self._port, self._path.lstrip('/')
578+
b64_path = base64.b64encode(self._path.encode()).decode()
579+
return "https://%s:%s/api/v2/device/%s" % (
580+
self._ip, self._port, b64_path
579581
)
580582

581583
@utils.retry_on_error()
582584
def _acquire(self):
583585
self._ensure_session()
584586
uri = "%s/acquire" % self._uri
585587
headers = {"X-Client-Token": self._id}
586-
resp = self._session.get(
588+
resp = self._session.post(
587589
uri, headers=headers, timeout=CONF.default_requests_timeout)
588590
LOG.debug("Returned code: %d. Msg: %s" % (
589591
resp.status_code, resp.content))
@@ -594,7 +596,7 @@ def _release(self):
594596
self._ensure_session()
595597
uri = "%s/release" % self._uri
596598
headers = {"X-Client-Token": self._id}
597-
resp = self._session.get(
599+
resp = self._session.post(
598600
uri, headers=headers, timeout=CONF.default_requests_timeout)
599601
LOG.debug("Returned code: %d. Msg: %s" %
600602
(resp.status_code, resp.content))

0 commit comments

Comments
 (0)