You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2013/11/04 15:25:04 UTC

[1/6] Fix checkstyle errors in Nicira NVP plugin

Updated Branches:
  refs/heads/master a196fbc83 -> 256763cf6


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
index 8b5af3c..78465e4 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
@@ -16,8 +16,18 @@
 // under the License.
 package com.cloud.network.resource;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -74,768 +84,769 @@ import com.cloud.network.nicira.NiciraNvpList;
 import com.cloud.network.nicira.SourceNatRule;
 
 public class NiciraNvpResourceTest {
-	NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class);
-	NiciraNvpResource _resource;
-	Map<String,Object> _parameters;
-	
-	@Before
-	public void setUp() throws ConfigurationException {
-		_resource = new NiciraNvpResource() {
-			protected NiciraNvpApi createNiciraNvpApi() {
-				return _nvpApi;
-			}
-		};
-
-		_parameters = new HashMap<String,Object>();
-		_parameters.put("name","nvptestdevice");
-		_parameters.put("ip","127.0.0.1");
-		_parameters.put("adminuser","adminuser");
-		_parameters.put("guid", "aaaaa-bbbbb-ccccc");
-		_parameters.put("zoneId", "blublub");
-		_parameters.put("adminpass","adminpass");
-	}
-	
-	@Test (expected=ConfigurationException.class)
-	public void resourceConfigureFailure() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", Collections.<String,Object>emptyMap());
-	}
-	
-	@Test 
-	public void resourceConfigure() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		verify(_nvpApi).setAdminCredentials("adminuser", "adminpass");
-		verify(_nvpApi).setControllerAddress("127.0.0.1");
-		
-		assertTrue("nvptestdevice".equals(_resource.getName()));
-		
-		/* Pretty lame test, but here to assure this plugin fails 
-		 * if the type name ever changes from L2Networking
-		 */ 
-		assertTrue(_resource.getType() == Host.Type.L2Networking);
-	}
-	
-	@Test
-	public void testInitialization() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		StartupCommand[] sc = _resource.initialize();
-		assertTrue(sc.length ==1);
-		assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
-		assertTrue("nvptestdevice".equals(sc[0].getName()));
-		assertTrue("blublub".equals(sc[0].getDataCenter()));
-	}
-	
-	@Test
-	public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("stable");
-		when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping != null);
-		assertTrue(ping.getHostId() == 42);
-		assertTrue(ping.getHostType() == Host.Type.L2Networking);		
-	}
-
-	@Test
-	public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("unstable");
-		when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping == null);
-	}
-
-	@Test
-	public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("unstable");
-		when(_nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping == null);
-	}
-	
-	@Test
-	public void testRetries() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertTrue(clsa.getResult());
-	}
-	
-	@Test
-	public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertTrue(clsa.getResult());
-		assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
-	}
-
-	@Test
-	public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertFalse(clsa.getResult());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
-		DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
-		assertTrue(dlsa.getResult());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitch((String)any());
-		
-		DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
-		DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
-		assertFalse(dlsa.getResult());
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertTrue(clspa.getResult());
-		assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
-		
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException());
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertFalse(clspa.getResult());		
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
-		
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertFalse(clspa.getResult());		
-		verify(_nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(),  (String) any());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
-		DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) _resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa","bbbb"));
-		assertFalse(dlspa.getResult());
-	}
-	
-	@Test
-	public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any());
-		UpdateLogicalSwitchPortAnswer dlspa = (UpdateLogicalSwitchPortAnswer) _resource.executeRequest(
-				new UpdateLogicalSwitchPortCommand("aaaa","bbbb","cccc","owner","nicname"));
-		assertFalse(dlspa.getResult());
-	}
-	
-	@Test
-	public void testFindLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalSwitchPort> lspl = (NiciraNvpList<LogicalSwitchPort>)mock(NiciraNvpList.class);
-		when(lspl.getResultCount()).thenReturn(1); 
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertTrue(flspa.getResult());
-	}
-
-	@Test
-	public void testFindLogicalSwitchPortNotFound() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalSwitchPort> lspl = (NiciraNvpList<LogicalSwitchPort>)mock(NiciraNvpList.class);
-		when(lspl.getResultCount()).thenReturn(0); 
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertFalse(flspa.getResult());
-	}
-
-	@Test
-	public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertFalse(flspa.getResult());
-	}
-	
-	@Test
-	public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		LogicalRouterPort lrp = mock(LogicalRouterPort.class);
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
-		when(lsp.getUuid()).thenReturn("fffff");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
-		when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertTrue(clra.getResult());
-		assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
-		verify(_nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any());
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-		verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		LogicalRouterPort lrp = mock(LogicalRouterPort.class);
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
-		when(lsp.getUuid()).thenReturn("fffff");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
-		when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
-		when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-		verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
-		verify(_nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff"));
-	}
-	
-	@Test
-	public void testDeleteLogicalRouterApiException() throws ConfigurationException,NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalRouter(eq("aaaaa"));
-		DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) _resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
-		assertFalse(dlspa.getResult());		
-	}
-	
-	@Test
-	public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalRouterPort> list = mock(NiciraNvpList.class);
-		
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
-		when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);
-		
-		ConfigurePublicIpsOnLogicalRouterAnswer answer = 
-				(ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		assertFalse(answer.getResult());
-		
-	}
-	
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-				        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-				        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		final UUID rule0Uuid = UUID.randomUUID();
-		final UUID rule1Uuid = UUID.randomUUID();
-		rulepair[0].setUuid(rule0Uuid);
-		rulepair[1].setUuid(rule1Uuid);
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
-			@Override
-			public boolean matches(Object argument) {
-				UUID uuid = (UUID) argument;
-				if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(0);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertFalse(a.getResult());
-		verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+    NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class);
+    NiciraNvpResource _resource;
+    Map<String,Object> _parameters;
+
+    @Before
+    public void setUp() throws ConfigurationException {
+        _resource = new NiciraNvpResource() {
+            @Override
+            protected NiciraNvpApi createNiciraNvpApi() {
+                return _nvpApi;
+            }
+        };
+
+        _parameters = new HashMap<String,Object>();
+        _parameters.put("name","nvptestdevice");
+        _parameters.put("ip","127.0.0.1");
+        _parameters.put("adminuser","adminuser");
+        _parameters.put("guid", "aaaaa-bbbbb-ccccc");
+        _parameters.put("zoneId", "blublub");
+        _parameters.put("adminpass","adminpass");
+    }
+
+    @Test (expected=ConfigurationException.class)
+    public void resourceConfigureFailure() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", Collections.<String,Object>emptyMap());
+    }
+
+    @Test
+    public void resourceConfigure() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        verify(_nvpApi).setAdminCredentials("adminuser", "adminpass");
+        verify(_nvpApi).setControllerAddress("127.0.0.1");
+
+        assertTrue("nvptestdevice".equals(_resource.getName()));
+
+        /* Pretty lame test, but here to assure this plugin fails
+         * if the type name ever changes from L2Networking
+         */
+        assertTrue(_resource.getType() == Host.Type.L2Networking);
+    }
+
+    @Test
+    public void testInitialization() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        StartupCommand[] sc = _resource.initialize();
+        assertTrue(sc.length ==1);
+        assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
+        assertTrue("nvptestdevice".equals(sc[0].getName()));
+        assertTrue("blublub".equals(sc[0].getDataCenter()));
+    }
+
+    @Test
+    public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("stable");
+        when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping != null);
+        assertTrue(ping.getHostId() == 42);
+        assertTrue(ping.getHostType() == Host.Type.L2Networking);
+    }
+
+    @Test
+    public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("unstable");
+        when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("unstable");
+        when(_nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testRetries() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertTrue(clsa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertTrue(clsa.getResult());
+        assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
+    }
+
+    @Test
+    public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertFalse(clsa.getResult());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+        DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
+        assertTrue(dlsa.getResult());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitch((String)any());
+
+        DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+        DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
+        assertFalse(dlsa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertTrue(clspa.getResult());
+        assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
+
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException());
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertFalse(clspa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
+
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertFalse(clspa.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(),  (String) any());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
+        DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) _resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa","bbbb"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any());
+        UpdateLogicalSwitchPortAnswer dlspa = (UpdateLogicalSwitchPortAnswer) _resource.executeRequest(
+                new UpdateLogicalSwitchPortCommand("aaaa","bbbb","cccc","owner","nicname"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
+        when(lspl.getResultCount()).thenReturn(1);
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertTrue(flspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPortNotFound() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
+        when(lspl.getResultCount()).thenReturn(0);
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertFalse(flspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertFalse(flspa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
+        when(lsp.getUuid()).thenReturn("fffff");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
+        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertTrue(clra.getResult());
+        assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
+        verify(_nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any());
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+        verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
+        when(lsp.getUuid()).thenReturn("fffff");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
+        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
+        when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+        verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
+        verify(_nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff"));
+    }
+
+    @Test
+    public void testDeleteLogicalRouterApiException() throws ConfigurationException,NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalRouter(eq("aaaaa"));
+        DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) _resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalRouterPort> list = mock(NiciraNvpList.class);
+
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+        when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
+        when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);
+
+        ConfigurePublicIpsOnLogicalRouterAnswer answer =
+                (ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
         final UUID rule0Uuid = UUID.randomUUID();
         final UUID rule1Uuid = UUID.randomUUID();
         rulepair[0].setUuid(rule0Uuid);
         rulepair[1].setUuid(rule1Uuid);
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
-			@Override
-			public boolean matches(Object argument) {
-				UUID uuid = (UUID) argument;
-				if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(0);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertFalse(a.getResult());
-		verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterPortRange() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 80, 85 }, "11.11.11.11", new int[] { 80, 85}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		// The expected result is false, Nicira does not support port ranges in DNAT
-		assertFalse(a.getResult());
-
-	}
-
-	@Test
-	public void testGenerateStaticNatRulePair() {
-		NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		assertTrue("DestinationNatRule".equals(rules[0].getType()));
-		assertTrue("SourceNatRule".equals(rules[1].getType()));
-		
-		DestinationNatRule dnr = (DestinationNatRule) rules[0];
-		assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
-		assertTrue(dnr.getToDestinationPort() == null);
-		assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));	
-		
-		SourceNatRule snr = (SourceNatRule) rules[1];
-		assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
-		assertTrue(snr.getToSourcePort() == null);
-		assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
-	}
-
-	@Test
-	public void testGeneratePortForwardingRulePair() {
-		NatRule[] rules = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080,  8080 }, "11.11.11.11", new int[] { 80, 80 }, "tcp" );
-		assertTrue("DestinationNatRule".equals(rules[0].getType()));
-		assertTrue("SourceNatRule".equals(rules[1].getType()));
-		
-		DestinationNatRule dnr = (DestinationNatRule) rules[0];
-		assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
-		assertTrue(dnr.getToDestinationPort() == 8080);
-		assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));	
-		assertTrue(dnr.getMatch().getDestinationPort() == 80 );
-		assertTrue(dnr.getMatch().getEthertype().equals("IPv4") && dnr.getMatch().getProtocol() == 6);
-		
-		SourceNatRule snr = (SourceNatRule) rules[1];
-		assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
-		assertTrue(snr.getToSourcePort() == 80);
-		assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
-		assertTrue(snr.getMatch().getSourcePort() == 8080);
-		assertTrue(snr.getMatch().getEthertype().equals("IPv4") && rules[1].getMatch().getProtocol() == 6);
-	}
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
+            @Override
+            public boolean matches(Object argument) {
+                UUID uuid = (UUID) argument;
+                if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(0);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertFalse(a.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        final UUID rule0Uuid = UUID.randomUUID();
+        final UUID rule1Uuid = UUID.randomUUID();
+        rulepair[0].setUuid(rule0Uuid);
+        rulepair[1].setUuid(rule1Uuid);
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
+            @Override
+            public boolean matches(Object argument) {
+                UUID uuid = (UUID) argument;
+                if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(0);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertFalse(a.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterPortRange() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 80, 85 }, "11.11.11.11", new int[] { 80, 85}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        // The expected result is false, Nicira does not support port ranges in DNAT
+        assertFalse(a.getResult());
+
+    }
+
+    @Test
+    public void testGenerateStaticNatRulePair() {
+        NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        assertTrue("DestinationNatRule".equals(rules[0].getType()));
+        assertTrue("SourceNatRule".equals(rules[1].getType()));
+
+        DestinationNatRule dnr = (DestinationNatRule) rules[0];
+        assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
+        assertTrue(dnr.getToDestinationPort() == null);
+        assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
+
+        SourceNatRule snr = (SourceNatRule) rules[1];
+        assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
+        assertTrue(snr.getToSourcePort() == null);
+        assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
+    }
+
+    @Test
+    public void testGeneratePortForwardingRulePair() {
+        NatRule[] rules = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080,  8080 }, "11.11.11.11", new int[] { 80, 80 }, "tcp" );
+        assertTrue("DestinationNatRule".equals(rules[0].getType()));
+        assertTrue("SourceNatRule".equals(rules[1].getType()));
+
+        DestinationNatRule dnr = (DestinationNatRule) rules[0];
+        assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
+        assertTrue(dnr.getToDestinationPort() == 8080);
+        assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
+        assertTrue(dnr.getMatch().getDestinationPort() == 80 );
+        assertTrue(dnr.getMatch().getEthertype().equals("IPv4") && dnr.getMatch().getProtocol() == 6);
+
+        SourceNatRule snr = (SourceNatRule) rules[1];
+        assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
+        assertTrue(snr.getToSourcePort() == 80);
+        assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
+        assertTrue(snr.getMatch().getSourcePort() == 8080);
+        assertTrue(snr.getMatch().getEthertype().equals("IPv4") && rules[1].getMatch().getProtocol() == 6);
+    }
 }
 


[2/6] Fix checkstyle errors in Nicira NVP plugin

Posted by hu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
index 58c0333..42e436f 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
@@ -16,8 +16,19 @@
 // under the License.
 package com.cloud.network.guru;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
 import java.util.Collections;
 
 import org.junit.Before;
@@ -25,16 +36,13 @@ import org.junit.Test;
 
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.CreateLogicalSwitchAnswer;
 import com.cloud.agent.api.DeleteLogicalSwitchAnswer;
 import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
@@ -61,404 +69,401 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.user.Account;
 import com.cloud.vm.ReservationContext;
 
