dep = "dep" + str(myapp_index) _, myapp1 = fd.create_myapp(localapp["localAppId"], dep) deviceIp = bestFit(100, 32) code, res = fd.install_app(dep, [deviceIp]) trial = 0 while code == 400: trial += 1 if trial == 50: print(DEPLOYMENT_NUMBER, "are too high value to deploy. (50 fails reached)") exit() fallimento += 1 deviceIp = bestFit(100, 32) code, res = fd.install_app(dep, [deviceIp]) fd.start_app(dep) r = requests.get('http://localhost:5000/result/simulationcounter') iteration_end = int(r.text) fallimenti.append(fallimento) iteration_count.append(iteration_end) print(simulation_count, ") Iter_count:", iteration_end, "(mean:", sum(iteration_count) / len(iteration_count), ") - fails", fallimento, "(mean ", sum(fallimenti) / float(len(fallimenti)), ")") print("STARTING RANDOM PHASE") ########################################################################################### # RANDOMFIT # ########################################################################################### fallimenti = []
100, "memory": 32, "network": [{ "interface-name": "eth0", "network-name": "iox-bridge0" }] } }) print("DEPLOYED", dep, "ON", deviceIp) # second installation r = random.random() deviceIp = "10.10.20." + str(math.floor(r * DEVICES_NUMBER) + 1) fg.start_app(dep) for myapp_index in range(0, int(DEPLOYMENT_NUMBER / 2)): # Creating myapp1 endpoint dep = "dep" + str(myapp_index) _, myapp1 = fg.create_myapp(localapp["localAppId"], dep) code, res = fg.install_app(dep, [deviceIp], resources={ "resources": { "profile": "c1.tiny", "cpu": 100, "memory": 32,
code, localapp = fd.add_app("./NettestApp2V1_lxc.tar.gz", publish_on_upload=True) _, myapp1 = fd.create_myapp(localapp["localAppId"], "dep1") _, myapp2 = fd.create_myapp(localapp["localAppId"], "dep2", minjobs=1) # Deploying on devices with default resources, # that are c1.small profile, defined by custom library code, res = fd.install_app("dep1", ["10.10.20.51"]) while code == 400: code, res = fd.install_app("dep1", ["10.10.20.51"]) code, res = fd.install_app("dep2", ["10.10.20.52"]) while code == 400: code, res = fd.install_app("dep2", ["10.10.20.52"]) fd.start_app("dep1") fd.start_app("dep2") def otherDevice(current): return "10.10.20.51" if current == "10.10.20.52" else "10.10.20.52" moved1 = False installedOn1 = False inStarting = 2 while True: _, alerts = fd.get_alerts() migrated2 = False for alert in alerts["data"]: if "APP_HEALTH" == alert["type"]: # Device issues if alert["appName"] == "dep1" and not moved1: print("migrating dep1")