Ejemplo n.º 1
0
    file  = open("simulation_results_paper.txt", "a")
    file.write("# STARTING NEW SIMULATION EPOCH: "+str(COUNTER_SIM)+"\n")
    for DEVICE_NUMBER in range(100, 151, 10):
        for APP_EXTRA in range(150, 151, 10): # APP_EXTRA = 150
            print("DevNumber", DEVICE_NUMBER, "APP_EXTRA", APP_EXTRA)
            add_devices()
            dev_list = fog_torch()
            # Uploading Application
            code, localapp = fd.add_app("./NettestApp2V1_lxc.tar.gz", publish_on_upload=True)

            for myapp_index in range(0, DEPLOYMENT_NUMBER):
                
                dev_list = dev_list_sort(dev_list)
                    
                dep = "dep"+str(myapp_index)
                _, myappId = fd.create_myapp(localapp["localAppId"], dep, minjobs=1)
                
                deviceId = dev_list[0][0]
                profile = "normal"
                r = random.random()
                if r < 0.2:
                    profile = "angry"
                code, res = fd.fast_install_app(myappId, [deviceId], profile=profile)

                device_notReachable = 0
                current_device = 0
                if code != 400:
                    dev_list[0][1] -= 100
                    dev_list[0][2] -= 32
                while code == 400:
                    if "Error" in res and res["Error"] == "Device does not reachable":
    dev_list = fog_torch()
    dev_list = dev_list_sort(dev_list)
    # Uploading Application
    code, localapp = fd.add_app("./NettestApp2V1_lxc.tar.gz",
                                publish_on_upload=True)
    print("STARTING TO DEPLOY", simulation_counter())
    for myapp_index in range(0, DEPLOYMENT_NUMBER):
        if DEPLOYMENT_NUMBER % 200 == 0:
            dev_list = fog_torch()
            dev_list = dev_list_sort(dev_list)
        else:
            dev_list = dev_list_sort(dev_list)

        dep = "dep" + str(myapp_index)
        _, myappId = fd.create_myapp(localapp["localAppId"], dep)

        deviceId = dev_list[0][0]
        code, res = fd.fast_install_app(myappId, [deviceId])
        if code != 400:
            dev_list[0][1] -= 100
            dev_list[0][2] -= 32
        while code == 400:
            fallimento += 1
            deviceId = dev_list[0][0]
            code, res = fd.fast_install_app(myappId, [deviceId])
            if code != 400:
                dev_list[0][1] -= 100
                dev_list[0][2] -= 32
        fd.fast_start_app(myappId)
    print("ENDING TO DEPLOY", simulation_counter())
    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
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")
Ejemplo n.º 4
0
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)

    code, res = fg.install_app(dep, [deviceIp],
                               resources={
                                   "resources": {
                                       "profile":
                                       "c1.tiny",
                                       "cpu":
                                       100,
                                       "memory":
                                       32,
                                       "network": [{
Ejemplo n.º 5
0
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")

# 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")