Example #1
0
 def __init__(self, token, hostname, ip, mode):
     threading.Thread.__init__(self)
     self.o = SysRp()
     self.token = token
     self.hostname = hostname
     self.ip = ip
     self.mode = mode
Example #2
0
class ThreadOverHead(threading.Thread):
    def __init__(self, token):
        threading.Thread.__init__(self)
        self.o = SysRp()
        self.token = token

    def run(self):
        self.o.mountImgCompress(self.token)
        event.set()
Example #3
0
class ThreadRescuteMode(threading.Thread):
    def __init__(self, token, hostname, ip, mode):
        threading.Thread.__init__(self)
        self.o = SysRp()
        self.token = token
        self.hostname = hostname
        self.ip = ip
        self.mode = mode

    def run(self):
        self.o.changePartition(self.ip, self.mode)
        print(self.o.reboot(self.token, self.hostname))
Example #4
0
class Run(object):
    def __init__(self, token):
        self.rP = RpCloud()
        self.arp = Arp()
        self.sys = SysRp()
        # Inicia la app
        self.start(token)

    def start(self, token):
        checked = self.rP.checkLogin(token)
        if (checked):
            # Consultamos el JSON actual (peticion ARP)
            generatedJson = self.sys.generateJson(token)

            # Ejecuta un hilo para montar y comprimir la imagen en el servidor
            threadOverHead1 = ThreadOverHead(
                token, "/mnt/img/uploads/minimalRaspyCloud.img")
            threadOverHead1.start()

            for pi in generatedJson.get("raspberryPi"):
                # Crea un hilo por cada raspberryPi
                hThread1 = Thread(token, pi.get("hostname"), pi.get("ip"))
                hThread1.start()

            return "Done"
        else:
            return "Invalid Token"
Example #5
0
def application(request):
    # get the request path
    #    print(request.path)
    # get the request host
    #    print(request.host)
    # get the request method
    print(request.args.get('PATH_INFO'))

    arpObject = Arp()
    rpCloudObject = RpCloud()
    sysRpObject = SysRp()
    # Dispatcher is dictionary {<method_name>: callable}
    dispatcher['scanARP'] = arpObject.update
    dispatcher['getArpTable'] = arpObject.getTable
    dispatcher['login'] = rpCloudObject.login
    dispatcher['checkPassword'] = rpCloudObject.checkPassword
    dispatcher['checkLogin'] = rpCloudObject.checkLogin
    dispatcher['logout'] = rpCloudObject.logout
    dispatcher['getHostname'] = sysRpObject.getHostname
    dispatcher['reboot'] = sysRpObject.reboot
    dispatcher['setHostname'] = sysRpObject.setHostname
    dispatcher['generateJson'] = sysRpObject.generateJson
    dispatcher['storageJson'] = sysRpObject.storageJson

    response = JSONRPCResponseManager.handle(request.data, dispatcher)
    return Response(response.json, mimetype='application/json')
Example #6
0
class Rescute(object):
    def __init__(self, token, mode):
        self.rP = RpCloud()
        self.arp = Arp()
        self.sys = SysRp()
        # Inicia la app
        self.start(token, mode)

    def start(self, token, mode):

        # Consultamos el JSON actual (peticion ARP)
        generatedJson = self.sys.generateJson(token)

        for pi in generatedJson.get("raspberryPi"):
            # Crea un hilo por cada raspberryPi
            hThreadRescute = ThreadRescuteMode(token, pi.get("hostname"), pi.get("ip"), mode)
            hThreadRescute.start()
        return "Done"
Example #7
0
 def __init__(self, token):
     threading.Thread.__init__(self)
     self.o = SysRp()
     self.token = token
Example #8
0
class Thread(threading.Thread):
    def __init__(self, token, hostname, ip):
        threading.Thread.__init__(self)
        self.o = SysRp()
        self.token = token
        self.hostname = hostname
        self.ip = ip

    def run(self):
        self.o.createPartition(self.ip)
        self.o.reboot(self.token, self.hostname)
        self.o.formatFileSystemAndMount(self.ip)
        event.wait()
        self.o.sendAndDecompress(self.ip)
        self.o.changePartition(self.ip, False)
        print(self.o.reboot(self.token, self.hostname))
Example #9
0
 def __init__(self, token):
     self.rP = RpCloud()
     self.arp = Arp()
     self.sys = SysRp()
     # Inicia la app
     self.start(token)
Example #10
0
def apiGenerateJson(token):
    return SysRp().generateJson(token)