~smoser/curtin/yakkety.lp1666986

« back to all changes in this revision

Viewing changes to tests/vmtests/test_network.py

  • Committer: Scott Moser
  • Date: 2016-07-12 16:28:59 UTC
  • mto: (58.1.1 pkg)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: smoser@ubuntu.com-20160712162859-f9jmixbnjsn3keu9
Tags: upstream-0.1.0~bzr399
ImportĀ upstreamĀ versionĀ 0.1.0~bzr399

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from . import VMBaseClass, logger
 
1
from . import VMBaseClass, logger, helpers
2
2
from .releases import base_vm_classes as relbase
3
3
 
4
4
import ipaddress
9
9
import yaml
10
10
 
11
11
 
12
 
def iface_extract(input):
13
 
    mo = re.search(r'^(?P<interface>\w+|\w+:\d+|\w+\.\d+)\s+' +
14
 
                   r'Link encap:(?P<link_encap>\S+)\s+' +
15
 
                   r'(HWaddr\s+(?P<mac_address>\S+))?' +
16
 
                   r'(\s+inet addr:(?P<address>\S+))?' +
17
 
                   r'(\s+Bcast:(?P<broadcast>\S+)\s+)?' +
18
 
                   r'(Mask:(?P<netmask>\S+)\s+)?',
19
 
                   input, re.MULTILINE)
20
 
 
21
 
    mtu = re.search(r'(\s+MTU:(?P<mtu>\d+)\s+)\s+', input, re.MULTILINE)
22
 
    mtu_info = mtu.groupdict('')
23
 
    mtu_info['mtu'] = int(mtu_info['mtu'])
24
 
 
25
 
    if mo:
26
 
        info = mo.groupdict('')
27
 
        info['running'] = False
28
 
        info['up'] = False
29
 
        info['multicast'] = False
30
 
        if 'RUNNING' in input:
31
 
            info['running'] = True
32
 
        if 'UP' in input:
33
 
            info['up'] = True
34
 
        if 'MULTICAST' in input:
35
 
            info['multicast'] = True
36
 
        info.update(mtu_info)
37
 
        return info
38
 
    return {}
39
 
 
40
 
 
41
 
def ifconfig_to_dict(ifconfig):
42
 
    interfaces = {}
43
 
    for iface in [iface_extract(iface) for iface in ifconfig.split('\n\n')
44
 
                  if iface.strip()]:
45
 
        interfaces[iface['interface']] = iface
46
 
 
47
 
    return interfaces
48
 
 
49
 
 
50
12
class TestNetworkAbs(VMBaseClass):
51
13
    interactive = False
52
14
    conf_file = "examples/tests/basic_network.yaml"
132
94
            ifconfig_a = fp.read()
133
95
            logger.debug('ifconfig -a:\n{}'.format(ifconfig_a))
134
96
 
135
 
        ifconfig_dict = ifconfig_to_dict(ifconfig_a)
 
97
        ifconfig_dict = helpers.ifconfig_to_dict(ifconfig_a)
136
98
        logger.debug('parsed ifcfg dict:\n{}'.format(
137
99
            yaml.dump(ifconfig_dict, default_flow_style=False, indent=4)))
138
100
 
340
302
            ifconfig_a = fp.read()
341
303
            logger.debug('ifconfig -a:\n{}'.format(ifconfig_a))
342
304
 
343
 
        ifconfig_dict = ifconfig_to_dict(ifconfig_a)
 
305
        ifconfig_dict = helpers.ifconfig_to_dict(ifconfig_a)
344
306
        logger.debug('parsed ifconfig dict:\n{}'.format(
345
307
            yaml.dump(ifconfig_dict, default_flow_style=False, indent=4)))
346
308
        print('parsed ifconfig dict:\n{}'.format(
411
373
    __test__ = False
412
374
 
413
375
 
414
 
class VividTestNetwork(relbase.vivid, TestNetworkAbs):
415
 
    __test__ = True
416
 
 
417
 
 
418
 
class VividTestNetworkStatic(relbase.vivid, TestNetworkStaticAbs):
419
 
    __test__ = True
420
 
 
421
 
 
422
376
class WilyTestNetwork(relbase.wily, TestNetworkAbs):
423
377
    __test__ = True
424
378
 
435
389
    __test__ = True
436
390
 
437
391
 
 
392
class YakketyTestNetwork(relbase.yakkety, TestNetworkAbs):
 
393
    __test__ = True
 
394
 
 
395
 
 
396
class YakketyTestNetworkStatic(relbase.yakkety, TestNetworkStaticAbs):
 
397
    __test__ = True
 
398
 
 
399
 
438
400
class PreciseTestNetworkVlan(relbase.precise, TestNetworkVlanAbs):
439
401
    __test__ = True
440
402
 
455
417
    __test__ = True
456
418
 
457
419
 
458
 
class VividTestNetworkVlan(relbase.vivid, TestNetworkVlanAbs):
459
 
    __test__ = True
460
 
 
461
 
 
462
420
class WilyTestNetworkVlan(relbase.wily, TestNetworkVlanAbs):
463
421
    __test__ = True
464
422
 
467
425
    __test__ = True
468
426
 
469
427
 
 
428
class YakketyTestNetworkVlan(relbase.yakkety, TestNetworkVlanAbs):
 
429
    __test__ = True
 
430
 
 
431
 
470
432
class PreciseTestNetworkENISource(relbase.precise, TestNetworkENISource):
471
433
    __test__ = False
472
434
    # not working, still debugging though; possible older ifupdown doesn't
477
439
    __test__ = True
478
440
 
479
441
 
480
 
class VividTestNetworkENISource(relbase.vivid, TestNetworkENISource):
481
 
    __test__ = True
482
 
 
483
 
 
484
442
class WilyTestNetworkENISource(relbase.wily, TestNetworkENISource):
485
443
    __test__ = True
486
444
 
487
445
 
488
446
class XenialTestNetworkENISource(relbase.xenial, TestNetworkENISource):
489
447
    __test__ = True
 
448
 
 
449
 
 
450
class YakketyTestNetworkENISource(relbase.yakkety, TestNetworkENISource):
 
451
    __test__ = True