github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/provider/maas/bridgescript_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package maas
     5  
     6  import (
     7  	"fmt"
     8  	"io/ioutil"
     9  	"os"
    10  	"path/filepath"
    11  	"runtime"
    12  	"strings"
    13  
    14  	jc "github.com/juju/testing/checkers"
    15  	"github.com/juju/utils/exec"
    16  	gc "gopkg.in/check.v1"
    17  
    18  	coretesting "github.com/juju/juju/testing"
    19  )
    20  
    21  type bridgeConfigSuite struct {
    22  	coretesting.BaseSuite
    23  
    24  	testConfig       string
    25  	testConfigPath   string
    26  	testPythonScript string
    27  	pythonVersions   []string
    28  }
    29  
    30  var _ = gc.Suite(&bridgeConfigSuite{})
    31  
    32  func (s *bridgeConfigSuite) SetUpSuite(c *gc.C) {
    33  	if runtime.GOOS == "windows" {
    34  		c.Skip("Skipping bridge config tests on windows")
    35  	}
    36  	s.BaseSuite.SetUpSuite(c)
    37  
    38  	for _, version := range []string{
    39  		"/usr/bin/python2",
    40  		"/usr/bin/python3",
    41  		"/usr/bin/python",
    42  	} {
    43  		if _, err := os.Stat(version); err == nil {
    44  			s.pythonVersions = append(s.pythonVersions, version)
    45  		}
    46  	}
    47  }
    48  
    49  func (s *bridgeConfigSuite) SetUpTest(c *gc.C) {
    50  	// We need at least one Python package installed.
    51  	c.Assert(s.pythonVersions, gc.Not(gc.HasLen), 0)
    52  
    53  	s.testConfigPath = filepath.Join(c.MkDir(), "network-config")
    54  	s.testPythonScript = filepath.Join(c.MkDir(), bridgeScriptName)
    55  	s.testConfig = "# test network config\n"
    56  	err := ioutil.WriteFile(s.testConfigPath, []byte(s.testConfig), 0644)
    57  	c.Assert(err, jc.ErrorIsNil)
    58  	err = ioutil.WriteFile(s.testPythonScript, []byte(bridgeScriptPython), 0644)
    59  	c.Assert(err, jc.ErrorIsNil)
    60  }
    61  
    62  func (s *bridgeConfigSuite) assertScript(c *gc.C, initialConfig, expectedConfig, bridgePrefix, bridgeName, interfaceToBridge string) {
    63  	for i, python := range s.pythonVersions {
    64  		c.Logf("test #%v using %s", i, python)
    65  		// To simplify most cases, trim trailing new lines.
    66  		initialConfig = strings.TrimSuffix(initialConfig, "\n")
    67  		expectedConfig = strings.TrimSuffix(expectedConfig, "\n")
    68  		err := ioutil.WriteFile(s.testConfigPath, []byte(initialConfig), 0644)
    69  		c.Check(err, jc.ErrorIsNil)
    70  		// Run the script and verify the modified config.
    71  		output, retcode := s.runScript(c, python, s.testConfigPath, bridgePrefix, bridgeName, interfaceToBridge)
    72  		c.Check(retcode, gc.Equals, 0)
    73  		c.Check(strings.Trim(output, "\n"), gc.Equals, expectedConfig)
    74  	}
    75  }
    76  
    77  func (s *bridgeConfigSuite) assertScriptWithPrefix(c *gc.C, initial, expected, prefix string) {
    78  	s.assertScript(c, initial, expected, prefix, "", "")
    79  }
    80  
    81  func (s *bridgeConfigSuite) assertScriptWithDefaultPrefix(c *gc.C, initial, expected string) {
    82  	s.assertScript(c, initial, expected, "", "", "")
    83  }
    84  
    85  func (s *bridgeConfigSuite) assertScriptWithoutPrefix(c *gc.C, initial, expected, bridgeName, interfaceToBridge string) {
    86  	s.assertScript(c, initial, expected, "", bridgeName, interfaceToBridge)
    87  }
    88  
    89  func (s *bridgeConfigSuite) TestBridgeScriptWithUndefinedArgs(c *gc.C) {
    90  	for i, python := range s.pythonVersions {
    91  		c.Logf("test #%v using %s", i, python)
    92  		_, code := s.runScript(c, python, "", "", "", "")
    93  		c.Check(code, gc.Equals, 1)
    94  	}
    95  }
    96  
    97  func (s *bridgeConfigSuite) TestBridgeScriptWithPrefixTransformation(c *gc.C) {
    98  	for i, v := range []struct {
    99  		initial  string
   100  		expected string
   101  		prefix   string
   102  	}{
   103  		{networkDHCPInitial, networkDHCPExpected, "test-br-"},
   104  		{networkDHCPWithAliasInitial, networkDHCPWithAliasExpected, "test-br-"},
   105  		{networkDHCPWithBondInitial, networkDHCPWithBondExpected, "test-br-"},
   106  		{networkDualNICInitial, networkDualNICExpected, "test-br-"},
   107  		{networkMultipleAliasesInitial, networkMultipleAliasesExpected, "test-br-"},
   108  		{networkMultipleStaticWithAliasesInitial, networkMultipleStaticWithAliasesExpected, "test-br-"},
   109  		{networkSmorgasboardInitial, networkSmorgasboardExpected, "juju-br-"},
   110  		{networkStaticInitial, networkStaticExpected, "test-br-"},
   111  		{networkVLANInitial, networkVLANExpected, "vlan-br-"},
   112  		{networkWithAliasInitial, networkWithAliasExpected, "test-br-"},
   113  	} {
   114  		c.Logf("test #%v - expected transformation", i)
   115  		s.assertScriptWithPrefix(c, v.initial, v.expected, v.prefix)
   116  		c.Logf("test #%v - idempotent transformation", i)
   117  		s.assertScriptWithPrefix(c, v.expected, v.expected, v.prefix)
   118  	}
   119  }
   120  
   121  func (s *bridgeConfigSuite) TestBridgeScriptWithDefaultPrefixTransformation(c *gc.C) {
   122  	for i, v := range []struct {
   123  		initial  string
   124  		expected string
   125  	}{
   126  		{networkLoopbackOnlyInitial, networkLoopbackOnlyExpected},
   127  		{networkStaticBondWithVLANsInitial, networkStaticBondWithVLANsExpected},
   128  		{networkVLANWithActiveDHCPDeviceInitial, networkVLANWithActiveDHCPDeviceExpected},
   129  		{networkVLANWithInactiveDeviceInitial, networkVLANWithInactiveDeviceExpected},
   130  		{networkVLANWithMultipleNameserversInitial, networkVLANWithMultipleNameserversExpected},
   131  		{networkWithEmptyDNSValuesInitial, networkWithEmptyDNSValuesExpected},
   132  		{networkWithMultipleDNSValuesInitial, networkWithMultipleDNSValuesExpected},
   133  		{networkPartiallyBridgedInitial, networkPartiallyBridgedExpected},
   134  	} {
   135  		c.Logf("test #%v - expected transformation", i)
   136  		s.assertScriptWithDefaultPrefix(c, v.initial, v.expected)
   137  		c.Logf("test #%v - idempotent transformation", i)
   138  		s.assertScriptWithDefaultPrefix(c, v.expected, v.expected)
   139  	}
   140  }
   141  
   142  func (s *bridgeConfigSuite) TestBridgeScriptInterfaceNameArgumentRequired(c *gc.C) {
   143  	for i, python := range s.pythonVersions {
   144  		c.Logf("test #%v using %s", i, python)
   145  		output, code := s.runScript(c, python, "# no content", "", "juju-br0", "")
   146  		c.Check(code, gc.Equals, 1)
   147  		c.Check(strings.Trim(output, "\n"), gc.Equals, "error: --interface-to-bridge required when using --bridge-name")
   148  	}
   149  }
   150  
   151  func (s *bridgeConfigSuite) TestBridgeScriptBridgeNameArgumentRequired(c *gc.C) {
   152  	for i, python := range s.pythonVersions {
   153  		c.Logf("test #%v using %s", i, python)
   154  		output, code := s.runScript(c, python, "# no content", "", "", "eth0")
   155  		c.Check(code, gc.Equals, 1)
   156  		c.Check(strings.Trim(output, "\n"), gc.Equals, "error: --bridge-name required when using --interface-to-bridge")
   157  	}
   158  }
   159  
   160  func (s *bridgeConfigSuite) TestBridgeScriptMatchingNonExistentSpecificIface(c *gc.C) {
   161  	s.assertScriptWithoutPrefix(c, networkStaticInitial, networkStaticInitial, "juju-br0", "eth1234567890")
   162  }
   163  
   164  func (s *bridgeConfigSuite) TestBridgeScriptMatchingExistingSpecificIfaceButMissingAutoStanza(c *gc.C) {
   165  	s.assertScriptWithoutPrefix(c, networkWithExistingSpecificIfaceInitial, networkWithExistingSpecificIfaceExpected, "juju-br0", "eth1")
   166  }
   167  
   168  func (s *bridgeConfigSuite) TestBridgeScriptMatchingExistingSpecificIface2(c *gc.C) {
   169  	s.assertScriptWithoutPrefix(c, networkLP1532167Initial, networkLP1532167Expected, "juju-br0", "bond0")
   170  }
   171  
   172  func (s *bridgeConfigSuite) runScript(c *gc.C, pythonBinary, configFile, bridgePrefix, bridgeName, interfaceToBridge string) (output string, exitCode int) {
   173  	if bridgePrefix != "" {
   174  		bridgePrefix = fmt.Sprintf("--bridge-prefix=%q", bridgePrefix)
   175  	}
   176  
   177  	if bridgeName != "" {
   178  		bridgeName = fmt.Sprintf("--bridge-name=%q", bridgeName)
   179  	}
   180  
   181  	if interfaceToBridge != "" {
   182  		interfaceToBridge = fmt.Sprintf("--interface-to-bridge=%q", interfaceToBridge)
   183  	}
   184  
   185  	script := fmt.Sprintf("%q %q %s %s %s %q\n", pythonBinary, s.testPythonScript, bridgePrefix, bridgeName, interfaceToBridge, configFile)
   186  	c.Log(script)
   187  	result, err := exec.RunCommands(exec.RunParams{Commands: script})
   188  	c.Assert(err, jc.ErrorIsNil, gc.Commentf("script failed unexpectedly"))
   189  	stdout := string(result.Stdout)
   190  	stderr := string(result.Stderr)
   191  	if stderr != "" {
   192  		return stdout + "\n" + stderr, result.Code
   193  	}
   194  	return stdout, result.Code
   195  }
   196  
   197  // The rest of the file contains various forms of network config for
   198  // both before and after it has been run through the python script.
   199  // They are used in individual test functions.
   200  
   201  const networkStaticInitial = `auto lo
   202  iface lo inet loopback
   203  
   204  auto eth0
   205  iface eth0 inet static
   206      address 1.2.3.4
   207      netmask 255.255.255.0
   208      gateway 4.3.2.1`
   209  
   210  const networkStaticExpected = `auto lo
   211  iface lo inet loopback
   212  
   213  iface eth0 inet manual
   214  
   215  auto test-br-eth0
   216  iface test-br-eth0 inet static
   217      address 1.2.3.4
   218      netmask 255.255.255.0
   219      gateway 4.3.2.1
   220      bridge_ports eth0`
   221  
   222  const networkDHCPInitial = `auto lo
   223  iface lo inet loopback
   224  
   225  auto eth0
   226  iface eth0 inet dhcp`
   227  
   228  const networkDHCPExpected = `auto lo
   229  iface lo inet loopback
   230  
   231  iface eth0 inet manual
   232  
   233  auto test-br-eth0
   234  iface test-br-eth0 inet dhcp
   235      bridge_ports eth0`
   236  
   237  const networkDualNICInitial = `auto lo
   238  iface lo inet loopback
   239  
   240  auto eth0
   241  iface eth0 inet static
   242      address 1.2.3.4
   243      netmask 255.255.255.0
   244      gateway 4.3.2.1
   245  
   246  auto eth1
   247  iface eth1 inet static
   248      address 1.2.3.5
   249      netmask 255.255.255.0
   250      gateway 4.3.2.1`
   251  
   252  const networkDualNICExpected = `auto lo
   253  iface lo inet loopback
   254  
   255  iface eth0 inet manual
   256  
   257  auto test-br-eth0
   258  iface test-br-eth0 inet static
   259      address 1.2.3.4
   260      netmask 255.255.255.0
   261      gateway 4.3.2.1
   262      bridge_ports eth0
   263  
   264  iface eth1 inet manual
   265  
   266  auto test-br-eth1
   267  iface test-br-eth1 inet static
   268      address 1.2.3.5
   269      netmask 255.255.255.0
   270      gateway 4.3.2.1
   271      bridge_ports eth1`
   272  
   273  const networkWithAliasInitial = `auto lo
   274  iface lo inet loopback
   275  
   276  auto eth0
   277  iface eth0 inet static
   278      address 1.2.3.4
   279      netmask 255.255.255.0
   280      gateway 4.3.2.1
   281  
   282  auto eth0:1
   283  iface eth0:1 inet static
   284      address 1.2.3.5`
   285  
   286  const networkWithAliasExpected = `auto lo
   287  iface lo inet loopback
   288  
   289  iface eth0 inet manual
   290  
   291  auto test-br-eth0
   292  iface test-br-eth0 inet static
   293      address 1.2.3.4
   294      netmask 255.255.255.0
   295      gateway 4.3.2.1
   296      bridge_ports eth0
   297  
   298  auto eth0:1
   299  iface eth0:1 inet static
   300      address 1.2.3.5`
   301  
   302  const networkDHCPWithAliasInitial = `auto lo
   303  iface lo inet loopback
   304  
   305  auto eth0
   306  iface eth0 inet static
   307      gateway 10.14.0.1
   308      address 10.14.0.102/24
   309  
   310  auto eth0:1
   311  iface eth0:1 inet static
   312      address 10.14.0.103/24
   313  
   314  auto eth0:2
   315  iface eth0:2 inet static
   316      address 10.14.0.100/24
   317  
   318  dns-nameserver 192.168.1.142`
   319  
   320  const networkDHCPWithAliasExpected = `auto lo
   321  iface lo inet loopback
   322  
   323  iface eth0 inet manual
   324  
   325  auto test-br-eth0
   326  iface test-br-eth0 inet static
   327      gateway 10.14.0.1
   328      address 10.14.0.102/24
   329      bridge_ports eth0
   330  
   331  auto eth0:1
   332  iface eth0:1 inet static
   333      address 10.14.0.103/24
   334  
   335  auto eth0:2
   336  iface eth0:2 inet static
   337      address 10.14.0.100/24
   338      dns-nameserver 192.168.1.142`
   339  
   340  const networkMultipleStaticWithAliasesInitial = `
   341  auto eth0
   342  iface eth0 inet static
   343      gateway 10.17.20.1
   344      address 10.17.20.201/24
   345      mtu 1500
   346  
   347  auto eth0:1
   348  iface eth0:1 inet static
   349      address 10.17.20.202/24
   350      mtu 1500
   351  
   352  auto eth1
   353  iface eth1 inet manual
   354      mtu 1500
   355  
   356  dns-nameservers 10.17.20.200
   357  dns-search maas`
   358  
   359  const networkMultipleStaticWithAliasesExpected = `iface eth0 inet manual
   360  
   361  auto test-br-eth0
   362  iface test-br-eth0 inet static
   363      gateway 10.17.20.1
   364      address 10.17.20.201/24
   365      mtu 1500
   366      bridge_ports eth0
   367  
   368  auto eth0:1
   369  iface eth0:1 inet static
   370      address 10.17.20.202/24
   371      mtu 1500
   372  
   373  auto eth1
   374  iface eth1 inet manual
   375      mtu 1500
   376      dns-nameservers 10.17.20.200
   377      dns-search maas`
   378  
   379  const networkDHCPWithBondInitial = `auto eth0
   380  iface eth0 inet manual
   381      bond-lacp_rate slow
   382      bond-xmit_hash_policy layer2
   383      bond-miimon 100
   384      bond-master bond0
   385      mtu 1500
   386      bond-mode active-backup
   387  
   388  auto eth1
   389  iface eth1 inet manual
   390      bond-lacp_rate slow
   391      bond-xmit_hash_policy layer2
   392      bond-miimon 100
   393      bond-master bond0
   394      mtu 1500
   395      bond-mode active-backup
   396  
   397  auto bond0
   398  iface bond0 inet dhcp
   399      bond-lacp_rate slow
   400      bond-xmit_hash_policy layer2
   401      bond-miimon 100
   402      mtu 1500
   403      bond-mode active-backup
   404      hwaddress 52:54:00:1c:f1:5b
   405      bond-slaves none
   406  
   407  dns-nameservers 10.17.20.200
   408  dns-search maas19`
   409  
   410  const networkDHCPWithBondExpected = `auto eth0
   411  iface eth0 inet manual
   412      bond-lacp_rate slow
   413      bond-xmit_hash_policy layer2
   414      bond-miimon 100
   415      bond-master bond0
   416      mtu 1500
   417      bond-mode active-backup
   418  
   419  auto eth1
   420  iface eth1 inet manual
   421      bond-lacp_rate slow
   422      bond-xmit_hash_policy layer2
   423      bond-miimon 100
   424      bond-master bond0
   425      mtu 1500
   426      bond-mode active-backup
   427  
   428  auto bond0
   429  iface bond0 inet manual
   430      bond-lacp_rate slow
   431      bond-xmit_hash_policy layer2
   432      bond-miimon 100
   433      mtu 1500
   434      bond-mode active-backup
   435      hwaddress 52:54:00:1c:f1:5b
   436      bond-slaves none
   437      dns-nameservers 10.17.20.200
   438      dns-search maas19
   439  
   440  auto test-br-bond0
   441  iface test-br-bond0 inet dhcp
   442      mtu 1500
   443      hwaddress 52:54:00:1c:f1:5b
   444      bridge_ports bond0
   445      dns-nameservers 10.17.20.200
   446      dns-search maas19`
   447  
   448  const networkMultipleAliasesInitial = `auto eth0
   449  iface eth0 inet dhcp
   450  
   451  auto eth1
   452  iface eth1 inet dhcp
   453  
   454  auto eth10
   455  iface eth10 inet static
   456      gateway 10.17.20.1
   457      address 10.17.20.201/24
   458      mtu 1500
   459  
   460  auto eth10:1
   461  iface eth10:1 inet static
   462      address 10.17.20.202/24
   463      mtu 1500
   464  
   465  auto eth10:2
   466  iface eth10:2 inet static
   467      address 10.17.20.203/24
   468      mtu 1500
   469  
   470  dns-nameservers 10.17.20.200
   471  dns-search maas19`
   472  
   473  const networkMultipleAliasesExpected = `iface eth0 inet manual
   474  
   475  auto test-br-eth0
   476  iface test-br-eth0 inet dhcp
   477      bridge_ports eth0
   478  
   479  iface eth1 inet manual
   480  
   481  auto test-br-eth1
   482  iface test-br-eth1 inet dhcp
   483      bridge_ports eth1
   484  
   485  iface eth10 inet manual
   486  
   487  auto test-br-eth10
   488  iface test-br-eth10 inet static
   489      gateway 10.17.20.1
   490      address 10.17.20.201/24
   491      mtu 1500
   492      bridge_ports eth10
   493  
   494  auto eth10:1
   495  iface eth10:1 inet static
   496      address 10.17.20.202/24
   497      mtu 1500
   498  
   499  auto eth10:2
   500  iface eth10:2 inet static
   501      address 10.17.20.203/24
   502      mtu 1500
   503      dns-nameservers 10.17.20.200
   504      dns-search maas19`
   505  
   506  const networkSmorgasboardInitial = `auto eth0
   507  iface eth0 inet manual
   508      bond-lacp_rate slow
   509      bond-xmit_hash_policy layer2
   510      bond-miimon 100
   511      bond-master bond0
   512      mtu 1500
   513      bond-mode active-backup
   514  
   515  auto eth1
   516  iface eth1 inet manual
   517      bond-lacp_rate slow
   518      bond-xmit_hash_policy layer2
   519      bond-miimon 100
   520      bond-master bond0
   521      mtu 1500
   522      bond-mode active-backup
   523  
   524  auto eth2
   525  iface eth2 inet manual
   526      bond-lacp_rate slow
   527      bond-xmit_hash_policy layer2
   528      bond-miimon 100
   529      bond-master bond1
   530      mtu 1500
   531      bond-mode active-backup
   532  
   533  auto eth3
   534  iface eth3 inet manual
   535      bond-lacp_rate slow
   536      bond-xmit_hash_policy layer2
   537      bond-miimon 100
   538      bond-master bond1
   539      mtu 1500
   540      bond-mode active-backup
   541  
   542  auto eth4
   543  iface eth4 inet static
   544      address 10.17.20.202/24
   545      mtu 1500
   546  
   547  auto eth5
   548  iface eth5 inet dhcp
   549      mtu 1500
   550  
   551  auto eth6
   552  iface eth6 inet static
   553      address 10.17.20.203/24
   554      mtu 1500
   555  
   556  auto eth6:1
   557  iface eth6:1 inet static
   558      address 10.17.20.205/24
   559      mtu 1500
   560  
   561  auto eth6:2
   562  iface eth6:2 inet static
   563      address 10.17.20.204/24
   564      mtu 1500
   565  
   566  auto eth6:3
   567  iface eth6:3 inet static
   568      address 10.17.20.206/24
   569      mtu 1500
   570  
   571  auto eth6:4
   572  iface eth6:4 inet static
   573      address 10.17.20.207/24
   574      mtu 1500
   575  
   576  auto bond0
   577  iface bond0 inet static
   578      gateway 10.17.20.1
   579      address 10.17.20.201/24
   580      bond-lacp_rate slow
   581      bond-xmit_hash_policy layer2
   582      bond-miimon 100
   583      mtu 1500
   584      bond-mode active-backup
   585      hwaddress 52:54:00:6a:4f:fd
   586      bond-slaves none
   587  
   588  auto bond1
   589  iface bond1 inet dhcp
   590      bond-lacp_rate slow
   591      bond-xmit_hash_policy layer2
   592      bond-miimon 100
   593      mtu 1500
   594      bond-mode active-backup
   595      hwaddress 52:54:00:8e:6e:b0
   596      bond-slaves none
   597  
   598  dns-nameservers 10.17.20.200
   599  dns-search maas19`
   600  
   601  const networkSmorgasboardExpected = `auto eth0
   602  iface eth0 inet manual
   603      bond-lacp_rate slow
   604      bond-xmit_hash_policy layer2
   605      bond-miimon 100
   606      bond-master bond0
   607      mtu 1500
   608      bond-mode active-backup
   609  
   610  auto eth1
   611  iface eth1 inet manual
   612      bond-lacp_rate slow
   613      bond-xmit_hash_policy layer2
   614      bond-miimon 100
   615      bond-master bond0
   616      mtu 1500
   617      bond-mode active-backup
   618  
   619  auto eth2
   620  iface eth2 inet manual
   621      bond-lacp_rate slow
   622      bond-xmit_hash_policy layer2
   623      bond-miimon 100
   624      bond-master bond1
   625      mtu 1500
   626      bond-mode active-backup
   627  
   628  auto eth3
   629  iface eth3 inet manual
   630      bond-lacp_rate slow
   631      bond-xmit_hash_policy layer2
   632      bond-miimon 100
   633      bond-master bond1
   634      mtu 1500
   635      bond-mode active-backup
   636  
   637  iface eth4 inet manual
   638  
   639  auto juju-br-eth4
   640  iface juju-br-eth4 inet static
   641      address 10.17.20.202/24
   642      mtu 1500
   643      bridge_ports eth4
   644  
   645  iface eth5 inet manual
   646  
   647  auto juju-br-eth5
   648  iface juju-br-eth5 inet dhcp
   649      mtu 1500
   650      bridge_ports eth5
   651  
   652  iface eth6 inet manual
   653  
   654  auto juju-br-eth6
   655  iface juju-br-eth6 inet static
   656      address 10.17.20.203/24
   657      mtu 1500
   658      bridge_ports eth6
   659  
   660  auto eth6:1
   661  iface eth6:1 inet static
   662      address 10.17.20.205/24
   663      mtu 1500
   664  
   665  auto eth6:2
   666  iface eth6:2 inet static
   667      address 10.17.20.204/24
   668      mtu 1500
   669  
   670  auto eth6:3
   671  iface eth6:3 inet static
   672      address 10.17.20.206/24
   673      mtu 1500
   674  
   675  auto eth6:4
   676  iface eth6:4 inet static
   677      address 10.17.20.207/24
   678      mtu 1500
   679  
   680  auto bond0
   681  iface bond0 inet manual
   682      gateway 10.17.20.1
   683      address 10.17.20.201/24
   684      bond-lacp_rate slow
   685      bond-xmit_hash_policy layer2
   686      bond-miimon 100
   687      mtu 1500
   688      bond-mode active-backup
   689      hwaddress 52:54:00:6a:4f:fd
   690      bond-slaves none
   691  
   692  auto juju-br-bond0
   693  iface juju-br-bond0 inet static
   694      gateway 10.17.20.1
   695      address 10.17.20.201/24
   696      mtu 1500
   697      hwaddress 52:54:00:6a:4f:fd
   698      bridge_ports bond0
   699  
   700  auto bond1
   701  iface bond1 inet manual
   702      bond-lacp_rate slow
   703      bond-xmit_hash_policy layer2
   704      bond-miimon 100
   705      mtu 1500
   706      bond-mode active-backup
   707      hwaddress 52:54:00:8e:6e:b0
   708      bond-slaves none
   709      dns-nameservers 10.17.20.200
   710      dns-search maas19
   711  
   712  auto juju-br-bond1
   713  iface juju-br-bond1 inet dhcp
   714      mtu 1500
   715      hwaddress 52:54:00:8e:6e:b0
   716      bridge_ports bond1
   717      dns-nameservers 10.17.20.200
   718      dns-search maas19`
   719  
   720  const networkVLANInitial = `auto eth0
   721  iface eth0 inet static
   722      gateway 10.17.20.1
   723      address 10.17.20.212/24
   724      mtu 1500
   725  
   726  auto eth1
   727  iface eth1 inet manual
   728      mtu 1500
   729  
   730  auto eth0.2
   731  iface eth0.2 inet static
   732      address 192.168.2.3/24
   733      vlan-raw-device eth0
   734      mtu 1500
   735      vlan_id 2
   736  
   737  auto eth1.3
   738  iface eth1.3 inet static
   739      address 192.168.3.3/24
   740      vlan-raw-device eth1
   741      mtu 1500
   742      vlan_id 3
   743  
   744  dns-nameservers 10.17.20.200
   745  dns-search maas19`
   746  
   747  const networkVLANExpected = `iface eth0 inet manual
   748  
   749  auto vlan-br-eth0
   750  iface vlan-br-eth0 inet static
   751      gateway 10.17.20.1
   752      address 10.17.20.212/24
   753      mtu 1500
   754      bridge_ports eth0
   755  
   756  auto eth1
   757  iface eth1 inet manual
   758      mtu 1500
   759  
   760  iface eth0.2 inet manual
   761      address 192.168.2.3/24
   762      vlan-raw-device eth0
   763      mtu 1500
   764      vlan_id 2
   765  
   766  auto vlan-br-eth0.2
   767  iface vlan-br-eth0.2 inet static
   768      address 192.168.2.3/24
   769      mtu 1500
   770      bridge_ports eth0.2
   771  
   772  iface eth1.3 inet manual
   773      address 192.168.3.3/24
   774      vlan-raw-device eth1
   775      mtu 1500
   776      vlan_id 3
   777      dns-nameservers 10.17.20.200
   778      dns-search maas19
   779  
   780  auto vlan-br-eth1.3
   781  iface vlan-br-eth1.3 inet static
   782      address 192.168.3.3/24
   783      mtu 1500
   784      bridge_ports eth1.3
   785      dns-nameservers 10.17.20.200
   786      dns-search maas19`
   787  
   788  const networkVLANWithMultipleNameserversInitial = `auto eth0
   789  iface eth0 inet static
   790      dns-nameservers 10.245.168.2
   791      gateway 10.245.168.1
   792      address 10.245.168.11/21
   793      mtu 1500
   794  
   795  auto eth1
   796  iface eth1 inet manual
   797      mtu 1500
   798  
   799  auto eth2
   800  iface eth2 inet manual
   801      mtu 1500
   802  
   803  auto eth3
   804  iface eth3 inet manual
   805      mtu 1500
   806  
   807  auto eth1.2667
   808  iface eth1.2667 inet static
   809      dns-nameservers 10.245.168.2
   810      address 10.245.184.2/24
   811      vlan-raw-device eth1
   812      mtu 1500
   813      vlan_id 2667
   814  
   815  auto eth1.2668
   816  iface eth1.2668 inet static
   817      dns-nameservers 10.245.168.2
   818      address 10.245.185.1/24
   819      vlan-raw-device eth1
   820      mtu 1500
   821      vlan_id 2668
   822  
   823  auto eth1.2669
   824  iface eth1.2669 inet static
   825      dns-nameservers 10.245.168.2
   826      address 10.245.186.1/24
   827      vlan-raw-device eth1
   828      mtu 1500
   829      vlan_id 2669
   830  
   831  auto eth1.2670
   832  iface eth1.2670 inet static
   833      dns-nameservers 10.245.168.2
   834      address 10.245.187.2/24
   835      vlan-raw-device eth1
   836      mtu 1500
   837      vlan_id 2670
   838  
   839  dns-nameservers 10.245.168.2
   840  dns-search dellstack`
   841  
   842  const networkVLANWithMultipleNameserversExpected = `iface eth0 inet manual
   843  
   844  auto br-eth0
   845  iface br-eth0 inet static
   846      gateway 10.245.168.1
   847      address 10.245.168.11/21
   848      mtu 1500
   849      bridge_ports eth0
   850      dns-nameservers 10.245.168.2
   851  
   852  auto eth1
   853  iface eth1 inet manual
   854      mtu 1500
   855  
   856  auto eth2
   857  iface eth2 inet manual
   858      mtu 1500
   859  
   860  auto eth3
   861  iface eth3 inet manual
   862      mtu 1500
   863  
   864  iface eth1.2667 inet manual
   865      address 10.245.184.2/24
   866      vlan-raw-device eth1
   867      mtu 1500
   868      vlan_id 2667
   869      dns-nameservers 10.245.168.2
   870  
   871  auto br-eth1.2667
   872  iface br-eth1.2667 inet static
   873      address 10.245.184.2/24
   874      mtu 1500
   875      bridge_ports eth1.2667
   876      dns-nameservers 10.245.168.2
   877  
   878  iface eth1.2668 inet manual
   879      address 10.245.185.1/24
   880      vlan-raw-device eth1
   881      mtu 1500
   882      vlan_id 2668
   883      dns-nameservers 10.245.168.2
   884  
   885  auto br-eth1.2668
   886  iface br-eth1.2668 inet static
   887      address 10.245.185.1/24
   888      mtu 1500
   889      bridge_ports eth1.2668
   890      dns-nameservers 10.245.168.2
   891  
   892  iface eth1.2669 inet manual
   893      address 10.245.186.1/24
   894      vlan-raw-device eth1
   895      mtu 1500
   896      vlan_id 2669
   897      dns-nameservers 10.245.168.2
   898  
   899  auto br-eth1.2669
   900  iface br-eth1.2669 inet static
   901      address 10.245.186.1/24
   902      mtu 1500
   903      bridge_ports eth1.2669
   904      dns-nameservers 10.245.168.2
   905  
   906  iface eth1.2670 inet manual
   907      address 10.245.187.2/24
   908      vlan-raw-device eth1
   909      mtu 1500
   910      vlan_id 2670
   911      dns-nameservers 10.245.168.2
   912      dns-search dellstack
   913  
   914  auto br-eth1.2670
   915  iface br-eth1.2670 inet static
   916      address 10.245.187.2/24
   917      mtu 1500
   918      bridge_ports eth1.2670
   919      dns-nameservers 10.245.168.2
   920      dns-search dellstack`
   921  
   922  const networkLoopbackOnlyInitial = `auto lo
   923  iface lo inet loopback`
   924  
   925  const networkLoopbackOnlyExpected = `auto lo
   926  iface lo inet loopback`
   927  
   928  const networkStaticBondWithVLANsInitial = `auto eth0
   929  iface eth0 inet manual
   930      bond-master bond0
   931      bond-mode active-backup
   932      bond-xmit_hash_policy layer2
   933      bond-miimon 100
   934      mtu 1500
   935      bond-lacp_rate slow
   936  
   937  auto eth1
   938  iface eth1 inet manual
   939      bond-master bond0
   940      bond-mode active-backup
   941      bond-xmit_hash_policy layer2
   942      bond-miimon 100
   943      mtu 1500
   944      bond-lacp_rate slow
   945  
   946  auto bond0
   947  iface bond0 inet static
   948      address 10.17.20.211/24
   949      gateway 10.17.20.1
   950      dns-nameservers 10.17.20.200
   951      bond-slaves none
   952      bond-mode active-backup
   953      bond-xmit_hash_policy layer2
   954      bond-miimon 100
   955      mtu 1500
   956      hwaddress 52:54:00:1c:f1:5b
   957      bond-lacp_rate slow
   958  
   959  auto bond0.2
   960  iface bond0.2 inet static
   961      address 192.168.2.102/24
   962      vlan-raw-device bond0
   963      mtu 1500
   964      vlan_id 2
   965  
   966  auto bond0.3
   967  iface bond0.3 inet static
   968      address 192.168.3.101/24
   969      vlan-raw-device bond0
   970      mtu 1500
   971      vlan_id 3
   972  
   973  dns-nameservers 10.17.20.200
   974  dns-search maas19`
   975  
   976  const networkStaticBondWithVLANsExpected = `auto eth0
   977  iface eth0 inet manual
   978      bond-master bond0
   979      bond-mode active-backup
   980      bond-xmit_hash_policy layer2
   981      bond-miimon 100
   982      mtu 1500
   983      bond-lacp_rate slow
   984  
   985  auto eth1
   986  iface eth1 inet manual
   987      bond-master bond0
   988      bond-mode active-backup
   989      bond-xmit_hash_policy layer2
   990      bond-miimon 100
   991      mtu 1500
   992      bond-lacp_rate slow
   993  
   994  auto bond0
   995  iface bond0 inet manual
   996      address 10.17.20.211/24
   997      gateway 10.17.20.1
   998      bond-slaves none
   999      bond-mode active-backup
  1000      bond-xmit_hash_policy layer2
  1001      bond-miimon 100
  1002      mtu 1500
  1003      hwaddress 52:54:00:1c:f1:5b
  1004      bond-lacp_rate slow
  1005      dns-nameservers 10.17.20.200
  1006  
  1007  auto br-bond0
  1008  iface br-bond0 inet static
  1009      address 10.17.20.211/24
  1010      gateway 10.17.20.1
  1011      mtu 1500
  1012      hwaddress 52:54:00:1c:f1:5b
  1013      bridge_ports bond0
  1014      dns-nameservers 10.17.20.200
  1015  
  1016  iface bond0.2 inet manual
  1017      address 192.168.2.102/24
  1018      vlan-raw-device bond0
  1019      mtu 1500
  1020      vlan_id 2
  1021  
  1022  auto br-bond0.2
  1023  iface br-bond0.2 inet static
  1024      address 192.168.2.102/24
  1025      mtu 1500
  1026      bridge_ports bond0.2
  1027  
  1028  iface bond0.3 inet manual
  1029      address 192.168.3.101/24
  1030      vlan-raw-device bond0
  1031      mtu 1500
  1032      vlan_id 3
  1033      dns-nameservers 10.17.20.200
  1034      dns-search maas19
  1035  
  1036  auto br-bond0.3
  1037  iface br-bond0.3 inet static
  1038      address 192.168.3.101/24
  1039      mtu 1500
  1040      bridge_ports bond0.3
  1041      dns-nameservers 10.17.20.200
  1042      dns-search maas19`
  1043  
  1044  const networkVLANWithInactiveDeviceInitial = `auto eth0
  1045  iface eth0 inet static
  1046      dns-nameservers 10.17.20.200
  1047      gateway 10.17.20.1
  1048      address 10.17.20.211/24
  1049      mtu 1500
  1050  
  1051  auto eth1
  1052  iface eth1 inet manual
  1053      mtu 1500
  1054  
  1055  auto eth1.2
  1056  iface eth1.2 inet dhcp
  1057      vlan-raw-device eth1
  1058      mtu 1500
  1059      vlan_id 2
  1060  
  1061  dns-nameservers 10.17.20.200
  1062  dns-search maas19
  1063  `
  1064  
  1065  const networkVLANWithInactiveDeviceExpected = `iface eth0 inet manual
  1066  
  1067  auto br-eth0
  1068  iface br-eth0 inet static
  1069      gateway 10.17.20.1
  1070      address 10.17.20.211/24
  1071      mtu 1500
  1072      bridge_ports eth0
  1073      dns-nameservers 10.17.20.200
  1074  
  1075  auto eth1
  1076  iface eth1 inet manual
  1077      mtu 1500
  1078  
  1079  iface eth1.2 inet manual
  1080      vlan-raw-device eth1
  1081      mtu 1500
  1082      vlan_id 2
  1083      dns-nameservers 10.17.20.200
  1084      dns-search maas19
  1085  
  1086  auto br-eth1.2
  1087  iface br-eth1.2 inet dhcp
  1088      mtu 1500
  1089      bridge_ports eth1.2
  1090      dns-nameservers 10.17.20.200
  1091      dns-search maas19`
  1092  
  1093  const networkVLANWithActiveDHCPDeviceInitial = `auto eth0
  1094  iface eth0 inet static
  1095      dns-nameservers 10.17.20.200
  1096      gateway 10.17.20.1
  1097      address 10.17.20.211/24
  1098      mtu 1500
  1099  
  1100  auto eth1
  1101  iface eth1 inet dhcp
  1102      mtu 1500
  1103  
  1104  auto eth1.2
  1105  iface eth1.2 inet dhcp
  1106      vlan-raw-device eth1
  1107      mtu 1500
  1108      vlan_id 2
  1109  
  1110  dns-nameservers 10.17.20.200
  1111  dns-search maas19
  1112  `
  1113  
  1114  const networkVLANWithActiveDHCPDeviceExpected = `iface eth0 inet manual
  1115  
  1116  auto br-eth0
  1117  iface br-eth0 inet static
  1118      gateway 10.17.20.1
  1119      address 10.17.20.211/24
  1120      mtu 1500
  1121      bridge_ports eth0
  1122      dns-nameservers 10.17.20.200
  1123  
  1124  iface eth1 inet manual
  1125  
  1126  auto br-eth1
  1127  iface br-eth1 inet dhcp
  1128      mtu 1500
  1129      bridge_ports eth1
  1130  
  1131  iface eth1.2 inet manual
  1132      vlan-raw-device eth1
  1133      mtu 1500
  1134      vlan_id 2
  1135      dns-nameservers 10.17.20.200
  1136      dns-search maas19
  1137  
  1138  auto br-eth1.2
  1139  iface br-eth1.2 inet dhcp
  1140      mtu 1500
  1141      bridge_ports eth1.2
  1142      dns-nameservers 10.17.20.200
  1143      dns-search maas19`
  1144  
  1145  const networkWithMultipleDNSValuesInitial = `auto eth0
  1146  iface eth0 inet static
  1147      dns-nameservers 10.245.168.2
  1148      gateway 10.245.168.1
  1149      address 10.245.168.11/21
  1150      mtu 1500
  1151      dns-nameservers 192.168.1.1
  1152      dns-nameservers 10.245.168.2 192.168.1.1 10.245.168.2
  1153  
  1154  auto eth1
  1155  iface eth1 inet static
  1156      gateway 10.245.168.1
  1157      address 10.245.168.12/21
  1158      mtu 1500
  1159      dns-sortlist 192.168.1.0/24 10.245.168.0/21 192.168.1.0/24
  1160      dns-sortlist 10.245.168.0/21 192.168.1.0/24
  1161  
  1162  auto eth2
  1163  iface eth2 inet static
  1164      gateway 10.245.168.1
  1165      address 10.245.168.13/21
  1166      mtu 1500
  1167      dns-search juju ubuntu
  1168      dns-search dellstack ubuntu dellstack
  1169  
  1170  auto eth3
  1171  iface eth3 inet static
  1172      gateway 10.245.168.1
  1173      address 10.245.168.14/21
  1174      mtu 1500
  1175      dns-nameservers 192.168.1.1
  1176      dns-nameservers 10.245.168.2 192.168.1.1 10.245.168.2
  1177      dns-sortlist 192.168.1.0/24 10.245.168.0/21 192.168.1.0/24
  1178      dns-sortlist 10.245.168.0/21 192.168.1.0/24
  1179      dns-search juju ubuntu
  1180      dns-search dellstack ubuntu dellstack
  1181  
  1182  dns-search ubuntu juju
  1183  dns-search dellstack ubuntu dellstack`
  1184  
  1185  const networkWithMultipleDNSValuesExpected = `iface eth0 inet manual
  1186  
  1187  auto br-eth0
  1188  iface br-eth0 inet static
  1189      gateway 10.245.168.1
  1190      address 10.245.168.11/21
  1191      mtu 1500
  1192      bridge_ports eth0
  1193      dns-nameservers 10.245.168.2 192.168.1.1
  1194  
  1195  iface eth1 inet manual
  1196  
  1197  auto br-eth1
  1198  iface br-eth1 inet static
  1199      gateway 10.245.168.1
  1200      address 10.245.168.12/21
  1201      mtu 1500
  1202      bridge_ports eth1
  1203      dns-sortlist 192.168.1.0/24 10.245.168.0/21
  1204  
  1205  iface eth2 inet manual
  1206  
  1207  auto br-eth2
  1208  iface br-eth2 inet static
  1209      gateway 10.245.168.1
  1210      address 10.245.168.13/21
  1211      mtu 1500
  1212      bridge_ports eth2
  1213      dns-search juju ubuntu dellstack
  1214  
  1215  iface eth3 inet manual
  1216  
  1217  auto br-eth3
  1218  iface br-eth3 inet static
  1219      gateway 10.245.168.1
  1220      address 10.245.168.14/21
  1221      mtu 1500
  1222      bridge_ports eth3
  1223      dns-nameservers 192.168.1.1 10.245.168.2
  1224      dns-search juju ubuntu dellstack
  1225      dns-sortlist 192.168.1.0/24 10.245.168.0/21`
  1226  
  1227  const networkWithEmptyDNSValuesInitial = `auto eth0
  1228  iface eth0 inet static
  1229      dns-nameservers
  1230      dns-search
  1231      dns-sortlist
  1232      gateway 10.245.168.1
  1233      address 10.245.168.11/21
  1234      mtu 1500
  1235  
  1236  auto eth1
  1237  iface eth1 inet static
  1238      dns-nameservers
  1239      dns-search
  1240      dns-sortlist
  1241      gateway 10.245.168.1
  1242      address 10.245.168.12/21
  1243      mtu 1500
  1244  
  1245  dns-nameservers
  1246  dns-search
  1247  dns-sortlist`
  1248  
  1249  const networkWithEmptyDNSValuesExpected = `iface eth0 inet manual
  1250  
  1251  auto br-eth0
  1252  iface br-eth0 inet static
  1253      gateway 10.245.168.1
  1254      address 10.245.168.11/21
  1255      mtu 1500
  1256      bridge_ports eth0
  1257  
  1258  iface eth1 inet manual
  1259  
  1260  auto br-eth1
  1261  iface br-eth1 inet static
  1262      gateway 10.245.168.1
  1263      address 10.245.168.12/21
  1264      mtu 1500
  1265      bridge_ports eth1`
  1266  
  1267  const networkLP1532167Initial = `auto eth0
  1268  iface eth0 inet manual
  1269      bond-lacp_rate fast
  1270      bond-xmit_hash_policy layer2+3
  1271      bond-miimon 100
  1272      bond-master bond0
  1273      mtu 1500
  1274      bond-mode 802.3ad
  1275  
  1276  auto eth1
  1277  iface eth1 inet manual
  1278      bond-lacp_rate fast
  1279      bond-xmit_hash_policy layer2+3
  1280      bond-miimon 100
  1281      bond-master bond0
  1282      mtu 1500
  1283      bond-mode 802.3ad
  1284  
  1285  auto eth2
  1286  iface eth2 inet manual
  1287      bond-lacp_rate fast
  1288      bond-xmit_hash_policy layer2+3
  1289      bond-miimon 100
  1290      bond-master bond1
  1291      mtu 1500
  1292      bond-mode 802.3ad
  1293  
  1294  auto eth3
  1295  iface eth3 inet manual
  1296      bond-lacp_rate fast
  1297      bond-xmit_hash_policy layer2+3
  1298      bond-miimon 100
  1299      bond-master bond1
  1300      mtu 1500
  1301      bond-mode 802.3ad
  1302  
  1303  auto bond0
  1304  iface bond0 inet static
  1305      gateway 10.38.160.1
  1306      address 10.38.160.24/24
  1307      bond-lacp_rate fast
  1308      bond-xmit_hash_policy layer2+3
  1309      bond-miimon 100
  1310      mtu 1500
  1311      bond-mode 802.3ad
  1312      hwaddress 44:a8:42:41:ab:37
  1313      bond-slaves none
  1314  
  1315  auto bond1
  1316  iface bond1 inet manual
  1317      bond-lacp_rate fast
  1318      bond-xmit_hash_policy layer2+3
  1319      bond-miimon 100
  1320      mtu 1500
  1321      bond-mode 802.3ad
  1322      hwaddress 00:0e:1e:b7:b5:50
  1323      bond-slaves none
  1324  
  1325  auto bond0.1016
  1326  iface bond0.1016 inet static
  1327      address 172.16.0.21/16
  1328      vlan-raw-device bond0
  1329      mtu 1500
  1330      vlan_id 1016
  1331  
  1332  auto bond0.161
  1333  iface bond0.161 inet static
  1334      address 10.38.161.21/24
  1335      vlan-raw-device bond0
  1336      mtu 1500
  1337      vlan_id 161
  1338  
  1339  auto bond0.162
  1340  iface bond0.162 inet static
  1341      address 10.38.162.21/24
  1342      vlan-raw-device bond0
  1343      mtu 1500
  1344      vlan_id 162
  1345  
  1346  auto bond0.163
  1347  iface bond0.163 inet static
  1348      address 10.38.163.21/24
  1349      vlan-raw-device bond0
  1350      mtu 1500
  1351      vlan_id 163
  1352  
  1353  auto bond1.1017
  1354  iface bond1.1017 inet static
  1355      address 172.17.0.21/16
  1356      vlan-raw-device bond1
  1357      mtu 1500
  1358      vlan_id 1017
  1359  
  1360  auto bond1.1018
  1361  iface bond1.1018 inet static
  1362      address 172.18.0.21/16
  1363      vlan-raw-device bond1
  1364      mtu 1500
  1365      vlan_id 1018
  1366  
  1367  auto bond1.1019
  1368  iface bond1.1019 inet static
  1369      address 172.19.0.21/16
  1370      vlan-raw-device bond1
  1371      mtu 1500
  1372      vlan_id 1019
  1373  
  1374  dns-nameservers 10.38.160.10
  1375  dns-search maas`
  1376  
  1377  const networkLP1532167Expected = `auto eth0
  1378  iface eth0 inet manual
  1379      bond-lacp_rate fast
  1380      bond-xmit_hash_policy layer2+3
  1381      bond-miimon 100
  1382      bond-master bond0
  1383      mtu 1500
  1384      bond-mode 802.3ad
  1385  
  1386  auto eth1
  1387  iface eth1 inet manual
  1388      bond-lacp_rate fast
  1389      bond-xmit_hash_policy layer2+3
  1390      bond-miimon 100
  1391      bond-master bond0
  1392      mtu 1500
  1393      bond-mode 802.3ad
  1394  
  1395  auto eth2
  1396  iface eth2 inet manual
  1397      bond-lacp_rate fast
  1398      bond-xmit_hash_policy layer2+3
  1399      bond-miimon 100
  1400      bond-master bond1
  1401      mtu 1500
  1402      bond-mode 802.3ad
  1403  
  1404  auto eth3
  1405  iface eth3 inet manual
  1406      bond-lacp_rate fast
  1407      bond-xmit_hash_policy layer2+3
  1408      bond-miimon 100
  1409      bond-master bond1
  1410      mtu 1500
  1411      bond-mode 802.3ad
  1412  
  1413  auto bond0
  1414  iface bond0 inet manual
  1415      gateway 10.38.160.1
  1416      address 10.38.160.24/24
  1417      bond-lacp_rate fast
  1418      bond-xmit_hash_policy layer2+3
  1419      bond-miimon 100
  1420      mtu 1500
  1421      bond-mode 802.3ad
  1422      hwaddress 44:a8:42:41:ab:37
  1423      bond-slaves none
  1424  
  1425  auto juju-br0
  1426  iface juju-br0 inet static
  1427      gateway 10.38.160.1
  1428      address 10.38.160.24/24
  1429      mtu 1500
  1430      hwaddress 44:a8:42:41:ab:37
  1431      bridge_ports bond0
  1432  
  1433  auto bond1
  1434  iface bond1 inet manual
  1435      bond-lacp_rate fast
  1436      bond-xmit_hash_policy layer2+3
  1437      bond-miimon 100
  1438      mtu 1500
  1439      bond-mode 802.3ad
  1440      hwaddress 00:0e:1e:b7:b5:50
  1441      bond-slaves none
  1442  
  1443  auto bond0.1016
  1444  iface bond0.1016 inet static
  1445      address 172.16.0.21/16
  1446      vlan-raw-device bond0
  1447      mtu 1500
  1448      vlan_id 1016
  1449  
  1450  auto bond0.161
  1451  iface bond0.161 inet static
  1452      address 10.38.161.21/24
  1453      vlan-raw-device bond0
  1454      mtu 1500
  1455      vlan_id 161
  1456  
  1457  auto bond0.162
  1458  iface bond0.162 inet static
  1459      address 10.38.162.21/24
  1460      vlan-raw-device bond0
  1461      mtu 1500
  1462      vlan_id 162
  1463  
  1464  auto bond0.163
  1465  iface bond0.163 inet static
  1466      address 10.38.163.21/24
  1467      vlan-raw-device bond0
  1468      mtu 1500
  1469      vlan_id 163
  1470  
  1471  auto bond1.1017
  1472  iface bond1.1017 inet static
  1473      address 172.17.0.21/16
  1474      vlan-raw-device bond1
  1475      mtu 1500
  1476      vlan_id 1017
  1477  
  1478  auto bond1.1018
  1479  iface bond1.1018 inet static
  1480      address 172.18.0.21/16
  1481      vlan-raw-device bond1
  1482      mtu 1500
  1483      vlan_id 1018
  1484  
  1485  auto bond1.1019
  1486  iface bond1.1019 inet static
  1487      address 172.19.0.21/16
  1488      vlan-raw-device bond1
  1489      mtu 1500
  1490      vlan_id 1019
  1491      dns-nameservers 10.38.160.10
  1492      dns-search maas`
  1493  
  1494  const networkWithExistingSpecificIfaceInitial = `auto lo
  1495  iface lo inet loopback
  1496  
  1497  # Note this has no auto stanza
  1498  iface eth0 inet static
  1499      address 1.2.3.4
  1500      netmask 255.255.255.0
  1501      gateway 4.3.2.1
  1502  
  1503  iface eth1 inet static
  1504      address 1.2.3.4
  1505      netmask 255.255.255.0
  1506      gateway 4.3.2.1`
  1507  
  1508  const networkWithExistingSpecificIfaceExpected = `auto lo
  1509  iface lo inet loopback
  1510  
  1511  iface eth0 inet static
  1512      address 1.2.3.4
  1513      netmask 255.255.255.0
  1514      gateway 4.3.2.1
  1515  
  1516  iface eth1 inet manual
  1517  
  1518  auto juju-br0
  1519  iface juju-br0 inet static
  1520      address 1.2.3.4
  1521      netmask 255.255.255.0
  1522      gateway 4.3.2.1
  1523      bridge_ports eth1`
  1524  
  1525  const networkPartiallyBridgedInitial = `auto lo
  1526  iface lo inet loopback
  1527  
  1528  iface eth0 inet manual
  1529  
  1530  auto br-eth0
  1531  iface br-eth0 inet static
  1532      address 1.2.3.4
  1533      netmask 255.255.255.0
  1534      gateway 4.3.2.1
  1535      bridge_ports eth0
  1536  
  1537  auto eth1
  1538  iface eth1 inet static
  1539      address 1.2.3.5
  1540      netmask 255.255.255.0
  1541      gateway 4.3.2.1`
  1542  
  1543  const networkPartiallyBridgedExpected = `auto lo
  1544  iface lo inet loopback
  1545  
  1546  iface eth0 inet manual
  1547  
  1548  auto br-eth0
  1549  iface br-eth0 inet static
  1550      address 1.2.3.4
  1551      netmask 255.255.255.0
  1552      gateway 4.3.2.1
  1553      bridge_ports eth0
  1554  
  1555  iface eth1 inet manual
  1556  
  1557  auto br-eth1
  1558  iface br-eth1 inet static
  1559      address 1.2.3.5
  1560      netmask 255.255.255.0
  1561      gateway 4.3.2.1
  1562      bridge_ports eth1`