def sda_manager_app_install():
            logging.info("[" + request.method +
                         "] sda manager app install - IN")

            l = list()
            d = dict()
            data = json.loads(request.data)

            response = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/agents/" +
                SDAManager.get_device_id() + "/deploy",
                data=data["data"],
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            d.update({"id": response.json()["id"], "name": data["name"]})

            root_path = os.getcwd()
            with open(root_path + "/static/user/apps", 'r') as content_file:
                content = content_file.read()
                if content == "":
                    apps = {"apps": l}
                else:
                    apps = json.loads(content)

            with open(root_path + "/static/user/apps", 'w+') as content_file:
                apps["apps"].append(d)
                content_file.write(json.dumps(apps))

            return "", 200
Beispiel #2
0
        def sda_manager_create_group():
            logging.info("[" + request.method +
                         "] sda manager create group - IN")

            l = list()

            data = json.loads(request.data)
            response = requests.post(url="http://" +
                                     SDAManager().get_sda_manager_endpoint() +
                                     "/api/v1/management/groups/create",
                                     data=json.dumps(data),
                                     timeout=1500)

            response2 = requests.post(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/groups/" + response.json()["id"] + "/join",
                data=json.dumps(data["members"]),
                timeout=1500)

            if response.status_code is not 200 or response2.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
 def sda_manager_device():
     logging.info("[" + request.method + "] sda manager device - IN")
     data = json.loads(request.data)
     if "id" in data:
         SDAManager.set_device_id(data["id"])
     if "ip" in data:
         SDAManager.set_device_ip(data["ip"])
     return "device", 200
        def sda_manager_check_address():
            logging.info("[" + request.method + "] sda manager check address - IN")

            if SDAManager.get_sda_manager_address() == "":
                logging.error("No SDAM Address - OUT")
                return "", 500
            else:
                return SDAManager.get_sda_manager_address(), 200
        def sda_manager_group_apps():
            logging.info("[" + request.method +
                         "] sda manager group apps - IN")

            l = list()
            apps = list()
            ret = dict()

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id() + "/apps",
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            root_path = os.getcwd()
            with open(root_path + "/static/user/apps", 'r') as content_file:
                content = content_file.read()
                if content != "":
                    apps = json.loads(content)["apps"]

            for obj in response.json()["apps"]:
                d = dict()
                d.update({"id": str(obj["id"])})
                response2 = requests.get(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/groups/" +
                    SDAManager.get_group_id() + "/apps/" + str(obj["id"]),
                    timeout=1500)

                if response2.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                d.update({
                    "services":
                    len(response2.json()["responses"][0]["services"])
                })

                for app in apps:
                    if "id" in app and app["id"] == str(obj["id"]):
                        d.update({"name": app["name"]})
                l.append(d)

            ret.update({
                "group":
                "Group Name: " + SDAManager.get_current_group_name(),
                "apps":
                l
            })

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_address():
            logging.info("[" + request.method + "] sda manager address - IN")

            if request.method == "GET":
                return SDAManager().get_sda_manager_ip(), 200
            elif request.method == "POST":
                data = json.loads(request.data)
                SDAManager.set_sda_manager_ip(data["ip"])
                return SDAManager().get_sda_manager_ip(), 200
            else:
                return abort(404)
        def sda_manager_reverseproxy():
            logging.info("[" + request.method +
                         "] sda manager reverse proxy - IN")

            if request.method == "GET":
                return SDAManager().get_reverse_proxy(), 200
            elif request.method == "POST":
                data = json.loads(request.data)
                SDAManager.set_reverse_proxy(data["enabled"])
                return SDAManager().get_reverse_proxy(), 200
            else:
                return abort(404)
        def sda_manager_resource():
            logging.info("[" + request.method + "] sda manager resource - IN")
            d = dict()
            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/monitoring/nodes/" + SDAManager.get_device_id() +
                "/resource",
                timeout=1500)
            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            d = response.json()
            return json.dumps(d), 200
