Esempio n. 1
0
 def get_testbed_config(self):
     name = self.json['Name']
     hosts = self.json['Hosts']
     t = Testbed(name)
     for host in hosts:
         host_name = host['Name'].replace(" ", "_")
         host_template = host['Template']
         host_memory = host['Memory']
         host_cpu = host['CPU']
         h = Host(host_name, host_template, host_memory, host_cpu)
         if 'Interfaces' in host:
             for interface in host['Interfaces']:
                 interface_name = interface['Name']
                 interface_bridge = interface['Bridge']
                 interface_mac = self.try_value(interface, 'Mac',
                                                self.random_mac())
                 interface_ip = self.try_value(interface, 'IP', "")
                 interface_mtu = self.try_value(interface, 'MTU', 1500)
                 interface_bw = self.try_value(interface, 'Bandwidth', -1)
                 interface_delay = self.try_value(interface, 'Delay', -1)
                 interface_jitter = self.try_value(interface, 'Jitter', -1)
                 interface_loss = self.try_value(interface, 'Loss', -1)
                 interface_tcpdump = self.try_value(interface, 'Tcpdump',
                                                    'no')
                 routes = dict()
                 if 'Routes' in interface:
                     for route in interface['Routes']:
                         for destination in route.keys():
                             routes[destination] = route[destination]
                 i = Interface(interface_name, interface_bridge,
                               interface_mac, interface_mtu, interface_ip,
                               interface_bw, interface_delay,
                               interface_jitter, interface_loss,
                               interface_tcpdump, routes)
                 h.add_interface(i)
         if 'Commands' in host:
             for command in host['Commands']:
                 command_command = command['Command']
                 command_time = command['Time']
                 command_background = command['Background']
                 command_repeat = self.try_value(command, 'RepeatUntil', 0)
                 c = Command(command_command, command_time,
                             command_background, command_repeat)
                 h.add_command(c)
         t.add_host(h)
     return t
Esempio n. 2
0
 def __init__(self, client, command_head, command_text, channel):
     Command.__init__(self, client, command_head, command_text, channel)
Esempio n. 3
0
 def __init__(self, client, command_head, command_text, channel):
     Command.__init__(self, client, command_head, command_text, channel)
     self.STAT_CHANNEL = None