def dev_se_data(fd):
    curpath = str(os.path.dirname(os.path.realpath(__file__)))
    filenam = curpath + "/dynamic.txt"
    with open(filenam) as f1:
        dy1 = f1.readlines()
        dy1 = [x.rstrip() for x in dy1]
        # print(dy1)
        dy = dy1[0]
        tr = dy
        tr = eval(tr)
        #print(tr)
        cm.ApplicationManager_to_Scheduler_Producer_interface(tr)
Example #2
0
def threaded(c):
    # print("rg")
    global reqid
    id = str(c.recv(4).decode('utf-8'))
    id = int(id)
    # print(id)
    c.send(b'hello')
    if (id == 1):

        user_name = str(c.recv(40).decode('utf-8'))
        c.send(b'hello')
        pass_word = str(c.recv(40).decode('utf-8'))

        userid[user_name] = pass_word
        c.send(bytes(str(1), 'utf8'))
        c.recv(4)
        c.send(bytes(str("Welcome"), 'utf8'))
        c.recv(4)
        c.send(bytes(str("http://127.0.0.1:4555/"), 'utf8'))
        fil = str(c.recv(40).decode('utf-8'))
        if (fil == "filled"):
            conf = {}
            zi = "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/" + user_name + ".zip"
            print(zi)
            with ZipFile(zi, 'r') as zipObj:
                zipObj.extractall(
                    "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/"
                )
            filename = "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/" + user_name + "/" + user_name + "_config.txt"
            con = []
            with open(filename) as f1:
                con = f1.readlines()
                con = [x.rstrip() for x in con]

            # print(con)
            for i in range(7):
                s = con[i]
                y = []
                y = s.split(":")
                print(y)
                conf[y[0]] = int(y[1])
            for i in range(7, len(con)):
                s = con[i]
                y = []
                y = s.split(":")
                conf[y[0]] = y[1]
            conf["reqid"] = reqid
            y_n = conf["old/runningservice"]
            reqid = reqid + 1
            y1 = json.dumps(conf)  #Python to JSON
            jsonData = json.loads(y1)  #JSON to Python
            isValid = validateJson(jsonData)
            if isValid:
                print("Given JSON data is Valid")
                confjson = json.dumps(jsonData)
                print(confjson)
                producer = KafkaProducer(bootstrap_servers='localhost:9092')
                if (y_n == "yes"):
                    cm.ApplicationManager_to_ServiceLifeCycle_Producer_interface(
                        confjson)
                else:
                    cm.ApplicationManager_to_Scheduler_Producer_interface(
                        confjson)
            else:
                print(jsonData)
                print("Given JSON data is InValid")
    if (id == 2):
        # print("EXISTING")

        user_name = str(c.recv(40).decode('utf-8'))
        c.send(b'hello')
        pass_word = str(c.recv(40).decode('utf-8'))
        # print(user_name)
        # print(pass_word)
        if user_name in userid and pass_word == userid[user_name]:
            c.send(bytes(str(1), 'utf8'))
            c.recv(4)
            c.send(bytes(str("Welcome"), 'utf8'))
            c.recv(4)
            c.send(bytes(str("http://127.0.0.1:4555/"), 'utf8'))
            fil = str(c.recv(40).decode('utf-8'))
            if (fil == "filled"):
                conf = {}
                zi = "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/" + user_name + ".zip"
                print(zi)
                with ZipFile(zi, 'r') as zipObj:
                    zipObj.extractall(
                        "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/"
                    )
                filename = "/home/dell/Pictures/course_work/ias/group3_team1/AM/config/" + user_name + "/" + user_name + "_config.txt"
                con = []
                with open(filename) as f1:
                    con = f1.readlines()
                    con = [x.rstrip() for x in con]

            # print(con)
                for i in range(7):
                    s = con[i]
                    y = []
                    y = s.split(":")
                    conf[y[0]] = int(y[1])
                for i in range(7, len(con)):
                    s = con[i]
                    y = []
                    y = s.split(":")
                    conf[y[0]] = y[1]
                conf["reqid"] = reqid
                y_n = conf["old/runningservice"]
                reqid = reqid + 1
                y1 = json.dumps(conf)  #Python to JSON
                jsonData = json.loads(y1)  #JSON to Python
                isValid = validateJson(jsonData)
                if isValid:
                    print("Given JSON data is Valid")
                    confjson = json.dumps(jsonData)
                    print(confjson)
                    producer = KafkaProducer(
                        bootstrap_servers='localhost:9092')
                    if (y_n == "yes"):
                        cm.ApplicationManager_to_ServiceLifeCycle_Producer_interface(
                            confjson)
                    else:
                        cm.ApplicationManager_to_Scheduler_Producer_interface(
                            confjson)
                else:
                    print(jsonData)
                    print("Given JSON data is InValid")

        else:
            c.send(bytes(str(11), 'utf8'))
            c.recv(4)
            c.send(bytes(str("Welcome"), 'utf8'))
            c.recv(4)
            c.send(bytes(str("Invalid Credentials"), 'utf8'))

    c.close()
Example #3
0
import sys
import json
# import datetime

# import time
# import collections
topic_own = "pandey"

sys.path.insert(
    0,
    "/home/dell/Pictures/course_work/ias/group3_team1/cm/communication_module")

import communication_module as cm

f = open('meta.json', )
data = json.load(f)

meta_data = {}
for i in data['scheduler']:
    meta_data.update(i)
data = meta_data
print(data)
# producer.send(topic,value=data)
# sleep(1)

cm.ApplicationManager_to_Scheduler_Producer_interface(data)