previous_simulation.append({current_identifier: output})
    file = open("simulation_results_fogtorch_best.txt", "a")
    file.write(str(current_identifier) + "\n")
    out = simplejson.dumps(output, indent=4, sort_keys=True)
    file.write(out)
    file.write("\n\n")
    file.close()
    return output


# Resetting simulator before start
url = "http://%s/simulationreset" % ("127.0.0.1:" + port)
r = requests.get(url)
print("STARTING SIMULATION")

fd = FogDirector("127.0.0.1:" + port)
code = fd.authenticate("admin", "admin_123")
if code == 401:
    print("Failed Authentication")

DEVICES_NUMBER = 20
DEPLOYMENT_NUMBER = 150

fallimenti = []
iteration_count = []

print("STARTING + BEST PHASE")
###########################################################################################
#                                   FTpi+best                                             #
###########################################################################################
for simulation_count in range(0, 3):
Example #2
0
from APIWrapper import FogDirector 
from infrastructure import ciscorouters_310pz_5b5m300s_withFails as infrastructure
from collections import defaultdict
import array, requests, simplejson, random, os
infrastructure.create()

MAX_SIMULATION_ITER = 15000

port = "5000"
fd = FogDirector("127.0.0.1:"+port)
code = fd.authenticate("admin", "admin_123")

def bestFit(cpu, mem):
    _, devices = fd.get_devices()
    devices = [ dev for dev in devices["data"] if dev["capabilities"]["nodes"][0]["cpu"]["available"] >= cpu 
                            and dev["capabilities"]["nodes"][0]["memory"]["available"] >= mem]
    devices.sort(reverse=True, key=(lambda dev: (dev["capabilities"]["nodes"][0]["cpu"]["available"], 
                                                dev["capabilities"]["nodes"][0]["memory"]["available"]) ))
    while len(devices) == 0:
        if simulation_counter() > 15000:
            print("Not able to find a bestfit. Simulation ends")
            exit()
        _, devices = fd.get_devices()
        devices = [ dev for dev in devices["data"] if dev["capabilities"]["nodes"][0]["cpu"]["available"] >= cpu 
                                    and dev["capabilities"]["nodes"][0]["memory"]["available"] >= mem]
        devices.sort(reverse=True, key=(lambda dev: (dev["capabilities"]["nodes"][0]["cpu"]["available"], 
                                                        dev["capabilities"]["nodes"][0]["memory"]["available"]) ))
    best_fit = devices[0]
    return best_fit["ipAddress"], best_fit["deviceId"]

def simulation_counter():
Example #3
0
from APIWrapper import FogDirector
import time, random, math
from infrastructure import ciscorouter_size300 as infrastructure

infrastructure.create()

fg = FogDirector("127.0.0.1:5000")
code = fg.authenticate("admin", "admin_123")
if code == 401:
    print("Failed Authentication")

DEVICES_NUMBER = 5
DEPLOYMENT_NUMBER = 30
# Adding devices
for i in range(0, DEVICES_NUMBER):
    deviceId = i + 1
    _, device1 = fg.add_device("10.10.20." + str(deviceId), "cisco", "cisco")

# Uploading Application
code, localapp = fg.add_app("./NettestApp2V1_lxc.tar.gz",
                            publish_on_upload=True)

for myapp_index in range(0, DEPLOYMENT_NUMBER):
    # Creating myapp1 endpoint
    dep = "dep" + str(myapp_index)
    _, myapp1 = fg.create_myapp(localapp["localAppId"], dep)

    # first installation
    r = random.random()
    deviceIp = "10.10.20." + str(math.floor(r * DEVICES_NUMBER) + 1)
Example #4
0
    previous_simulation.append({current_identifier: output})
    file = open("simulation_results_firstFit.txt", "a")
    file.write(str(current_identifier) + "\n")
    out = simplejson.dumps(output, indent=4, sort_keys=True)
    file.write(out)
    file.write("\n\n")
    file.close()
    return output


