Change in vdsm[master]: register: Add --persist-uuid
dougsland at redhat.com
dougsland at redhat.com
Wed Aug 5 15:11:57 UTC 2015
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: register: Add --persist-uuid
......................................................................
register: Add --persist-uuid
This patch adds --persist-uuid option for cases where the machine
duplicates UUID.
Change-Id: I5926b635201662db53956dbac18b9a2981d6e645
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M lib/vdsm/tool/register.py
1 file changed, 28 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/44431/1
diff --git a/lib/vdsm/tool/register.py b/lib/vdsm/tool/register.py
index df56671..ad5436d 100644
--- a/lib/vdsm/tool/register.py
+++ b/lib/vdsm/tool/register.py
@@ -40,7 +40,7 @@
fingerprint=None, ssh_port=None,
ssh_user=None, check_fqdn=True,
vdsm_port=None, node_address=None,
- node_name=None):
+ persist_uuid=None, node_name=None):
"""
Attributes:
@@ -55,6 +55,8 @@
vdsm_port - VDSM listen port
node_address - Specify node address or FQDN
node_name - Specify node name
+ persist_uuid - Persist the UUID provided, useful for machines
+ that duplicates UUID
"""
self.logger = self._set_logger()
self.logger.debug("=======================================")
@@ -109,6 +111,10 @@
else:
self.vdsm_port = vdsm_port
self.logger.debug("VDSM Port: {sp}".format(sp=self.vdsm_port))
+
+ self.persist_uuid = persist_uuid
+ self.logger.debug("Persist uuid: {uuid_provided}".format(
+ uuid_provided=self.persist_uuid))
self.ca_dir = "/etc/pki/ovirt-engine/"
self.ca_engine = "{d}{f}".format(d=self.ca_dir, f="ca.pem")
@@ -246,12 +252,24 @@
Determine host UUID and if there is no existing /etc/vdsm/vdsm.id
it will genereate UUID and save/persist in /etc/vdsm/vdsm.id
"""
- self.uuid = getHostUUID(legacy=False)
+
+ if self.persist_uuid:
+ self.uuid = self.persist_uuid
+ else:
+ self.uuid = getHostUUID(legacy=False)
+
self.url_reg += "&uniqueId={u}".format(u=self.uuid)
self.logger.debug("Registration via: {u}".format(u=self.url_reg))
__VDSM_ID = "/etc/vdsm/vdsm.id"
+
+ if self.persist_uuid and os.path.exists(__VDSM_ID):
+ if utils.isOvirtNode():
+ from ovirt.node.utils.fs import Config
+ Config().unpersist(__VDSM_ID)
+ os.unlink(__VDSM_ID)
+
if not os.path.exists(__VDSM_ID):
with open(__VDSM_ID, 'w') as f:
f.write(self.uuid)
@@ -433,6 +451,12 @@
" If not provided, will be used the default 54321",
)
+ parser.add_argument(
+ '--persist-uuid',
+ help="Specify the UUID to be used. This option is useful for machines "
+ "that provides duplicate UUID."
+ )
+
# Using [1:] to remove the 'register' option from arguments
# and avoid vdsm-tool recognize it as an unknown option
args = parser.parse_args(args=args[1:])
@@ -445,7 +469,8 @@
ssh_user=args.ssh_user,
ssh_port=args.ssh_port,
fingerprint=args.fingerprint,
- check_fqdn=args.check_fqdn)
+ check_fqdn=args.check_fqdn,
+ persist_uuid=args.persist_uuid)
try:
reg.handshake()
--
To view, visit https://gerrit.ovirt.org/44431
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5926b635201662db53956dbac18b9a2981d6e645
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>
More information about the vdsm-patches
mailing list