cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [4/6] Checkstyle adjustments in code and configuration
Date Mon, 18 Nov 2013 18:24:55 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 ea69a09..a3b3542 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
@@ -72,19 +72,26 @@ import com.google.gson.JsonParseException;
 import com.google.gson.reflect.TypeToken;
 
 public class NiciraNvpApi {
+    private static final String TEXT_HTML_CONTENT_TYPE = "text/html";
+    private static final String JSON_CONTENT_TYPE = "application/json";
+    private static final String CONTENT_TYPE = "Content-Type";
+    private static final int BODY_RESP_MAX_LEN = 1024;
+    private static final String SWITCH_URI_PREFIX = "/ws.v1/lswitch";
+    private static final String ROUTER_URI_PREFIX = "/ws.v1/lrouter";
+    private static final int HTTPS_PORT = 443;
     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 final static String protocol = "https";
+    private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
 
-    private String _name;
-    private String _host;
-    private String _adminuser;
-    private String _adminpass;
+    private String name;
+    private String host;
+    private String adminuser;
+    private String adminpass;
 
-    private HttpClient _client;
-    private String _nvpversion;
+    private final HttpClient client;
+    private String nvpVersion;
 
-    private Gson _gson;
+    private final Gson gson;
 
     /* This factory method is protected so we can extend this
      * in the unittests.
@@ -93,10 +100,10 @@ public class NiciraNvpApi {
         return new HttpClient(s_httpClientManager);
     }
 
-    protected HttpMethod createMethod(String type, String uri) throws NiciraNvpApiException {
+    protected HttpMethod createMethod(final String type, final String uri) throws NiciraNvpApiException {
         String url;
         try {
-            url = new URL(_protocol, _host, uri).toString();
+            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);
@@ -104,76 +111,71 @@ public class NiciraNvpApi {
 
         if ("post".equalsIgnoreCase(type)) {
             return new PostMethod(url);
-        }
-        else if ("get".equalsIgnoreCase(type)) {
+        } else if ("get".equalsIgnoreCase(type)) {
             return new GetMethod(url);
-        }
-        else if ("delete".equalsIgnoreCase(type)) {
+        } else if ("delete".equalsIgnoreCase(type)) {
             return new DeleteMethod(url);
-        }
-        else if ("put".equalsIgnoreCase(type)) {
+        } else if ("put".equalsIgnoreCase(type)) {
             return new PutMethod(url);
-        }
-        else {
+        } else {
             throw new NiciraNvpApiException("Requesting unknown method type");
         }
     }
 
     public NiciraNvpApi() {
-        _client = createHttpClient();
-        _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+        client = createHttpClient();
+        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
 
         try {
             // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
-            Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), 443));
+            Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), HTTPS_PORT));
         } 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();
-
+        gson = new GsonBuilder()
+                .registerTypeAdapter(NatRule.class, new NatRuleAdapter())
+                .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+                .create();
     }
 
-    public void setControllerAddress(String address) {
-        _host = address;
+    public void setControllerAddress(final String address) {
+        host = address;
     }
 
-    public void setAdminCredentials(String username, String password) {
-        _adminuser = username;
-        _adminpass = password;
+    public void setAdminCredentials(final String username, final String 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()) {
+        if (host == null || host.isEmpty() ||
+                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();
+            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);
+        pm.addParameter("username", adminuser);
+        pm.addParameter("password", adminpass);
 
         try {
-            _client.executeMethod(pm);
+            client.executeMethod(pm);
         } catch (HttpException e) {
             throw new NiciraNvpApiException("Nicira NVP API login failed ", e);
         } catch (IOException e) {
@@ -189,44 +191,47 @@ public class NiciraNvpApi {
 
         // Extract the version for later use
         if (pm.getResponseHeader("Server") != null) {
-            _nvpversion = pm.getResponseHeader("Server").getValue();
-            s_logger.debug("NVP Controller reports version " + _nvpversion);
+            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";
+    public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX;
         LogicalSwitch createdLogicalSwitch = executeCreateObject(logicalSwitch, new TypeToken<LogicalSwitch>(){}.getType(), uri, Collections.<String,String>emptyMap());
 
         return createdLogicalSwitch;
     }
 
-    public void deleteLogicalSwitch(String uuid) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lswitch/" + uuid;
+    public void deleteLogicalSwitch(final String uuid) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + 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());;
+    public LogicalSwitchPort createLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort)
+            throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + logicalSwitchUuid + "/lport";
+        LogicalSwitchPort createdLogicalSwitchPort = executeCreateObject(logicalSwitchPort,
+                new TypeToken<LogicalSwitchPort>(){}.getType(), uri, Collections.<String,String>emptyMap());
 
         return createdLogicalSwitchPort;
     }
 
-    public void modifyLogicalSwitchPortAttachment(String logicalSwitchUuid, String logicalSwitchPortUuid, Attachment attachment) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment";
+    public void modifyLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid,
+            Attachment attachment) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + 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;
+    public void deleteLogicalSwitchPort(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid;
         executeDeleteObject(uri);
     }
 
-    public String findLogicalSwitchPortUuidByVifAttachmentUuid(String logicalSwitchUuid, String vifAttachmentUuid) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
+    public String findLogicalSwitchPortUuidByVifAttachmentUuid(final String logicalSwitchUuid, final String vifAttachmentUuid) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + logicalSwitchUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_vif_uuid", vifAttachmentUuid);
         params.put("fields", "uuid");
@@ -248,8 +253,9 @@ public class NiciraNvpApi {
         return ccs;
     }
 
-    public NiciraNvpList<LogicalSwitchPort> findLogicalSwitchPortsByUuid(String logicalSwitchUuid, String logicalSwitchPortUuid) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
+    public NiciraNvpList<LogicalSwitchPort> findLogicalSwitchPortsByUuid(final String logicalSwitchUuid,
+            final String logicalSwitchPortUuid) throws NiciraNvpApiException {
+        String uri = SWITCH_URI_PREFIX + logicalSwitchUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("uuid", logicalSwitchPortUuid);
         params.put("fields", "uuid");
@@ -263,64 +269,66 @@ public class NiciraNvpApi {
         return lspl;
     }
 
-    public LogicalRouterConfig createLogicalRouter(LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lrouter";
+    public LogicalRouterConfig createLogicalRouter(final LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX;
 
         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;
+    public void deleteLogicalRouter(final String logicalRouterUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + logicalRouterUuid;
 
         executeDeleteObject(uri);
     }
 
-    public LogicalRouterPort createLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+    public LogicalRouterPort createLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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;
+    public void deleteLogicalRouterPort(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + logicalRouterUuid + "/lport/" +  logicalRouterPortUuid;
 
         executeDeleteObject(uri);
     }
 
-    public void modifyLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPort.getUuid();
+    public void modifyLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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";
+    public void modifyLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid,
+            final Attachment attachment) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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";
+    public NatRule createLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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();
+    public void modifyLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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();
+    public void deleteLogicalRouterNatRule(final String logicalRouterUuid, final UUID natRuleUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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";
+    public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(
+            final String logicalRouterUuid, final String gatewayServiceUuid, final long vlanId) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + logicalRouterUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_gwsvc_uuid", gatewayServiceUuid);
         params.put("attachment_vlan", "0");
@@ -329,28 +337,29 @@ public class NiciraNvpApi {
         return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
     }
 
-    public LogicalRouterConfig findOneLogicalRouterByUuid(String logicalRouterUuid) throws NiciraNvpApiException {
-        String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
+    public LogicalRouterConfig findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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();
+    public void updateLogicalRouterPortConfig(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + 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";
+    public NiciraNvpList<NatRule> findNatRulesByLogicalRouterUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + logicalRouterUuid + "/nat";
         Map<String,String> params = new HashMap<String,String>();
         params.put("fields","*");
 
         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";
+    public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(final String logicalRouterUuid,
+            final String l3GatewayServiceUuid) throws NiciraNvpApiException {
+        String uri = ROUTER_URI_PREFIX + logicalRouterUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("fields", "*");
         params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
@@ -358,18 +367,18 @@ public class NiciraNvpApi {
         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()) {
+    protected <T> void executeUpdateObject(final T newObject, final String uri, final 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");
         }
 
         PutMethod pm = (PutMethod) createMethod("put", uri);
-        pm.setRequestHeader("Content-Type", "application/json");
+        pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
         try {
             pm.setRequestEntity(new StringRequestEntity(
-                    _gson.toJson(newObject),"application/json", null));
+                    gson.toJson(newObject),JSON_CONTENT_TYPE, null));
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
@@ -385,18 +394,19 @@ 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()) {
+    protected <T> T executeCreateObject(final T newObject, final Type returnObjectType, final String uri,
+            final 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");
         }
 
         PostMethod pm = (PostMethod) createMethod("post", uri);
-        pm.setRequestHeader("Content-Type", "application/json");
+        pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
         try {
             pm.setRequestEntity(new StringRequestEntity(
-                    _gson.toJson(newObject),"application/json", null));
+                    gson.toJson(newObject),JSON_CONTENT_TYPE, null));
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
@@ -412,7 +422,7 @@ public class NiciraNvpApi {
 
         T result;
         try {
-            result = (T)_gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
+            result = (T)gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
         } catch (IOException e) {
             throw new NiciraNvpApiException("Failed to decode json response body", e);
         } finally {
@@ -422,15 +432,15 @@ public class NiciraNvpApi {
         return result;
     }
 
-    protected void executeDeleteObject(String uri) throws NiciraNvpApiException {
-        if (_host == null || _host.isEmpty() ||
-                _adminuser == null || _adminuser.isEmpty() ||
-                _adminpass == null || _adminpass.isEmpty()) {
+    protected void executeDeleteObject(final 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");
         }
 
         DeleteMethod dm = (DeleteMethod) createMethod("delete", uri);
-        dm.setRequestHeader("Content-Type", "application/json");
+        dm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
 
         executeMethod(dm);
 
@@ -443,15 +453,16 @@ 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()) {
+    protected <T> T executeRetrieveObject(final Type returnObjectType, final String uri,
+            final 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");
         }
 
         GetMethod gm = (GetMethod) createMethod("get", uri);
-        gm.setRequestHeader("Content-Type", "application/json");
+        gm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
         if (parameters != null && !parameters.isEmpty()) {
             List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
             for (Entry<String,String> e : parameters.entrySet()) {
@@ -471,7 +482,7 @@ public class NiciraNvpApi {
 
         T returnValue;
         try {
-            returnValue = (T)_gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
+            returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
         } catch (IOException e) {
             s_logger.error("IOException while retrieving response body",e);
             throw new NiciraNvpApiException(e);
@@ -481,14 +492,14 @@ public class NiciraNvpApi {
         return returnValue;
     }
 
-    protected void executeMethod(HttpMethodBase method) throws NiciraNvpApiException {
+    protected void executeMethod(final HttpMethodBase method) throws NiciraNvpApiException {
         try {
-            _client.executeMethod(method);
+            client.executeMethod(method);
             if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
                 method.releaseConnection();
                 // login and try again
                 login();
-                _client.executeMethod(method);
+                client.executeMethod(method);
             }
         } catch (HttpException e) {
             s_logger.error("HttpException caught while trying to connect to the Nicira NVP Controller", e);
@@ -501,15 +512,15 @@ public class NiciraNvpApi {
         }
     }
 
-    private String responseToErrorMessage(HttpMethodBase method) {
+    private String responseToErrorMessage(final 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())) {
+        if (TEXT_HTML_CONTENT_TYPE.equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
             // The error message is the response content
             // Safety margin of 1024 characters, anything longer is probably useless
             // and will clutter the logs
             try {
-                return  method.getResponseBodyAsString(1024);
+                return  method.getResponseBodyAsString(BODY_RESP_MAX_LEN);
             } catch (IOException e) {
                 s_logger.debug("Error while loading response body", e);
             }
@@ -531,22 +542,22 @@ public class NiciraNvpApi {
         public TrustingProtocolSocketFactory() throws IOException {
             // Create a trust manager that does not validate certificate chains
             TrustManager[] trustAllCerts = new TrustManager[] {
-                    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
-                        }
+                new X509TrustManager() {
+                    @Override
+                    public X509Certificate[] getAcceptedIssuers() {
+                        return null;
+                    }
+
+                    @Override
+                    public void checkClientTrusted(final X509Certificate[] certs, final String authType) {
+                        // Trust always
                     }
+
+                    @Override
+                    public void checkServerTrusted(final X509Certificate[] certs, final String authType) {
+                        // Trust always
+                    }
+                }
             };
 
             try {
@@ -562,26 +573,25 @@ public class NiciraNvpApi {
         }
 
         @Override
-        public Socket createSocket(String host, int port) throws IOException,
-        UnknownHostException {
+        public Socket createSocket(final String host, final int port) throws IOException {
             return ssf.createSocket(host, port);
         }
 
         @Override
-        public Socket createSocket(String address, int port, InetAddress localAddress,
-                int localPort) throws IOException, UnknownHostException {
+        public Socket createSocket(final String address, final int port, final InetAddress localAddress,
+                final int localPort) throws IOException, UnknownHostException {
             return ssf.createSocket(address, port, localAddress, localPort);
         }
 
         @Override
-        public Socket createSocket(Socket socket, String host, int port,
-                boolean autoClose) throws IOException, UnknownHostException {
+        public Socket createSocket(final Socket socket, final String host, final int port,
+                final boolean autoClose) throws IOException, UnknownHostException {
             return ssf.createSocket(socket, host, port, autoClose);
         }
 
         @Override
-        public Socket createSocket(String host, int port, InetAddress localAddress,
-                int localPort, HttpConnectionParams params) throws IOException,
+        public Socket createSocket(final String host, final int port, final InetAddress localAddress,
+                final int localPort, final HttpConnectionParams params) throws IOException,
                 UnknownHostException, ConnectTimeoutException {
             int timeout = params.getConnectionTimeout();
             if (timeout == 0) {
@@ -594,16 +604,15 @@ public class NiciraNvpApi {
                 return s;
             }
         }
-
-
     }
 
     public static class NatRuleAdapter implements JsonDeserializer<NatRule> {
 
         @Override
-        public NatRule deserialize(JsonElement jsonElement, Type type,
-                JsonDeserializationContext context) throws JsonParseException {
+        public NatRule deserialize(final JsonElement jsonElement, final Type type,
+                final JsonDeserializationContext context) throws JsonParseException {
             JsonObject jsonObject = jsonElement.getAsJsonObject();
+
             if (!jsonObject.has("type")) {
                 throw new JsonParseException("Deserializing as a NatRule, but no type present in the json object");
             }
@@ -611,8 +620,7 @@ public class NiciraNvpApi {
             String natRuleType = jsonObject.get("type").getAsString();
             if ("SourceNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, SourceNatRule.class);
-            }
-            else if ("DestinationNatRule".equals(natRuleType)) {
+            } else if ("DestinationNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, DestinationNatRule.class);
             }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApiException.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApiException.java
index db34a15..facc5ab 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApiException.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApiException.java
@@ -21,15 +21,15 @@ public class NiciraNvpApiException extends Exception {
     public NiciraNvpApiException() {
     }
 
-    public NiciraNvpApiException(String message) {
+    public NiciraNvpApiException(final String message) {
         super(message);
     }
 
-    public NiciraNvpApiException(Throwable cause) {
+    public NiciraNvpApiException(final Throwable cause) {
         super(cause);
     }
 
-    public NiciraNvpApiException(String message, Throwable cause) {
+    public NiciraNvpApiException(final String message, final Throwable cause) {
         super(message, cause);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 9d78e84..ba6ff97 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
@@ -20,10 +20,10 @@ import java.util.List;
 
 public class NiciraNvpList<T> {
     private List<T> results;
-    private int result_count;
+    private int resultCount;
 
     public List<T> getResults() {
-        return results;
+        return this.results;
     }
 
     public void setResults(List<T> results) {
@@ -31,15 +31,15 @@ public class NiciraNvpList<T> {
     }
 
     public int getResultCount() {
-        return result_count;
+        return resultCount;
     }
 
-    public void setResultCount(int result_count) {
-        this.result_count = result_count;
+    public void setResultCount(int resultCount) {
+        this.resultCount = resultCount;
     }
 
     public boolean isEmpty() {
-        return result_count == 0;
+        return this.resultCount == 0;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 a5dd3bd..0b69cc9 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
@@ -19,6 +19,7 @@ package com.cloud.network.nicira;
 import org.apache.log4j.Logger;
 
 public class NiciraNvpTag {
+    private static final int TAG_MAX_LEN = 40;
     private static final Logger s_logger = Logger.getLogger(NiciraNvpTag.class);
     private String scope;
     private String tag;
@@ -29,7 +30,7 @@ public class NiciraNvpTag {
         this.scope = scope;
         if (tag.length() > 40) {
             s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters");
-            this.tag = tag.substring(0, 40);
+            this.tag = tag.substring(0, TAG_MAX_LEN);
         } else {
             this.tag = tag;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 137f071..ebad6f9 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
@@ -21,18 +21,19 @@ package com.cloud.network.nicira;
  */
 public class PatchAttachment extends Attachment {
     private final String type = "PatchAttachment";
-    private String peer_port_uuid;
+    private String peerPortUuid;
 
     public PatchAttachment(String peerPortUuid) {
-        peer_port_uuid = peerPortUuid;
+        this.peerPortUuid = peerPortUuid;
     }
 
     public String getPeerPortUuid() {
-        return peer_port_uuid;
+        return peerPortUuid;
     }
 
     public void setPeerPortUuid(String peerPortUuid) {
-        peer_port_uuid = peerPortUuid;
+        this.peerPortUuid = peerPortUuid;
     }
 
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 a204e55..7622c68 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
@@ -20,19 +20,18 @@ package com.cloud.network.nicira;
  *
  */
 public class RouterNextHop {
-    private String gateway_ip_address;
-    private String type = "RouterNextHop";
+    private String gatewayIpAddress;
+    private final String type = "RouterNextHop";
 
     public RouterNextHop(String gatewayIpAddress) {
-        gateway_ip_address = gatewayIpAddress;
+        this.gatewayIpAddress = gatewayIpAddress;
     }
 
     public String getGatewayIpAddress() {
-        return gateway_ip_address;
+        return gatewayIpAddress;
     }
 
-    public void setGatewayIpAddress(String gateway_ip_address) {
-        this.gateway_ip_address = gateway_ip_address;
+    public void setGatewayIpAddress(String gatewayIpAddress) {
+        this.gatewayIpAddress = gatewayIpAddress;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 1228deb..bbe1cb5 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
@@ -20,19 +20,18 @@ package com.cloud.network.nicira;
  *
  */
 public class SingleDefaultRouteImplictRoutingConfig extends RoutingConfig {
-    public RouterNextHop default_route_next_hop;
+    public RouterNextHop defaultRouteNextHop;
     public String type = "SingleDefaultRouteImplicitRoutingConfig";
 
     public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
-        default_route_next_hop = routerNextHop;
+        defaultRouteNextHop = routerNextHop;
     }
 
     public RouterNextHop getDefaultRouteNextHop() {
-        return default_route_next_hop;
+        return defaultRouteNextHop;
     }
 
-    public void setDefaultRouteNextHop(RouterNextHop default_route_next_hop) {
-        this.default_route_next_hop = default_route_next_hop;
+    public void setDefaultRouteNextHop(RouterNextHop defaultRouteNextHop) {
+        this.defaultRouteNextHop = defaultRouteNextHop;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 910f830..db1bdb4 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
@@ -29,7 +29,7 @@ public class SourceNatRule extends NatRule {
         return toSourceIpAddressMax;
     }
 
-    public void setToSourceIpAddressMax(String toSourceIpAddressMax) {
+    public void setToSourceIpAddressMax(final String toSourceIpAddressMax) {
         this.toSourceIpAddressMax = toSourceIpAddressMax;
     }
 
@@ -37,7 +37,7 @@ public class SourceNatRule extends NatRule {
         return toSourceIpAddressMin;
     }
 
-    public void setToSourceIpAddressMin(String toSourceIpAddressMin) {
+    public void setToSourceIpAddressMin(final String toSourceIpAddressMin) {
         this.toSourceIpAddressMin = toSourceIpAddressMin;
     }
 
@@ -45,7 +45,7 @@ public class SourceNatRule extends NatRule {
         return toSourcePort;
     }
 
-    public void setToSourcePort(Integer toSourcePort) {
+    public void setToSourcePort(final Integer toSourcePort) {
         this.toSourcePort = toSourcePort;
     }
 
@@ -67,7 +67,7 @@ public class SourceNatRule extends NatRule {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj)
             return true;
         if (!super.equals(obj))
@@ -94,7 +94,7 @@ public class SourceNatRule extends NatRule {
     }
 
     @Override
-    public boolean equalsIgnoreUuid(Object obj) {
+    public boolean equalsIgnoreUuid(final Object obj) {
         if (this == obj)
             return true;
         if (!super.equalsIgnoreUuid(obj))

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 9c5f44d..a5047e0 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
@@ -17,30 +17,30 @@
 package com.cloud.network.nicira;
 
 public class TransportZoneBinding {
-    private String zone_uuid;
-    private String transport_type;
+    private String zoneUuid;
+    private String transportType;
 
     public TransportZoneBinding() {}
 
-    public TransportZoneBinding(String zone_uuid, String transport_type) {
-        this.zone_uuid = zone_uuid;
-        this.transport_type = transport_type;
+    public TransportZoneBinding(String zoneUuid, String transportType) {
+        this.zoneUuid = zoneUuid;
+        this.transportType = transportType;
     }
 
-    public String getZone_uuid() {
-        return zone_uuid;
+    public String getZoneUuid() {
+        return zoneUuid;
     }
 
-    public void setZone_uuid(String zone_uuid) {
-        this.zone_uuid = zone_uuid;
+    public void setZoneUuid(String zoneUuid) {
+        this.zoneUuid = zoneUuid;
     }
 
-    public String getTransport_type() {
-        return transport_type;
+    public String getTransportType() {
+        return transportType;
     }
 
-    public void setTransport_type(String transport_type) {
-        this.transport_type = transport_type;
+    public void setTransportType(String transportType) {
+        this.transportType = transportType;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 3a0b5f3..7b37ac1 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
@@ -18,21 +18,21 @@ package com.cloud.network.nicira;
 
 public class VifAttachment extends Attachment {
     private final String type = "VifAttachment";
-    private String vif_uuid;
+    private String vifUuid;
 
     public VifAttachment() {
     }
 
-    public VifAttachment(String vifUuid) {
-        vif_uuid = vifUuid;
+    public VifAttachment(final String vifUuid) {
+        this.vifUuid = vifUuid;
     }
 
-    public String getVif_uuid() {
-        return vif_uuid;
+    public String getVifUuid() {
+        return vifUuid;
     }
 
-    public void setVif_uuid(String vif_uuid) {
-        this.vif_uuid = vif_uuid;
+    public void setVifUuid(String vifUuid) {
+        this.vifUuid = vifUuid;
     }
 
     public String getType() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 3ab5f2b..c04c9ba 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
@@ -82,39 +82,41 @@ import com.cloud.network.nicira.VifAttachment;
 import com.cloud.resource.ServerResource;
 
 public class NiciraNvpResource implements ServerResource {
+    private static final int NAME_MAX_LEN = 40;
+
     private static final Logger s_logger = Logger.getLogger(NiciraNvpResource.class);
 
-    private String _name;
-    private String _guid;
-    private String _zoneId;
-    private int _numRetries;
+    private String name;
+    private String guid;
+    private String zoneId;
+    private int numRetries;
 
-    private NiciraNvpApi _niciraNvpApi;
+    private NiciraNvpApi niciraNvpApi;
 
     protected NiciraNvpApi createNiciraNvpApi() {
         return new NiciraNvpApi();
     }
 
     @Override
-    public boolean configure(String name, Map<String, Object> params)
+    public boolean configure(String ignoredName, final Map<String, Object> params)
             throws ConfigurationException {
 
-        _name = (String) params.get("name");
-        if (_name == null) {
+        name = (String) params.get("name");
+        if (name == null) {
             throw new ConfigurationException("Unable to find name");
         }
 
-        _guid = (String)params.get("guid");
-        if (_guid == null) {
+        guid = (String)params.get("guid");
+        if (guid == null) {
             throw new ConfigurationException("Unable to find the guid");
         }
 
-        _zoneId = (String) params.get("zoneId");
-        if (_zoneId == null) {
+        zoneId = (String) params.get("zoneId");
+        if (zoneId == null) {
             throw new ConfigurationException("Unable to find zone");
         }
 
-        _numRetries = 2;
+        numRetries = 2;
 
         String ip = (String) params.get("ip");
         if (ip == null) {
@@ -131,9 +133,9 @@ public class NiciraNvpResource implements ServerResource {
             throw new ConfigurationException("Unable to find admin password");
         }
 
-        _niciraNvpApi = createNiciraNvpApi();
-        _niciraNvpApi.setControllerAddress(ip);
-        _niciraNvpApi.setAdminCredentials(adminuser,adminpass);
+        niciraNvpApi = createNiciraNvpApi();
+        niciraNvpApi.setControllerAddress(ip);
+        niciraNvpApi.setAdminCredentials(adminuser,adminpass);
 
         return true;
     }
@@ -150,7 +152,7 @@ public class NiciraNvpResource implements ServerResource {
 
     @Override
     public String getName() {
-        return _name;
+        return name;
     }
 
     @Override
@@ -162,9 +164,9 @@ public class NiciraNvpResource implements ServerResource {
     @Override
     public StartupCommand[] initialize() {
         StartupNiciraNvpCommand sc = new StartupNiciraNvpCommand();
-        sc.setGuid(_guid);
-        sc.setName(_name);
-        sc.setDataCenter(_zoneId);
+        sc.setGuid(guid);
+        sc.setName(name);
+        sc.setDataCenter(zoneId);
         sc.setPod("");
         sc.setPrivateIpAddress("");
         sc.setStorageIpAddress("");
@@ -173,9 +175,9 @@ public class NiciraNvpResource implements ServerResource {
     }
 
     @Override
-    public PingCommand getCurrentStatus(long id) {
+    public PingCommand getCurrentStatus(final long id) {
         try {
-            ControlClusterStatus ccs = _niciraNvpApi.getControlClusterStatus();
+            ControlClusterStatus ccs = niciraNvpApi.getControlClusterStatus();
             if (!"stable".equals(ccs.getClusterStatus())) {
                 s_logger.error("ControlCluster state is not stable: "
                         + ccs.getClusterStatus());
@@ -189,11 +191,11 @@ public class NiciraNvpResource implements ServerResource {
     }
 
     @Override
-    public Answer executeRequest(Command cmd) {
-        return executeRequest(cmd, _numRetries);
+    public Answer executeRequest(final Command cmd) {
+        return executeRequest(cmd, numRetries);
     }
 
-    public Answer executeRequest(Command cmd, int numRetries) {
+    public Answer executeRequest(final Command cmd, final int numRetries) {
         if (cmd instanceof ReadyCommand) {
             return executeRequest((ReadyCommand) cmd);
         }
@@ -247,18 +249,18 @@ public class NiciraNvpResource implements ServerResource {
     }
 
     @Override
-    public void setAgentControl(IAgentControl agentControl) {
+    public void setAgentControl(final IAgentControl agentControl) {
     }
 
-    private Answer executeRequest(CreateLogicalSwitchCommand cmd, int numRetries) {
+    private Answer executeRequest(final CreateLogicalSwitchCommand cmd, int numRetries) {
         LogicalSwitch logicalSwitch = new LogicalSwitch();
-        logicalSwitch.setDisplay_name(truncate("lswitch-" + cmd.getName(), 40));
-        logicalSwitch.setPort_isolation_enabled(false);
+        logicalSwitch.setDisplayName(truncate("lswitch-" + cmd.getName(), NAME_MAX_LEN));
+        logicalSwitch.setPortIsolationEnabled(false);
 
         // Set transport binding
         List<TransportZoneBinding> ltzb = new ArrayList<TransportZoneBinding>();
         ltzb.add(new TransportZoneBinding(cmd.getTransportUuid(), cmd.getTransportType()));
-        logicalSwitch.setTransport_zones(ltzb);
+        logicalSwitch.setTransportZones(ltzb);
 
         // Tags set to scope cs_account and account name
         List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
@@ -266,7 +268,7 @@ public class NiciraNvpResource implements ServerResource {
         logicalSwitch.setTags(tags);
 
         try {
-            logicalSwitch = _niciraNvpApi.createLogicalSwitch(logicalSwitch);
+            logicalSwitch = niciraNvpApi.createLogicalSwitch(logicalSwitch);
             return new CreateLogicalSwitchAnswer(cmd, true, "Logicalswitch " + logicalSwitch.getUuid() + " created", logicalSwitch.getUuid());
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -279,9 +281,9 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(DeleteLogicalSwitchCommand cmd, int numRetries) {
+    private Answer executeRequest(final DeleteLogicalSwitchCommand cmd, int numRetries) {
         try {
-            _niciraNvpApi.deleteLogicalSwitch(cmd.getLogicalSwitchUuid());
+            niciraNvpApi.deleteLogicalSwitch(cmd.getLogicalSwitchUuid());
             return new DeleteLogicalSwitchAnswer(cmd, true, "Logicalswitch " + cmd.getLogicalSwitchUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -293,7 +295,7 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(CreateLogicalSwitchPortCommand cmd, int numRetries) {
+    private Answer executeRequest(final CreateLogicalSwitchPortCommand cmd, int numRetries) {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
 
@@ -303,12 +305,12 @@ public class NiciraNvpResource implements ServerResource {
             tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
 
             LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort(attachmentUuid, tags, true);
-            LogicalSwitchPort newPort = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, logicalSwitchPort);
+            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());
+                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());
@@ -323,9 +325,9 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(DeleteLogicalSwitchPortCommand cmd, int numRetries) {
+    private Answer executeRequest(final DeleteLogicalSwitchPortCommand cmd, int numRetries) {
         try {
-            _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), cmd.getLogicalSwitchPortUuid());
+            niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), cmd.getLogicalSwitchPortUuid());
             return new DeleteLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + cmd.getLogicalSwitchPortUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -337,7 +339,7 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(UpdateLogicalSwitchPortCommand cmd, int numRetries) {
+    private Answer executeRequest(final UpdateLogicalSwitchPortCommand cmd, int numRetries) {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
@@ -347,7 +349,7 @@ public class NiciraNvpResource implements ServerResource {
             List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
             tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
 
-            _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
+            niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
             return new UpdateLogicalSwitchPortAnswer(cmd, true, "Attachment for  " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid);
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -360,12 +362,12 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(FindLogicalSwitchPortCommand cmd, int numRetries) {
+    private Answer executeRequest(final FindLogicalSwitchPortCommand cmd, int numRetries) {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
 
         try {
-            NiciraNvpList<LogicalSwitchPort> ports = _niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
+            NiciraNvpList<LogicalSwitchPort> ports = niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
             if (ports.getResultCount() == 0) {
                 return new FindLogicalSwitchPortAnswer(cmd, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
             }
@@ -382,7 +384,7 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(CreateLogicalRouterCommand cmd, int numRetries) {
+    private Answer executeRequest(final CreateLogicalRouterCommand cmd, int numRetries) {
         String routerName = cmd.getName();
         String gatewayServiceUuid = cmd.getGatewayServiceUuid();
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
@@ -401,11 +403,11 @@ public class NiciraNvpResource implements ServerResource {
         try {
             // Create the Router
             LogicalRouterConfig lrc = new LogicalRouterConfig();
-            lrc.setDisplayName(truncate(routerName, 40));
+            lrc.setDisplayName(truncate(routerName, NAME_MAX_LEN));
             lrc.setTags(tags);
             lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(
                     new RouterNextHop(publicNetworkNextHopIp)));
-            lrc = _niciraNvpApi.createLogicalRouter(lrc);
+            lrc = niciraNvpApi.createLogicalRouter(lrc);
 
             // store the switchport for rollback
             LogicalSwitchPort lsp = null;
@@ -414,40 +416,40 @@ public class NiciraNvpResource implements ServerResource {
                 // Create the outside port for the router
                 LogicalRouterPort lrpo = new LogicalRouterPort();
                 lrpo.setAdminStatusEnabled(true);
-                lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
+                lrpo.setDisplayName(truncate(routerName + "-outside-port", NAME_MAX_LEN));
                 lrpo.setTags(tags);
                 List<String> outsideIpAddresses = new ArrayList<String>();
                 outsideIpAddresses.add(publicNetworkIpAddress);
                 lrpo.setIpAddresses(outsideIpAddresses);
-                lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
+                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);
+                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.setDisplayName(truncate(routerName + "-inside-port", NAME_MAX_LEN));
                 lrpi.setTags(tags);
                 List<String> insideIpAddresses = new ArrayList<String>();
                 insideIpAddresses.add(internalNetworkAddress);
                 lrpi.setIpAddresses(insideIpAddresses);
-                lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
+                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);
+                lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", NAME_MAX_LEN), 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(),
+                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(),
+                niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(),
                         new PatchAttachment(lrpi.getUuid()));
 
                 // Setup the source nat rule
@@ -458,14 +460,14 @@ public class NiciraNvpResource implements ServerResource {
                 match.setSourceIpAddresses(internalNetworkAddress);
                 snr.setMatch(match);
                 snr.setOrder(200);
-                _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr);
+                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());
+                    niciraNvpApi.deleteLogicalRouter(lrc.getUuid());
                     if (lsp != null) {
-                        _niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
+                        niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
                     }
                 } catch (NiciraNvpApiException ex) {}
 
@@ -483,9 +485,9 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(DeleteLogicalRouterCommand cmd, int numRetries) {
+    private Answer executeRequest(final DeleteLogicalRouterCommand cmd, int numRetries) {
         try {
-            _niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
+            niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
             return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -497,15 +499,15 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
+    private Answer executeRequest(final ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
         try {
-            NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
+            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);
+            niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
 
             return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() +
                     " ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
@@ -520,9 +522,9 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(ConfigureStaticNatRulesOnLogicalRouterCommand cmd, int numRetries) {
+    private Answer executeRequest(final ConfigureStaticNatRulesOnLogicalRouterCommand cmd, int numRetries) {
         try {
-            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            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
@@ -555,10 +557,10 @@ public class NiciraNvpResource implements ServerResource {
                 if (incoming != null && outgoing != null) {
                     if (rule.revoked()) {
                         s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
 
                         s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
                     }
                 }
                 else {
@@ -568,15 +570,15 @@ public class NiciraNvpResource implements ServerResource {
                         break;
                     }
 
-                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    rulepair[0] = niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
                     s_logger.debug("Created " + natRuleToString(rulepair[0]));
 
                     try {
-                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        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());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
                         throw ex; // Rethrow original exception
                     }
 
@@ -593,9 +595,9 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    private Answer executeRequest(ConfigurePortForwardingRulesOnLogicalRouterCommand cmd, int numRetries) {
+    private Answer executeRequest(final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd, int numRetries) {
         try {
-            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            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
@@ -637,10 +639,10 @@ public class NiciraNvpResource implements ServerResource {
                 if (incoming != null && outgoing != null) {
                     if (rule.revoked()) {
                         s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
 
                         s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
                     }
                 }
                 else {
@@ -650,15 +652,15 @@ public class NiciraNvpResource implements ServerResource {
                         break;
                     }
 
-                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    rulepair[0] = niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
                     s_logger.debug("Created " + natRuleToString(rulepair[0]));
 
                     try {
-                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        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());
+                        niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
                         throw ex; // Rethrow the original exception
                     }
 
@@ -676,20 +678,20 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(ReadyCommand cmd) {
+    private Answer executeRequest(final ReadyCommand cmd) {
         return new ReadyAnswer(cmd);
     }
 
-    private Answer executeRequest(MaintainCommand cmd) {
+    private Answer executeRequest(final MaintainCommand cmd) {
         return new MaintainAnswer(cmd);
     }
 
-    private Answer retry(Command cmd, int numRetries) {
+    private Answer retry(final Command cmd, final int numRetries) {
         s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);
         return executeRequest(cmd, numRetries);
     }
 
-    private String natRuleToString(NatRule rule) {
+    private String natRuleToString(final NatRule rule) {
 
         StringBuilder natRuleStr = new StringBuilder();
         natRuleStr.append("Rule ");
@@ -726,7 +728,7 @@ public class NiciraNvpResource implements ServerResource {
         return natRuleStr.toString();
     }
 
-    private String truncate(String string, int length) {
+    private String truncate(final String string, final int length) {
         if (string.length() <= length) {
             return string;
         }
@@ -735,7 +737,7 @@ public class NiciraNvpResource implements ServerResource {
         }
     }
 
-    protected NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) {
+    protected NatRule[] generateStaticNatRulePair(final String insideIp, final String outsideIp) {
         NatRule[] rulepair = new NatRule[2];
         rulepair[0] = new DestinationNatRule();
         rulepair[0].setType("DestinationNatRule");
@@ -760,8 +762,9 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    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
+    protected NatRule[] generatePortForwardingRulePair(final String insideIp, final int[] insidePorts,
+            final String outsideIp, final int[] outsidePorts, final 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]);
@@ -791,15 +794,13 @@ public class NiciraNvpResource implements ServerResource {
     }
 
     @Override
-    public void setName(String name) {
+    public void setName(final String name) {
         // TODO Auto-generated method stub
-
     }
 
     @Override
-    public void setConfigParams(Map<String, Object> params) {
+    public void setConfigParams(final Map<String, Object> params) {
         // TODO Auto-generated method stub
-
     }
 
     @Override
@@ -815,9 +816,8 @@ public class NiciraNvpResource implements ServerResource {
     }
 
     @Override
-    public void setRunLevel(int level) {
+    public void setRunLevel(final int level) {
         // TODO Auto-generated method stub
-
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/876b7e49/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 9202241..97f5f2f 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
@@ -72,59 +72,60 @@ import com.cloud.vm.ReservationContext;
 
 public class NiciraNvpElementTest {
 
-    NiciraNvpElement _element = new NiciraNvpElement();
-    NetworkOrchestrationService _networkManager = mock(NetworkOrchestrationService.class);
-    NetworkModel _networkModel = mock(NetworkModel.class);
-    NetworkServiceMapDao _ntwkSrvcDao = mock(NetworkServiceMapDao.class);
-    AgentManager _agentManager = mock(AgentManager.class);
-    HostDao _hostDao = mock(HostDao.class);
-    NiciraNvpDao _niciraNvpDao = mock(NiciraNvpDao.class);
-    NiciraNvpRouterMappingDao _niciraNvpRouterMappingDao = mock(NiciraNvpRouterMappingDao.class);
+    private static final long NETWORK_ID = 42L;
+    NiciraNvpElement element = new NiciraNvpElement();
+    NetworkOrchestrationService networkManager = mock(NetworkOrchestrationService.class);
+    NetworkModel networkModel = mock(NetworkModel.class);
+    NetworkServiceMapDao ntwkSrvcDao = mock(NetworkServiceMapDao.class);
+    AgentManager agentManager = mock(AgentManager.class);
+    HostDao hostDao = mock(HostDao.class);
+    NiciraNvpDao niciraNvpDao = mock(NiciraNvpDao.class);
+    NiciraNvpRouterMappingDao niciraNvpRouterMappingDao = mock(NiciraNvpRouterMappingDao.class);
 
     @Before
     public void setUp() throws ConfigurationException {
-        _element._resourceMgr = mock(ResourceManager.class);
-        _element._networkManager = _networkManager;
-        _element._ntwkSrvcDao = _ntwkSrvcDao;
-        _element._networkModel = _networkModel;
-        _element._agentMgr = _agentManager;
-        _element._hostDao = _hostDao;
-        _element._niciraNvpDao = _niciraNvpDao;
-        _element._niciraNvpRouterMappingDao = _niciraNvpRouterMappingDao;
+        element.resourceMgr = mock(ResourceManager.class);
+        element.networkManager = networkManager;
+        element.ntwkSrvcDao = ntwkSrvcDao;
+        element.networkModel = networkModel;
+        element.agentMgr = agentManager;
+        element.hostDao = hostDao;
+        element.niciraNvpDao = niciraNvpDao;
+        element.niciraNvpRouterMappingDao = niciraNvpRouterMappingDao;
 
         // Standard responses
-        when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
+        when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true);
 
-        _element.configure("NiciraNvpTestElement", Collections.<String, Object> emptyMap());
+        element.configure("NiciraNvpTestElement", Collections.<String, Object> emptyMap());
     }
 
     @Test
     public void canHandleTest() {
         Network net = mock(Network.class);
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-        when(net.getId()).thenReturn(42L);
+        when(net.getId()).thenReturn(NETWORK_ID);
 
-        when(_ntwkSrvcDao.canProviderSupportServiceInNetwork(42L, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
+        when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
         // Golden path
-        assertTrue(_element.canHandle(net, Service.Connectivity));
+        assertTrue(element.canHandle(net, Service.Connectivity));
 
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vlan);
         // Only broadcastdomaintype lswitch is supported
-        assertFalse(_element.canHandle(net, Service.Connectivity));
+        assertFalse(element.canHandle(net, Service.Connectivity));
 
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-        when(_ntwkSrvcDao.canProviderSupportServiceInNetwork(42L, Service.Connectivity, Provider.NiciraNvp)).thenReturn(false);
+        when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(false);
         // No nvp provider in the network
-        assertFalse(_element.canHandle(net, Service.Connectivity));
+        assertFalse(element.canHandle(net, Service.Connectivity));
 
-        when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(false);
-        when(_ntwkSrvcDao.canProviderSupportServiceInNetwork(42L, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
+        when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(false);
+        when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
         // NVP provider does not provide Connectivity for this network
-        assertFalse(_element.canHandle(net, Service.Connectivity));
+        assertFalse(element.canHandle(net, Service.Connectivity));
 
-        when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
+        when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true);
         // Only service Connectivity is supported
-        assertFalse(_element.canHandle(net, Service.Dhcp));
+        assertFalse(element.canHandle(net, Service.Dhcp));
 
     }
 
@@ -132,10 +133,10 @@ public class NiciraNvpElementTest {
     public void implementTest() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
         Network network = mock(Network.class);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-        when(network.getId()).thenReturn(42L);
+        when(network.getId()).thenReturn(NETWORK_ID);
 
         NetworkOffering offering = mock(NetworkOffering.class);
-        when(offering.getId()).thenReturn(42L);
+        when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
@@ -148,19 +149,17 @@ public class NiciraNvpElementTest {
         ReservationContext context = mock(ReservationContext.class);
         when(context.getDomain()).thenReturn(dom);
         when(context.getAccount()).thenReturn(acc);
-
-        // assertTrue(_element.implement(network, offering, dest, context));
     }
 
     @Test
     public void applyIpTest() throws ResourceUnavailableException {
         Network network = mock(Network.class);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-        when(network.getId()).thenReturn(42L);
-        when(network.getPhysicalNetworkId()).thenReturn(42L);
+        when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
 
         NetworkOffering offering = mock(NetworkOffering.class);
-        when(offering.getId()).thenReturn(42L);
+        when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
@@ -186,23 +185,23 @@ public class NiciraNvpElementTest {
         List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
         NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
         NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
-        when(_niciraNvpRouterMappingDao.findByNetworkId(42L)).thenReturn(nnrmVO);
+        when(niciraNvpRouterMappingDao.findByNetworkId(NETWORK_ID)).thenReturn(nnrmVO);
         when(nnrmVO.getLogicalRouterUuid()).thenReturn("abcde");
-        when(nndVO.getHostId()).thenReturn(42L);
+        when(nndVO.getHostId()).thenReturn(NETWORK_ID);
         HostVO hvo = mock(HostVO.class);
-        when(hvo.getId()).thenReturn(42L);
+        when(hvo.getId()).thenReturn(NETWORK_ID);
         when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
-        when(_hostDao.findById(42L)).thenReturn(hvo);
+        when(hostDao.findById(NETWORK_ID)).thenReturn(hvo);
         deviceList.add(nndVO);
-        when(_niciraNvpDao.listByPhysicalNetwork(42L)).thenReturn(deviceList);
+        when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(deviceList);
 
         ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
         when(answer.getResult()).thenReturn(true);
-        when(_agentManager.easySend(eq(42L), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);
+        when(agentManager.easySend(eq(NETWORK_ID), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);
 
-        assertTrue(_element.applyIps(network, ipAddresses, services));
+        assertTrue(element.applyIps(network, ipAddresses, services));
 
-        verify(_agentManager, atLeast(1)).easySend(eq(42L),
+        verify(agentManager, atLeast(1)).easySend(eq(NETWORK_ID),
                 argThat(new ArgumentMatcher<ConfigurePublicIpsOnLogicalRouterCommand>() {
                     @Override
                     public boolean matches(Object argument) {


Mime
View raw message