def validate(env=None, **kwargs): """ usage: juice validate Validate network. Doesn't work for now since there is no flent installed """ inventory = env["inventory"] roles = env["roles"] validate_network(roles, inventory)
def tc(env=None, network_constraints=None, extra_vars=None, **kwargs): """ Usage: enos tc [-e ENV|--env=ENV] [--test] [-s|--silent|-vv] Enforce network constraints Options: -e ENV --env=ENV Path to the environment directory. You should use this option when you want to link a specific experiment. -h --help Show this help message. -s --silent Quiet mode. --test Test the rules by generating various reports. -vv Verbose mode. """ roles = env["rsc"] inventory = env["inventory"] # We inject the influx_vip for annotation purpose influx_vip = env["config"].get("influx_vip") test = kwargs['--test'] reset = kwargs['--reset'] if not extra_vars: extra_vars = {} extra_vars.update(influx_vip=influx_vip) if test: validate_network(roles, inventory, extra_vars=extra_vars) elif reset: reset_network(roles, inventory, extra_vars=extra_vars) else: if not network_constraints: network_constraints = env["config"].get("network_constraints", {}) emulate_network(roles, inventory, network_constraints, extra_vars=extra_vars)
"box": "debian/jessie64", "resources": { "machines": [{ "role": "control1", "flavor": "tiny", "number": 1, "networks": ["n1", "n2"] }, { "role": "control2", "flavor": "tiny", "number": 1, "networks": ["n1", "n3"] }] } } tc = { "enable": True, "default_delay": "20ms", "default_rate": "1gbit", } inventory = os.path.join(os.getcwd(), "hosts") provider = Enos_vagrant(provider_conf) roles, networks = provider.init() generate_inventory(roles, networks, inventory, check_networks=True) #result = run_command("control*", "ping -c 1 {{hostvars['enos-1']['ansible_' + n1].ipv4.address}}", inventory) result = run_command("control*", "date", inventory) print(result["ok"]) emulate_network(roles, inventory, tc) validate_network(roles, inventory)
def validate(env=None, **kwargs): """Validates the network constraints.""" roles = env["roles"] validate_network(roles)
} } tc = { "enable": True, "default_delay": "20ms", "default_rate": "1gbit", } # path to the inventory inventory = os.path.join(os.getcwd(), "hosts") # claim the resources conf = Configuration.from_dictionnary(provider_conf) provider = Enos_vagrant(conf) roles, networks = provider.init() generate_inventory(roles, networks, inventory, check_networks=True) # apply network constraints emulate_network(roles, inventory, tc) # validate network constraints validate_network(roles, inventory) # reset network constraints reset_network(roles, inventory) # validate network constraints and saving in an alternative validate_network(roles, inventory, output_dir="after_reset")
} } 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() generate_inventory(roles, networks, "hosts.ini") check_networks(roles, networks) generate_inventory(roles, networks, "hosts.ini") # apply network constraints emulate_network(roles, tc) # validate network constraints validate_network(roles) # reset network constraints reset_network(roles) # validate network constraints and saving in an alternative validate_network(roles, output_dir="after_reset")
def validate(env=None, **kwargs): """Validates the network constraints.""" inventory = env["inventory"] roles = env["roles"] validate_network(roles, inventory)
def validate(env=None, **kwargs): inventory = env["inventory"] roles = env["roles"] validate_network(roles, inventory)
conf.finalize() # 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": delay, "symetric": True }) emulation_conf["constraints"] = constraints logging.info(emulation_conf) discover_networks(roles, networks) emulate_network(emulation_conf, roles=roles) validate_network(roles=roles)
def validate(env=None, **kwargs): roles = env["roles"] validate_network(roles)