initial import code into git
[platform/upstream/mic.git] / plugins / imager / fs_plugin.py
1 #!/usr/bin/python
2
3 from micng.pluginbase.imager_plugin import ImagerPlugin
4 from micng.imager.fs import *
5 import micng.configmgr as configmgr
6 try:
7     import argparse
8 except:
9     import micng.utils.argparse
10
11 class FsPlugin(ImagerPlugin):
12     """hello livecd
13     """
14     @classmethod
15     def do_options(self, parser):
16         parser.add_argument('ksfile', nargs='?', help='kickstart file')
17         parser.add_argument('--release', help='fs options test')
18
19     @classmethod
20     def do_create(self, args):
21         if args.release:
22             print "fs option release: ", args.release
23         if not args.ksfile:
24             print "please specify a kickstart file"
25             return
26 #        print "ksfile", args.ksfile
27         self.configmgr = configmgr.getConfigMgr()
28         self.configmgr.setProperty('ksfile', args.ksfile)
29 #        print "ksfile", self.configmgr.getProperty('ksfile')
30         self.ks = self.configmgr.getProperty('kickstart')
31         self.name = self.configmgr.getProperty('name')
32         fs = FsImageCreator(self.ks, self.name)
33         try:
34             fs.outdir = self.configmgr.getProperty('outdir')
35             fs.mount(None, self.configmgr.cache)
36             fs.install()
37             fs.configure(self.configmgr.repometadata)
38             fs.unmount()
39             fs.package(self.configmgr.outdir)
40             print "Finished"
41         except Exception, e:
42             print "failed to create image: %s" % e
43         finally:
44             fs.cleanup()
45
46
47 mic_plugin = ["fs", FsPlugin]