fd.uninstall_app("dep1", alert["ipAddress"])
                code, _ = fd.install_app("dep1", ["10.10.20.53"]) 
                while code == 400:
                    code, _ = fd.install_app("dep1", ["10.10.20.53"]) 
                fd.start_app("dep1")
                moved1 = True

                if not installedOn1:
                    print("INSTALLING 1")
                    installedOn1 = True
                    fd.stop_app("dep2")
                    code, _ = fd.install_app("dep2", ["10.10.20.51"])
                    count = 0
                    while code == 400:
                        print("FAILED to migrate to","10.10.20.51", count)
                        count+=1
                        if count == 20:
                            print(fd.get_devices(searchByAnyMatch="10.10.20.51"))
                            exit()
                        print("INSTALLING 1")
                        code, response = fd.install_app("dep2", ["10.10.20.51"])  
                    installedOn1 = True
                    code, _ = fd.start_app("dep2")
            #elif alert["appName"] == "dep2":
            #    if migrated2 == True:
            #        continue
            #    migrated2 = True
            #    print("dep2", alert["ipAddress"],"->",otherDevice(alert["ipAddress"]))
            #    code, _ = fd.uninstall_app("dep2", alert["ipAddress"])

                
예제 #2
0
                        myapp_problems[myappId][devId] += 1
                        if myapp_problems[myappId][devId] == 5:
                            dep = alert["appName"]
                            if dep in migrated:
                                continue
                            else:
                                migrated.append(dep)
                            _, app_det = fd.get_myapp_details(dep)
                            myappId = app_det["myappId"]
                            fd.fast_stop_app(myappId)
                            fd.fast_uninstall_app(myappId, alert["deviceId"])
                            deviceIp, deviceId = bestFit(100, 32) # BUONA FORTUNA...
                            code, _ = fd.fast_install_app(myappId, [deviceId])
                            while code == 400:
                                if check_termination():
                                    break
                                deviceIp, deviceId = bestFit(100, 32)
                                code, _ = fd.fast_install_app(myappId, [deviceId]) 
                            fd.fast_start_app(myappId)
                    elif "MYAPP_MEM_CONSUMING" == alert["type"]:
                        pass # guarda sopra e buona fortuna

                _, devices = fd.get_devices()
                for dev in devices["data"]:
                    devId = dev["deviceId"]
                    if devId in offline_devices:
                        for myappId in dev_unreachable_appId[devId]:
                            fd.fast_uninstall_app(myappId, devId)
                        dev_unreachable_appId[devId] = []
            reset_simulation()
예제 #3
0
                fd.stop_app("dep1")
                fd.uninstall_app("dep1", alert["ipAddress"])
                code, _ = fd.install_app("dep1", ["10.10.20.53"])
                while code == 400:
                    code, _ = fd.install_app("dep1", ["10.10.20.53"])
                fd.start_app("dep1")
                moved1 = True
            elif alert["appName"] == "dep2":
                if migrated2 == True:
                    continue
                migrated2 = True
                print("dep2", alert["ipAddress"], "->",
                      otherDevice(alert["ipAddress"]))
                fd.stop_app("dep2")
                code, _ = fd.uninstall_app("dep2", alert["ipAddress"])
                code, _ = fd.install_app("dep2",
                                         [otherDevice(alert["ipAddress"])])
                count = 0
                while code == 400:
                    print("FAILED to migrate to",
                          otherDevice(alert["ipAddress"]), count)
                    count += 1
                    if count == 20:
                        print(
                            fd.get_devices(searchByAnyMatch=otherDevice(
                                alert["ipAddress"])))
                        exit()
                    code, response = fd.install_app(
                        "dep2", [otherDevice(alert["ipAddress"])])

                code, _ = fd.start_app("dep2")