summaryrefslogtreecommitdiff
path: root/src/flufigut.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/flufigut.py')
-rwxr-xr-xsrc/flufigut.py97
1 files changed, 52 insertions, 45 deletions
diff --git a/src/flufigut.py b/src/flufigut.py
index 966a935..04216ea 100755
--- a/src/flufigut.py
+++ b/src/flufigut.py
@@ -3,8 +3,8 @@
# 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
+# 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.
#
@@ -60,6 +60,7 @@ flow = {}
### sanity checks ###############################################
+machines = {}
# TODO:
# - worker<->machine only 1:1
# - list of workers (mark usage later)
@@ -92,7 +93,7 @@ for format in transcode.keys():
if samplerate not in samplerates:
if input['samplerate'] != samplerate:
samplerates.append(samplerate)
- for profile in transcode[format]:
+ for profile in transcode[format]:
resolution = globals['profiles'][profile]['video']
if resolution not in resolutions:
if input['resolution'] != resolution:
@@ -174,7 +175,7 @@ for format in transcode.keys():
}
muxer = globals['formats'][format]['muxer']
- flow['muxer']['muxer-%s-%s' % (muxer, profile)] = {
+ flow['muxer']['muxer-%s-%s' % (format, profile)] = {
'type': '%s-mux' % muxer,
'desc': "%s muxer profile %s" % (format, profile),
'worker': 'muxer-%s' % muxer,
@@ -182,51 +183,57 @@ for format in transcode.keys():
'feeder_video': video_encoder,
'properties': {},
}
-
+
### generate streamer components ################################
flow['streamer'] = {}
-# TODO
-### generate porter for all streamer/machines ###################
-#
-# idx = 0
-# for streamer in stream:
-# worker = 'streamer%i'%(idx)
-# port = streamer['config']['port']
-# found = False
-# for machine in globals['machines'].keys():
-# if worker in globals['machines'][machine]:
-# if machine in machines:
-# if 'porter' in machines[machine]:
-# if port in machines[machine]['porter']:
-# raise SystemExit("Porter: machine %s already uses port %i" % (machine, port))
-# 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),
-# }
-
-# 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:
-# raise SystemExit("Streamer %i has no machine assigned" % (idx))
-# idx+=1
+for cluster in stream.keys():
+ streamer_cnt = stream[cluster]['count']
+ port = stream[cluster]['port']
+ for idx in range(streamer_cnt):
+ worker = '%s%i'%(cluster, idx+1)
+ for machine in globals['machines'].keys():
+ if worker in globals['machines'][machine]:
+ if machine in machines:
+ if 'porter' in machines[machine]:
+ if port in machines[machine]['porter']:
+ raise SystemExit("Porter: machine %s already uses port %i" % (machine, port))
+ else:
+ machines[machine]['porter'] = {}
+ else:
+ machines[machine] = { 'porter': {} }
+
+ machines[machine]['porter'][port] = {
+ 'socket-path': "porter-%s"%(rand_string()),
+ 'username': rand_string(size=12),
+ 'password': rand_string(size=12),
+ }
+
+ 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'],
+ },
+ }
+
+ for format in stream[cluster]['formats']:
+ for profile in transcode[format]:
+ feeder = 'muxer-%s-%s' % (format, profile)
+ name = '%s-%s%i-%s-%s' % (stream[cluster]['type'], cluster, idx+1, format, profile)
+ flow['streamer'][name] = {
+ 'type': "%s-stream" % stream[cluster]['type'],
+ 'desc': "%s streamer for %s-%s (part %i of %s)" % (stream[cluster]['type'], format, profile, idx+1, cluster),
+ 'worker': worker,
+ 'feeder': feeder,
+ 'properties': {
+ }
+ }
### initialize and render templates #############################