summaryrefslogtreecommitdiff
path: root/modules/CIAO/DAnCE/bin/generate_plan.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/DAnCE/bin/generate_plan.py')
-rwxr-xr-xmodules/CIAO/DAnCE/bin/generate_plan.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/modules/CIAO/DAnCE/bin/generate_plan.py b/modules/CIAO/DAnCE/bin/generate_plan.py
new file mode 100755
index 00000000000..15310877bec
--- /dev/null
+++ b/modules/CIAO/DAnCE/bin/generate_plan.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+import sys, os
+
+sys.path.append (os.getenv ("DANCE_ROOT"))
+
+
+def parse_args ():
+ from optparse import OptionParser
+
+ parser = OptionParser ("""usage %prog [options]
+ Note that this script is very simple. It assumes that the idl and mpc follow
+ canonical and predictable patterns.""")
+
+ parser.add_option ("-o", "--output", dest="output", action="store", type="string",
+ help="Output filename", default="Plan.cdp")
+ parser.add_option ("--home", dest="homes", action="append", type="string",
+ help="Home types to be included")
+ parser.add_option ("-c", "--component", dest="components", action="append",
+ type="string", help="Component types to be included")
+ parser.add_option ("--homed-component", dest="homed_components", action="append",
+ type="string", help="Homed component types to be included")
+ parser.add_option ("-u", "--uuid", dest="uuid", action="store",
+ type="string", help="UUID for the generated plan")
+ parser.add_option ("-n", "--namespace", dest="namespace", action="store", default="",
+ type="string", help="IDL namespace any components may be in")
+
+ (options, arguments) = parser.parse_args ()
+
+ return (options, arguments)
+
+def main ():
+ (opts, args) = parse_args ()
+
+ # compset = set (opts.homes) | set (opts.components) | set (homed_components)
+
+ from PythonDAnCE import generator
+ retval = ""
+ retval += generator.header.template (opts.uuid)
+
+ artifacts = {}
+
+ if opts.namespace != "":
+ opts.namespace += "_"
+
+ #implementations
+ if opts.homes is not None:
+ for item in opts.homes:
+ retval += generator.home_impl.template (item, opts.namespace)
+ artifacts[item] = 1
+
+ if opts.homed_components is not None:
+ for item in opts.homed_components:
+ retval += generator.homed_comp_impl.template (item)
+ artifacts[item] = 1
+
+ if opts.components is not None:
+ for item in opts.components:
+ retval += generator.comp_impl.template (item, opts.namespace)
+ artifacts[item] = 1
+
+ #instances
+ if opts.homes is not None:
+ for item in opts.homes:
+ retval += generator.home_inst.template (item)
+
+ if opts.homed_components is not None:
+ for item in opts.homed_components:
+ retval += generator.homed_comp_inst.template (item)
+
+ if opts.components is not None:
+ for item in opts.components:
+ retval += generator.comp_inst.template (item)
+
+ #artifacts
+ if artifacts is not None:
+ for item in artifacts.keys():
+ retval += generator.artifact.template(item)
+
+ retval += generator.footer.template ()
+
+ outfile = open (opts.output, 'w')
+ outfile.write (retval)
+ outfile.close ()
+
+
+if __name__ == "__main__":
+ main ()
+
+
+