I am using TitanGraphDB + Cassandra.I am starting Titan as follows
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
I have a Rexster shell that I can use to communicate to Titan+Cassandra above.
cd rexster-console-2.3.0
bin/rexster-console.sh
I want to program the Titan Graph DB from my python program.I am using bulbs package for that.
I create a vertex from python using bulbs as given below.
fe1 = self.g.vertices.get_or_create('switch_dpid',switch_dpid,
{'actionOutputPort':actionOutputPort,
'switch_state':'FE_SWITCH_UPDATED',
'matchInPort': MatchInPort,
'type': 'flow_entry',
'user_state':'FE_USER_ADD',
'actions': ['type':'ACTION_OUTPUT', 'action':[port=actionOutputPort maxLen=0];]})
This is giving me an error
'actions': ['type':'ACTION_OUTPUT', 'action':[port=actionOutputPort maxLen=0];]})
SyntaxError: invalid syntax
The output that I would expect from the Rexster console is as follows.
switch_dpid=00:00:00:00:00:00:02:05,
actionOutputPort=1,
switch_state=FE_SWITCH_UPDATED,
matchInPort=2,
flow_entry_id=0x4ee30a9400000012,
type=flow_entry,
actions=[[type=ACTION_OUTPUT action=[port=1 maxLen=0]];],
user_state=FE_USER_ADD
How do I program actions
so that it is as above.?
You're mixing up Groovy syntax with Python.
actions
is a dictionary and action
is a dictionary so in Python it should be:
'actions': {'type': 'ACTION_OUTPUT',
'action': {port: actionOutputPort,
maxLen: 0}}
Note it is usually more convenient (less quotes) to create Python dictionaries using the dict
function:
'actions' = dict(type = 'ACTION_OUTPUT',
action = dict(port = actionOutputPort,
maxLen = 0))