1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""CmdBase
15
16 Dump location data from pre 0.11.7 database to text to be reloaded
17 in new location format
18
19 $Id: LocationDump.py,v 1.4 2003/11/21 21:18:11 edahl Exp $"""
20
21 __version__ = "$Revision: 1.4 $"[11:-2]
22
23
24 from ZCmdBase import ZCmdBase
25
27
29 outfile = open(self.options.outfile, "w")
30 if not hasattr(self.dataroot, "getSubDevices"):
31 raise "DataRootError", "dataroot doesn't have getSubDevices"
32 devs = self.dataroot.getSubDevices()
33 for dev in devs:
34 dcname = dev.getDataCenterName()
35 rname = dev.getRackName()
36 if rname:
37 locpath = dcname.split("-")
38 locpath.append(rname)
39 else:
40 locpath = ("NoLocation",)
41 line = "%s|%s\n" % (dev.getId(), "/" + "/".join(locpath))
42 outfile.write(line)
43 outfile.close()
44
45
47 ZCmdBase.buildOptions(self)
48 self.parser.add_option('-o', '--outfile',
49 dest='outfile',
50 default="locdump.out",
51 help='output file')
52
53
54 if __name__ == "__main__":
55 ld = LocationDump()
56 ld.dump()
57