1

TitanGraphDB + Cassandraを使用しています。次のようにTitanを起動しています

cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties

上記の Titan + Cassandra との通信に使用できる Rexster シェルがあります。

cd rexster-console-2.3.0
bin/rexster-console.sh

Python プログラムから Titan Graph DB をプログラムしたいのですが、そのために電球パッケージを使用しています。

以下に示すように、電球を使用して python から 3 種類の頂点を作成します。3種類の頂点は

- switch
- port
- device

 from bulbs.titan import Graph
 vswitch = self.g.vertices.get_or_create('dpid',dpid_str,{'state':'active','dpid':dpid_str,'type':'switch'})
 vport   = self.g.vertices.get_or_create('port_id',port_id,{'desc':desc,'port_id':port_id,'state':state,'port_state':port_state,'number':number,'type':'port'})

変数 vswitch、vport、および vdevice を出力しようとすると、次の結果が得られます。

vswitch     <Vertex: http://localhost:8182/graphs/graph/vertices/4>
vport       <Vertex: http://localhost:8182/graphs/graph/vertices/28>

ただし、次のようにキーを使用して上記の頂点を取得しようとするとします。

vswitch = self.g.vertices.index.lookup(dpid=dpid_str)
vport   = self.g.vertices.index.lookup(port_id=port_id_str)

for s in vswitch
     print s

Here 's' prints the the node `<Vertex: http://localhost:8182/graphs/graph/vertices/4>`
which is expected.How do I extract the key-value pairs from this node?

'dpid'  : dpid_str,
'state' :'active',
'type'  :'switch'
4

1 に答える 1