3 mcuAddress
= "ccmcu40.in2p3.fr"
4 mcuProxy
= xmlrpclib
.ServerProxy("http://%s/RPC2" % mcuAddress
)
5 mcuUser
= "indico-support@cern.ch"
6 mcuPassword
= "xK!34(25"
8 # RmsApi should be used to create conference
9 def CreateConference(**params
):
10 return invokeMethod("conference.create", params
)
12 # RmsApi should be used to destroy conference
13 def DestroyConference(**params
):
14 return invokeMethod("conference.destroy", params
)
16 def EnumerateConferences(**params
):
17 return invokeMethod("conference.enumerate", params
)
19 def EnumerateAllConferences(**params
):
20 return enumerateAll(EnumerateConferences
, "conferences", **params
)
22 def SelectConferences(**params
):
23 return selectDictionaries(EnumerateAllConferences(**params
), params
)
25 def QueryConferenceStreaming(**params
):
26 return invokeMethod("conference.query", params
)
28 def ModifyConference(**params
):
29 return invokeMethod("conference.modify", params
)
31 def AddParticipant(**params
):
32 return invokeMethod("participant.add", params
)
34 def RemoveParticipant(**params
):
35 return invokeMethod("participant.remove", params
)
37 def EnumerateParticipants(**params
):
38 return invokeMethod("participant.enumerate", params
)
40 def EnumerateAllParticipants(**params
):
41 return enumerateAll(EnumerateParticipants
, "participants", **params
)
43 def SelectParticipants(params
, **filter):
44 return selectDictionaries(EnumerateAllParticipants(**params
), filter)
46 def ModifyParticipant(**params
):
47 return invokeMethod("participant.modify", params
)
49 def ConnectParticipant(**params
):
50 return invokeMethod("participant.connect", params
)
52 def DisconnectParticipant(**params
):
53 return invokeMethod("participant.disconnect", params
)
55 def invokeMethod(name
, params
):
57 "authenticationUser": mcuUser
,
58 "authenticationPassword": mcuPassword
61 return getattr(mcuProxy
, name
)(args
)
63 def enumerateAll(method
, key
, **params
):
67 ret
= method(**params
)
69 params
["enumerateID"] = id
70 ret
= method(**params
)
71 for item
in ret
.get(key
, []):
73 id = ret
.get("enumerateID", None)
77 def selectDictionaries(dictionaries
, pairs
):
78 return [dictionary
for dictionary
in dictionaries
if hasAllPairs(dictionary
, pairs
)]
80 def hasAllPairs(target
, source
):
81 for key
, value
in source
.iteritems():
84 if target
[key
] != value
: