From 66f9e44e868a7ec381e110d0b3b2797d86f4dc17 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@88d0365b-309c-4eec-8061-d8e0c04ad69e> Date: Thu, 27 Sep 2012 17:50:52 +0000 Subject: renameing of flufig to flufigut finished git-svn-id: https://svn.spreadspace.org/flufigut/trunk@14 88d0365b-309c-4eec-8061-d8e0c04ad69e --- src/flufig.py | 118 ------------------------------------------------------- src/flufigut.py | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 118 deletions(-) delete mode 100755 src/flufig.py create mode 100755 src/flufigut.py (limited to 'src') diff --git a/src/flufig.py b/src/flufig.py deleted file mode 100755 index a765bc3..0000000 --- a/src/flufig.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/python -# -# flufig -# -# flufig is a simple flumotion configuration generator using -# pyhton jinja2 template engine and simplejson. flufig generates -# planet.xml and worker.xml files from configuration templates and -# an easy representation of the flow structure written in json. -# -# -# Copyright (C) 2012 Christian Pointner -# Michael Gebetsroither -# -# This file is part of flufig. -# -# flufig 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 -# any later version. -# -# flufig 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 flufig. If not, see . -# - -import string -import random -import sys -import simplejson as json -from exceptions import * -from jinja2 import Environment, FileSystemLoader - -### helper functions ############################################ -# -def rand_string(size=8, chars=string.ascii_lowercase + string.ascii_uppercase + string.digits): - return ''.join(random.choice(chars) for x in range(size)) - -### parse json file ############################################# -# -if len(sys.argv) <= 2: - raise SystemExit("No template name and or config file given") - -cf = open(sys.argv[2], 'r') -config = json.load(cf); -cf.close(); - -### initialization ############################################## -# -data = { 'globals' : config['globals'], 'atmosphere' : {}, 'flow' : {} } -machines = {} - -### generate porter for all streamer/machines ################### -# -idx = 0 -for streamer in config['streamer']: - worker = 'streamer%i'%(idx) - port = streamer['config']['port'] - found = False - for machine in config['globals']['machines'].keys(): - if worker in config['globals']['machines'][machine]: - if machine in machines: - if 'porter' in machines[machine]: - if port in machines[machine]['porter']: - print "Porter: machine %s already uses port %i" % (machine, port) - sys.exit(1) - else: - machines[machine]['porter'] = {} - else: - machines[machine] = { 'porter': {} } - - found = True - machines[machine]['porter'][port] = { - 'socket-path': "porter%i-%s"%(idx, rand_string()), - 'username': rand_string(size=12), - 'password': rand_string(size=12), - } - - data['atmosphere']['porter-%s-%i'%(machine, port)] = { - 'type': "porter", - 'desc': "Porter for %s on port %i"%(machine, port), - 'worker': worker, - 'properties': { - 'port': port, - 'socket-path': machines[machine]['porter'][port]['socket-path'], - 'username': machines[machine]['porter'][port]['username'], - 'password': machines[machine]['porter'][port]['password'], - }, - } - if not found: - print "Streamer %i has no machine assigned" % (idx) - sys.exit(1) - idx+=1 - -### generate input components ################################### -# TODO - -### generate encoder components ################################# -# TODO - -### generate muxer components ################################### -# TODO - -### generate streamer components ################################ -# TODO - -### initialize and render templates ############################# -# -env = Environment(loader=FileSystemLoader('../templates/%s/' % (sys.argv[1]))) -template = env.get_template('planet.xml') -planet = template.render(globals=data['globals'], atmosphere=data['atmosphere'], flow=data['flow']) - -sys.stdout.write(planet.encode("utf8")) - -### end ######################################################### diff --git a/src/flufigut.py b/src/flufigut.py new file mode 100755 index 0000000..c55b0ff --- /dev/null +++ b/src/flufigut.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# +# flufigut +# +# flufigut, the flumotion configuration utility, is a simple tool +# that generates flumotion configuration files using pyhton jinja2 +# template engine and simplejson. flufigut generates planet.xml +# and worker.xml files from configuration templates and an easy to +# understand representation of the flow structure written in json. +# +# +# Copyright (C) 2012 Christian Pointner +# Michael Gebetsroither +# +# This file is part of flufigut. +# +# flufigut 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 +# any later version. +# +# flufigut 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 flufigut. If not, see . +# + +import string +import random +import sys +import simplejson as json +from exceptions import * +from jinja2 import Environment, FileSystemLoader + +### helper functions ############################################ +# +def rand_string(size=8, chars=string.ascii_lowercase + string.ascii_uppercase + string.digits): + return ''.join(random.choice(chars) for x in range(size)) + +### parse json file ############################################# +# +if len(sys.argv) <= 2: + raise SystemExit("No template name and or config file given") + +cf = open(sys.argv[2], 'r') +config = json.load(cf); +cf.close(); + +### initialization ############################################## +# +data = { 'globals' : config['globals'], 'atmosphere' : {}, 'flow' : {} } +machines = {} + +### generate porter for all streamer/machines ################### +# +idx = 0 +for streamer in config['streamer']: + worker = 'streamer%i'%(idx) + port = streamer['config']['port'] + found = False + for machine in config['globals']['machines'].keys(): + if worker in config['globals']['machines'][machine]: + if machine in machines: + if 'porter' in machines[machine]: + if port in machines[machine]['porter']: + print "Porter: machine %s already uses port %i" % (machine, port) + sys.exit(1) + else: + machines[machine]['porter'] = {} + else: + machines[machine] = { 'porter': {} } + + found = True + machines[machine]['porter'][port] = { + 'socket-path': "porter%i-%s"%(idx, rand_string()), + 'username': rand_string(size=12), + 'password': rand_string(size=12), + } + + data['atmosphere']['porter-%s-%i'%(machine, port)] = { + 'type': "porter", + 'desc': "Porter for %s on port %i"%(machine, port), + 'worker': worker, + 'properties': { + 'port': port, + 'socket-path': machines[machine]['porter'][port]['socket-path'], + 'username': machines[machine]['porter'][port]['username'], + 'password': machines[machine]['porter'][port]['password'], + }, + } + if not found: + print "Streamer %i has no machine assigned" % (idx) + sys.exit(1) + idx+=1 + +### generate input components ################################### +# TODO + +### generate encoder components ################################# +# TODO + +### generate muxer components ################################### +# TODO + +### generate streamer components ################################ +# TODO + +### initialize and render templates ############################# +# +env = Environment(loader=FileSystemLoader('../templates/%s/' % (sys.argv[1]))) +template = env.get_template('planet.xml') +planet = template.render(globals=data['globals'], atmosphere=data['atmosphere'], flow=data['flow']) + +sys.stdout.write(planet.encode("utf8")) + +### end ######################################################### -- cgit v1.2.3