flavour="tiny", number=1)\ .add_machine(roles=["compute"], flavour="tiny", number=1)\ .add_network(roles=["mynetwork"], cidr="192.168.42.0/24")\ .finalize() # claim the resources provider = Enos_vagrant(conf) roles, networks = provider.init() # generate an inventory compatible with ansible discover_networks(roles, networks) tc = { "enable": True, "default_delay": "20ms", "default_rate": "1gbit", } netem = Netem(tc, roles=roles) netem.deploy() netem.validate() netem.backup() netem.destroy() # destroy the boxes provider.destroy()
} } tc = {"enable": True, "default_delay": "20ms", "default_rate": "1gbit"} inventory = os.path.join(os.getcwd(), "hosts") print("Starting ressources with the provider vagrant") provider = Enos_vagrant(VagrantConf.from_dictionnary(provider_conf)) roles, networks = provider.init() print("Building the machine list") resources = {"machines": [], "networks": []} for role, machines in roles.items(): for machine in machines: resources["machines"].append({ "address": machine.address, "alias": machine.alias, "user": machine.user, "port": int(machine.port), "keyfile": machine.keyfile, "roles": [role], }) resources["networks"] = networks provider = Static(StaticConf.from_dictionnary({"resources": resources})) roles, networks = provider.init() discover_networks(roles, networks) netem = Netem(tc, roles=roles) netem.deploy() netem.validate()
}] } } tc = { "enable": True, "default_delay": "20ms", "default_rate": "1gbit", } # claim the resources conf = Configuration.from_dictionnary(provider_conf) provider = Enos_vagrant(conf) roles, networks = provider.init() discover_networks(roles, networks) netem = Netem(tc, roles=roles) # apply network constraints netem.deploy() # validate network constraints netem.validate() # reset network constraints netem.destroy() # validate network constraints and saving in an alternative netem.validate(output_dir="after_reset")
"key_name": "enos_matt", "user": "******", "image": "CC-Ubuntu16.04", "prefix": "plop", "resources": { "machines": [ { "roles": ["control"], "flavour": "m1.medium", "number": 1 }, { "roles": ["compute"], "flavour": "m1.medium", "number": 5 }, ], "networks": ["network_interface"], }, } tc = {"enable": True, "default_delay": "20ms", "default_rate": "1gbit"} inventory = os.path.join(os.getcwd(), "hosts") conf = Configuration.from_dictionnary(provider_conf) provider = Openstack(conf) roles, networks = provider.init() discover_networks(roles, networks) netem = Netem(roles, networks) netem.deploy() netem.validate()
def validate(env=None, **kwargs): """Validates the network constraints.""" roles = env["roles"] netem = Netem(tc, roles=roles) netem.validate()
def emulate(env=None, **kwargs): """Emulates the network.""" roles = env["roles"] netem = Netem(tc, roles=roles) netem.deploy()
# Starting the machnes provider = VMonG5k(conf) roles, networks = provider.init() # Building the network constraints emulation_conf = { "enable": True, "default_delay": "0.3ms", "default_rate": "1gbit", "groups": cities } # Building the specific constraints constraints = [] for city, others in CITIES.items(): for other, delay in others.items(): constraints.append({ "src": city, "dst": other, "delay": "%sms" % delay, "symetric": True }) emulation_conf["constraints"] = constraints logging.info(emulation_conf) discover_networks(roles, networks) netem = Netem(emulation_conf, roles=roles) netem.deploy() netem.validate()
def validate(env=None, **kwargs): roles = env["roles"] netem = Netem(tc, roles=roles) netem.validate()
def emulate(env=None, **kwargs): roles = env["roles"] netem = Netem(tc, roles=roles) netem.deploy()