# Resetting simulator before start
url = "http://%s/simulationreset" % "127.0.0.1:5000"
r = requests.get(url)
print("STARTING SIMULATION")

fd = FogDirector("127.0.0.1:5000")
code = fd.authenticate("admin", "admin_123")
if code == 401:
    print("Failed Authentication")

DEVICES_NUMBER = 10
DEPLOYMENT_NUMBER = 110

fallimenti = []
iteration_count = []

print("STARTING BESTFIT PHASE")
###########################################################################################
#                                   BESTFIT                                               #
###########################################################################################
for simulation_count in range(0, 10):
Example #5
0
from APIWrapper import FogDirector
import time, random, math
from infrastructure import ciscorouters_310pz_5b5m300s as infrastructure
import requests
import simplejson, signal, os

infrastructure.create()

port = os.environ.get('SERVER_PORT', "5000")
fd = FogDirector("127.0.0.1:"+port)
code = fd.authenticate("admin", "admin_123")

def simulation_counter():
    r = requests.get('http://localhost:'+port+'/result/simulationcounter')
    return int(r.text)

def bestFit(cpu, mem):
    _, devices = fd.get_devices()
    devices = [ dev for dev in devices["data"] if dev["capabilities"]["nodes"][0]["cpu"]["available"] >= cpu 
                            and dev["capabilities"]["nodes"][0]["memory"]["available"] >= mem]
    devices.sort(reverse=True, key=(lambda dev: (dev["capabilities"]["nodes"][0]["cpu"]["available"], 
                                                dev["capabilities"]["nodes"][0]["memory"]["available"]) ))
    trial = 0
    while len(devices) == 0:
        trial += 1
        if trial == 100:
            return None, None
        _, devices = fd.get_devices()
        devices = [ dev for dev in devices["data"] if dev["capabilities"]["nodes"][0]["cpu"]["available"] >= cpu 
                                    and dev["capabilities"]["nodes"][0]["memory"]["available"] >= mem]
        devices.sort(reverse=True, key=(lambda dev: (dev["capabilities"]["nodes"][0]["cpu"]["available"], 
from APIWrapper import FogDirector
import time, random, math
from infrastructure import ciscorouters_310pz_5b5m300s_withFails as infrastructure
import requests
import simplejson, signal, os
from collections import defaultdict
import array

infrastructure.create()

port = os.environ.get('SERVER_PORT', "5000")
fd = FogDirector("127.0.0.1:" + port)
code = fd.authenticate("admin", "admin_123")


def simulation_counter():
    r = requests.get('http://localhost:' + port + '/result/simulationcounter')
    return int(r.text)


def bestFit(cpu, mem):
    _, devices = fd.get_devices()
    devices = [
        dev for dev in devices["data"]
        if dev["capabilities"]["nodes"][0]["cpu"]["available"] >= cpu
        and dev["capabilities"]["nodes"][0]["memory"]["available"] >= mem
    ]
    devices.sort(
        reverse=True,
        key=(lambda dev:
             (dev["capabilities"]["nodes"][0]["cpu"]["available"], dev[
from APIWrapper import FogDirector
import time, requests
from infrastructure import fogdirmime_infra as infrastructure

infrastructure.create()

FOG_DIRECTOR_HOST = "127.0.0.1:5000"

def reset_simulation():
    url = "http://%s/simulationreset" % "127.0.0.1:5000"
    r = requests.get(url)
    return r.json()
reset_simulation()

fd = FogDirector(FOG_DIRECTOR_HOST)
code = fd.authenticate("admin", "admin_123")
if code == 401:
    print("Failed Authentication")

# Adding devices
_, device1 = fd.add_device("10.10.20.51", "cisco", "cisco")
_, device2 = fd.add_device("10.10.20.52", "cisco", "cisco")
_, device3 = fd.add_device("10.10.20.53", "cisco", "cisco")

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