-import java.util.Arrays;
-
 public class NiciraNvpGuestNetworkGuruTest {
-	PhysicalNetworkDao physnetdao = mock (PhysicalNetworkDao.class);
-	NiciraNvpDao nvpdao = mock(NiciraNvpDao.class);
-	DataCenterDao dcdao = mock(DataCenterDao.class);
-	NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
-	AgentManager agentmgr = mock (AgentManager.class);
-	NetworkOrchestrationService netmgr = mock (NetworkOrchestrationService.class);
-	NetworkModel netmodel = mock (NetworkModel.class);
-
-	HostDao hostdao = mock (HostDao.class);
-	NetworkDao netdao = mock(NetworkDao.class);
-	NiciraNvpGuestNetworkGuru guru;
-	
-	
-	@Before
-	public void setUp() {
-		guru = new NiciraNvpGuestNetworkGuru();
-		((GuestNetworkGuru) guru)._physicalNetworkDao = physnetdao;
-		guru._physicalNetworkDao = physnetdao;
-		guru._niciraNvpDao = nvpdao;
-		guru._dcDao = dcdao;
-		guru._ntwkOfferingSrvcDao = nosd;
-		guru._networkModel = netmodel;
-		guru._hostDao = hostdao;
-		guru._agentMgr = agentmgr;
-		guru._networkDao = netdao;
-		
-		DataCenterVO dc = mock(DataCenterVO.class);
-		when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
-		when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
-		
-		when(dcdao.findById((Long) any())).thenReturn((DataCenterVO) dc);
-	}
-	
-	@Test
-	public void testCanHandle() {
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-	
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
-		
-		assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported TrafficType != Guest
-		when(offering.getTrafficType()).thenReturn(TrafficType.Management);
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported: GuestType Shared
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Shared);
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported: Basic networking
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
-		
-		// Not supported: IsolationMethod != STT
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-	}
-	
-	
-	@Test
-	public void testDesign() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork != null);
-		assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);		
-	}
-	
-	@Test
-	public void testDesignNoElementOnPhysicalNetwork() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);	
-	}
-	
-	@Test
-	public void testDesignNoIsolationMethodSTT() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);			
-	}
-	
-	@Test
-	public void testDesignNoConnectivityInOffering() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);		
-	}
-	
-	@Test
-	public void testImplement() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork != null);		
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-
-	@Test
-	public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getGateway()).thenReturn("10.1.1.1");
-		when(network.getCidr()).thenReturn("10.1.1.0/24");
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork != null);		
-		assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
-		assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-	
-	@Test
-	public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		//when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork == null);		
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-	
-	@Test
-	public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-		when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		when(netdao.findById(42L)).thenReturn(network);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		NetworkProfile implementednetwork = mock(NetworkProfile.class);
- 		when(implementednetwork.getId()).thenReturn(42L);
- 		when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
- 		when(offering.getSpecifyVlan()).thenReturn(false);
- 		
- 		guru.shutdown(implementednetwork, offering);
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-		verify(implementednetwork, times(1)).setBroadcastUri(null);
-	}
+    PhysicalNetworkDao physnetdao = mock(PhysicalNetworkDao.class);
+    NiciraNvpDao nvpdao = mock(NiciraNvpDao.class);
+    DataCenterDao dcdao = mock(DataCenterDao.class);
+    NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
+    AgentManager agentmgr = mock (AgentManager.class);
+    NetworkOrchestrationService netmgr = mock (NetworkOrchestrationService.class);
+    NetworkModel netmodel = mock (NetworkModel.class);
+
+    HostDao hostdao = mock (HostDao.class);
+    NetworkDao netdao = mock(NetworkDao.class);
+    NiciraNvpGuestNetworkGuru guru;
+
+
+    @Before
+    public void setUp() {
+        guru = new NiciraNvpGuestNetworkGuru();
+        ((GuestNetworkGuru) guru)._physicalNetworkDao = physnetdao;
+        guru._physicalNetworkDao = physnetdao;
+        guru._niciraNvpDao = nvpdao;
+        guru._dcDao = dcdao;
+        guru._ntwkOfferingSrvcDao = nosd;
+        guru._networkModel = netmodel;
+        guru._hostDao = hostdao;
+        guru._agentMgr = agentmgr;
+        guru._networkDao = netdao;
+
+        DataCenterVO dc = mock(DataCenterVO.class);
+        when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
+        when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
+
+        when(dcdao.findById((Long) any())).thenReturn(dc);
+    }
+
+    @Test
+    public void testCanHandle() {
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
+
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported TrafficType != Guest
+        when(offering.getTrafficType()).thenReturn(TrafficType.Management);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: GuestType Shared
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Shared);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: Basic networking
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+        assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
+
+        // Not supported: IsolationMethod != STT
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+    }
+
+    @Test
+    public void testDesign() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork != null);
+        assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
+    }
+
+    @Test
+    public void testDesignNoElementOnPhysicalNetwork() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testDesignNoIsolationMethodSTT() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testDesignNoConnectivityInOffering() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testImplement() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork != null);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getGateway()).thenReturn("10.1.1.1");
+        when(network.getCidr()).thenReturn("10.1.1.0/24");
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork != null);
+        assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
+        assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        //when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork == null);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
+        when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+        when(netdao.findById(42L)).thenReturn(network);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        NetworkProfile implementednetwork = mock(NetworkProfile.class);
+        when(implementednetwork.getId()).thenReturn(42L);
+        when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
+        when(offering.getSpecifyVlan()).thenReturn(false);
+
+        guru.shutdown(implementednetwork, offering);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+        verify(implementednetwork, times(1)).setBroadcastUri(null);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
index 8e7245e..9c6f85e 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
@@ -16,7 +16,7 @@
 // under the License.
 package com.cloud.network.nicira;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
