Skip to content
Permalink
Browse files

- implementation of passive mode (-P) to prevent function execution w…

…hen using snafu only for function management
  • Loading branch information...
spio
spio committed Sep 7, 2017
1 parent 23c5262 commit c274074a8dde0426319380b2b274a6d8f87d3f5c
Showing with 15 additions and 0 deletions.
  1. +2 −0 TODO
  2. +13 −0 snafulib/snafucontrol.py
2 TODO
@@ -73,6 +73,8 @@ A marketplace is needed to host functions. For its implementation, a
passive snafu-control mode which only allows for function management but
not for execution would be suitable.

-> simple passive mode is now implemented

# Misc:
# better error messages for docker (+ maybe docker also for pure snafu)
# check for oracle functions
@@ -188,6 +188,7 @@ class SnafuControl:
port = None
snafu = None
authenticatormods = []
passive = False

def __init__(self):
pass
@@ -251,6 +252,8 @@ def getfunctionopenwhisk(namespace, function):
@app.route("/api/v1/namespaces/<namespace>/actions/<function>", methods=["POST"])
# ?blocking=true&result=true
def invokeopenwhisk(namespace, function):
if SnafuControl.passive:
return ControlUtil.notauthorised()
data = flask.request.data.decode("utf-8")
dataargs = json.loads(data)
#print("F", function, dataargs)
@@ -273,6 +276,8 @@ def listfunctionsgoogle(project, location):

@app.route("/v1beta2/projects/<project>/locations/<location>/functions/<function>", methods=["POST"])
def invokegoogle(project, location, function):
if SnafuControl.passive:
return ControlUtil.notauthorised()
function = function.split(":")[0]
response = SnafuControl.snafu.execute(function)
return json.dumps(response)
@@ -405,6 +410,8 @@ def getputfunctionconfiguration(function):
auth = SnafuControl.authorise()
if not auth:
return ControlUtil.notauthorised()
if SnafuControl.passive:
return ControlUtil.notauthorised()

if function in SnafuControl.snafu.functions:
if flask.request.method == "GET":
@@ -426,6 +433,8 @@ def addpermission(function):
auth = SnafuControl.authorise()
if not auth:
return ControlUtil.notauthorised()
if SnafuControl.passive:
return ControlUtil.notauthorised()

data = flask.request.data.decode("utf-8")
"""
@@ -440,6 +449,8 @@ def invoke(function):
auth = SnafuControl.authorise()
if not auth:
return ControlUtil.notauthorised()
if SnafuControl.passive:
return ControlUtil.notauthorised()

if SnafuControl.snafu.executormods[0].__name__ == "snafulib.executors.docker":
response = SnafuControl.snafu.executormods[0].executecontrol(flask.request, auth[1])
@@ -497,6 +508,7 @@ def run(self):
parser.add_argument("-p", "--port", help="HTTP port number", type=int, default=10000)
parser.add_argument("-r", "--reaper", help="closed connection reaper", action="store_true")
parser.add_argument("-d", "--deployer", help="automated hot deployment", action="store_true")
parser.add_argument("-P", "--passive", help="passive mode without function execution", action="store_true")

for action in parser._actions:
if action.dest == "executor":
@@ -515,6 +527,7 @@ def run(self):

SnafuControl.snafu = snafulib.snafu.Snafu(args.quiet)
SnafuControl.port = args.port
SnafuControl.passive = args.passive
# FIXME: should now provide the choice between lambda, gfunctions and openwhisk depending on modular activation

self.snafu.configpath = args.settings

0 comments on commit c274074

Please sign in to comment.
You can’t perform that action at this time.