Beispiel #9
0
        def sda_manager_group_delete():
            logging.info("[" + request.method +
                         "] sda manager group delete - IN")

            response = requests.delete(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/groups/" + SDAManager.get_group_id(),
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
Beispiel #10
0
        def sda_manager_group_devices():
            logging.info("[" + request.method +
                         "] sda manager group devices - IN")

            l = list()
            l2 = list()
            ret = dict()

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/groups/" + SDAManager.get_group_id(),
                timeout=1500)

            response2 = requests.get(url="http://" +
                                     SDAManager().get_sda_manager_endpoint() +
                                     "/api/v1/management/nodes")

            if response.status_code is not 200 or response2.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            for obj in response.json()["members"]:
                l2.append(str(obj))

            for obj in response2.json()["nodes"]:
                d = dict()
                if "id" in obj and str(obj["id"]) in l2:
                    d.update({"id": str(obj["id"])})
                    res = requests.get(
                        url="http://" +
                        SDAManager().get_sda_manager_endpoint() +
                        "/api/v1/management/nodes/" + str(obj["id"]) +
                        "/configuration",
                        timeout=1500)
                    if res.status_code is 200:
                        for prop in res.json()["properties"]:
                            if "devicename" in prop:
                                d.update({"name": str(prop["devicename"])})
                    if "ip" in obj:
                        d.update({"ip": str(obj["ip"])})
                    if "status" in obj:
                        d.update({"status": str(obj["status"])})
                    l.append(d)

            ret.update({"devices": l})

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_device_unregister():
            logging.info("[" + request.method +
                         "] sda manager device register - IN")

            response = requests.post(
                url="http://" + SDAManager.get_sda_manager_endpoint() +
                "/api/v1/management/nodes/" + SDAManager.get_device_id() +
                "/unregister",
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
        def sda_manager_device_register():
            logging.info("[" + request.method +
                         "] sda manager device register - IN")

            d = dict()
            d2 = dict()
            d3 = dict()
            data = json.loads(request.data)

            d2.update({"manager": str(SDAManager().get_sda_manager_ip())})
            d2.update({"agent": str(data["ip"])})
            d3.update({"interval": str(data["interval"])})
            d.update({"ip": d2, "healthCheck": d3})

            response = requests.post(url="http://" + data["ip"] + ":" +
                                     str(Port.sda_port()) + "/api/v1/register",
                                     data=json.dumps(d),
                                     timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
        def sda_manager_devices():
            logging.info("[" + request.method + "] sda manager devices - IN")

            l = list()
            ret = dict()

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/agents",
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            for obj in response.json()["agents"]:
                d = dict()
                if "id" in obj:
                    d.update({"id": str(obj["id"])})
                if "host" in obj:
                    d.update({"host": str(obj["host"])})
                if "port" in obj:
                    d.update({"port": str(obj["port"])})
                l.append(d)

            ret.update({"devices": l})
            return json.dumps(json.dumps(ret)), 200
        def sda_manager_groups():
            logging.info("[" + request.method + "] sda manager groups - IN")

            l = list()
            ret = dict()

            # No Input Target Address
            if SDAManager().get_sda_manager_ip() == "":
                d = dict()
                d.update({"address": ""})
                return json.dumps(d), 200

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups",
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            root_path = os.getcwd()
            with open(root_path + "/static/user/groups", 'r') as content_file:
                content = content_file.read()

            for obj in response.json()["groups"]:
                d = dict()
                if "id" in obj:
                    d.update({"id": str(obj["id"])})
                    if content != "":
                        groups = json.loads(content)
                        for group in groups["groups"]:
                            if group["id"] == str(obj["id"]):
                                d.update({"groupname": group["groupname"]})
                if "description" in obj:
                    d.update({"name": str(obj["description"])})
                if "members" in obj:
                    d.update({"members": str(len(obj["members"]))})
                l.append(d)

            ret.update({
                "groups": l,
                "address": SDAManager().get_sda_manager_ip()
            })

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_group_app_update():
            logging.info("[" + request.method +
                         "] sda manager group app update - IN")

            response = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id() + "/apps/" +
                SDAManager.get_app_id() + "/update",
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
Beispiel #16
0
        def sda_manager_group_app_yaml():
            logging.info("[" + request.method +
                         "] sda manager group app YAML - IN")

            data = json.loads(request.data)

            response = requests.post(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/groups/" + SDAManager.get_group_id() +
                "/apps/" + SDAManager.get_app_id(),
                data=data["data"],
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
        def sda_manager_create_group():
            logging.info("[" + request.method +
                         "] sda manager create group - IN")

            l = list()

            data = json.loads(request.data)
            response = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/create",
                timeout=1500)

            response2 = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                response.json()["id"] + "/join",
                data=json.dumps(data["members"]),
                timeout=1500)

            if response.status_code is not 200 or response2.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            group = {
                "id": response.json()["id"],
                "groupname": data["groupname"]
            }
            root_path = os.getcwd()
            with open(root_path + "/static/user/groups", 'r') as content_file:
                content = content_file.read()
                if content == "":
                    groups = {"groups": l}
                else:
                    groups = json.loads(content)
                groups["groups"].append(group)

            with open(root_path + "/static/user/groups", 'w+') as content_file:
                content_file.write(json.dumps(groups))

            return "", 200
        def sda_manager_app():
            logging.info("[" + request.method + "] sda manager app - IN")
            if request.method == "POST":

                l = list()
                ret = dict()

                data = json.loads(request.data)
                SDAManager.set_app_id(data["id"])

                response = requests.get(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/agents/" +
                    SDAManager.get_device_id() + "/apps/" +
                    SDAManager.get_app_id(),
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                for obj in response.json()["services"]:
                    d = dict()
                    d.update({"name": str(obj["name"])})
                    d.update({"state": str(obj["state"]["Status"])})
                    d.update({"exitcode": str(obj["state"]["ExitCode"])})
                    l.append(d)

                ret.update({"services": l})

                return json.dumps(json.dumps(ret)), 200
            elif request.method == "DELETE":
                response = requests.delete(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/agents/" +
                    SDAManager.get_device_id() + "/apps/" +
                    SDAManager.get_app_id(),
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                return "", 200
            else:
                return abort(404)
Beispiel #19
0
        def sda_manager_groups():
            logging.info("[" + request.method + "] sda manager groups - IN")

            l = list()
            ret = dict()

            # No Input Target Address
            if SDAManager().get_sda_manager_ip() == "":
                d = dict()
                d.update({"address": ""})
                return json.dumps(d), 200

            response = requests.get(url="http://" +
                                    SDAManager().get_sda_manager_endpoint() +
                                    "/api/v1/management/groups",
                                    timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            for obj in response.json()["groups"]:
                d = dict()
                if "id" in obj:
                    d.update({"id": str(obj["id"])})
                if "name" in obj:
                    d.update({"name": (obj["name"]).encode('utf-8')})
                if "members" in obj:
                    d.update({"members": str(len(obj["members"]))})
                l.append(d)

            ret.update({
                "groups": l,
                "address": SDAManager().get_sda_manager_ip()
            })

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_device_info():
            logging.info("[" + request.method + "] sda manager device - IN")
            if request.method == "GET":
                d = dict()
                response = requests.get(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/nodes/" + SDAManager.get_device_id() +
                    "/configuration",
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)
                if "properties" in response.json():
                    for prop in response.json()["properties"]:
                        if "devicename" in prop:
                            d.update({"name": str(prop["devicename"])})
                        elif "pinginterval" in prop:
                            d.update(
                                {"pinginterval": str(prop["pinginterval"])})

                return json.dumps(d), 200

            elif request.method == "POST":
                response = requests.post(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/nodes/" + SDAManager.get_device_id() +
                    "/configuration",
                    data=request.data,
                    timeout=1500)
                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)
                return "", 200
            else:
                return abort(404)
        def sda_manager_device():
            logging.info("[" + request.method + "] sda manager device - IN")

            data = json.loads(request.data)
            SDAManager.set_device_id(data["id"])
            SDAManager.set_device_ip(data["host"])
            SDAManager.set_device_port(data["port"])

            return "device", 200
        def sda_manager_group_members():
            logging.info("[" + request.method +
                         "] sda manager group members - IN")

            join_dict = dict()
            leave_dict = dict()

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id(),
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            join_list = request.json["agents"]
            leave_list = response.json()["members"]

            for i in join_list:
                if i in leave_list:
                    join_list.remove(i)
                    leave_list.remove(i)

            join_dict.update({"agents": join_list})
            leave_dict.update({"agents": leave_list})

            response2 = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id() + "/join",
                data=json.dumps(join_dict),
                timeout=1500)

            response3 = requests.post(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id() + "/leave",
                data=json.dumps(leave_dict),
                timeout=1500)

            if response2.status_code is not 200 and response3.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            return "", 200
        def sda_manager_group():
            logging.info("[" + request.method + "] sda manager group - IN")

            l = list()
            ret = dict()

            data = json.loads(request.data)
            SDAManager.set_group_id(data["id"])
            SDAManager.set_current_group_name(data["groupname"])

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/groups/" +
                SDAManager.get_group_id(),
                timeout=1500)

            response2 = requests.get(
                url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                str(Port.sda_manager_port()) + "/api/v1/agents",
                timeout=1500)

            if response.status_code is not 200 or response2.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            for obj in response2.json()["agents"]:
                for member in response.json()["members"]:
                    d = dict()
                    if obj["id"] == member:
                        if "id" in obj:
                            d.update({"id": str(obj["id"])})
                        if "host" in obj:
                            d.update({"host": str(obj["host"])})
                        if "port" in obj:
                            d.update({"port": str(obj["port"])})
                        l.append(d)

            ret.update({"devices": l})

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_app_yaml():
            logging.info("[" + request.method + "] sda manager app YAML - IN")

            if request.method == "GET":
                d = dict()
                response = requests.get(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/agents/" +
                    SDAManager.get_device_id() + "/apps/" +
                    SDAManager.get_app_id(),
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                if "description" in response.json():
                    d = response.json()["description"]

                return json.dumps(json.dumps(d)), 200
            elif request.method == "POST":
                data = json.loads(request.data)

                response = requests.post(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/agents/" +
                    SDAManager.get_device_id() + "/apps/" +
                    SDAManager.get_app_id(),
                    data=data["data"],
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                return "", 200
Beispiel #25
0
        def sda_manager_group_app():
            if request.method == "POST":
                logging.info("[" + request.method +
                             "] sda manager group app - IN")

                l = list()
                l2 = list()
                ret = dict()

                SDAManager.set_app_id(json.loads(request.data)["id"])

                response = requests.get(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/nodes",
                    timeout=1500)

                response2 = requests.get(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/groups/" + SDAManager.get_group_id() +
                    "/apps",
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                for obj in response.json()["nodes"]:
                    d = dict()
                    if "id" in obj:
                        d.update({"id": str(obj["id"])})

                        res = requests.get(
                            url="http://" +
                            SDAManager().get_sda_manager_endpoint() +
                            "/api/v1/management/nodes/" + str(obj["id"]) +
                            "/configuration",
                            timeout=1500)
                        if res.status_code is 200:
                            for prop in res.json()["properties"]:
                                if "devicename" in prop:
                                    d.update({"name": str(prop["devicename"])})
                    if "ip" in obj:
                        d.update({"ip": str(obj["ip"])})
                    if "status" in obj:
                        d.update({"status": str(obj["status"])})
                    l.append(d)

                for obj2 in response2.json()["apps"]:
                    if obj2["id"] == SDAManager.get_app_id():
                        for device in l:
                            for member in obj2["members"]:
                                if device["id"] == member:
                                    l2.append(device)
                                    break

                    ret.update({"devices": l2})

                return json.dumps(json.dumps(ret)), 200
            elif request.method == "DELETE":
                response = requests.delete(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/groups/" + SDAManager.get_group_id() +
                    "/apps/" + SDAManager.get_app_id(),
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                return "", 200
        def sda_manager_apps():
            logging.info("[" + request.method + "] sda manager apps - IN")

            l = list()
            apps = list()
            ret = dict()

            response = requests.get(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/nodes/" + SDAManager.get_device_id(),
                timeout=1500)

            if response.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            root_path = os.getcwd()

            if not os.path.exists(root_path + "/static/user/apps"):
                with open(root_path + "/static/user/apps", 'w'):
                    pass

            with open(root_path + "/static/user/apps", 'r') as content_file:
                content = content_file.read()
                if content != "":
                    apps = json.loads(content)["apps"]

            for obj in response.json()["apps"]:
                d = dict()
                d.update({"id": str(obj)})
                response2 = requests.get(
                    url="http://" + SDAManager().get_sda_manager_endpoint() +
                    "/api/v1/management/nodes/" + SDAManager.get_device_id() +
                    "/apps/" + str(obj),
                    timeout=1500)

                if response2.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                d.update({"services": len(response2.json()["services"])})
                d.update({"state": response2.json()["state"]})

                for app in apps:
                    if "id" in app and app["id"] == str(obj):
                        d.update({"name": app["name"]})

                l.append(d)
            response3 = requests.get(
                url="http://" + SDAManager().get_sda_manager_endpoint() +
                "/api/v1/management/nodes/" + SDAManager.get_device_id() +
                "/configuration",
                timeout=1500)
            if response3.status_code is not 200:
                logging.error("SDAM Server Return Error, Error Code(" +
                              str(response.status_code) + ") - OUT")
                abort(500)

            if "properties" in response3.json():
                for prop in response3.json()["properties"]:
                    if "devicename" in prop:
                        device_name = str(prop["devicename"])
                        ret.update({
                            "device":
                            device_name + "(" + SDAManager.get_device_ip() +
                            ")",
                            "apps":
                            l
                        })

            return json.dumps(json.dumps(ret)), 200
        def sda_manager_group_app():
            if request.method == "POST":
                logging.info("[" + request.method +
                             "] sda manager group app - IN")

                l = list()
                l2 = list()
                ret = dict()

                SDAManager.set_app_id(json.loads(request.data)["id"])

                response = requests.get(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/agents",
                    timeout=1500)

                response2 = requests.get(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/groups/" +
                    SDAManager.get_group_id() + "/apps",
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                for obj in response.json()["agents"]:
                    d = dict()
                    if "id" in obj:
                        d.update({"id": str(obj["id"])})
                    if "host" in obj:
                        d.update({"host": str(obj["host"])})
                    if "port" in obj:
                        d.update({"port": str(obj["port"])})
                    l.append(d)

                for obj2 in response2.json()["apps"]:
                    if obj2["id"] == SDAManager.get_app_id():
                        for device in l:
                            for member in obj2["members"]:
                                if device["id"] == member:
                                    l2.append(device)
                                    break

                    ret.update({"devices": l2})

                return json.dumps(json.dumps(ret)), 200
            elif request.method == "DELETE":
                response = requests.delete(
                    url="http://" + SDAManager().get_sda_manager_ip() + ":" +
                    str(Port.sda_manager_port()) + "/api/v1/groups/" +
                    SDAManager.get_group_id() + "/apps/" +
                    SDAManager.get_app_id(),
                    timeout=1500)

                if response.status_code is not 200:
                    logging.error("SDAM Server Return Error, Error Code(" +
                                  str(response.status_code) + ") - OUT")
                    abort(500)

                return "", 200