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