protected void assertThatBridgeIfCommandIsExecuted() {
   String[] expectedCommand =
       new String[] {
         "brctl",
         "addif",
         String.format("pibr%d", instance.getVlanId()),
         String.format(
             "%s.%d", properties.getProperty("vnet.private.interface"), instance.getVlanId())
       };
   assertTrue(stubCommandExecutor.assertCommand(expectedCommand));
 }
 protected void assertThatBridgeDownCommandIsExecuted() {
   String[] expectedCommand =
       new String[] {
         "ip", "link", "set", "dev", String.format("pibr%d", instance.getVlanId()), "down"
       };
   assertTrue(stubCommandExecutor.assertCommand(expectedCommand));
 }
 protected void assertThatVconfigRemoveVlanCommandIsExecuted() {
   String[] expectedCommand =
       new String[] {
         "vconfig",
         "rem",
         String.format(
             "%s.%d", properties.getProperty("vnet.private.interface"), instance.getVlanId())
       };
   assertTrue(stubCommandExecutor.assertCommand(expectedCommand));
 }
 protected void assertThatDomainXmlContainsNecessaryFields(String domainXml) {
   String errorMessage = String.format("Instance: %s, XML: %s", instance, domainXml);
   assertTrue(errorMessage, domainXml.contains(String.format("<name>%s</name>", instanceId)));
   assertTrue(
       errorMessage, domainXml.contains(String.format("<type>%s</type>", instance.getPlatform())));
   assertTrue(
       errorMessage,
       domainXml.contains(
           String.format(
               "<kernel>%s/%s/%s/%s</kernel>",
               properties.getProperty("instances.directory"),
               instance.getUserId(),
               instanceId,
               KERNEL_ID)));
   assertTrue(errorMessage, domainXml.contains("<cmdline> ro</cmdline>"));
   assertTrue(errorMessage, domainXml.contains("<root>/dev/sda1</root>"));
   assertTrue(
       errorMessage,
       domainXml.contains(
           String.format(
               "<source file='%s/%s/%s/%s'/>",
               properties.getProperty("instances.directory"),
               instance.getUserId(),
               instanceId,
               instance.getImageId())));
   assertTrue(
       errorMessage,
       domainXml.contains(
           String.format(
               "<source file='%s/%s/%s/ephemeral'/>",
               properties.getProperty("instances.directory"), instance.getUserId(), instanceId)));
   assertTrue(
       errorMessage,
       domainXml.contains(
           String.format(
               "<source file='%s/%s/%s/swap'/>",
               properties.getProperty("instances.directory"), instance.getUserId(), instanceId)));
   assertTrue(errorMessage, domainXml.contains("<target dev='sda1'/>"));
   assertTrue(errorMessage, domainXml.contains("<target dev='sda2'/>"));
   assertTrue(errorMessage, domainXml.contains("<target dev='sda3'/>"));
   assertTrue(errorMessage, domainXml.contains("<interface type='bridge'>"));
   assertTrue(
       errorMessage,
       domainXml.contains(String.format("<mac address='%s'/>", instance.getPrivateMacAddress())));
   assertTrue(
       errorMessage,
       domainXml.contains(
           String.format(
               "<source bridge='%s'/>",
               VlanAddressUtils.getBridgeNameForVlan(instance.getVlanId()))));
   assertTrue(errorMessage, domainXml.contains("<script path='/etc/xen/scripts/vif-bridge'/>"));
 }
 protected void assertThatBringInterfaceDownCommandIsExecuted() {
   String[] expectedCommand =
       new String[] {
         "ip",
         "link",
         "set",
         "dev",
         String.format(
             "%s.%d", properties.getProperty("vnet.private.interface"), instance.getVlanId()),
         "down"
       };
   assertTrue(stubCommandExecutor.assertCommand(expectedCommand));
 }
 protected void assertThatNewBridgeCommandIsExecuted() {
   String[] expectedCommand =
       new String[] {"brctl", "addbr", String.format("pibr%d", instance.getVlanId())};
   assertTrue(stubCommandExecutor.assertCommand(expectedCommand));
 }