When browsing through my laptop filesystem, I noticed one of the scripts which I used in past to convert a data domain to export domain to get my VMs back from a rhevm crashed instance.. Please note that, I had only one master domain in a NFS DC.
My NFS master data domain metadata had entries similar to this :
CLASS=Data
DESCRIPTION=datastore
IOOPTIMEOUTSEC=10
LEASERETRIES=3
LEASETIMESEC=60
LOCKPOLICY=
LOCKRENEWALINTERVALSEC=5
MASTER_VERSION=2
POOL_DESCRIPTION=NFS-DC
POOL_DOMAINS=48ed1611-3ee1-42eb-897b-1126da73bec4:Active,102dd75d-a3ae-4ea4-8ba7-cf145047498e:Active
POOL_SPM_ID=4
POOL_SPM_LVER=11
POOL_UUID=055f10f3-cb0f-4a15-ab65-de34fe12a636
REMOTE_PATH=10.65.211.81:/ovirt/datastore
ROLE=Master
SDUUID=48ed1611-3ee1-42eb-897b-1126da73bec4
TYPE=NFS
VERSION=0
_SHA_CKSUM=7ed45cda1369588f93e931828fb524f4f57bfd2b
Here is the script I was referring above.. ( More enhancement needed for the script though)
[Desktop]$ cat convert.py
#!/usr/bin/python
# Copyright (C) 2012 Red Hat Inc.
# Author
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Use this script only in damaged setup and use with caution.
import sys
export_domain_path=sys.argv[3]
keylist=[“CLASS”, “DESCRIPTION”, “POOL_DOMAINS”, “POOL_UUID”, “REMOTE_PATH”, “ROLE”, “_SHA_CKSUM”]
try:
fd=open(sys.argv[1])
nfd=open(sys.argv[2],”w”)
except:
print “Error to open source/destination meta file”
for line in fd:
key=line.split(“=”)[0]
if key in keylist:
if key == “CLASS”:
nfd.write(“CLASS=Backup”)
if key == “DESCRIPTION”:
nfd.write(“DESCRIPTION=exportstore”)
if key == “POOL_DOMAINS”:
nfd.write(“POOL_DOMAINS=”)
if key == “POOL_UUID”:
nfd.write(“POOL_UUID=”)
if key == “ROLE”:
nfd.write(“ROLE=REGULAR”)
if key == “REMOTE_PATH”:
entry= key+’=’+export_domain_path
nfd.write(entry)
if key == “_SHA_CKSUM”:
pass
nfd.write(‘\n’)
else:
nfd.write(line)
[Desktop]$
Now ‘convert.py’ requires 3 args
1) input file which contains master data domain metadata
2) output file name where you want to store converted export domain metadata
3) NFS export path which going to be the export domain storage
For ex:
[ Desktop]$ ./convert.py master_dom_metadata expot_metadata 10.65.210.218:/export/vms
After successful execution of above, the expot_metadata can be found similar to:
[ Desktop]$ cat expot_metadata
CLASS=Backup
DESCRIPTION=exportstore
IOOPTIMEOUTSEC=10
LEASERETRIES=3
LEASETIMESEC=60
LOCKPOLICY=
LOCKRENEWALINTERVALSEC=5
MASTER_VERSION=2
POOL_DESCRIPTION=NFS-DC
POOL_DOMAINS=
POOL_SPM_ID=4
POOL_SPM_LVER=11
POOL_UUID=
REMOTE_PATH=10.65.210.218:/export/vms
ROLE=REGULAR
SDUUID=48ed1611-3ee1-42eb-897b-1126da73bec4
TYPE=NFS
VERSION=0
[Desktop]$
By replacing the export domain metadata with generated content , you should be able to ‘import’ previous data domain as an export domain in RHEV/Ovirt setup..
*** Disclaimer ***
Above procedure can be tried when there is no other recovery is possible. Also, this article is generated with my testing. No guarantee it will work for you. 🙂
*********************