Skip to content

Commit

Permalink
Merge pull request #14 from GlobalNOC/1.0.0-dev
Browse files Browse the repository at this point in the history
1.0.0 dev
  • Loading branch information
ajragusa committed Oct 2, 2014
2 parents 91a3f2d + efad18b commit f88e852
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
49 changes: 49 additions & 0 deletions Bro/scipass.bro
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@load base/protocols/ftp
@load base/utils/exec

#@load base/protocols/ftp/gridftp
#module GridFTP;

function signalSciPass(c: connection)
{
local anagram : Exec::Command;

local prog = fmt("curl -X PUT -d '{\"nw_dst\":\"%s/32\", \"nw_src\":\"%s/32\", \"tp_src\":\"%d\", \"tp_dst\":\"%d\"}' http://scipass-controller:8080/scipass/flows/good_flow",
c$id$resp_h, c$id$orig_h,c$id$orig_p, c$id$resp_p);
#print prog;
local param = "";
anagram = [$cmd = prog, $stdin = param];
when ( local result = Exec::run(anagram))
{
if ( result$exit_code != 0 )
{
return;
}
}
return;
}

event bro_init()
{
print "BRO Starting";
}


event ftp_request(c: connection, command: string, arg: string)
{
#print fmt("FTP REQUEST!! command: %s args: %s", command, arg);

}

event ftp_reply(c: connection, code: count, msg: string, cont_resp: bool)
{
#print fmt("FTP REPLY!! code: %d, msg: %s", code, msg);
}



event file_over_new_connection(f: fa_file, c: connection, is_orig: bool)
{
print "FILE TRANSFER STARTED!";
signalSciPass(c);
}
3 changes: 2 additions & 1 deletion SciPass.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rm -rf $RPM_BUILD_ROOT
%{__install} -d -p %{buildroot}/etc/init.d
%{__install} python/*.py %{buildroot}/%{python_sitelib}/SciPass/
%{__install} etc/SciPass.xml %{buildroot}/etc/SciPass/
%{__install} etc/ryu.conf %{buildroot}/etc/SciPass/
%{__install} etc/scipass-init %{buildroot}/etc/init.d/scipass
%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -33,6 +34,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
/etc/init.d/scipass
/etc/SciPass/SciPass.xml
/etc/SciPass/ryu.conf
%{python_sitelib}/SciPass/*

%doc
Expand All @@ -41,4 +43,3 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Fri Jul 25 2014 aragusa <[email protected]> -
- Initial build.

6 changes: 3 additions & 3 deletions etc/scipass-init
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
# TTS Server for Speech Synthesis
#

options="--config-file /etc/SciPass/SciPass.cfg --verbose --use-syslog"
options="--config-file /etc/SciPass/ryu.conf --use-syslog --nouse-stderr"

CMD="ryu-manager /usr/share/SciPass/SciPass.py $options"
CMD="ryu-manager /usr/share/SciPass/Ryu.py $options"

start() {
$CMD 2>&1 &
echo "SciPass Started"
}

stop() {
pid=`ps -ef | grep 'SciPass.py' | awk '{ print $2 }'`
pid=`ps -ef | grep 'ryu-manager /usr/share/SciPass/Ryu.py' | grep -v "grep" | awk '{ print $2 }'`
echo $pid
kill $pid
sleep 2
Expand Down
3 changes: 2 additions & 1 deletion python/Ryu.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def update_sensor_load(self, req):
return Response(content_type='application/json',body=json.dumps(result))

class Ryu(app_manager.RyuApp):

OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
_CONTEXTS = { 'wsgi': WSGIApplication }

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -139,6 +139,7 @@ def changeSwitchForwardingState(self, dpid=None, header=None, actions=None, comm

if(not self.datapaths.has_key(dpid)):
self.logger.error("unable to find switch with dpid " + dpid)
self.logger.error(self.datapaths)
return

datapath = self.datapaths[dpid]
Expand Down
4 changes: 2 additions & 2 deletions python/SciPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ def setSensorLoad(self, sensor, load):
def run_balancers(self):
for dpid in self.config:
for domain_name in self.config[dpid]:
self.logger.info("Balancing: %s %s", dpid, domain_name)
self.logger.debug("Balancing: %s %s", dpid, domain_name)
self.config[dpid][domain_name]['balancer'].balance()


Expand All @@ -924,7 +924,7 @@ def getBalancer(self, dpid, domain_name):


def TimeoutFlows(self, dpid, flows):
self.logger.error("Looking for flows to timeout")
self.logger.debug("Looking for flows to timeout")
now = time.time()
for flow in self.hardTimeouts:
if(flow['dpid'] == dpid):
Expand Down

0 comments on commit f88e852

Please sign in to comment.