Skip to content

Commit addefd4

Browse files
author
Szymon Mentel
committed
Adjust the app to separation between dobby server and dobby client
The dobby repository have been splitted into dobby and dobby_clib.
1 parent 59f682e commit addefd4

4 files changed

Lines changed: 22 additions & 17 deletions

File tree

rebar.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
{deps,
44
[{lager, "2.1.1", {git, "https://github.com/basho/lager", {tag, "2.1.1"}}},
55
{meck, "0.8.2", {git, "https://github.com/eproxus/meck.git", {tag, "0.8.2"}}},
6+
{ct_tty_hook, ".*", {git, "https://github.com/mpmiszczyk/ct_tty_hook.git", {branch, master}}},
7+
{recon, ".*", {git, "https://github.com/ferd/recon.git", {branch, "master"}}},
68
%% TODO: Change to https when opensourcing
79
{dobby, ".*", {git, "git@github.com:shivarammysore/dobby.git", {branch, master}}},
8-
{ct_tty_hook, ".*", {git, "https://github.com/mpmiszczyk/ct_tty_hook.git", {branch, master}}},
9-
{recon, ".*", {git, "https://github.com/ferd/recon.git", {branch, "master"}}}]
10+
{dobby_clib, ".*", {git, "git@github.com:shivarammysore/dobby_clib.git", {branch, master}}}]
1011
}.
1112

1213
{cover_enabled, true}.

src/dobby_oflib.app.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{applications, [
77
kernel,
88
stdlib,
9+
dobby_clib,
910
lager
1011
]},
1112
{env, []}

src/dobby_oflib.erl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
-export([get_path/2,
1212
publish_new_flow/3]).
1313

14-
-include_lib("dobby/include/dobby.hrl").
14+
-include_lib("dobby_clib/include/dobby.hrl").
1515

1616
%% -define(MYMAC, "MY").
1717

@@ -58,6 +58,8 @@ get_path(SrcEndpoint, DstEndpoint) ->
5858
publish_new_flow(SrcEndpoint, DstEndpoint, OpenFlowPath) ->
5959
NfId = publish_net_flow_identifer(SrcEndpoint, DstEndpoint),
6060
publish_openflow_path(NfId, OpenFlowPath),
61+
lager:info("Published NetFlow: ~p between endpoints src: ~p dst: ~p ~n",
62+
[NfId, SrcEndpoint, DstEndpoint]),
6163
NfId.
6264

6365
%%%=============================================================================
@@ -67,8 +69,8 @@ publish_new_flow(SrcEndpoint, DstEndpoint, OpenFlowPath) ->
6769
publish_net_flow_identifer(Src, Dst) ->
6870
%% TODO: In transaction
6971
NfId = net_flow_identifier(Src, Dst),
70-
dby:publish(Src, NfId, link_metadata(ep_to_nf, Src), [persistent]),
71-
dby:publish(NfId, Dst, link_metadata(ep_to_nf, NfId), [persistent]),
72+
publish(Src, NfId, link_metadata(ep_to_nf, Src)),
73+
publish(NfId, Dst, link_metadata(ep_to_nf, NfId)),
7274
NfId.
7375

7476
publish_openflow_path(NetFlowId, OpenFlowPath0) ->
@@ -77,18 +79,18 @@ publish_openflow_path(NetFlowId, OpenFlowPath0) ->
7779

7880
publish_openflow_path(NetFlowId, [ExtendedFlowMod | T], LastId)
7981
when LastId =:= NetFlowId ->
80-
Identifier = {Id, _Md} = flow_mod_identifier(ExtendedFlowMod),
81-
LinkMd = link_metadata(of_path_starts_at, {NetFlowId, NetFlowId}),
82-
dby:publish(NetFlowId, Identifier, LinkMd, [persistent]),
82+
publish(NetFlowId,
83+
{Id, _Md} = flow_mod_identifier(ExtendedFlowMod),
84+
link_metadata(of_path_starts_at, {NetFlowId, NetFlowId})),
8385
publish_openflow_path(NetFlowId, T, Id);
8486
publish_openflow_path(NetFlowId, [ExtendedFlowMod | T], LastId) ->
85-
Identifier = {Id, _Md} = flow_mod_identifier(ExtendedFlowMod),
86-
LinkMd = link_metadata(of_path_forwards_to, {NetFlowId, LastId}),
87-
dby:publish(LastId, Identifier, LinkMd, [persistent]),
87+
publish(LastId,
88+
{Id, _Md} = flow_mod_identifier(ExtendedFlowMod),
89+
link_metadata(of_path_forwards_to, {NetFlowId, LastId})),
8890
publish_openflow_path(NetFlowId, T, Id);
8991
publish_openflow_path(NetFlowId, [], LastId) ->
90-
LinkMd = link_metadata(of_path_ends_at, {NetFlowId, LastId}),
91-
dby:publish(LastId, NetFlowId, LinkMd, [persistent]).
92+
publish(LastId, NetFlowId,
93+
link_metadata(of_path_ends_at, {NetFlowId, LastId})).
9294

9395
net_flow_identifier(Src, Dst) ->
9496
<<"NF:", Src/binary, ":", Dst/binary>>.
@@ -106,6 +108,9 @@ link_metadata(Type, {NetFlowId, Src})
106108
Type =:= of_path_forwards_to ->
107109
#{type => Type, src => Src, net_flow_ids => [NetFlowId]}.
108110

111+
publish(Src, Dst, LinkMetadata) ->
112+
dby:publish(Src, Dst, LinkMetadata, [persistent]).
113+
109114
flatten_openflow_path(FlowPath0) ->
110115
Fun = fun({Dpid, {OFVersion, FlowMods}}) ->
111116
[{Dpid, OFVersion, FlowMod} || FlowMod <- FlowMods]

test/dobby_oflib_SUITE.erl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ assert_flow_path_published(NetFlowId, [], LastId) ->
8989
%%%=============================================================================
9090

9191
mock_dobby() ->
92-
ok = meck:expect(dby, publish,
93-
fun(SrcEp, DstEp) ->
94-
<<"NFL:", SrcEp/binary, ":", DstEp/binary>>
95-
end).
92+
ok = meck:expect(dby, publish, 4, _Ret = ok).
93+
9694
unmock_dobby() ->
9795
ok = meck:unload(dby).
9896

0 commit comments

Comments
 (0)