#!/usr/bin/python3 import subprocess import os import sys import math from core_allocator import core_allocation # CONFIGS TO SET: MANIFEST_FILE = "App/manifest.yaml" ''' Generate a manifest file with: N: number of clients M: number of servers T: number of threads for each server B: msg_size ''' def generate_manifest(N, M, T, B, TOKEN_CHANNEL = True, token_out=1, token_in=1, id_out=1, id_in=1): (servers_allocation, client_allocation) = core_allocation(M, T) assert servers_allocation is not None assert client_allocation is not None mf = open(MANIFEST_FILE, 'w+') manifest_params = '''params: # The total max number of users user_count: {N} # The size of a message in bytes msg_size: {B} # The number of token channel messages each user can send per epoch token_out: {toko} # The number of token channel messages each user can receive per epoch token_in: {toki} # The number of ID channel messages each user can send per epoch id_out: {ido} # The number of ID channel messages each user can receive per epoch id_in: {idi} # Token channel or ID channel routing protocol selection token_channel: {TOKEN_CHANNEL} # Currently hardcoding an AES key for client -> server communications, # but in reality, a key exchange would be done master_secret: \"AHardCodedAESKey\"\n'''.format(N = str(N), B = str(B), TOKEN_CHANNEL=str(TOKEN_CHANNEL),\ toko = str(token_out), toki = str(token_in), ido = str(id_out), idi = str(id_in)) # print (manifest_params) mf.write(manifest_params) server_params = '''\ns{i}: sprvfile: keys/priv.seal.s{i} pubfile: keys/pub.s{i} weight: 1 listen: 127.0.0.{i}:12500 clisten: 127.0.0.{i}:13000 slisten: 127.0.0.{i}:13001 launchprefix: numactl {nstring} args: -t {T} roles: 7\n''' for s in range(1, M+1): core_alloc = servers_allocation[s-1] numa_string = "-C " + ",".join(map(str, core_alloc)) curr_params = server_params.format(i = str(s), nstring = numa_string, T = str(T)) # print(curr_params) mf.write(curr_params) mf.close() if __name__ == "__main__": if(len(sys.argv)!=5): print("Incorrect usage!\n Expects 4 parameters. n,m,t,b") exit() n = int(sys.argv[1]) m = int(sys.argv[2]) t = int(sys.argv[3]) b = int(sys.argv[4]) generate_manifest(n, m, t, b)