@@ -25,14 +25,14 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
 public class NatRuleTest {
-	
+
     @Test
     public void testNatRuleEncoding() {
         Gson gson = new GsonBuilder()
-            .registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
-            .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
-            .create();
-        
+        .registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
+        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+        .create();
+
         DestinationNatRule rn1 = new DestinationNatRule();
         rn1.setToDestinationIpAddress("10.10.10.10");
         rn1.setToDestinationPort(80);
@@ -41,12 +41,12 @@ public class NatRuleTest {
         mr1.setEthertype("IPv4");
         mr1.setProtocol(6);
         rn1.setMatch(mr1);
-        
+
         String jsonString = gson.toJson(rn1);
         NatRule dnr = gson.fromJson(jsonString, NatRule.class);
 
         assertTrue(dnr instanceof DestinationNatRule);
         assertTrue(rn1.equals(dnr));
     }
-	
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 42eb96e..1467d47 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -16,8 +16,12 @@
 // under the License.
 package com.cloud.network.nicira;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -36,271 +40,271 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class NiciraNvpApiTest {
-	NiciraNvpApi _api;
-	HttpClient _client = mock(HttpClient.class);
-	HttpMethod _method;
-	
-	@Before
-	public void setUp() {
-		HttpClientParams hmp = mock(HttpClientParams.class);
-		when (_client.getParams()).thenReturn(hmp);
-		_api = new NiciraNvpApi() {
-			@Override
-			protected HttpClient createHttpClient() {
-				return _client;
-			}
-			
-			@Override
-			protected HttpMethod createMethod(String type, String uri) {
-				return _method;
-			}
-		};
-		_api.setAdminCredentials("admin", "adminpass");
-		_api.setControllerAddress("localhost");
-	}
-	
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.login();
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.login();
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test
-	public void executeMethodTest() throws NiciraNvpApiException {
-		GetMethod gm = mock(GetMethod.class);
-		
-		when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		_api.executeMethod(gm);
-		verify(gm, times(1)).getStatusCode();
-	}
-
-	/* Bit of a roundabout way to ensure that login is called after an un authorized result
-	 * It not possible to properly mock login()
-	 */
-	@Test (expected=NiciraNvpApiException.class)
-	public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
-		GetMethod gm = mock(GetMethod.class);
-		when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-		when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
-		_api.executeMethod(gm);
-		verify(gm, times(1)).getStatusCode();
-	}
-	
-	@Test
-	public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		assertTrue("aaaa".equals(ls.getUuid()));
-		verify(_method, times(1)).releaseConnection();
-		
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		try {
-			ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test
-	public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException());
-		try {
-			_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test
-	public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-		_api.executeDeleteObject("/");
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeDeleteObject("/");
-		} finally {
-			verify(_method, times(1)).releaseConnection();			
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		try {
-			_api.executeDeleteObject("/");
-		} finally {
-			verify(_method, times(1)).releaseConnection();			
-		}	
-	}
-
-	@Test
-	public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		try {
-			_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-	
+    NiciraNvpApi _api;
+    HttpClient _client = mock(HttpClient.class);
+    HttpMethod _method;
+
+    @Before
+    public void setUp() {
+        HttpClientParams hmp = mock(HttpClientParams.class);
+        when (_client.getParams()).thenReturn(hmp);
+        _api = new NiciraNvpApi() {
+            @Override
+            protected HttpClient createHttpClient() {
+                return _client;
+            }
+
+            @Override
+            protected HttpMethod createMethod(String type, String uri) {
+                return _method;
+            }
+        };
+        _api.setAdminCredentials("admin", "adminpass");
+        _api.setControllerAddress("localhost");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.login();
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.login();
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test
+    public void executeMethodTest() throws NiciraNvpApiException {
+        GetMethod gm = mock(GetMethod.class);
+
+        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        _api.executeMethod(gm);
+        verify(gm, times(1)).getStatusCode();
+    }
+
+    /* Bit of a roundabout way to ensure that login is called after an un authorized result
+     * It not possible to properly mock login()
+     */
+    @Test (expected=NiciraNvpApiException.class)
+    public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
+        GetMethod gm = mock(GetMethod.class);
+        when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
+        _api.executeMethod(gm);
+        verify(gm, times(1)).getStatusCode();
+    }
+
+    @Test
+    public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        assertTrue("aaaa".equals(ls.getUuid()));
+        verify(_method, times(1)).releaseConnection();
+
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        try {
+            ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException());
+        try {
+            _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        _api.executeDeleteObject("/");
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeDeleteObject("/");
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        try {
+            _api.executeDeleteObject("/");
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        try {
+            _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
 }


[5/6] git commit: updated refs/heads/master to 256763c

Posted by hu...@apache.org.
Fix checkstyle errors in Nicira NVP plugin


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/256763cf
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/256763cf
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/256763cf

Branch: refs/heads/master
Commit: 256763cf65beb9f9ee4dc74b720f1819017f83d9
Parents: f39b6b2
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Nov 4 15:23:02 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Nov 4 15:24:54 2013 +0100

----------------------------------------------------------------------
 .../cloudstack/nvp/spring-nvp-context.xml       |    2 +-
 ...ortForwardingRulesOnLogicalRouterAnswer.java |   18 +-
 ...rtForwardingRulesOnLogicalRouterCommand.java |   69 +-
 ...ConfigurePublicIpsOnLogicalRouterAnswer.java |   13 +-
 ...onfigurePublicIpsOnLogicalRouterCommand.java |   80 +-
 ...gureStaticNatRulesOnLogicalRouterAnswer.java |   36 +-
 ...ureStaticNatRulesOnLogicalRouterCommand.java |   74 +-
 .../agent/api/CreateLogicalRouterAnswer.java    |    8 +-
 .../agent/api/CreateLogicalRouterCommand.java   |  178 +-
 .../agent/api/CreateLogicalSwitchAnswer.java    |    4 +-
 .../agent/api/CreateLogicalSwitchCommand.java   |   10 +-
 .../api/CreateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/CreateLogicalSwitchPortCommand.java     |   14 +-
 .../agent/api/DeleteLogicalRouterAnswer.java    |    6 +-
 .../agent/api/DeleteLogicalRouterCommand.java   |   37 +-
 .../agent/api/DeleteLogicalSwitchCommand.java   |    6 +-
 .../api/DeleteLogicalSwitchPortCommand.java     |   10 +-
 .../agent/api/FindLogicalSwitchPortAnswer.java  |    6 +-
 .../agent/api/FindLogicalSwitchPortCommand.java |   16 +-
 .../api/UpdateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/UpdateLogicalSwitchPortCommand.java     |   16 +-
 .../api/commands/AddNiciraNvpDeviceCmd.java     |   45 +-
 .../api/commands/DeleteNiciraNvpDeviceCmd.java  |   24 +-
 .../ListNiciraNvpDeviceNetworksCmd.java         |    8 +-
 .../api/commands/ListNiciraNvpDevicesCmd.java   |   14 +-
 .../api/response/NiciraNvpDeviceResponse.java   |   30 +-
 .../com/cloud/network/NiciraNvpDeviceVO.java    |   25 +-
 .../cloud/network/NiciraNvpNicMappingVO.java    |   17 +-
 .../cloud/network/NiciraNvpRouterMappingVO.java |   92 +-
 .../com/cloud/network/dao/NiciraNvpDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpNicMappingDao.java     |    9 +-
 .../network/dao/NiciraNvpNicMappingDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpRouterMappingDao.java  |    2 +-
 .../dao/NiciraNvpRouterMappingDaoImpl.java      |   29 +-
 .../cloud/network/element/NiciraNvpElement.java |   38 +-
 .../network/guru/NiciraNvpGuestNetworkGuru.java |    1 -
 .../network/nicira/ControlClusterStatus.java    |  108 +-
 .../network/nicira/DestinationNatRule.java      |    5 +-
 .../network/nicira/L3GatewayAttachment.java     |   60 +-
 .../network/nicira/LogicalRouterConfig.java     |   53 +-
 .../cloud/network/nicira/LogicalRouterPort.java |  132 +-
 .../com/cloud/network/nicira/LogicalSwitch.java |   28 +-
 .../cloud/network/nicira/LogicalSwitchPort.java |    4 +-
 .../src/com/cloud/network/nicira/Match.java     |  238 ++-
 .../src/com/cloud/network/nicira/NatRule.java   |   14 +-
 .../com/cloud/network/nicira/NiciraNvpApi.java  |  351 ++--
 .../com/cloud/network/nicira/NiciraNvpList.java |    4 +-
 .../com/cloud/network/nicira/NiciraNvpTag.java  |   14 +-
 .../cloud/network/nicira/PatchAttachment.java   |   31 +-
 .../com/cloud/network/nicira/RouterNextHop.java |   34 +-
 .../SingleDefaultRouteImplictRoutingConfig.java |   34 +-
 .../com/cloud/network/nicira/SourceNatRule.java |    4 +-
 .../network/nicira/TransportZoneBinding.java    |    6 +-
 .../com/cloud/network/nicira/VifAttachment.java |    8 +-
 .../network/resource/NiciraNvpResource.java     |  978 +++++------
 .../network/element/NiciraNvpElementTest.java   |   21 +-
 .../guru/NiciraNvpGuestNetworkGuruTest.java     |  811 ++++-----
 .../com/cloud/network/nicira/NatRuleTest.java   |   16 +-
 .../cloud/network/nicira/NiciraNvpApiTest.java  |  542 ++++---
 .../network/resource/NiciraNvpResourceTest.java | 1533 +++++++++---------
 60 files changed, 2993 insertions(+), 2997 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml b/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
index 302b072..8d9813a 100644
--- a/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
+++ b/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
@@ -36,5 +36,5 @@
     <bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
         <property name="name" value="NiciraNvp" />
     </bean>
-    
+
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
index 40bde6c..94931a0 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,18 +17,16 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class ConfigurePortForwardingRulesOnLogicalRouterAnswer extends Answer {
 
-	public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command,
-			Exception e) {
-		super(command, e);
-	}
+    public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
index 5f0ea38..16ef2c4 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -21,40 +21,41 @@ import java.util.List;
 import com.cloud.agent.api.to.PortForwardingRuleTO;
 
 /**
- * 
+ *
  */
 public class ConfigurePortForwardingRulesOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private List<PortForwardingRuleTO> rules;
-
-	public ConfigurePortForwardingRulesOnLogicalRouterCommand(String logicalRouterUuid, List<PortForwardingRuleTO> rules) {
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.rules = rules;
-	}
-	
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-
-	public List<PortForwardingRuleTO> getRules() {
-		return rules;
-	}
-
-	public void setRules(List<PortForwardingRuleTO> rules) {
-		this.rules = rules;
-	}
-
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+
+    private String logicalRouterUuid;
+    private List<PortForwardingRuleTO> rules;
+
+    public ConfigurePortForwardingRulesOnLogicalRouterCommand(String logicalRouterUuid, List<PortForwardingRuleTO> rules) {
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.rules = rules;
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public List<PortForwardingRuleTO> getRules() {
+        return rules;
+    }
+
+    public void setRules(List<PortForwardingRuleTO> rules) {
+        this.rules = rules;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
index 12b1a1f..09a3e7e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
@@ -18,13 +18,12 @@ package com.cloud.agent.api;
 
 public class ConfigurePublicIpsOnLogicalRouterAnswer extends Answer {
 
-	public ConfigurePublicIpsOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, Exception e) {
-		super(command, e);
-	}
+    public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
index 8ee3793..c08f540 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
@@ -19,47 +19,45 @@ package com.cloud.agent.api;
 import java.util.List;
 
 public class ConfigurePublicIpsOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private String l3GatewayServiceUuid;
-	private List<String> publicCidrs;
-	
-	public ConfigurePublicIpsOnLogicalRouterCommand(String logicalRouterUuid,
-			String l3GatewayServiceUuid,
-			List<String> publicCidrs) {
-		super();
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.publicCidrs = publicCidrs;
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
 
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-	
-	public String getL3GatewayServiceUuid() {
-		return l3GatewayServiceUuid;
-	}
-
-	public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
-
-	public List<String> getPublicCidrs() {
-		return publicCidrs;
-	}
-
-	public void setPublicCidrs(List<String> publicCidrs) {
-		this.publicCidrs = publicCidrs;
-	}
-
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+    private String logicalRouterUuid;
+    private String l3GatewayServiceUuid;
+    private List<String> publicCidrs;
+
+    public ConfigurePublicIpsOnLogicalRouterCommand(String logicalRouterUuid, String l3GatewayServiceUuid, List<String> publicCidrs) {
+        super();
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.publicCidrs = publicCidrs;
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public String getL3GatewayServiceUuid() {
+        return l3GatewayServiceUuid;
+    }
+
+    public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
+
+    public List<String> getPublicCidrs() {
+        return publicCidrs;
+    }
+
+    public void setPublicCidrs(List<String> publicCidrs) {
+        this.publicCidrs = publicCidrs;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
index 463dd46..caab316 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,27 +17,25 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class ConfigureStaticNatRulesOnLogicalRouterAnswer extends Answer {
 
-	/**
-	 * @param command
-	 * @param success
-	 * @param details
-	 */
-	public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    /**
+     * @param command
+     * @param success
+     * @param details
+     */
+    public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	/**
-	 * @param command
-	 * @param e
-	 */
-	public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command,
-			Exception e) {
-		super(command, e);
-	}
+    /**
+     * @param command
+     * @param e
+     */
+    public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
index 960f609..5f79ffc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -21,43 +21,43 @@ import java.util.List;
 import com.cloud.agent.api.to.StaticNatRuleTO;
 
 /**
- * 
+ *
  */
 public class ConfigureStaticNatRulesOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private List<StaticNatRuleTO> rules;
-
-	public ConfigureStaticNatRulesOnLogicalRouterCommand(
-			String logicalRouterUuid, List<StaticNatRuleTO> rules) {
-		super();
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.rules = rules;
-
-	}
-
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-
-	public List<StaticNatRuleTO> getRules() {
-		return rules;
-	}
-
-	public void setRules(List<StaticNatRuleTO> rules) {
-		this.rules = rules;
-	}
-
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+
+    private String logicalRouterUuid;
+    private List<StaticNatRuleTO> rules;
+
+    public ConfigureStaticNatRulesOnLogicalRouterCommand(String logicalRouterUuid, List<StaticNatRuleTO> rules) {
+        super();
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.rules = rules;
+
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public List<StaticNatRuleTO> getRules() {
+        return rules;
+    }
+
+    public void setRules(List<StaticNatRuleTO> rules) {
+        this.rules = rules;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
index 4a09e44..72a275b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,7 +17,7 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class CreateLogicalRouterAnswer extends Answer {
 
@@ -26,9 +26,9 @@ public class CreateLogicalRouterAnswer extends Answer {
     public CreateLogicalRouterAnswer(Command command, boolean success,
             String details, String logicalRouterUuid) {
         super(command, success, details);
-        this._logicalRouterUuid = logicalRouterUuid;
+        _logicalRouterUuid = logicalRouterUuid;
     }
-    
+
     public CreateLogicalRouterAnswer(Command command, Exception e) {
         super(command, e);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
index 57440df..1f3f24e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,99 +17,99 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class CreateLogicalRouterCommand extends Command {
-	private String _gatewayServiceUuid;
-	private String _logicalSwitchUuid;
-	private long _vlanId;
-	private String _name;
-	private String _ownerName;
-	private String _publicIpCidr;
-	private String _publicNextHop;
-	private String _internalIpCidr;
-	
-	public CreateLogicalRouterCommand(String gatewayServiceUuid, long vlanId,
-			String logicalSwitchUuid, String name, 
-			String publicIpCidr, String publicNextHop, 
-			String internalIpCidr, String ownerName) {
-		super();
-		this._gatewayServiceUuid = gatewayServiceUuid;
-		this._logicalSwitchUuid = logicalSwitchUuid;
-		this._vlanId = vlanId;
-		this._name = name;
-		this._ownerName = ownerName;
-		this._publicIpCidr = publicIpCidr;
-		this._publicNextHop = publicNextHop;
-		this._internalIpCidr = internalIpCidr;
-	}
-	
+    private String _gatewayServiceUuid;
+    private String _logicalSwitchUuid;
+    private long _vlanId;
+    private String _name;
+    private String _ownerName;
+    private String _publicIpCidr;
+    private String _publicNextHop;
+    private String _internalIpCidr;
+
+    public CreateLogicalRouterCommand(String gatewayServiceUuid, long vlanId,
+            String logicalSwitchUuid, String name,
+            String publicIpCidr, String publicNextHop,
+            String internalIpCidr, String ownerName) {
+        super();
+        _gatewayServiceUuid = gatewayServiceUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _vlanId = vlanId;
+        _name = name;
+        _ownerName = ownerName;
+        _publicIpCidr = publicIpCidr;
+        _publicNextHop = publicNextHop;
+        _internalIpCidr = internalIpCidr;
+    }
+
     @Override
     public boolean executeInSequence() {
         return false;
     }
 
-	public String getGatewayServiceUuid() {
-		return _gatewayServiceUuid;
-	}
-
-	public void setGatewayServiceUuid(String gatewayServiceUuid) {
-		this._gatewayServiceUuid = gatewayServiceUuid;
-	}
-	
-	public String getLogicalSwitchUuid() {
-		return _logicalSwitchUuid;
-	}
-	
-	public void setLogicalSwitchUuid(String logicalSwitchUuid) {
-		_logicalSwitchUuid = logicalSwitchUuid;
-	}
-
-	public long getVlanId() {
-		return _vlanId;
-	}
-
-	public void setVlanId(long vlanId) {
-		this._vlanId = vlanId;
-	}
-
-	public String getName() {
-		return _name;
-	}
-
-	public void setName(String name) {
-		this._name = name;
-	}
-
-	public String getOwnerName() {
-		return _ownerName;
-	}
-
-	public void setOwnerName(String ownerName) {
-		this._ownerName = ownerName;
-	}
-
-	public String getPublicIpCidr() {
-		return _publicIpCidr;
-	}
-
-	public void setPublicIpCidr(String publicIpCidr) {
-		this._publicIpCidr = publicIpCidr;
-	}
-
-	public String getInternalIpCidr() {
-		return _internalIpCidr;
-	}
-
-	public void setInternalIpCidr(String internalIpCidr) {
-		this._internalIpCidr = internalIpCidr;
-	}
-	
-	public String getPublicNextHop() {
-		return _publicNextHop;
-	}
-	
-	public void setPublicNextHop(String publicNextHop) {
-		this._publicNextHop = publicNextHop;
-	}
+    public String getGatewayServiceUuid() {
+        return _gatewayServiceUuid;
+    }
+
+    public void setGatewayServiceUuid(String gatewayServiceUuid) {
+        _gatewayServiceUuid = gatewayServiceUuid;
+    }
+
+    public String getLogicalSwitchUuid() {
+        return _logicalSwitchUuid;
+    }
+
+    public void setLogicalSwitchUuid(String logicalSwitchUuid) {
+        _logicalSwitchUuid = logicalSwitchUuid;
+    }
+
+    public long getVlanId() {
+        return _vlanId;
+    }
+
+    public void setVlanId(long vlanId) {
+        _vlanId = vlanId;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public String getOwnerName() {
+        return _ownerName;
+    }
+
+    public void setOwnerName(String ownerName) {
+        _ownerName = ownerName;
+    }
+
+    public String getPublicIpCidr() {
+        return _publicIpCidr;
+    }
+
+    public void setPublicIpCidr(String publicIpCidr) {
+        _publicIpCidr = publicIpCidr;
+    }
+
+    public String getInternalIpCidr() {
+        return _internalIpCidr;
+    }
+
+    public void setInternalIpCidr(String internalIpCidr) {
+        _internalIpCidr = internalIpCidr;
+    }
+
+    public String getPublicNextHop() {
+        return _publicNextHop;
+    }
+
+    public void setPublicNextHop(String publicNextHop) {
+        _publicNextHop = publicNextHop;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
index d8c864d..753edec 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
@@ -22,9 +22,9 @@ public class CreateLogicalSwitchAnswer extends Answer {
     public CreateLogicalSwitchAnswer(Command command, boolean success,
             String details, String logicalSwitchUuid) {
         super(command, success, details);
-        this._logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
     }
-    
+
     public CreateLogicalSwitchAnswer(Command command, Exception e) {
         super(command, e);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
index 83b03bc..b2a5aaf 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
@@ -17,17 +17,17 @@
 package com.cloud.agent.api;
 
 public class CreateLogicalSwitchCommand extends Command {
-    
+
     private String _transportUuid;
     private String _transportType;
     private String _name;
     private String _ownerName;
 
     public CreateLogicalSwitchCommand(String transportUuid, String transportType, String name, String ownerName) {
-        this._transportUuid = transportUuid;
-        this._transportType = transportType;
-        this._name = name;
-        this._ownerName = ownerName;
+        _transportUuid = transportUuid;
+        _transportType = transportType;
+        _name = name;
+        _ownerName = ownerName;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
index 6c6ce77..8fa7927 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class CreateLogicalSwitchPortAnswer extends Answer {
     public CreateLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class CreateLogicalSwitchPortAnswer extends Answer {
     public CreateLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
index 5a28432..fe3f683 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
@@ -21,15 +21,15 @@ public class CreateLogicalSwitchPortCommand extends Command {
     private String _attachmentUuid;
     private String _ownerName;
     private String _nicName;
-    
+
     public CreateLogicalSwitchPortCommand(String logicalSwitchUuid, String attachmentUuid, String ownerName, String nicName) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._attachmentUuid = attachmentUuid;
-        this._ownerName = ownerName;
-        this._nicName = nicName;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _attachmentUuid = attachmentUuid;
+        _ownerName = ownerName;
+        _nicName = nicName;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
index 8a6bb9f..db07547 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,10 +17,10 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class DeleteLogicalRouterAnswer extends Answer {
-	
+
     public DeleteLogicalRouterAnswer(Command command, boolean success,
             String details) {
         super(command, success, details);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
index 4799f9e..96e2cb9 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,25 +17,26 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class DeleteLogicalRouterCommand extends Command {
-	
-	private String _logicalRouterUuid;
-	
-	public DeleteLogicalRouterCommand(String logicalRouterUuid) {
-		this._logicalRouterUuid = logicalRouterUuid;
-	}
 
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+    private String _logicalRouterUuid;
+
+    public DeleteLogicalRouterCommand(String logicalRouterUuid) {
+        _logicalRouterUuid = logicalRouterUuid;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
-	public String getLogicalRouterUuid() {
-		return _logicalRouterUuid;
-	}
+    public String getLogicalRouterUuid() {
+        return _logicalRouterUuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
index ce6b82b..25aa339 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
@@ -17,11 +17,11 @@
 package com.cloud.agent.api;
 
 public class DeleteLogicalSwitchCommand extends Command {
-    
+
     private String _logicalSwitchUuid;
-    
+
     public DeleteLogicalSwitchCommand(String logicalSwitchUuid) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
index aad6eea..e91a032 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
@@ -19,16 +19,16 @@ package com.cloud.agent.api;
 public class DeleteLogicalSwitchPortCommand extends Command {
     private String _logicalSwitchUuid;
     private String _logicalSwithPortUuid;
-    
+
     public DeleteLogicalSwitchPortCommand(String logicalSwitchUuid, String logicalSwitchPortUuid) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwithPortUuid = logicalSwitchPortUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwithPortUuid = logicalSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwithPortUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
index f54bd85..edc0c5f 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class FindLogicalSwitchPortAnswer extends Answer {
     public FindLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class FindLogicalSwitchPortAnswer extends Answer {
     public FindLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
index cccce67..b737c50 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
@@ -17,25 +17,25 @@
 package com.cloud.agent.api;
 
 public class FindLogicalSwitchPortCommand extends Command {
-	private String _logicalSwitchUuid;
+    private String _logicalSwitchUuid;
     private String _logicalSwitchPortUuid;
-    
+
     public FindLogicalSwitchPortCommand(String logicalSwitchUuid, String logicalSwitchPortUuid) {
-    	this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwitchPortUuid = logicalSwitchPortUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchPortUuid = logicalSwitchPortUuid;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }
 
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
 
-    
+
     @Override
     public boolean executeInSequence() {
         return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
index 3b7fbf7..f4c4130 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class UpdateLogicalSwitchPortAnswer extends Answer {
     public UpdateLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class UpdateLogicalSwitchPortAnswer extends Answer {
     public UpdateLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
index 83ae231..1b8b590 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
@@ -22,16 +22,16 @@ public class UpdateLogicalSwitchPortCommand extends Command {
     private String _attachmentUuid;
     private String _ownerName;
     private String _nicName;
-    
+
     public UpdateLogicalSwitchPortCommand(String logicalSwitchPortUuid, String logicalSwitchUuid, String attachmentUuid, String ownerName, String nicName) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwitchPortUuid = logicalSwitchPortUuid;
-        this._attachmentUuid = attachmentUuid;
-        this._ownerName = ownerName;
-        this._nicName = nicName;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchPortUuid = logicalSwitchPortUuid;
+        _attachmentUuid = attachmentUuid;
+        _ownerName = ownerName;
+        _nicName = nicName;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
index 7f0d87c..937b665 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
@@ -18,12 +18,15 @@ package com.cloud.api.commands;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.api.response.NiciraNvpDeviceResponse;
@@ -42,7 +45,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
     private static final Logger s_logger = Logger.getLogger(AddNiciraNvpDeviceCmd.class.getName());
     private static final String s_name = "addniciranvpdeviceresponse";
     @Inject NiciraNvpElementService _niciraNvpElementService;
-    
+
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
@@ -56,16 +59,16 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
 
     @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="Credentials to access the Nicira Controller API")
     private String username;
-    
+
     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="Credentials to access the Nicira Controller API")
     private String password;
-    
+
     @Parameter(name=ApiConstants.NICIRA_NVP_TRANSPORT_ZONE_UUID, type=CommandType.STRING, required = true, description="The Transportzone UUID configured on the Nicira Controller")
     private String transportzoneuuid;
-    
+
     @Parameter(name=ApiConstants.NICIRA_NVP_GATEWAYSERVICE_UUID, type=CommandType.STRING, required = false, description="The L3 Gateway Service UUID configured on the Nicira Controller")
     private String l3gatewayserviceuuid;
-    
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -85,13 +88,13 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
     public String getPassword() {
         return password;
     }
-    
+
     public String getTransportzoneUuid() {
         return transportzoneuuid;
     }
-    
+
     public String getL3GatewayServiceUuid() {
-    	return l3gatewayserviceuuid;
+        return l3gatewayserviceuuid;
     }
 
     /////////////////////////////////////////////////////
@@ -106,7 +109,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
                 NiciraNvpDeviceResponse response = _niciraNvpElementService.createNiciraNvpDeviceResponse(niciraNvpDeviceVO);
                 response.setObjectName("niciranvpdevice");
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nicira NVP device due to internal error.");
             }
@@ -116,7 +119,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
         }
     }
- 
+
     @Override
     public String getCommandName() {
         return s_name;
@@ -127,13 +130,13 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
         return CallContext.current().getCallingAccount().getId();
     }
 
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_ADD;
-	}
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_ADD;
+    }
 
-	@Override
-	public String getEventDescription() {
-		return "Adding a Nicira Nvp Controller";
-	}
+    @Override
+    public String getEventDescription() {
+        return "Adding a Nicira Nvp Controller";
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
index 948f1bf..6eb6764 100755
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
@@ -18,20 +18,18 @@ package com.cloud.api.commands;
 
 import javax.inject.Inject;
 
-import com.cloud.api.response.NiciraNvpDeviceResponse;
-
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
 
+import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -74,7 +72,7 @@ public class DeleteNiciraNvpDeviceCmd extends BaseAsyncCmd {
             if (result) {
                 SuccessResponse response = new SuccessResponse(getCommandName());
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Nicira device.");
             }
@@ -95,14 +93,14 @@ public class DeleteNiciraNvpDeviceCmd extends BaseAsyncCmd {
         return CallContext.current().getCallingAccount().getId();
     }
 
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_DELETE;
-	}
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_DELETE;
+    }
 
-	@Override
-	public String getEventDescription() {
-		return "Deleting Nicira Nvp Controller";
-	}
+    @Override
+    public String getEventDescription() {
+        return "Deleting Nicira Nvp Controller";
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
index e224cea..53203a7 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
@@ -21,18 +21,18 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import com.cloud.api.response.NiciraNvpDeviceResponse;
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
+
+import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -85,7 +85,7 @@ public class ListNiciraNvpDeviceNetworksCmd extends BaseListCmd {
 
             response.setResponses(networkResponses);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         }  catch (InvalidParameterValueException invalidParamExcp) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
index 81cbb23..3e02e19 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
@@ -21,17 +21,17 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.response.ListResponse;
 import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -48,7 +48,7 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
     private static final String s_name = "listniciranvpdeviceresponse";
     @Inject NiciraNvpElementService _niciraNvpElementService;
 
-   /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
@@ -92,7 +92,7 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
 
             response.setResponses(niciraDevicesResponse);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         }  catch (InvalidParameterValueException invalidParamExcp) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {
@@ -104,5 +104,5 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
     public String getCommandName() {
         return s_name;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
index 097ecd9..d6085e2 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
@@ -16,13 +16,15 @@
 // under the License.
 package com.cloud.api.response;
 
-import com.cloud.network.NiciraNvpDeviceVO;
-import org.apache.cloudstack.api.ApiConstants;
-import com.cloud.serializer.Param;
 import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.EntityReference;
 
+import com.cloud.network.NiciraNvpDeviceVO;
+import com.cloud.serializer.Param;
+
 @EntityReference(value=NiciraNvpDeviceVO.class)
 public class NiciraNvpDeviceResponse extends BaseResponse {
     @SerializedName(ApiConstants.NICIRA_NVP_DEVICE_ID) @Param(description="device id of the Nicire Nvp")
@@ -47,7 +49,7 @@ public class NiciraNvpDeviceResponse extends BaseResponse {
     private String l3GatewayServiceUuid;
 
     public void setId(String nvpDeviceId) {
-        this.id = nvpDeviceId;
+        id = nvpDeviceId;
     }
 
     public void setPhysicalNetworkId(String physicalNetworkId) {
@@ -62,18 +64,16 @@ public class NiciraNvpDeviceResponse extends BaseResponse {
         this.deviceName = deviceName;
     }
 
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
 
+    public void setTransportZoneUuid(String transportZoneUuid) {
+        this.transportZoneUuid = transportZoneUuid;
+    }
 
-	public void setHostName(String hostName) {
-		this.hostName = hostName;
-	}
-
-	public void setTransportZoneUuid(String transportZoneUuid) {
-		this.transportZoneUuid = transportZoneUuid;
-	}
-
-	public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
+    public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
index a1097b9..3832123 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import java.util.UUID;
 
 import javax.persistence.Column;
@@ -27,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="external_nicira_nvp_devices")
 public class NiciraNvpDeviceVO implements InternalIdentity {
@@ -35,25 +35,25 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name="id")
     private long id;
-    
+
     @Column(name="uuid")
     private String uuid;
-    
+
     @Column(name="host_id")
     private long hostId;
-    
+
     @Column(name="physical_network_id")
     private long physicalNetworkId;
-    
+
     @Column(name="provider_name")
     private String providerName;
-    
+
     @Column(name="device_name")
     private String deviceName;
 
-    
+
     public NiciraNvpDeviceVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public NiciraNvpDeviceVO(long hostId, long physicalNetworkId,
@@ -63,13 +63,14 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
         this.physicalNetworkId = physicalNetworkId;
         this.providerName = providerName;
         this.deviceName = deviceName;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
+    @Override
     public long getId() {
         return id;
     }
-    
+
     public String getUuid() {
         return uuid;
     }
@@ -93,5 +94,5 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
     public String getDeviceName() {
         return deviceName;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
index 4c948cc..d9dbb02 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -25,6 +23,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="nicira_nvp_nic_map")
 public class NiciraNvpNicMappingVO implements InternalIdentity {
@@ -36,16 +36,16 @@ public class NiciraNvpNicMappingVO implements InternalIdentity {
 
     @Column(name="logicalswitch")
     private String logicalSwitchUuid;
-    
+
     @Column(name="logicalswitchport")
     private String logicalSwitchPortUuid;
-    
+
     @Column(name="nic")
     private String nicUuid;
-    
-    public NiciraNvpNicMappingVO () {    
+
+    public NiciraNvpNicMappingVO () {
     }
-    
+
     public NiciraNvpNicMappingVO (String logicalSwitchUuid, String logicalSwitchPortUuid, String nicUuid) {
         this.logicalSwitchUuid = logicalSwitchUuid;
         this.logicalSwitchPortUuid = logicalSwitchPortUuid;
@@ -76,8 +76,9 @@ public class NiciraNvpNicMappingVO implements InternalIdentity {
         this.nicUuid = nicUuid;
     }
 
+    @Override
     public long getId() {
         return id;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
index ced880f..1e2a831 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -25,57 +23,59 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="nicira_nvp_router_map")
 public class NiciraNvpRouterMappingVO implements InternalIdentity {
-	//FIXME the ddl for this table should be in one of the upgrade scripts
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	@Column(name="id")
-	private long id;
-	
-	@Column(name="logicalrouter_uuid")
-	private String logicalRouterUuid;
-	
-	@Column(name="network_id")
-	private long networkId;
-	
-	public NiciraNvpRouterMappingVO() {
-	}
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="logicalrouter_uuid")
+    private String logicalRouterUuid;
+
+    @Column(name="network_id")
+    private long networkId;
+
+    public NiciraNvpRouterMappingVO() {
+    }
+
+    public NiciraNvpRouterMappingVO(String logicalRouterUuid, long networkId) {
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.networkId = networkId;
+    }
+
+    public NiciraNvpRouterMappingVO(long id, String logicalRouterUuid, long networkId) {
+        this.id = id;
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.networkId = networkId;
+    }
 
-	public NiciraNvpRouterMappingVO(String logicalRouterUuid, long networkId) {
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.networkId = networkId;
-	}
-	
-	public NiciraNvpRouterMappingVO(long id, String logicalRouterUuid, long networkId) {
-		this.id = id;
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.networkId = networkId;
-	}
+    @Override
+    public long getId() {
+        return id;
+    }
 
-	public long getId() {
-		return id;
-	}
+    public void setId(long id) {
+        this.id = id;
+    }
 
-	public void setId(long id) {
-		this.id = id;
-	}
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
 
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
 
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
+    public long getNetworkId() {
+        return networkId;
+    }
 
-	public long getNetworkId() {
-		return networkId;
-	}
+    public void setNetworkId(long networkId) {
+        this.networkId = networkId;
+    }
 
-	public void setNetworkId(long networkId) {
-		this.networkId = networkId;
-	}
-	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
index 62662c5..5e07246 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
@@ -31,10 +31,10 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Component
 @Local(value=NiciraNvpDao.class)
 public class NiciraNvpDaoImpl extends GenericDaoBase<NiciraNvpDeviceVO, Long>
-        implements NiciraNvpDao {
-    
+implements NiciraNvpDao {
+
     protected final SearchBuilder<NiciraNvpDeviceVO> physicalNetworkIdSearch;
-    
+
     public NiciraNvpDaoImpl() {
         physicalNetworkIdSearch = createSearchBuilder();
         physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
index b463fe8..f693dcb 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
@@ -21,9 +21,12 @@ import com.cloud.utils.db.GenericDao;
 
 public interface NiciraNvpNicMappingDao extends GenericDao<NiciraNvpNicMappingVO, Long> {
 
-    /** find the mapping for a nic 
-     * @param nicUuid the Uuid of a nic attached to a logical switch port
-     * @return NiciraNvpNicMapping for this nic uuid or null if it does not exist
+    /**
+     * find the mapping for a nic
+     * @param nicUuid
+     *            the Uuid of a nic attached to a logical switch port
+     * @return NiciraNvpNicMapping for this nic uuid or null if it does not
+     *         exist
      */
     public NiciraNvpNicMappingVO findByNicUuid(String nicUuid);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
index b40aad4..1a0fcd1 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
@@ -29,16 +29,16 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Component
 @Local(value=NiciraNvpNicMappingDao.class)
 public class NiciraNvpNicMappingDaoImpl extends
-        GenericDaoBase<NiciraNvpNicMappingVO, Long> implements NiciraNvpNicMappingDao {
+GenericDaoBase<NiciraNvpNicMappingVO, Long> implements NiciraNvpNicMappingDao {
 
     protected final SearchBuilder<NiciraNvpNicMappingVO> nicSearch;
-    
+
     public NiciraNvpNicMappingDaoImpl() {
         nicSearch = createSearchBuilder();
         nicSearch.and("nicUuid", nicSearch.entity().getNicUuid(), Op.EQ);
         nicSearch.done();
     }
-    
+
     @Override
     public NiciraNvpNicMappingVO findByNicUuid(String nicUuid) {
         SearchCriteria<NiciraNvpNicMappingVO> sc = nicSearch.create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
index c6c58c8..e822ebd 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
@@ -21,5 +21,5 @@ import com.cloud.utils.db.GenericDao;
 
 public interface NiciraNvpRouterMappingDao extends GenericDao<NiciraNvpRouterMappingVO, Long> {
 
-	public NiciraNvpRouterMappingVO findByNetworkId(long id);
+    public NiciraNvpRouterMappingVO findByNetworkId(long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
index d3192ec..dc41f57 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
@@ -30,20 +30,19 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Local(value=NiciraNvpRouterMappingDao.class)
 public class NiciraNvpRouterMappingDaoImpl extends GenericDaoBase<NiciraNvpRouterMappingVO, Long> implements NiciraNvpRouterMappingDao {
 
-	protected final SearchBuilder<NiciraNvpRouterMappingVO> networkSearch;
-	
-	public NiciraNvpRouterMappingDaoImpl() {
-		networkSearch = createSearchBuilder();
-		networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
-		networkSearch.done();
-	}
-	
-	@Override
-	public NiciraNvpRouterMappingVO findByNetworkId(long id) {
-		SearchCriteria<NiciraNvpRouterMappingVO> sc = networkSearch.create();
-		sc.setParameters("network_id", id);
-		return findOneBy(sc);
-	}
-	
+    protected final SearchBuilder<NiciraNvpRouterMappingVO> networkSearch;
+
+    public NiciraNvpRouterMappingDaoImpl() {
+        networkSearch = createSearchBuilder();
+        networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
+        networkSearch.done();
+    }
+
+    @Override
+    public NiciraNvpRouterMappingVO findByNetworkId(long id) {
+        SearchCriteria<NiciraNvpRouterMappingVO> sc = networkSearch.create();
+        sc.setParameters("network_id", id);
+        return findOneBy(sc);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
index ef8ec86..3e9e16a 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
@@ -30,6 +30,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
 
@@ -128,9 +129,9 @@ import com.cloud.vm.dao.NicDao;
         SourceNatServiceProvider.class, StaticNatServiceProvider.class,
         PortForwardingServiceProvider.class, IpDeployer.class} )
 public class NiciraNvpElement extends AdapterBase implements
-        ConnectivityProvider, SourceNatServiceProvider,
-        PortForwardingServiceProvider, StaticNatServiceProvider,
-        NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
+ConnectivityProvider, SourceNatServiceProvider,
+PortForwardingServiceProvider, StaticNatServiceProvider,
+NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     private static final Logger s_logger = Logger
             .getLogger(NiciraNvpElement.class);
 
@@ -217,8 +218,8 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean implement(Network network, NetworkOffering offering,
             DeployDestination dest, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException,
-            InsufficientCapacityException {
+                    throws ConcurrentOperationException, ResourceUnavailableException,
+                    InsufficientCapacityException {
         s_logger.debug("entering NiciraNvpElement implement function for network "
                 + network.getDisplayText()
                 + " (state "
@@ -247,17 +248,6 @@ public class NiciraNvpElement extends AdapterBase implements
 
         Account owner = context.getAccount();
 
-        /**
-         * Lock the network as we might need to do multiple operations that
-         * should be done only once.
-         */
-//		Network lock = _networkDao.acquireInLockTable(network.getId(),
-//				_networkModel.getNetworkLockTimeout());
-//		if (lock == null) {
-//			throw new ConcurrentOperationException("Unable to lock network "
-//					+ network.getId());
-//		}
-
         // Implement SourceNat immediately as we have al the info already
         if (_networkModel.isProviderSupportServiceInNetwork(
                 network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
@@ -277,9 +267,9 @@ public class NiciraNvpElement extends AdapterBase implements
                     BroadcastDomainType.getValue(network.getBroadcastUri()),
                     "router-" + network.getDisplayText(), publicCidr,
                     sourceNatIp.getGateway(), internalCidr, context
-                            .getDomain().getName()
-                            + "-"
-                            + context.getAccount().getAccountName());
+                    .getDomain().getName()
+                    + "-"
+                    + context.getAccount().getAccountName());
             CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr
                     .easySend(niciraNvpHost.getId(), cmd);
             if (answer.getResult() == false) {
@@ -343,7 +333,7 @@ public class NiciraNvpElement extends AdapterBase implements
                         BroadcastDomainType.getValue(network.getBroadcastUri()),
                         nicVO.getUuid(), context.getDomain().getName() + "-"
                                 + context.getAccount().getAccountName(),
-                        nic.getName());
+                                nic.getName());
                 _agentMgr.easySend(niciraNvpHost.getId(), cmd);
                 return true;
             } else {
@@ -489,7 +479,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean shutdownProviderInstances(
             PhysicalNetworkServiceProvider provider, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException {
+                    throws ConcurrentOperationException, ResourceUnavailableException {
         // Nothing to do here.
         return true;
     }
@@ -618,7 +608,7 @@ public class NiciraNvpElement extends AdapterBase implements
                                 physicalNetworkId, ntwkSvcProvider.getProviderName(),
                                 deviceName);
                         _niciraNvpDao.persist(niciraNvpDevice);
-        
+
                         DetailVO detail = new DetailVO(host.getId(),
                                 "niciranvpdeviceid", String.valueOf(niciraNvpDevice
                                         .getId()));
@@ -818,7 +808,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean applyIps(Network network,
             List<? extends PublicIpAddress> ipAddress, Set<Service> services)
-            throws ResourceUnavailableException {
+                    throws ResourceUnavailableException {
         if (services.contains(Service.SourceNat)) {
             // Only if we need to provide SourceNat we need to configure the logical router
             // SourceNat is required for StaticNat and PortForwarding
@@ -869,7 +859,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean applyStaticNats(Network network,
             List<? extends StaticNat> rules)
-            throws ResourceUnavailableException {
+                    throws ResourceUnavailableException {
         if (!canHandle(network, Service.StaticNat)) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
index 51c59bf..7057915 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
@@ -62,7 +62,6 @@ import com.cloud.user.Account;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkGuru.class)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
index 10890d5..2914d35 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
@@ -17,66 +17,68 @@
 package com.cloud.network.nicira;
 
 public class ControlClusterStatus {
-	private String cluster_status;
-	private Stats node_stats;
-	private Stats lqueue_stats;
-	private Stats lport_stats;
-	private Stats lrouterport_stats;
-	private Stats lswitch_stats;
-	private Stats zone_stats;
-	private Stats lrouter_stats;
-	private Stats security_profile_stats;
-	
-	public String getClusterStatus() {
-		return cluster_status;
-	}
+    private String cluster_status;
+    private Stats node_stats;
+    private Stats lqueue_stats;
+    private Stats lport_stats;
+    private Stats lrouterport_stats;
+    private Stats lswitch_stats;
+    private Stats zone_stats;
+    private Stats lrouter_stats;
+    private Stats security_profile_stats;
 
-	public Stats getNodeStats() {
-		return node_stats;
-	}
+    public String getClusterStatus() {
+        return cluster_status;
+    }
 
-	public Stats getLqueueStats() {
-		return lqueue_stats;
-	}
+    public Stats getNodeStats() {
+        return node_stats;
+    }
 
-	public Stats getLportStats() {
-		return lport_stats;
-	}
+    public Stats getLqueueStats() {
+        return lqueue_stats;
+    }
 
-	public Stats getLrouterportStats() {
-		return lrouterport_stats;
-	}
+    public Stats getLportStats() {
+        return lport_stats;
+    }
 
-	public Stats getLswitchStats() {
-		return lswitch_stats;
-	}
+    public Stats getLrouterportStats() {
+        return lrouterport_stats;
+    }
 
-	public Stats getZoneStats() {
-		return zone_stats;
-	}
+    public Stats getLswitchStats() {
+        return lswitch_stats;
+    }
 
-	public Stats getLrouterStats() {
-		return lrouter_stats;
-	}
+    public Stats getZoneStats() {
+        return zone_stats;
+    }
 
-	public Stats getSecurityProfileStats() {
-		return security_profile_stats;
-	}
+    public Stats getLrouterStats() {
+        return lrouter_stats;
+    }
 
-	public class Stats {
-		private int error_state_count;
-		private int registered_count;
-		private int active_count;
-		
-		public int getErrorStateCount() {
-			return error_state_count;
-		}
-		public int getRegisteredCount() {
-			return registered_count;
-		}
-		public int getActiveCount() {
-			return active_count;
-		}
-		
-	}
+    public Stats getSecurityProfileStats() {
+        return security_profile_stats;
+    }
+
+    public class Stats {
+        private int error_state_count;
+        private int registered_count;
+        private int active_count;
+
+        public int getErrorStateCount() {
+            return error_state_count;
+        }
+
+        public int getRegisteredCount() {
+            return registered_count;
+        }
+
+        public int getActiveCount() {
+            return active_count;
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
index 20afea9..d149c4b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
@@ -19,7 +19,7 @@ package com.cloud.network.nicira;
 public class DestinationNatRule extends NatRule {
     private String toDestinationIpAddress;
     private Integer toDestinationPort;
-    
+
     public DestinationNatRule() {
         setType("DestinationNatRule");
     }
@@ -28,17 +28,14 @@ public class DestinationNatRule extends NatRule {
         return toDestinationIpAddress;
     }
 
-
     public void setToDestinationIpAddress(String toDestinationIpAddress) {
         this.toDestinationIpAddress = toDestinationIpAddress;
     }
 
-
     public Integer getToDestinationPort() {
         return toDestinationPort;
     }
 
-
     public void setToDestinationPort(Integer toDestinationPort) {
         this.toDestinationPort = toDestinationPort;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
index 8b807fd..96d1991 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,36 +17,36 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class L3GatewayAttachment extends Attachment {
-	private String l3_gateway_service_uuid;
-	private String type = "L3GatewayAttachment";
-	private Long vlan_id;
-	
-	public L3GatewayAttachment(String l3_gateway_service_uuid) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-	}
-	
-	public L3GatewayAttachment(String l3_gateway_service_uuid, long vlan_id) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-		this.vlan_id = vlan_id;
-	}
-	
-	public String getL3GatewayServiceUuid() {
-		return l3_gateway_service_uuid;
-	}
-	
-	public void setL3GatewayServiceUuid(String l3_gateway_service_uuid) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-	}
-	
-	public long getVlanId() {
-		return vlan_id;
-	}
-	
-	public void setVlanId(long vlan_id) {
-		this.vlan_id = vlan_id;
-	}
+    private String l3_gateway_service_uuid;
+    private String type = "L3GatewayAttachment";
+    private Long vlan_id;
+
+    public L3GatewayAttachment(String l3_gateway_service_uuid) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+    }
+
+    public L3GatewayAttachment(String l3_gateway_service_uuid, long vlan_id) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+        this.vlan_id = vlan_id;
+    }
+
+    public String getL3GatewayServiceUuid() {
+        return l3_gateway_service_uuid;
+    }
+
+    public void setL3GatewayServiceUuid(String l3_gateway_service_uuid) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+    }
+
+    public long getVlanId() {
+        return vlan_id;
+    }
+
+    public void setVlanId(long vlan_id) {
+        this.vlan_id = vlan_id;
+    }
 
 }


[6/6] git commit: updated refs/heads/master to 256763c

Posted by hu...@apache.org.
Add checkstyle to the build process and enable it for the Nicira NVP plugin


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f39b6b2c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f39b6b2c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f39b6b2c

Branch: refs/heads/master
Commit: f39b6b2c56596f5bd2328c89e402893aa279ce10
Parents: a196fbc
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Nov 4 15:22:12 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Nov 4 15:24:54 2013 +0100

----------------------------------------------------------------------
 parents/checkstyle/pom.xml                      |  7 ++++
 .../src/main/resources/tooling/checkstyle.xml   | 21 ++++++++++++
 plugins/network-elements/nicira-nvp/pom.xml     | 35 ++++++++++++++++++++
 pom.xml                                         |  2 ++
 4 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/parents/checkstyle/pom.xml
----------------------------------------------------------------------
diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml
new file mode 100644
index 0000000..245631b
--- /dev/null
+++ b/parents/checkstyle/pom.xml
@@ -0,0 +1,7 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <name>Apache CloudStack Checkstyle Configuration</name>
+  <groupId>org.apache.cloudstack</groupId>
+  <artifactId>checkstyle</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
----------------------------------------------------------------------
diff --git a/parents/checkstyle/src/main/resources/tooling/checkstyle.xml b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
new file mode 100644
index 0000000..8465383
--- /dev/null
+++ b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+    <module name="FileTabCharacter">
+        <property name="eachLine" value="true"/>
+    </module>
+
+    <module name="RegexpSingleline">
+        <!-- \s matches whitespace character, $ matches end of line. -->
+        <property name="format" value="\s+$"/>
+        <property name="message" value="Line has trailing spaces."/>
+    </module>
+    <module name="TreeWalker">
+       <module name="RedundantImport"/>
+       <module name="UnusedImports"/>
+    </module>
+
+</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/plugins/network-elements/nicira-nvp/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml
index 5030ddf..5c65e6a 100644
--- a/plugins/network-elements/nicira-nvp/pom.xml
+++ b/plugins/network-elements/nicira-nvp/pom.xml
@@ -26,4 +26,39 @@
     <version>4.3.0-SNAPSHOT</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${cs.checkstyle.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.cloudstack</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>tooling/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
+          <excludes>**\/target\/,**\/bin\/</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 82ee75d..b8b2a37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,7 @@
     <cs.target.dir>target</cs.target.dir>
     <cs.daemon.version>1.0.10</cs.daemon.version>
     <cs.jna.version>4.0.0</cs.jna.version>
+    <cs.checkstyle.version>2.10</cs.checkstyle.version>
   </properties>
 
   <distributionManagement>
@@ -174,6 +175,7 @@
     <module>services</module>
     <module>maven-standard</module>
     <module>quickcloud</module>
+    <module>parents/checkstyle</module>
   </modules>
 
   <dependencyManagement>


[4/6] Fix checkstyle errors in Nicira NVP plugin

Posted by hu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
index 897ee06..088cefc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,39 +19,39 @@ package com.cloud.network.nicira;
 import java.util.List;
 
 /**
- * 
+ *
  */
 public class LogicalRouterConfig {
-	private String display_name;
-	private RoutingConfig routing_config;
-	private String type = "LogicalRouterConfig";
-	private String uuid;
+    private String display_name;
+    private RoutingConfig routing_config;
+    private String type = "LogicalRouterConfig";
+    private String uuid;
     private List<NiciraNvpTag> tags;
-	
-	public RoutingConfig getRoutingConfig() {
-		return routing_config;
-	}
-	
-	public void setRoutingConfig(RoutingConfig routing_config) {
-		this.routing_config = routing_config;
-	}
-	
-	public String getDisplayName() {
-		return display_name;
-	}
-	
-	public void setDisplayName(String display_name) {
-		this.display_name = display_name;
-	}
-	
+
+    public RoutingConfig getRoutingConfig() {
+        return routing_config;
+    }
+
+    public void setRoutingConfig(RoutingConfig routing_config) {
+        this.routing_config = routing_config;
+    }
+
+    public String getDisplayName() {
+        return display_name;
+    }
+
+    public void setDisplayName(String display_name) {
+        this.display_name = display_name;
+    }
+
     public String getUuid() {
         return uuid;
     }
-    
+
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
     public List<NiciraNvpTag> getTags() {
         return tags;
     }
@@ -59,6 +59,5 @@ public class LogicalRouterConfig {
     public void setTags(List<NiciraNvpTag> tags) {
         this.tags = tags;
     }
-	
-	
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
index 196106d..112825d 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,72 +19,72 @@ package com.cloud.network.nicira;
 import java.util.List;
 
 /**
- * 
+ *
  */
 public class LogicalRouterPort {
-	private String display_name;
-	private List<NiciraNvpTag> tags;
-	private Integer portno;
-	private boolean admin_status_enabled;
-	private List<String> ip_addresses;
-	private String mac_address;
-	private String type = "LogicalRouterPortConfig";
-	private String uuid;
-	
-	public int getPortno() {
-		return portno;
-	}
-	
-	public void setPortno(int portno) {
-		this.portno = portno;
-	}
-	
-	public boolean isAdminStatusEnabled() {
-		return admin_status_enabled;
-	}
-	
-	public void setAdminStatusEnabled(boolean admin_status_enabled) {
-		this.admin_status_enabled = admin_status_enabled;
-	}
-	
-	public List<String> getIpAddresses() {
-		return ip_addresses;
-	}
-	
-	public void setIpAddresses(List<String> ip_addresses) {
-		this.ip_addresses = ip_addresses;
-	}
-	
-	public String getMacAddress() {
-		return mac_address;
-	}
-	
-	public void setMacAddress(String mac_address) {
-		this.mac_address = mac_address;
-	}
-	
-	public String getDisplayName() {
-		return display_name;
-	}
-
-	public void setDisplayName(String display_name) {
-		this.display_name = display_name;
-	}
-
-	public List<NiciraNvpTag> getTags() {
-		return tags;
-	}
-
-	public void setTags(List<NiciraNvpTag> tags) {
-		this.tags = tags;
-	}
-
-	public String getUuid() {
-		return uuid;
-	}
-
-	public void setUuid(String uuid) {
-		this.uuid = uuid;
-	}
+    private String display_name;
+    private List<NiciraNvpTag> tags;
+    private Integer portno;
+    private boolean admin_status_enabled;
+    private List<String> ip_addresses;
+    private String mac_address;
+    private String type = "LogicalRouterPortConfig";
+    private String uuid;
+
+    public int getPortno() {
+        return portno;
+    }
+
+    public void setPortno(int portno) {
+        this.portno = portno;
+    }
+
+    public boolean isAdminStatusEnabled() {
+        return admin_status_enabled;
+    }
+
+    public void setAdminStatusEnabled(boolean admin_status_enabled) {
+        this.admin_status_enabled = admin_status_enabled;
+    }
+
+    public List<String> getIpAddresses() {
+        return ip_addresses;
+    }
+
+    public void setIpAddresses(List<String> ip_addresses) {
+        this.ip_addresses = ip_addresses;
+    }
+
+    public String getMacAddress() {
+        return mac_address;
+    }
+
+    public void setMacAddress(String mac_address) {
+        this.mac_address = mac_address;
+    }
+
+    public String getDisplayName() {
+        return display_name;
+    }
+
+    public void setDisplayName(String display_name) {
+        this.display_name = display_name;
+    }
+
+    public List<NiciraNvpTag> getTags() {
+        return tags;
+    }
+
+    public void setTags(List<NiciraNvpTag> tags) {
+        this.tags = tags;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
index f565189..f022ff7 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
@@ -29,51 +29,51 @@ public class LogicalSwitch {
     //private RequestQueryParameters _query;
     //private LogicalSwitchRelations _relations;
     private String _schema;
-    
+
     public String getDisplay_name() {
         return display_name;
     }
-    
+
     public void setDisplay_name(String display_name) {
         this.display_name = display_name;
     }
-    
+
     public boolean isPort_isolation_enabled() {
         return port_isolation_enabled;
     }
-    
+
     public void setPort_isolation_enabled(boolean port_isolation_enabled) {
         this.port_isolation_enabled = port_isolation_enabled;
     }
-    
+
     public String getType() {
         return type;
     }
-    
+
     public void setType(String type) {
         this.type = type;
     }
-    
+
     public String getUuid() {
         return uuid;
     }
-    
+
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
     public String get_href() {
         return _href;
     }
-    
+
     public void set_href(String _href) {
         this._href = _href;
     }
-    
+
     public String get_schema() {
         return _schema;
     }
-    
+
     public void set_schema(String _schema) {
         this._schema = _schema;
     }
@@ -93,6 +93,6 @@ public class LogicalSwitch {
     public void setTransport_zones(List<TransportZoneBinding> transport_zones) {
         this.transport_zones = transport_zones;
     }
-    
-    
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
index c571458..aaf5494 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
@@ -29,7 +29,7 @@ public class LogicalSwitchPort {
     private List<String> mirror_targets;
     private String type;
     private String uuid;
-    
+
     public LogicalSwitchPort() {
         super();
     }
@@ -113,5 +113,5 @@ public class LogicalSwitchPort {
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
index f777782..e437344 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,131 +17,117 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class Match {
-	private Integer protocol;
-	private String source_ip_addresses;
-	private String destination_ip_addresses;
-	private Integer source_port;
-	private Integer destination_port;
-	private String ethertype = "IPv4";
-	
-	public Integer getProtocol() {
-		return protocol;
-	}
-	
-	public void setProtocol(Integer protocol) {
-		this.protocol = protocol;
-	}
-	
-	public Integer getSourcePort() {
-		return source_port;
-	}
-	
-	public void setSourcePort(Integer source_port) {
-		this.source_port = source_port;
-	}
-		
-	public Integer getDestinationPort() {
-		return destination_port;
-	}
-	
-	public void setDestinationPort(Integer destination_port) {
-		this.destination_port = destination_port;
-	}
-		
-	public String getEthertype() {
-		return ethertype;
-	}
-	
-	public void setEthertype(String ethertype) {
-		this.ethertype = ethertype;
-	}
-
-	public String getSourceIpAddresses() {
-		return source_ip_addresses;
-	}
-
-	public void setSourceIpAddresses(String source_ip_addresses) {
-		this.source_ip_addresses = source_ip_addresses;
-	}
-
-	public String getDestinationIpAddresses() {
-		return destination_ip_addresses;
-	}
-
-	public void setDestinationIpAddresses(String destination_ip_addresses) {
-		this.destination_ip_addresses = destination_ip_addresses;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime
-				* result
-				+ ((destination_ip_addresses == null) ? 0
-						: destination_ip_addresses.hashCode());
-		result = prime
-				* result
-				+ ((destination_port == null) ? 0 : destination_port
-						.hashCode());
-		result = prime * result
-				+ ((ethertype == null) ? 0 : ethertype.hashCode());
-		result = prime * result
-				+ ((protocol == null) ? 0 : protocol.hashCode());
-		result = prime
-				* result
-				+ ((source_ip_addresses == null) ? 0 : source_ip_addresses
-						.hashCode());
-		result = prime * result
-				+ ((source_port == null) ? 0 : source_port.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		Match other = (Match) obj;
-		if (destination_ip_addresses == null) {
-			if (other.destination_ip_addresses != null)
-				return false;
-		} else if (!destination_ip_addresses
-				.equals(other.destination_ip_addresses))
-			return false;
-		if (destination_port == null) {
-			if (other.destination_port != null)
-				return false;
-		} else if (!destination_port.equals(other.destination_port))
-			return false;
-		if (ethertype == null) {
-			if (other.ethertype != null)
-				return false;
-		} else if (!ethertype.equals(other.ethertype))
-			return false;
-		if (protocol == null) {
-			if (other.protocol != null)
-				return false;
-		} else if (!protocol.equals(other.protocol))
-			return false;
-		if (source_ip_addresses == null) {
-			if (other.source_ip_addresses != null)
-				return false;
-		} else if (!source_ip_addresses.equals(other.source_ip_addresses))
-			return false;
-		if (source_port == null) {
-			if (other.source_port != null)
-				return false;
-		} else if (!source_port.equals(other.source_port))
-			return false;
-		return true;
-	}
-	
-	
+    private Integer protocol;
+    private String source_ip_addresses;
+    private String destination_ip_addresses;
+    private Integer source_port;
+    private Integer destination_port;
+    private String ethertype = "IPv4";
+
+    public Integer getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(Integer protocol) {
+        this.protocol = protocol;
+    }
+
+    public Integer getSourcePort() {
+        return source_port;
+    }
+
+    public void setSourcePort(Integer source_port) {
+        this.source_port = source_port;
+    }
+
+    public Integer getDestinationPort() {
+        return destination_port;
+    }
+
+    public void setDestinationPort(Integer destination_port) {
+        this.destination_port = destination_port;
+    }
+
+    public String getEthertype() {
+        return ethertype;
+    }
+
+    public void setEthertype(String ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    public String getSourceIpAddresses() {
+        return source_ip_addresses;
+    }
+
+    public void setSourceIpAddresses(String source_ip_addresses) {
+        this.source_ip_addresses = source_ip_addresses;
+    }
+
+    public String getDestinationIpAddresses() {
+        return destination_ip_addresses;
+    }
+
+    public void setDestinationIpAddresses(String destination_ip_addresses) {
+        this.destination_ip_addresses = destination_ip_addresses;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((destination_ip_addresses == null) ? 0 : destination_ip_addresses.hashCode());
+        result = prime * result + ((destination_port == null) ? 0 : destination_port.hashCode());
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
+        result = prime * result + ((source_ip_addresses == null) ? 0 : source_ip_addresses.hashCode());
+        result = prime * result + ((source_port == null) ? 0 : source_port.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Match other = (Match) obj;
+        if (destination_ip_addresses == null) {
+            if (other.destination_ip_addresses != null)
+                return false;
+        } else if (!destination_ip_addresses.equals(other.destination_ip_addresses))
+            return false;
+        if (destination_port == null) {
+            if (other.destination_port != null)
+                return false;
+        } else if (!destination_port.equals(other.destination_port))
+            return false;
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        if (protocol == null) {
+            if (other.protocol != null)
+                return false;
+        } else if (!protocol.equals(other.protocol))
+            return false;
+        if (source_ip_addresses == null) {
+            if (other.source_ip_addresses != null)
+                return false;
+        } else if (!source_ip_addresses.equals(other.source_ip_addresses))
+            return false;
+        if (source_port == null) {
+            if (other.source_port != null)
+                return false;
+        } else if (!source_port.equals(other.source_port))
+            return false;
+        return true;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
index 93de51e..f33f249 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,7 +19,7 @@ package com.cloud.network.nicira;
 import java.util.UUID;
 
 /**
- * 
+ *
  */
 public abstract class NatRule {
     protected Match match;
@@ -53,15 +53,15 @@ public abstract class NatRule {
     public void setType(String type) {
         this.type = type;
     }
-    
+
     public int getOrder() {
         return order;
     }
-    
+
     public void setOrder(int order) {
         this.order = order;
     }
-    
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -101,7 +101,7 @@ public abstract class NatRule {
             return false;
         return true;
     }
-    
+
     public boolean equalsIgnoreUuid(Object obj) {
         if (this == obj)
             return true;
@@ -124,6 +124,6 @@ public abstract class NatRule {
             return false;
         return true;
     }
-    
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
index 12fa6c0..ea69a09 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
@@ -75,103 +75,103 @@ public class NiciraNvpApi {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpApi.class);
     private final static String _protocol = "https";
     private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
-    
+
     private String _name;
     private String _host;
     private String _adminuser;
     private String _adminpass;
-    
+
     private HttpClient _client;
     private String _nvpversion;
-    
+
     private Gson _gson;
-    
+
     /* This factory method is protected so we can extend this
      * in the unittests.
      */
     protected HttpClient createHttpClient() {
-    	return new HttpClient(s_httpClientManager);
+        return new HttpClient(s_httpClientManager);
     }
-    
+
     protected HttpMethod createMethod(String type, String uri) throws NiciraNvpApiException {
-    	String url;
+        String url;
         try {
             url = new URL(_protocol, _host, uri).toString();
         } catch (MalformedURLException e) {
             s_logger.error("Unable to build Nicira API URL", e);
             throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
         }
-        
+
         if ("post".equalsIgnoreCase(type)) {
-        	return new PostMethod(url);    	
+            return new PostMethod(url);
         }
         else if ("get".equalsIgnoreCase(type)) {
-        	return new GetMethod(url);
+            return new GetMethod(url);
         }
         else if ("delete".equalsIgnoreCase(type)) {
-        	return new DeleteMethod(url);
+            return new DeleteMethod(url);
         }
         else if ("put".equalsIgnoreCase(type)) {
-        	return new PutMethod(url);
+            return new PutMethod(url);
         }
         else {
-        	throw new NiciraNvpApiException("Requesting unknown method type");
+            throw new NiciraNvpApiException("Requesting unknown method type");
         }
     }
 
     public NiciraNvpApi() {
         _client = createHttpClient();
         _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-        
-        try {             
+
+        try {
             // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
             Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), 443));
         } catch (IOException e) {
             s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
         }
-        
+
         _gson = new GsonBuilder()
-                .registerTypeAdapter(NatRule.class, new NatRuleAdapter())
-                .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
-                .create();
-        
+        .registerTypeAdapter(NatRule.class, new NatRuleAdapter())
+        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+        .create();
+
     }
-    
+
     public void setControllerAddress(String address) {
-    	this._host = address;
+        _host = address;
     }
-    
+
     public void setAdminCredentials(String username, String password) {
-    	this._adminuser = username;
-    	this._adminpass = password;
+        _adminuser = username;
+        _adminpass = password;
     }
-    
+
     /**
-     * Logs into the Nicira API. The cookie is stored in the <code>_authcookie<code> variable.
+     * Logs into the Nicira API. The cookie is stored in the
+     * <code>_authcookie<code> variable.
      * <p>
      * The method returns false if the login failed or the connection could not be made.
-     * 
      */
     protected void login() throws NiciraNvpApiException {
         String url;
-        
+
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         try {
             url = new URL(_protocol, _host, "/ws.v1/login").toString();
         } catch (MalformedURLException e) {
             s_logger.error("Unable to build Nicira API URL", e);
             throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
         }
-        
+
         PostMethod pm = new PostMethod(url);
         pm.addParameter("username", _adminuser);
         pm.addParameter("password", _adminpass);
-        
+
         try {
             _client.executeMethod(pm);
         } catch (HttpException e) {
@@ -181,25 +181,25 @@ public class NiciraNvpApi {
         } finally {
             pm.releaseConnection();
         }
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_OK) {
             s_logger.error("Nicira NVP API login failed : " + pm.getStatusText());
             throw new NiciraNvpApiException("Nicira NVP API login failed " + pm.getStatusText());
         }
-        
+
         // Extract the version for later use
         if (pm.getResponseHeader("Server") != null) {
             _nvpversion = pm.getResponseHeader("Server").getValue();
             s_logger.debug("NVP Controller reports version " + _nvpversion);
         }
-        
+
         // Success; the cookie required for login is kept in _client
     }
-    
+
     public LogicalSwitch createLogicalSwitch(LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch";
         LogicalSwitch createdLogicalSwitch = executeCreateObject(logicalSwitch, new TypeToken<LogicalSwitch>(){}.getType(), uri, Collections.<String,String>emptyMap());
-        
+
         return createdLogicalSwitch;
     }
 
@@ -207,11 +207,11 @@ public class NiciraNvpApi {
         String uri = "/ws.v1/lswitch/" + uuid;
         executeDeleteObject(uri);
     }
-    
+
     public LogicalSwitchPort createLogicalSwitchPort(String logicalSwitchUuid, LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
         LogicalSwitchPort createdLogicalSwitchPort = executeCreateObject(logicalSwitchPort, new TypeToken<LogicalSwitchPort>(){}.getType(), uri, Collections.<String,String>emptyMap());;
-        
+
         return createdLogicalSwitchPort;
     }
 
@@ -219,28 +219,28 @@ public class NiciraNvpApi {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment";
         executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void deleteLogicalSwitchPort(String logicalSwitchUuid, String logicalSwitchPortUuid) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid;
         executeDeleteObject(uri);
     }
-    
+
     public String findLogicalSwitchPortUuidByVifAttachmentUuid(String logicalSwitchUuid, String vifAttachmentUuid) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_vif_uuid", vifAttachmentUuid);
         params.put("fields", "uuid");
-            
+
         NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>(){}.getType(), uri, params);
-                
+
         if (lspl == null || lspl.getResultCount() != 1) {
             throw new NiciraNvpApiException("Unexpected response from API");
         }
-        
+
         LogicalSwitchPort lsp = lspl.getResults().get(0);
         return lsp.getUuid();
     }
-    
+
     public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException {
         String uri = "/ws.v1/control-cluster/status";
         ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>(){}.getType(), uri, null);
@@ -253,118 +253,118 @@ public class NiciraNvpApi {
         Map<String,String> params = new HashMap<String,String>();
         params.put("uuid", logicalSwitchPortUuid);
         params.put("fields", "uuid");
-            
+
         NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>(){}.getType(), uri, params);
-                
+
         if (lspl == null ) {
             throw new NiciraNvpApiException("Unexpected response from API");
         }
-        
+
         return lspl;
     }
-    
+
     public LogicalRouterConfig createLogicalRouter(LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter";
-    	
-    	LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
-    	
-    	return lrc;
+        String uri = "/ws.v1/lrouter";
+
+        LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
+
+        return lrc;
     }
 
     public void deleteLogicalRouter(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
+
+        executeDeleteObject(uri);
     }
-    
+
     public LogicalRouterPort createLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
-    	
-    	LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>(){}.getType(), uri, Collections.<String,String>emptyMap());
-    	return lrp;    	
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+
+        LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        return lrp;
     }
-    
+
     public void deleteLogicalRouterPort(String logicalRouterUuid, String logicalRouterPortUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPortUuid;
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPortUuid;
+
+        executeDeleteObject(uri);
     }
 
     public void modifyLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPort.getUuid();
-    	
-    	executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPort.getUuid();
+
+        executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void modifyLogicalRouterPortAttachment(String logicalRouterUuid, String logicalRouterPortUuid, Attachment attachment) throws NiciraNvpApiException {
         String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid + "/attachment";
         executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public NatRule createLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
-    	
-    	return executeCreateObject(natRule, new TypeToken<NatRule>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
+
+        return executeCreateObject(natRule, new TypeToken<NatRule>(){}.getType(), uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void modifyLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
-    	
-    	executeUpdateObject(natRule, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
+
+        executeUpdateObject(natRule, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void deleteLogicalRouterNatRule(String logicalRouterUuid, UUID natRuleUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
+
+        executeDeleteObject(uri);
     }
-    
+
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(String logicalRouterUuid, String gatewayServiceUuid, long vlanId) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_gwsvc_uuid", gatewayServiceUuid);
         params.put("attachment_vlan", "0");
         params.put("fields","*");
-        
+
         return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
     }
-    
+
     public LogicalRouterConfig findOneLogicalRouterByUuid(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
-    	
-    	return executeRetrieveObject(new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
+
+        return executeRetrieveObject(new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void updateLogicalRouterPortConfig(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
-    	
-    	executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
+
+        executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public NiciraNvpList<NatRule> findNatRulesByLogicalRouterUuid(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
         Map<String,String> params = new HashMap<String,String>();
         params.put("fields","*");
-        
-    	return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>(){}.getType(), uri, params);
+
+        return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>(){}.getType(), uri, params);
     }
-    
+
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(String logicalRouterUuid, String l3GatewayServiceUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
-    	Map<String,String> params = new HashMap<String,String>();
-    	params.put("fields", "*");
-    	params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
-    	
-    	return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
-    }
-    
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+        Map<String,String> params = new HashMap<String,String>();
+        params.put("fields", "*");
+        params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
+
+        return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
+    }
+
     protected <T> void executeUpdateObject(T newObject, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         PutMethod pm = (PutMethod) createMethod("put", uri);
         pm.setRequestHeader("Content-Type", "application/json");
         try {
@@ -373,9 +373,9 @@ public class NiciraNvpApi {
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
-                
+
         executeMethod(pm);
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_OK) {
             String errorMessage = responseToErrorMessage(pm);
             pm.releaseConnection();
@@ -384,14 +384,14 @@ public class NiciraNvpApi {
         }
         pm.releaseConnection();
     }
-    
+
     protected <T> T executeCreateObject(T newObject, Type returnObjectType, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         PostMethod pm = (PostMethod) createMethod("post", uri);
         pm.setRequestHeader("Content-Type", "application/json");
         try {
@@ -400,16 +400,16 @@ public class NiciraNvpApi {
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
-                
+
         executeMethod(pm);
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_CREATED) {
             String errorMessage = responseToErrorMessage(pm);
             pm.releaseConnection();
             s_logger.error("Failed to create object : " + errorMessage);
             throw new NiciraNvpApiException("Failed to create object : " + errorMessage);
         }
-        
+
         T result;
         try {
             result = (T)_gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
@@ -418,22 +418,22 @@ public class NiciraNvpApi {
         } finally {
             pm.releaseConnection();
         }
-        
-        return result;        
+
+        return result;
     }
-    
+
     protected void executeDeleteObject(String uri) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-           
+
         DeleteMethod dm = (DeleteMethod) createMethod("delete", uri);
         dm.setRequestHeader("Content-Type", "application/json");
-                
+
         executeMethod(dm);
-        
+
         if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
             String errorMessage = responseToErrorMessage(dm);
             dm.releaseConnection();
@@ -442,33 +442,33 @@ public class NiciraNvpApi {
         }
         dm.releaseConnection();
     }
-    
+
     protected <T> T executeRetrieveObject(Type returnObjectType, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-            
+
         GetMethod gm = (GetMethod) createMethod("get", uri);
         gm.setRequestHeader("Content-Type", "application/json");
         if (parameters != null && !parameters.isEmpty()) {
-	        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
-	        for (Entry<String,String> e : parameters.entrySet()) {
-	            nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
-	        }
-	        gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
+            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
+            for (Entry<String,String> e : parameters.entrySet()) {
+                nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
+            }
+            gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
         }
-                
+
         executeMethod(gm);
-        
+
         if (gm.getStatusCode() != HttpStatus.SC_OK) {
             String errorMessage = responseToErrorMessage(gm);
             gm.releaseConnection();
             s_logger.error("Failed to retrieve object : " + errorMessage);
             throw new NiciraNvpApiException("Failed to retrieve object : " + errorMessage);
         }
-            
+
         T returnValue;
         try {
             returnValue = (T)_gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
@@ -480,7 +480,7 @@ public class NiciraNvpApi {
         }
         return returnValue;
     }
-    
+
     protected void executeMethod(HttpMethodBase method) throws NiciraNvpApiException {
         try {
             _client.executeMethod(method);
@@ -497,13 +497,13 @@ public class NiciraNvpApi {
         } catch (IOException e) {
             s_logger.error("IOException caught while trying to connect to the Nicira NVP Controller", e);
             method.releaseConnection();
-            throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);            
+            throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);
         }
     }
-    
+
     private String responseToErrorMessage(HttpMethodBase method) {
         assert method.isRequestSent() : "no use getting an error message unless the request is sent";
-        
+
         if ("text/html".equals(method.getResponseHeader("Content-Type").getValue())) {
             // The error message is the response content
             // Safety margin of 1024 characters, anything longer is probably useless
@@ -514,38 +514,41 @@ public class NiciraNvpApi {
                 s_logger.debug("Error while loading response body", e);
             }
         }
-        
+
         // The default
         return method.getStatusText();
     }
-    
-    /* The Nicira controller uses a self-signed certificate. The 
+
+    /* The Nicira controller uses a self-signed certificate. The
      * TrustingProtocolSocketFactory will accept any provided
-     * certificate when making an SSL connection to the SDN 
+     * certificate when making an SSL connection to the SDN
      * Manager
      */
     private class TrustingProtocolSocketFactory implements SecureProtocolSocketFactory {
 
         private SSLSocketFactory ssf;
-        
+
         public TrustingProtocolSocketFactory() throws IOException {
             // Create a trust manager that does not validate certificate chains
             TrustManager[] trustAllCerts = new TrustManager[] {
-                new X509TrustManager() {
-                    public X509Certificate[] getAcceptedIssuers() {
-                        return null;
-                    }
-         
-                    public void checkClientTrusted(X509Certificate[] certs, String authType) {
-                        // Trust always
-                    }
-         
-                    public void checkServerTrusted(X509Certificate[] certs, String authType) {
-                        // Trust always
+                    new X509TrustManager() {
+                        @Override
+                        public X509Certificate[] getAcceptedIssuers() {
+                            return null;
+                        }
+
+                        @Override
+                        public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                            // Trust always
+                        }
+
+                        @Override
+                        public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                            // Trust always
+                        }
                     }
-                }
             };
-         
+
             try {
                 // Install the all-trusting trust manager
                 SSLContext sc = SSLContext.getInstance("SSL");
@@ -557,10 +560,10 @@ public class NiciraNvpApi {
                 throw new IOException(e);
             }
         }
-        
+
         @Override
         public Socket createSocket(String host, int port) throws IOException,
-                UnknownHostException {
+        UnknownHostException {
             return ssf.createSocket(host, port);
         }
 
@@ -592,21 +595,19 @@ public class NiciraNvpApi {
             }
         }
 
-        
+
     }
-    
+
     public static class NatRuleAdapter implements JsonDeserializer<NatRule> {
 
         @Override
         public NatRule deserialize(JsonElement jsonElement, Type type,
                 JsonDeserializationContext context) throws JsonParseException {
             JsonObject jsonObject = jsonElement.getAsJsonObject();
-            NatRule natRule = null;
-            
             if (!jsonObject.has("type")) {
                 throw new JsonParseException("Deserializing as a NatRule, but no type present in the json object");
             }
-            
+
             String natRuleType = jsonObject.get("type").getAsString();
             if ("SourceNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, SourceNatRule.class);
@@ -614,7 +615,7 @@ public class NiciraNvpApi {
             else if ("DestinationNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, DestinationNatRule.class);
             }
-            
+
             throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\"");
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
index c97e40e..9d78e84 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
@@ -37,9 +37,9 @@ public class NiciraNvpList<T> {
     public void setResultCount(int result_count) {
         this.result_count = result_count;
     }
-    
+
     public boolean isEmpty() {
-    	return result_count == 0;
+        return result_count == 0;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
index 157c3b5..a5dd3bd 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
@@ -22,9 +22,9 @@ public class NiciraNvpTag {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpTag.class);
     private String scope;
     private String tag;
-    
+
     public NiciraNvpTag() {}
-    
+
     public NiciraNvpTag(String scope, String tag) {
         this.scope = scope;
         if (tag.length() > 40) {
@@ -34,19 +34,19 @@ public class NiciraNvpTag {
             this.tag = tag;
         }
     }
-    
+
     public String getScope() {
         return scope;
     }
-    
+
     public void setScope(String scope) {
         this.scope = scope;
     }
-    
+
     public String getTag() {
         return tag;
     }
-    
+
     public void setTag(String tag) {
         if (tag.length() > 40) {
             s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters");
@@ -55,5 +55,5 @@ public class NiciraNvpTag {
             this.tag = tag;
         }
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
index e57c249..137f071 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,23 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class PatchAttachment extends Attachment {
-	private final String type = "PatchAttachment";
-	private String peer_port_uuid;
-	
-	public PatchAttachment(String peerPortUuid) {
-		this.peer_port_uuid = peerPortUuid;
-	}
+    private final String type = "PatchAttachment";
+    private String peer_port_uuid;
+
+    public PatchAttachment(String peerPortUuid) {
+        peer_port_uuid = peerPortUuid;
+    }
+
+    public String getPeerPortUuid() {
+        return peer_port_uuid;
+    }
 
-	public String getPeerPortUuid() {
-		return peer_port_uuid;
-	}
+    public void setPeerPortUuid(String peerPortUuid) {
+        peer_port_uuid = peerPortUuid;
+    }
 
-	public void setPeerPortUuid(String peerPortUuid) {
-		this.peer_port_uuid = peerPortUuid;
-	}
-	
-	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
index c018af3..a204e55 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,22 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class RouterNextHop {
-	private String gateway_ip_address;
-	private String type = "RouterNextHop";
-	
-	public RouterNextHop(String gatewayIpAddress) {
-		this.gateway_ip_address = gatewayIpAddress;
-	}
-		
-	public String getGatewayIpAddress() {
-		return gateway_ip_address;
-	}
-	
-	public void setGatewayIpAddress(String gateway_ip_address) {
-		this.gateway_ip_address = gateway_ip_address;
-	}
-		
+    private String gateway_ip_address;
+    private String type = "RouterNextHop";
+
+    public RouterNextHop(String gatewayIpAddress) {
+        gateway_ip_address = gatewayIpAddress;
+    }
+
+    public String getGatewayIpAddress() {
+        return gateway_ip_address;
+    }
+
+    public void setGatewayIpAddress(String gateway_ip_address) {
+        this.gateway_ip_address = gateway_ip_address;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
index b4eda44..1228deb 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,22 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class SingleDefaultRouteImplictRoutingConfig extends RoutingConfig {
-	public RouterNextHop default_route_next_hop;
-	public String type = "SingleDefaultRouteImplicitRoutingConfig";
-	
-	public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
-		default_route_next_hop = routerNextHop;
-	}
-	
-	public RouterNextHop getDefaultRouteNextHop() {
-		return default_route_next_hop;
-	}
-	
-	public void setDefaultRouteNextHop(RouterNextHop default_route_next_hop) {
-		this.default_route_next_hop = default_route_next_hop;
-	}
-	
+    public RouterNextHop default_route_next_hop;
+    public String type = "SingleDefaultRouteImplicitRoutingConfig";
+
+    public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
+        default_route_next_hop = routerNextHop;
+    }
+
+    public RouterNextHop getDefaultRouteNextHop() {
+        return default_route_next_hop;
+    }
+
+    public void setDefaultRouteNextHop(RouterNextHop default_route_next_hop) {
+        this.default_route_next_hop = default_route_next_hop;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
index 4132da4..910f830 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
@@ -20,7 +20,7 @@ public class SourceNatRule extends NatRule {
     private String toSourceIpAddressMax;
     private String toSourceIpAddressMin;
     private Integer toSourcePort;
-    
+
     public SourceNatRule() {
         setType("SourceNatRule");
     }
@@ -119,5 +119,5 @@ public class SourceNatRule extends NatRule {
             return false;
         return true;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
index e55d759..9c5f44d 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
@@ -19,9 +19,9 @@ package com.cloud.network.nicira;
 public class TransportZoneBinding {
     private String zone_uuid;
     private String transport_type;
-    
+
     public TransportZoneBinding() {}
-    
+
     public TransportZoneBinding(String zone_uuid, String transport_type) {
         this.zone_uuid = zone_uuid;
         this.transport_type = transport_type;
@@ -42,5 +42,5 @@ public class TransportZoneBinding {
     public void setTransport_type(String transport_type) {
         this.transport_type = transport_type;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
index dc87a5a..3a0b5f3 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
@@ -19,12 +19,12 @@ package com.cloud.network.nicira;
 public class VifAttachment extends Attachment {
     private final String type = "VifAttachment";
     private String vif_uuid;
-    
+
     public VifAttachment() {
     }
-    
+
     public VifAttachment(String vifUuid) {
-        this.vif_uuid = vifUuid;
+        vif_uuid = vifUuid;
     }
 
     public String getVif_uuid() {
@@ -38,5 +38,5 @@ public class VifAttachment extends Attachment {
     public String getType() {
         return type;
     }
-    
+
 }


[3/6] Fix checkstyle errors in Nicira NVP plugin

Posted by hu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
index 114c939..3ab5f2b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
@@ -83,54 +83,54 @@ import com.cloud.resource.ServerResource;
 
 public class NiciraNvpResource implements ServerResource {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpResource.class);
-    
+
     private String _name;
     private String _guid;
     private String _zoneId;
     private int _numRetries;
-    
+
     private NiciraNvpApi _niciraNvpApi;
-    
+
     protected NiciraNvpApi createNiciraNvpApi() {
-    	return new NiciraNvpApi();
+        return new NiciraNvpApi();
     }
-    
+
     @Override
     public boolean configure(String name, Map<String, Object> params)
             throws ConfigurationException {
-    	
+
         _name = (String) params.get("name");
         if (_name == null) {
             throw new ConfigurationException("Unable to find name");
         }
-        
+
         _guid = (String)params.get("guid");
         if (_guid == null) {
             throw new ConfigurationException("Unable to find the guid");
         }
-        
+
         _zoneId = (String) params.get("zoneId");
         if (_zoneId == null) {
             throw new ConfigurationException("Unable to find zone");
         }
-        
+
         _numRetries = 2;
 
         String ip = (String) params.get("ip");
         if (ip == null) {
             throw new ConfigurationException("Unable to find IP");
         }
-        
+
         String adminuser = (String) params.get("adminuser");
         if (adminuser == null) {
             throw new ConfigurationException("Unable to find admin username");
         }
-        
+
         String adminpass = (String) params.get("adminpass");
         if (adminpass == null) {
             throw new ConfigurationException("Unable to find admin password");
-        }               
-        
+        }
+
         _niciraNvpApi = createNiciraNvpApi();
         _niciraNvpApi.setControllerAddress(ip);
         _niciraNvpApi.setAdminCredentials(adminuser,adminpass);
@@ -172,21 +172,21 @@ public class NiciraNvpResource implements ServerResource {
         return new StartupCommand[] { sc };
     }
 
-	@Override
-	public PingCommand getCurrentStatus(long id) {
+    @Override
+    public PingCommand getCurrentStatus(long id) {
         try {
             ControlClusterStatus ccs = _niciraNvpApi.getControlClusterStatus();
             if (!"stable".equals(ccs.getClusterStatus())) {
-            	s_logger.error("ControlCluster state is not stable: "
-            			+ ccs.getClusterStatus());
-            	return null;
+                s_logger.error("ControlCluster state is not stable: "
+                        + ccs.getClusterStatus());
+                return null;
             }
         } catch (NiciraNvpApiException e) {
-        	s_logger.error("getControlClusterStatus failed", e);
-        	return null;
+            s_logger.error("getControlClusterStatus failed", e);
+            return null;
         }
         return new PingCommand(Host.Type.L2Networking, id);
-	}
+    }
 
     @Override
     public Answer executeRequest(Command cmd) {
@@ -213,25 +213,25 @@ public class NiciraNvpResource implements ServerResource {
             return executeRequest((DeleteLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof UpdateLogicalSwitchPortCommand) {
-        	return executeRequest((UpdateLogicalSwitchPortCommand) cmd, numRetries);
+            return executeRequest((UpdateLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof FindLogicalSwitchPortCommand) {
-        	return executeRequest((FindLogicalSwitchPortCommand) cmd, numRetries);
+            return executeRequest((FindLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof CreateLogicalRouterCommand) {
-        	return executeRequest((CreateLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((CreateLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof DeleteLogicalRouterCommand) {
-        	return executeRequest((DeleteLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((DeleteLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof ConfigureStaticNatRulesOnLogicalRouterCommand) {
-        	return executeRequest((ConfigureStaticNatRulesOnLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((ConfigureStaticNatRulesOnLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof ConfigurePortForwardingRulesOnLogicalRouterCommand) {
-        	return executeRequest((ConfigurePortForwardingRulesOnLogicalRouterCommand) cmd, numRetries);
-        }       
+            return executeRequest((ConfigurePortForwardingRulesOnLogicalRouterCommand) cmd, numRetries);
+        }
         else if (cmd instanceof ConfigurePublicIpsOnLogicalRouterCommand) {
-        	return executeRequest((ConfigurePublicIpsOnLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((ConfigurePublicIpsOnLogicalRouterCommand) cmd, numRetries);
         }
         s_logger.debug("Received unsupported command " + cmd.toString());
         return Answer.createUnsupportedCommandAnswer(cmd);
@@ -249,7 +249,7 @@ public class NiciraNvpResource implements ServerResource {
     @Override
     public void setAgentControl(IAgentControl agentControl) {
     }
-    
+
     private Answer executeRequest(CreateLogicalSwitchCommand cmd, int numRetries) {
         LogicalSwitch logicalSwitch = new LogicalSwitch();
         logicalSwitch.setDisplay_name(truncate("lswitch-" + cmd.getName(), 40));
@@ -264,39 +264,39 @@ public class NiciraNvpResource implements ServerResource {
         List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
         tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
         logicalSwitch.setTags(tags);
-        
+
         try {
             logicalSwitch = _niciraNvpApi.createLogicalSwitch(logicalSwitch);
             return new CreateLogicalSwitchAnswer(cmd, true, "Logicalswitch " + logicalSwitch.getUuid() + " created", logicalSwitch.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalSwitchAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalSwitchAnswer(cmd, e);
+            }
         }
-        
+
     }
-    
+
     private Answer executeRequest(DeleteLogicalSwitchCommand cmd, int numRetries) {
         try {
             _niciraNvpApi.deleteLogicalSwitch(cmd.getLogicalSwitchUuid());
             return new DeleteLogicalSwitchAnswer(cmd, true, "Logicalswitch " + cmd.getLogicalSwitchUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalSwitchAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalSwitchAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(CreateLogicalSwitchPortCommand cmd, int numRetries) {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
-        
+
         try {
             // Tags set to scope cs_account and account name
             List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
@@ -305,35 +305,35 @@ public class NiciraNvpResource implements ServerResource {
             LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort(attachmentUuid, tags, true);
             LogicalSwitchPort newPort = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, logicalSwitchPort);
             try {
-            	_niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
+                _niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
             } catch (NiciraNvpApiException ex) {
-            	s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport");
-            	_niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid());
-            	throw (ex); // Rethrow the original exception
+                s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport");
+                _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid());
+                throw (ex); // Rethrow the original exception
             }
             return new CreateLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + newPort.getUuid() + " created", newPort.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalSwitchPortAnswer(cmd, e);
+            }
         }
-        
+
     }
-    
+
     private Answer executeRequest(DeleteLogicalSwitchPortCommand cmd, int numRetries) {
         try {
             _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), cmd.getLogicalSwitchPortUuid());
             return new DeleteLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + cmd.getLogicalSwitchPortUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalSwitchPortAnswer(cmd, e);
+            }
         }
     }
 
@@ -341,7 +341,7 @@ public class NiciraNvpResource implements ServerResource {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
-        
+
         try {
             // Tags set to scope cs_account and account name
             List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
@@ -350,474 +350,474 @@ public class NiciraNvpResource implements ServerResource {
             _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
             return new UpdateLogicalSwitchPortAnswer(cmd, true, "Attachment for  " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid);
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new UpdateLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new UpdateLogicalSwitchPortAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(FindLogicalSwitchPortCommand cmd, int numRetries) {
-    	String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
+        String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
-        
+
         try {
-        	NiciraNvpList<LogicalSwitchPort> ports = _niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
-        	if (ports.getResultCount() == 0) {
-        		return new FindLogicalSwitchPortAnswer(cmd, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
-        	}
-        	else {
-        		return new FindLogicalSwitchPortAnswer(cmd, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
-        	}
+            NiciraNvpList<LogicalSwitchPort> ports = _niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
+            if (ports.getResultCount() == 0) {
+                return new FindLogicalSwitchPortAnswer(cmd, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
+            }
+            else {
+                return new FindLogicalSwitchPortAnswer(cmd, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
+            }
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new FindLogicalSwitchPortAnswer(cmd, e);
-        	}
-        }    	
-    }
-    
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new FindLogicalSwitchPortAnswer(cmd, e);
+            }
+        }
+    }
+
     private Answer executeRequest(CreateLogicalRouterCommand cmd, int numRetries) {
-    	String routerName = cmd.getName();
-    	String gatewayServiceUuid = cmd.getGatewayServiceUuid();
-    	String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
-    	
+        String routerName = cmd.getName();
+        String gatewayServiceUuid = cmd.getGatewayServiceUuid();
+        String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
+
         List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
         tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
-        
+
         String publicNetworkNextHopIp = cmd.getPublicNextHop();
         String publicNetworkIpAddress = cmd.getPublicIpCidr();
         String internalNetworkAddress = cmd.getInternalIpCidr();
-        
-        s_logger.debug("Creating a logical router with external ip " 
-        		+ publicNetworkIpAddress + " and internal ip " + internalNetworkAddress
-        		+ "on gateway service " + gatewayServiceUuid);
-        
+
+        s_logger.debug("Creating a logical router with external ip "
+                + publicNetworkIpAddress + " and internal ip " + internalNetworkAddress
+                + "on gateway service " + gatewayServiceUuid);
+
         try {
-        	// Create the Router
-        	LogicalRouterConfig lrc = new LogicalRouterConfig();
-        	lrc.setDisplayName(truncate(routerName, 40));
-        	lrc.setTags(tags);
-        	lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(
-        			new RouterNextHop(publicNetworkNextHopIp)));
-        	lrc = _niciraNvpApi.createLogicalRouter(lrc);
-        	
-        	// store the switchport for rollback
-        	LogicalSwitchPort lsp = null;
-        	
-        	try {
-	        	// Create the outside port for the router
-	        	LogicalRouterPort lrpo = new LogicalRouterPort();
-	        	lrpo.setAdminStatusEnabled(true);
-	        	lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
-	        	lrpo.setTags(tags);
-	        	List<String> outsideIpAddresses = new ArrayList<String>();
-	        	outsideIpAddresses.add(publicNetworkIpAddress);
-	        	lrpo.setIpAddresses(outsideIpAddresses);
-	        	lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
-	        	
-	        	// Attach the outside port to the gateway service on the correct VLAN
-	        	L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
-	        	if (cmd.getVlanId() != 0) {
-	        		attachment.setVlanId(cmd.getVlanId());
-	        	}
-	        	_niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
-	        	
-	        	// Create the inside port for the router
-	        	LogicalRouterPort lrpi = new LogicalRouterPort();
-	        	lrpi.setAdminStatusEnabled(true);
-	        	lrpi.setDisplayName(truncate(routerName + "-inside-port", 40));
-	        	lrpi.setTags(tags);
-	        	List<String> insideIpAddresses = new ArrayList<String>();
-	        	insideIpAddresses.add(internalNetworkAddress);
-	        	lrpi.setIpAddresses(insideIpAddresses);
-	        	lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
-	        	
-	        	// Create the inside port on the lswitch
-	            lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true);
-	            lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
-	       	
-	        	// Attach the inside router port to the lswitch port with a PatchAttachment
-	            _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(), 
-	            		new PatchAttachment(lsp.getUuid()));
-	        	
-	        	// Attach the inside lswitch port to the router with a PatchAttachment
-	            _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), 
-	            		new PatchAttachment(lrpi.getUuid()));
-	            
-	            // Setup the source nat rule
-	            SourceNatRule snr = new SourceNatRule();
-	            snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
-	            snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
-	            Match match = new Match();
-	            match.setSourceIpAddresses(internalNetworkAddress);
-	            snr.setMatch(match);
-	            snr.setOrder(200); 
-	            _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr);
-        	} catch (NiciraNvpApiException e) {
-        		// We need to destroy the router if we already created it
-        		// this will also take care of any router ports and rules
-        		try {
-        			_niciraNvpApi.deleteLogicalRouter(lrc.getUuid());
-        			if (lsp != null) {
-        				_niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
-        			}
-        		} catch (NiciraNvpApiException ex) {}
-        		
-        		throw e;
-        	}
-            
-            return new CreateLogicalRouterAnswer(cmd, true, "Logical Router created (uuid " + lrc.getUuid() + ")", lrc.getUuid());    	
+            // Create the Router
+            LogicalRouterConfig lrc = new LogicalRouterConfig();
+            lrc.setDisplayName(truncate(routerName, 40));
+            lrc.setTags(tags);
+            lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(
+                    new RouterNextHop(publicNetworkNextHopIp)));
+            lrc = _niciraNvpApi.createLogicalRouter(lrc);
+
+            // store the switchport for rollback
+            LogicalSwitchPort lsp = null;
+
+            try {
+                // Create the outside port for the router
+                LogicalRouterPort lrpo = new LogicalRouterPort();
+                lrpo.setAdminStatusEnabled(true);
+                lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
+                lrpo.setTags(tags);
+                List<String> outsideIpAddresses = new ArrayList<String>();
+                outsideIpAddresses.add(publicNetworkIpAddress);
+                lrpo.setIpAddresses(outsideIpAddresses);
+                lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
+
+                // Attach the outside port to the gateway service on the correct VLAN
+                L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
+                if (cmd.getVlanId() != 0) {
+                    attachment.setVlanId(cmd.getVlanId());
+                }
+                _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
+
+                // Create the inside port for the router
+                LogicalRouterPort lrpi = new LogicalRouterPort();
+                lrpi.setAdminStatusEnabled(true);
+                lrpi.setDisplayName(truncate(routerName + "-inside-port", 40));
+                lrpi.setTags(tags);
+                List<String> insideIpAddresses = new ArrayList<String>();
+                insideIpAddresses.add(internalNetworkAddress);
+                lrpi.setIpAddresses(insideIpAddresses);
+                lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
+
+                // Create the inside port on the lswitch
+                lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true);
+                lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
+
+                // Attach the inside router port to the lswitch port with a PatchAttachment
+                _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(),
+                        new PatchAttachment(lsp.getUuid()));
+
+                // Attach the inside lswitch port to the router with a PatchAttachment
+                _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(),
+                        new PatchAttachment(lrpi.getUuid()));
+
+                // Setup the source nat rule
+                SourceNatRule snr = new SourceNatRule();
+                snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
+                snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
+                Match match = new Match();
+                match.setSourceIpAddresses(internalNetworkAddress);
+                snr.setMatch(match);
+                snr.setOrder(200);
+                _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr);
+            } catch (NiciraNvpApiException e) {
+                // We need to destroy the router if we already created it
+                // this will also take care of any router ports and rules
+                try {
+                    _niciraNvpApi.deleteLogicalRouter(lrc.getUuid());
+                    if (lsp != null) {
+                        _niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
+                    }
+                } catch (NiciraNvpApiException ex) {}
+
+                throw e;
+            }
+
+            return new CreateLogicalRouterAnswer(cmd, true, "Logical Router created (uuid " + lrc.getUuid() + ")", lrc.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalRouterAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(DeleteLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		_niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
-    		return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
+        try {
+            _niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
+            return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalRouterAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
-    		if (ports.getResultCount() != 1) {
-    			return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
-    		}
-    		LogicalRouterPort lrp = ports.getResults().get(0);
-    		lrp.setIpAddresses(cmd.getPublicCidrs());
-    		_niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
-    		
-    		return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + 
-    				" ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
+        try {
+            NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
+            if (ports.getResultCount() != 1) {
+                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
+            }
+            LogicalRouterPort lrp = ports.getResults().get(0);
+            lrp.setIpAddresses(cmd.getPublicCidrs());
+            _niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
+
+            return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() +
+                    " ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(ConfigureStaticNatRulesOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
-    		// Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
-    		// A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
-    		// Any other SourceNat rule should have a corresponding DestinationNat rule
-    		
-    		for (StaticNatRuleTO rule : cmd.getRules()) {
-    			
-    			NatRule[] rulepair = generateStaticNatRulePair(rule.getDstIp(), rule.getSrcIp());
-    							
-				NatRule incoming = null;
-				NatRule outgoing = null;
-
-				for (NatRule storedRule : existingRules.getResults()) {					
-    				if (storedRule.equalsIgnoreUuid(rulepair[1])) {
-						// The outgoing rule exists
-    					outgoing = storedRule;
-    					s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
-    					if (incoming != null) {
-    						break;
-    					}
-        			}    					
-    				else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
-    					// The incoming rule exists
-    					incoming = storedRule;
-    					s_logger.debug("Found matching incoming rule " + incoming.getUuid());
-    					if (outgoing != null) {
-    						break;
-    					}
-    				}
-    			}
-				if (incoming != null && outgoing != null) {
-					if (rule.revoked()) {
-						s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
-						
-						s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
-					}
-				}
-				else {
-					if (rule.revoked()) {
-						s_logger.warn("Tried deleting a rule that does not exist, " + 
-								rule.getSrcIp() + " -> " + rule.getDstIp());
-						break;
-					}
-					
-					rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
-					s_logger.debug("Created " + natRuleToString(rulepair[0]));
-					
-					try {
-						rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
-						s_logger.debug("Created " + natRuleToString(rulepair[1]));
-					} catch (NiciraNvpApiException ex) {
-						s_logger.debug("Failed to create SourceNatRule, rolling back DestinationNatRule");
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
-						throw ex; // Rethrow original exception
-					}
-					
-				}
-    		}
-    		return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" StaticNat rules applied");
+        try {
+            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            // Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
+            // A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
+            // Any other SourceNat rule should have a corresponding DestinationNat rule
+
+            for (StaticNatRuleTO rule : cmd.getRules()) {
+
+                NatRule[] rulepair = generateStaticNatRulePair(rule.getDstIp(), rule.getSrcIp());
+
+                NatRule incoming = null;
+                NatRule outgoing = null;
+
+                for (NatRule storedRule : existingRules.getResults()) {
+                    if (storedRule.equalsIgnoreUuid(rulepair[1])) {
+                        // The outgoing rule exists
+                        outgoing = storedRule;
+                        s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
+                        if (incoming != null) {
+                            break;
+                        }
+                    }
+                    else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
+                        // The incoming rule exists
+                        incoming = storedRule;
+                        s_logger.debug("Found matching incoming rule " + incoming.getUuid());
+                        if (outgoing != null) {
+                            break;
+                        }
+                    }
+                }
+                if (incoming != null && outgoing != null) {
+                    if (rule.revoked()) {
+                        s_logger.debug("Deleting incoming rule " + incoming.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+
+                        s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                    }
+                }
+                else {
+                    if (rule.revoked()) {
+                        s_logger.warn("Tried deleting a rule that does not exist, " +
+                                rule.getSrcIp() + " -> " + rule.getDstIp());
+                        break;
+                    }
+
+                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    s_logger.debug("Created " + natRuleToString(rulepair[0]));
+
+                    try {
+                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        s_logger.debug("Created " + natRuleToString(rulepair[1]));
+                    } catch (NiciraNvpApiException ex) {
+                        s_logger.debug("Failed to create SourceNatRule, rolling back DestinationNatRule");
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
+                        throw ex; // Rethrow original exception
+                    }
+
+                }
+            }
+            return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" StaticNat rules applied");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, e);
+            }
         }
     }
 
     private Answer executeRequest(ConfigurePortForwardingRulesOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
-    		// Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
-    		// A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
-    		// Any other SourceNat rule should have a corresponding DestinationNat rule
-    		
-    		for (PortForwardingRuleTO rule : cmd.getRules()) {
-    			if (rule.isAlreadyAdded() && !rule.revoked()) {
-    				// Don't need to do anything
-    				continue;
-    			}
-    			
-    			if (rule.getDstPortRange()[0] != rule.getDstPortRange()[1] || 
-    			        rule.getSrcPortRange()[0] != rule.getSrcPortRange()[1]    ) {
-    				return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, false, "Nicira NVP doesn't support port ranges for port forwarding");
-    			}
-    			
-    			NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol());
-				
-				NatRule incoming = null;
-				NatRule outgoing = null;
-
-				for (NatRule storedRule : existingRules.getResults()) {
-    				if (storedRule.equalsIgnoreUuid(rulepair[1])) {
-						// The outgoing rule exists
-    					outgoing = storedRule;
-    					s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
-    					if (incoming != null) {
-    						break;
-    					}
-        			}    					
-    				else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
-    					// The incoming rule exists
-    					incoming = storedRule;
-    					s_logger.debug("Found matching incoming rule " + incoming.getUuid());
-    					if (outgoing != null) {
-    						break;
-    					}
-    				}
-				}
-				if (incoming != null && outgoing != null) {
-					if (rule.revoked()) {
-						s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
-						
-						s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
-					}
-				}
-				else {
-					if (rule.revoked()) {
-						s_logger.warn("Tried deleting a rule that does not exist, " + 
-								rule.getSrcIp() + " -> " + rule.getDstIp());
-						break;
-					}
-					
-					rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
-					s_logger.debug("Created " + natRuleToString(rulepair[0]));
-					
-					try {
-						rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
-						s_logger.debug("Created " + natRuleToString(rulepair[1]));
-					} catch (NiciraNvpApiException ex) {
-						s_logger.warn("NiciraNvpApiException during create call, rolling back previous create");
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
-						throw ex; // Rethrow the original exception
-					}
-					
-				}
-    		}
-    		return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" PortForwarding rules applied");
+        try {
+            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            // Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
+            // A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
+            // Any other SourceNat rule should have a corresponding DestinationNat rule
+
+            for (PortForwardingRuleTO rule : cmd.getRules()) {
+                if (rule.isAlreadyAdded() && !rule.revoked()) {
+                    // Don't need to do anything
+                    continue;
+                }
+
+                if (rule.getDstPortRange()[0] != rule.getDstPortRange()[1] ||
+                        rule.getSrcPortRange()[0] != rule.getSrcPortRange()[1]    ) {
+                    return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, false, "Nicira NVP doesn't support port ranges for port forwarding");
+                }
+
+                NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol());
+
+                NatRule incoming = null;
+                NatRule outgoing = null;
+
+                for (NatRule storedRule : existingRules.getResults()) {
+                    if (storedRule.equalsIgnoreUuid(rulepair[1])) {
+                        // The outgoing rule exists
+                        outgoing = storedRule;
+                        s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
+                        if (incoming != null) {
+                            break;
+                        }
+                    }
+                    else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
+                        // The incoming rule exists
+                        incoming = storedRule;
+                        s_logger.debug("Found matching incoming rule " + incoming.getUuid());
+                        if (outgoing != null) {
+                            break;
+                        }
+                    }
+                }
+                if (incoming != null && outgoing != null) {
+                    if (rule.revoked()) {
+                        s_logger.debug("Deleting incoming rule " + incoming.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+
+                        s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                    }
+                }
+                else {
+                    if (rule.revoked()) {
+                        s_logger.warn("Tried deleting a rule that does not exist, " +
+                                rule.getSrcIp() + " -> " + rule.getDstIp());
+                        break;
+                    }
+
+                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    s_logger.debug("Created " + natRuleToString(rulepair[0]));
+
+                    try {
+                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        s_logger.debug("Created " + natRuleToString(rulepair[1]));
+                    } catch (NiciraNvpApiException ex) {
+                        s_logger.warn("NiciraNvpApiException during create call, rolling back previous create");
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
+                        throw ex; // Rethrow the original exception
+                    }
+
+                }
+            }
+            return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" PortForwarding rules applied");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(ReadyCommand cmd) {
         return new ReadyAnswer(cmd);
     }
-    
+
     private Answer executeRequest(MaintainCommand cmd) {
         return new MaintainAnswer(cmd);
-    }    
+    }
 
     private Answer retry(Command cmd, int numRetries) {
         s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);
         return executeRequest(cmd, numRetries);
     }
-    
+
     private String natRuleToString(NatRule rule) {
-    	
-		StringBuilder natRuleStr = new StringBuilder();
-		natRuleStr.append("Rule ");
-		natRuleStr.append(rule.getUuid());
-		natRuleStr.append(" (");
-		natRuleStr.append(rule.getType());
-		natRuleStr.append(") :");
-		Match m = rule.getMatch();
-		natRuleStr.append("match (");
-		natRuleStr.append(m.getProtocol());
-		natRuleStr.append(" ");
-		natRuleStr.append(m.getSourceIpAddresses());
-		natRuleStr.append(" [");
-		natRuleStr.append(m.getSourcePort());
-		natRuleStr.append(" ] -> ");
-		natRuleStr.append(m.getDestinationIpAddresses());
-		natRuleStr.append(" [");
-		natRuleStr.append(m.getDestinationPort());
-		natRuleStr.append(" ]) -->");
-		if ("SourceNatRule".equals(rule.getType())) {
-			natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMin());
-			natRuleStr.append("-");
-			natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMax());
-			natRuleStr.append(" [");
-			natRuleStr.append(((SourceNatRule)rule).getToSourcePort());
-			natRuleStr.append(" ])");
-		}
-		else {
-			natRuleStr.append(((DestinationNatRule)rule).getToDestinationIpAddress());
-			natRuleStr.append(" [");
-			natRuleStr.append(((DestinationNatRule)rule).getToDestinationPort());
-			natRuleStr.append(" ])");
-		}
-		return natRuleStr.toString();
-    }
-    
+
+        StringBuilder natRuleStr = new StringBuilder();
+        natRuleStr.append("Rule ");
+        natRuleStr.append(rule.getUuid());
+        natRuleStr.append(" (");
+        natRuleStr.append(rule.getType());
+        natRuleStr.append(") :");
+        Match m = rule.getMatch();
+        natRuleStr.append("match (");
+        natRuleStr.append(m.getProtocol());
+        natRuleStr.append(" ");
+        natRuleStr.append(m.getSourceIpAddresses());
+        natRuleStr.append(" [");
+        natRuleStr.append(m.getSourcePort());
+        natRuleStr.append(" ] -> ");
+        natRuleStr.append(m.getDestinationIpAddresses());
+        natRuleStr.append(" [");
+        natRuleStr.append(m.getDestinationPort());
+        natRuleStr.append(" ]) -->");
+        if ("SourceNatRule".equals(rule.getType())) {
+            natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMin());
+            natRuleStr.append("-");
+            natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMax());
+            natRuleStr.append(" [");
+            natRuleStr.append(((SourceNatRule)rule).getToSourcePort());
+            natRuleStr.append(" ])");
+        }
+        else {
+            natRuleStr.append(((DestinationNatRule)rule).getToDestinationIpAddress());
+            natRuleStr.append(" [");
+            natRuleStr.append(((DestinationNatRule)rule).getToDestinationPort());
+            natRuleStr.append(" ])");
+        }
+        return natRuleStr.toString();
+    }
+
     private String truncate(String string, int length) {
-    	if (string.length() <= length) {
-    		return string;
-    	}
-    	else {
-    		return string.substring(0, length);
-    	}
-    }
-    
+        if (string.length() <= length) {
+            return string;
+        }
+        else {
+            return string.substring(0, length);
+        }
+    }
+
     protected NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) {
-    	NatRule[] rulepair = new NatRule[2];
-    	rulepair[0] = new DestinationNatRule();
-    	rulepair[0].setType("DestinationNatRule");
-    	rulepair[0].setOrder(100);
-    	rulepair[1] = new SourceNatRule();
-    	rulepair[1].setType("SourceNatRule");
-    	rulepair[1].setOrder(100);
-    	
-		Match m = new Match();
-		m.setDestinationIpAddresses(outsideIp);
-		rulepair[0].setMatch(m);
-		((DestinationNatRule)rulepair[0]).setToDestinationIpAddress(insideIp);
-
-		// create matching snat rule
-		m = new Match();
-		m.setSourceIpAddresses(insideIp);
-		rulepair[1].setMatch(m);
-		((SourceNatRule)rulepair[1]).setToSourceIpAddressMin(outsideIp);
-		((SourceNatRule)rulepair[1]).setToSourceIpAddressMax(outsideIp);
-    	
-    	return rulepair;
-    	
-    }
-    
+        NatRule[] rulepair = new NatRule[2];
+        rulepair[0] = new DestinationNatRule();
+        rulepair[0].setType("DestinationNatRule");
+        rulepair[0].setOrder(100);
+        rulepair[1] = new SourceNatRule();
+        rulepair[1].setType("SourceNatRule");
+        rulepair[1].setOrder(100);
+
+        Match m = new Match();
+        m.setDestinationIpAddresses(outsideIp);
+        rulepair[0].setMatch(m);
+        ((DestinationNatRule)rulepair[0]).setToDestinationIpAddress(insideIp);
+
+        // create matching snat rule
+        m = new Match();
+        m.setSourceIpAddresses(insideIp);
+        rulepair[1].setMatch(m);
+        ((SourceNatRule)rulepair[1]).setToSourceIpAddressMin(outsideIp);
+        ((SourceNatRule)rulepair[1]).setToSourceIpAddressMax(outsideIp);
+
+        return rulepair;
+
+    }
+
     protected NatRule[] generatePortForwardingRulePair(String insideIp, int[] insidePorts, String outsideIp, int[] outsidePorts, String protocol) {
-       	// Start with a basic static nat rule, then add port and protocol details
-    	NatRule[] rulepair = generateStaticNatRulePair(insideIp, outsideIp);
-    	
-    	((DestinationNatRule)rulepair[0]).setToDestinationPort(insidePorts[0]);
-    	rulepair[0].getMatch().setDestinationPort(outsidePorts[0]);
-    	rulepair[0].setOrder(50);
-    	rulepair[0].getMatch().setEthertype("IPv4");
-		if ("tcp".equals(protocol)) {
-			rulepair[0].getMatch().setProtocol(6);
-		}
-		else if ("udp".equals(protocol)) {
-			rulepair[0].getMatch().setProtocol(17);
-		}
-
-    	((SourceNatRule)rulepair[1]).setToSourcePort(outsidePorts[0]);
-    	rulepair[1].getMatch().setSourcePort(insidePorts[0]);
-    	rulepair[1].setOrder(50);
-    	rulepair[1].getMatch().setEthertype("IPv4");
-		if ("tcp".equals(protocol)) {
-			rulepair[1].getMatch().setProtocol(6);
-		}
-		else if ("udp".equals(protocol)) {
-			rulepair[1].getMatch().setProtocol(17);
-		}
-
-		return rulepair;
-   	
-    }
-
-	@Override
-	public void setName(String name) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public void setConfigParams(Map<String, Object> params) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public Map<String, Object> getConfigParams() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public int getRunLevel() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public void setRunLevel(int level) {
-		// TODO Auto-generated method stub
-		
-	}
-    
+        // Start with a basic static nat rule, then add port and protocol details
+        NatRule[] rulepair = generateStaticNatRulePair(insideIp, outsideIp);
+
+        ((DestinationNatRule)rulepair[0]).setToDestinationPort(insidePorts[0]);
+        rulepair[0].getMatch().setDestinationPort(outsidePorts[0]);
+        rulepair[0].setOrder(50);
+        rulepair[0].getMatch().setEthertype("IPv4");
+        if ("tcp".equals(protocol)) {
+            rulepair[0].getMatch().setProtocol(6);
+        }
+        else if ("udp".equals(protocol)) {
+            rulepair[0].getMatch().setProtocol(17);
+        }
+
+        ((SourceNatRule)rulepair[1]).setToSourcePort(outsidePorts[0]);
+        rulepair[1].getMatch().setSourcePort(insidePorts[0]);
+        rulepair[1].setOrder(50);
+        rulepair[1].getMatch().setEthertype("IPv4");
+        if ("tcp".equals(protocol)) {
+            rulepair[1].getMatch().setProtocol(6);
+        }
+        else if ("udp".equals(protocol)) {
+            rulepair[1].getMatch().setProtocol(17);
+        }
+
+        return rulepair;
+
+    }
+
+    @Override
+    public void setName(String name) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setConfigParams(Map<String, Object> params) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Map<String, Object> getConfigParams() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public int getRunLevel() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setRunLevel(int level) {
+        // TODO Auto-generated method stub
+
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
index 6b5c103..9202241 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
@@ -16,6 +16,16 @@
 // under the License.
 package com.cloud.network.element;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -31,7 +41,6 @@ import org.mockito.ArgumentMatcher;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 
 import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer;
 import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand;
 import com.cloud.deploy.DeployDestination;
@@ -41,11 +50,11 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
+import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
-import com.cloud.network.IpAddress;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
@@ -55,18 +64,12 @@ import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NiciraNvpDao;
 import com.cloud.network.dao.NiciraNvpRouterMappingDao;
-import com.cloud.network.nicira.NatRule;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.resource.ResourceManager;
 import com.cloud.user.Account;
 import com.cloud.utils.net.Ip;
 import com.cloud.vm.ReservationContext;
 
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
 public class NiciraNvpElementTest {
 
     NiciraNvpElement _element = new NiciraNvpElement();
@@ -136,7 +139,7 @@ public class NiciraNvpElementTest {
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        mock(DeployDestination.class);
 
         Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");