~raharper/curtin/trunk.simple-bridge

« back to all changes in this revision

Viewing changes to curtin/net/network_state.py

  • Committer: Ryan Harper
  • Date: 2017-02-09 17:10:24 UTC
  • mfrom: (384.1.13 trunk.vmtest-bridges)
  • Revision ID: ryan.harper@canonical.com-20170209171024-wci4wsnpxgzammjd
Add tests for network bridging configuration

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
 
74
74
        required_keys = NETWORK_STATE_REQUIRED_KEYS[state['version']]
75
75
        if not self.valid_command(state, required_keys):
76
 
            msg = 'Invalid state, missing keys: {}'.format(required_keys)
 
76
            msg = 'Invalid state, missing keys: %s' % (required_keys)
77
77
            LOG.error(msg)
78
78
            raise Exception(msg)
79
79
 
113
113
            'name',
114
114
        ]
115
115
        if not self.valid_command(command, required_keys):
116
 
            LOG.warn('Skipping Invalid command: {}'.format(command))
 
116
            LOG.warn('Skipping Invalid command: %s', command)
117
117
            LOG.debug(self.dump_network_state())
118
118
            return
119
119
 
240
240
            iface br0 inet static
241
241
                    address 10.10.10.1
242
242
                    netmask 255.255.255.0
243
 
                    bridge_ports eth0 eth1
244
 
                    bridge_stp off
245
 
                    bridge_fd 0
246
 
                    bridge_maxwait 0
 
243
                    bridge_ports eth1 eth2
 
244
                    bridge_ageing: 250
 
245
                    bridge_bridgeprio: 22
 
246
                    bridge_fd: 1
 
247
                    bridge_gcint: 2
 
248
                    bridge_hello: 1
 
249
                    bridge_hw: 00:11:22:33:44:55
 
250
                    bridge_maxage: 10
 
251
                    bridge_maxwait: 0
 
252
                    bridge_pathcost: eth1 50
 
253
                    bridge_pathcost: eth2 75
 
254
                    bridge_portprio: eth1 64
 
255
                    bridge_portprio: eth2 192
 
256
                    bridge_stp: 'off'
 
257
                    bridge_waitport: 1 eth1
 
258
                    bridge_waitport: 2 eth2
247
259
 
248
260
        bridge_params = [
249
261
            "bridge_ports",
267
279
            'params',
268
280
        ]
269
281
        if not self.valid_command(command, required_keys):
270
 
            print('Skipping Invalid command: {}'.format(command))
271
 
            print(self.dump_network_state())
 
282
            LOG.warn('Skipping Invalid command: %s', command)
 
283
            LOG.warn(self.dump_network_state())
272
284
            return
273
285
 
274
286
        # find one of the bridge port ifaces to get mac_addr
288
300
        self.handle_physical(command)
289
301
        iface = interfaces.get(command.get('name'), {})
290
302
        iface['bridge_ports'] = command['bridge_interfaces']
291
 
        for param, val in command.get('params').items():
 
303
        for param, val in command.get('params', {}).items():
292
304
            iface.update({param: val})
293
305
 
294
306
        interfaces.update({iface['name']: iface})
298
310
            'address',
299
311
        ]
300
312
        if not self.valid_command(command, required_keys):
301
 
            print('Skipping Invalid command: {}'.format(command))
302
 
            print(self.dump_network_state())
 
313
            LOG.warn('Skipping Invalid command: %s', command)
 
314
            LOG.warn(self.dump_network_state())
303
315
            return
304
316
 
305
317
        dns = self.network_state.get('dns')
321
333
            'destination',
322
334
        ]
323
335
        if not self.valid_command(command, required_keys):
324
 
            print('Skipping Invalid command: {}'.format(command))
325
 
            print(self.dump_network_state())
 
336
            LOG.warn('Skipping Invalid command: %s', command)
 
337
            LOG.warn(self.dump_network_state())
326
338
            return
327
339
 
328
340
        routes = self.network_state.get('routes')