cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [23/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Date Thu, 20 Feb 2014 19:17:29 GMT
Nvp and rest refactoring and more tests

Signed-off-by: Hugo Trippaers <htrippaers@schubergphilis.com>


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

Branch: refs/heads/ui-restyle
Commit: 510972abde3b5435ed2a4d02fc4f59a1f6dabefe
Parents: dda47db
Author: Antonio Fornie <afornie@schubergphilis.com>
Authored: Wed Feb 5 10:01:06 2014 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Tue Feb 18 09:51:54 2014 +0100

----------------------------------------------------------------------
 .../network/nicira/AccessConfiguration.java     |  90 +--
 .../src/com/cloud/network/nicira/Acl.java       |   1 -
 .../cloud/network/nicira/BaseNiciraEntity.java  |  85 +++
 .../network/nicira/BaseNiciraNamedEntity.java   |  44 ++
 .../com/cloud/network/nicira/LogicalRouter.java |  71 ++
 .../network/nicira/LogicalRouterConfig.java     |  65 --
 .../cloud/network/nicira/LogicalRouterPort.java |  41 +-
 .../com/cloud/network/nicira/LogicalSwitch.java |  68 +-
 .../cloud/network/nicira/LogicalSwitchPort.java |  50 +-
 .../com/cloud/network/nicira/NiciraNvpApi.java  | 745 +++++++------------
 ...SingleDefaultRouteImplicitRoutingConfig.java |  40 +
 .../SingleDefaultRouteImplictRoutingConfig.java |  40 -
 .../com/cloud/network/nicira/VifAttachment.java |  35 +-
 .../network/resource/NiciraNvpResource.java     |  20 +-
 .../network/element/NiciraNvpElementTest.java   |  42 +-
 .../guru/NiciraNvpGuestNetworkGuruTest.java     | 154 ++--
 .../com/cloud/network/nicira/NatRuleTest.java   |  12 +-
 .../cloud/network/nicira/NiciraNvpApiIT.java    | 200 ++++-
 .../cloud/network/nicira/NiciraNvpApiTest.java  | 650 ++++++----------
 .../com/cloud/network/nicira/NiciraTagTest.java |   8 +-
 .../network/resource/NiciraNvpResourceTest.java | 258 ++++---
 pom.xml                                         |   6 +
 utils/pom.xml                                   |  27 +
 .../BasicEncodedRESTValidationStrategy.java     |  47 ++
 .../utils/rest/CloudstackRESTException.java     |  36 +
 .../cloud/utils/rest/RESTServiceConnector.java  | 377 ++++++++++
 .../utils/rest/RESTValidationStrategy.java      | 146 ++++
 .../utils/rest/RESTServiceConnectorTest.java    | 373 ++++++++++
 28 files changed, 2277 insertions(+), 1454 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
index 487f14b..b5291dc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
@@ -19,32 +19,12 @@
 
 package com.cloud.network.nicira;
 
-import java.io.Serializable;
 import java.util.List;
 
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
+public abstract class AccessConfiguration<T extends AccessRule> extends BaseNiciraNamedEntity {
 
-@SuppressWarnings("serial")
-public abstract class AccessConfiguration<T extends AccessRule> implements Serializable {
-
-    protected String displayName;
     protected List<T> logicalPortEgressRules;
     protected List<T> logicalPortIngressRules;
-    protected List<NiciraNvpTag> tags;
-    protected String uuid;
-    protected String href;
-    protected String schema;
-
-    public String getDisplayName() {
-        return displayName;
-    }
-
-    public void setDisplayName(final String displayName) {
-        this.displayName = displayName;
-    }
 
     public List<T> getLogicalPortEgressRules() {
         return logicalPortEgressRules;
@@ -61,72 +41,4 @@ public abstract class AccessConfiguration<T extends AccessRule> implements Seria
     public void setLogicalPortIngressRules(final List<T> logicalPortIngressRules) {
         this.logicalPortIngressRules = logicalPortIngressRules;
     }
-
-    public String getUuid() {
-        return uuid;
-    }
-
-    public void setUuid(final String uuid) {
-        this.uuid = uuid;
-    }
-
-    public String getHref() {
-        return href;
-    }
-
-    public void setHref(final String href) {
-        this.href = href;
-    }
-
-    public String getSchema() {
-        return schema;
-    }
-
-    public void setSchema(final String schema) {
-        this.schema = schema;
-    }
-
-    public List<NiciraNvpTag> getTags() {
-        return tags;
-    }
-
-    public void setTags(final List<NiciraNvpTag> tags) {
-        this.tags = tags;
-    }
-
-    @Override
-    public String toString() {
-        return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
-    }
-
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder(17, 31)
-            .append(displayName).append(logicalPortEgressRules)
-            .append(logicalPortIngressRules).append(tags)
-            .append(uuid).append(href).append(schema)
-            .toHashCode();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public boolean equals(final Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (!(this.getClass().isInstance(obj))) {
-            return false;
-        }
-        final AccessConfiguration<? extends AccessRule> another =
-                (AccessConfiguration<? extends AccessRule>) obj;
-        return new EqualsBuilder()
-                .append(displayName, another.displayName)
-                .append(uuid, another.uuid)
-                .append(href, another.href)
-                .append(schema, another.schema)
-                .isEquals();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
index 976177f..870124e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
@@ -19,6 +19,5 @@
 
 package com.cloud.network.nicira;
 
-@SuppressWarnings("serial")
 public class Acl extends AccessConfiguration<AclRule> {
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
new file mode 100644
index 0000000..afcd233
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
@@ -0,0 +1,85 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// 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,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.nicira;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+public abstract class BaseNiciraEntity implements Serializable {
+    protected String href;
+    protected String schema;
+    protected String uuid;
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(final String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getHref() {
+        return href;
+    }
+
+    public void setHref(final String href) {
+        this.href = href;
+    }
+
+    public String getSchema() {
+        return schema;
+    }
+
+    public void setSchema(final String schema) {
+        this.schema = schema;
+    }
+
+    @Override
+    public String toString() {
+        return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 31)
+                .append(this.getClass())
+                .append(uuid)
+                .toHashCode();
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (!(this.getClass().isInstance(obj))) {
+            return false;
+        }
+        final BaseNiciraEntity another = (BaseNiciraEntity) obj;
+        return new EqualsBuilder().append(uuid, another.uuid).isEquals();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
new file mode 100644
index 0000000..0e21ddb
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
@@ -0,0 +1,44 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// 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,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.nicira;
+
+import java.util.List;
+
+public abstract class BaseNiciraNamedEntity extends BaseNiciraEntity {
+
+    protected String displayName;
+    protected List<NiciraNvpTag> tags;
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(final String displayName) {
+        this.displayName = displayName;
+    }
+
+    public List<NiciraNvpTag> getTags() {
+        return tags;
+    }
+
+    public void setTags(final List<NiciraNvpTag> tags) {
+        this.tags = tags;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
new file mode 100644
index 0000000..edc9351
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
@@ -0,0 +1,71 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// 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,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.nicira;
+
+
+/**
+ *
+ */
+public class LogicalRouter extends BaseNiciraNamedEntity {
+    public static final String REPLICATION_MODE_SERVICE = "service";
+    public static final String REPLICATION_MODE_SOURCE = "source";
+
+    private final String type = "LogicalRouterConfig";
+    private RoutingConfig routingConfig;
+    private boolean distributed;
+    private boolean natSynchronizationEnabled;
+    private String replicationMode;
+
+    public String getType() {
+        return type;
+    }
+
+    public RoutingConfig getRoutingConfig() {
+        return routingConfig;
+    }
+
+    public void setRoutingConfig(final RoutingConfig routingConfig) {
+        this.routingConfig = routingConfig;
+    }
+
+    public boolean isDistributed() {
+        return distributed;
+    }
+
+    public void setDistributed(final boolean distributed) {
+        this.distributed = distributed;
+    }
+
+    public boolean isNatSynchronizationEnabled() {
+        return natSynchronizationEnabled;
+    }
+
+    public void setNatSynchronizationEnabled(final boolean natSynchronizationEnabled) {
+        this.natSynchronizationEnabled = natSynchronizationEnabled;
+    }
+
+    public String getReplicationMode() {
+        return replicationMode;
+    }
+
+    public void setReplicationMode(final String replicationMode) {
+        this.replicationMode = replicationMode;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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
deleted file mode 100644
index b6eaa8f..0000000
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// 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,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-
-package com.cloud.network.nicira;
-
-import java.util.List;
-
-/**
- *
- */
-public class LogicalRouterConfig {
-    private String displayName;
-    private RoutingConfig routingConfig;
-    private final String type = "LogicalRouterConfig";
-    private String uuid;
-    private List<NiciraNvpTag> tags;
-
-    public RoutingConfig getRoutingConfig() {
-        return routingConfig;
-    }
-
-    public void setRoutingConfig(RoutingConfig routingConfig) {
-        this.routingConfig = routingConfig;
-    }
-
-    public String getDisplayName() {
-        return displayName;
-    }
-
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
-
-    public String getUuid() {
-        return uuid;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public List<NiciraNvpTag> getTags() {
-        return tags;
-    }
-
-    public void setTags(List<NiciraNvpTag> tags) {
-        this.tags = tags;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 8ffe054..d9ee09a 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
@@ -21,24 +21,18 @@ package com.cloud.network.nicira;
 
 import java.util.List;
 
-/**
- *
- */
-public class LogicalRouterPort {
-    private String displayName;
-    private List<NiciraNvpTag> tags;
+public class LogicalRouterPort extends BaseNiciraNamedEntity {
     private Integer portno;
     private boolean adminStatusEnabled;
     private List<String> ipAddresses;
     private String macAddress;
     private final String type = "LogicalRouterPortConfig";
-    private String uuid;
 
     public int getPortno() {
         return portno;
     }
 
-    public void setPortno(int portno) {
+    public void setPortno(final int portno) {
         this.portno = portno;
     }
 
@@ -46,7 +40,7 @@ public class LogicalRouterPort {
         return adminStatusEnabled;
     }
 
-    public void setAdminStatusEnabled(boolean adminStatusEnabled) {
+    public void setAdminStatusEnabled(final boolean adminStatusEnabled) {
         this.adminStatusEnabled = adminStatusEnabled;
     }
 
@@ -54,7 +48,7 @@ public class LogicalRouterPort {
         return ipAddresses;
     }
 
-    public void setIpAddresses(List<String> ipAddresses) {
+    public void setIpAddresses(final List<String> ipAddresses) {
         this.ipAddresses = ipAddresses;
     }
 
@@ -62,32 +56,7 @@ public class LogicalRouterPort {
         return macAddress;
     }
 
-    public void setMacAddress(String macAddress) {
+    public void setMacAddress(final String macAddress) {
         this.macAddress = macAddress;
     }
-
-    public String getDisplayName() {
-        return displayName;
-    }
-
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
-
-    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/510972ab/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 2379354..b527d94 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
@@ -21,29 +21,20 @@ package com.cloud.network.nicira;
 
 import java.util.List;
 
-public class LogicalSwitch {
-    private String displayName;
+public class LogicalSwitch extends BaseNiciraNamedEntity {
+    public static final String REPLICATION_MODE_SERVICE = "service";
+    public static final String REPLICATION_MODE_SOURCE = "source";
+
+    private final String type = "LogicalSwitchConfig";
     private boolean portIsolationEnabled;
-    private List<NiciraNvpTag> tags;
     private List<TransportZoneBinding> transportZones;
-    private String type;
-    private String uuid;
-    private String href;
-    private String schema;
-
-    public String getDisplayName() {
-        return displayName;
-    }
-
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
+    private String replicationMode;
 
     public boolean isPortIsolationEnabled() {
         return portIsolationEnabled;
     }
 
-    public void setPortIsolationEnabled(boolean portIsolationEnabled) {
+    public void setPortIsolationEnabled(final boolean portIsolationEnabled) {
         this.portIsolationEnabled = portIsolationEnabled;
     }
 
@@ -51,48 +42,19 @@ public class LogicalSwitch {
         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 getHref() {
-        return href;
-    }
-
-    public void setHref(String href) {
-        this.href = href;
-    }
-
-    public String getSchema() {
-        return schema;
-    }
-
-    public void setSchema(String schema) {
-        this.schema = schema;
-    }
-
-    public List<NiciraNvpTag> getTags() {
-        return tags;
-    }
-
-    public void setTags(List<NiciraNvpTag> tags) {
-        this.tags = tags;
-    }
-
     public List<TransportZoneBinding> getTransportZones() {
         return transportZones;
     }
 
-    public void setTransportZones(List<TransportZoneBinding> transportZones) {
+    public void setTransportZones(final List<TransportZoneBinding> transportZones) {
         this.transportZones = transportZones;
     }
 
+    public String getReplicationMode() {
+        return replicationMode;
+    }
+
+    public void setReplicationMode(final String replicationMode) {
+        this.replicationMode = replicationMode;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 3565fbe..5e07423 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
@@ -21,16 +21,13 @@ package com.cloud.network.nicira;
 
 import java.util.List;
 
-public class LogicalSwitchPort {
-    private String displayName;
-    private List<NiciraNvpTag> tags;
+public class LogicalSwitchPort extends BaseNiciraNamedEntity {
     private Integer portno;
     private boolean adminStatusEnabled;
     private String queueUuid;
     private List<String> securityProfiles;
     private List<String> mirrorTargets;
-    private String type;
-    private String uuid;
+    private final String type = "LogicalSwitchPortConfig";
 
     public LogicalSwitchPort() {
         super();
@@ -43,27 +40,11 @@ public class LogicalSwitchPort {
         this.adminStatusEnabled = adminStatusEnabled;
     }
 
-    public String getDisplayName() {
-        return displayName;
-    }
-
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
-
-    public List<NiciraNvpTag> getTags() {
-        return tags;
-    }
-
-    public void setTags(List<NiciraNvpTag> tags) {
-        this.tags = tags;
-    }
-
     public Integer getPortno() {
         return portno;
     }
 
-    public void setPortno(Integer portno) {
+    public void setPortno(final Integer portno) {
         this.portno = portno;
     }
 
@@ -71,7 +52,7 @@ public class LogicalSwitchPort {
         return adminStatusEnabled;
     }
 
-    public void setAdminStatusEnabled(boolean adminStatusEnabled) {
+    public void setAdminStatusEnabled(final boolean adminStatusEnabled) {
         this.adminStatusEnabled = adminStatusEnabled;
     }
 
@@ -79,7 +60,7 @@ public class LogicalSwitchPort {
         return queueUuid;
     }
 
-    public void setQueueUuid(String queueUuid) {
+    public void setQueueUuid(final String queueUuid) {
         this.queueUuid = queueUuid;
     }
 
@@ -87,7 +68,7 @@ public class LogicalSwitchPort {
         return securityProfiles;
     }
 
-    public void setSecurityProfiles(List<String> securityProfiles) {
+    public void setSecurityProfiles(final List<String> securityProfiles) {
         this.securityProfiles = securityProfiles;
     }
 
@@ -95,24 +76,7 @@ public class LogicalSwitchPort {
         return mirrorTargets;
     }
 
-    public void setMirrorTargets(List<String> mirrorTargets) {
+    public void setMirrorTargets(final List<String> mirrorTargets) {
         this.mirrorTargets = mirrorTargets;
     }
-
-    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;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 83d0075..3861d63 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
@@ -18,55 +18,14 @@
 //
 
 package com.cloud.network.nicira;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Type;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.UUID;
 
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-import org.apache.log4j.Logger;
-
-import com.google.gson.FieldNamingPolicy;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
@@ -74,33 +33,24 @@ import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
 import com.google.gson.reflect.TypeToken;
 
+import com.cloud.utils.rest.CloudstackRESTException;
+import com.cloud.utils.rest.RESTServiceConnector;
+import com.cloud.utils.rest.RESTValidationStrategy;
+
 @SuppressWarnings("rawtypes")
 public class NiciraNvpApi {
     protected static final String GET_METHOD_TYPE = "get";
     protected static final String DELETE_METHOD_TYPE = "delete";
     protected static final String PUT_METHOD_TYPE = "put";
     protected static final String POST_METHOD_TYPE = "post";
-    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;
+
     protected static final String SEC_PROFILE_URI_PREFIX = "/ws.v1/security-profile";
     protected static final String ACL_URI_PREFIX = "/ws.v1/acl";
     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 final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
-
-    private String host;
-    private String adminuser;
-    private String adminpass;
-
-    private final HttpClient client;
-    private String nvpVersion;
+    private static final String LOGIN_URL = "/ws.v1/login";
 
-    private final Gson gson;
+    protected RESTServiceConnector restConnector;
 
     protected final static Map<Class, String> prefixMap;
 
@@ -112,115 +62,174 @@ public class NiciraNvpApi {
         prefixMap = new HashMap<Class, String>();
         prefixMap.put(SecurityProfile.class, SEC_PROFILE_URI_PREFIX);
         prefixMap.put(Acl.class, ACL_URI_PREFIX);
+        prefixMap.put(LogicalSwitch.class, SWITCH_URI_PREFIX);
+        prefixMap.put(LogicalRouter.class, ROUTER_URI_PREFIX);
 
         listTypeMap = new HashMap<Class, Type>();
         listTypeMap.put(SecurityProfile.class, new TypeToken<NiciraNvpList<SecurityProfile>>() {
         }.getType());
         listTypeMap.put(Acl.class, new TypeToken<NiciraNvpList<Acl>>() {
         }.getType());
+        listTypeMap.put(LogicalSwitch.class, new TypeToken<NiciraNvpList<LogicalSwitch>>() {
+        }.getType());
+        listTypeMap.put(LogicalRouter.class, new TypeToken<NiciraNvpList<LogicalRouter>>() {
+        }.getType());
 
         defaultListParams = new HashMap<String, String>();
         defaultListParams.put("fields", "*");
     }
 
-    /* This factory method is protected so we can extend this
-     * in the unittests.
-     */
-    protected HttpClient createHttpClient() {
-        return new HttpClient(s_httpClientManager);
+    public NiciraNvpApi() {
+        final List<Class<?>> classList = new ArrayList<Class<?>>();
+        classList.add(NatRule.class);
+        classList.add(RoutingConfig.class);
+        final List<JsonDeserializer<?>> deserializerList = new ArrayList<JsonDeserializer<?>>();
+        deserializerList.add(new NatRuleAdapter());
+        deserializerList.add(new RoutingConfigAdapter());
+
+        restConnector = new RESTServiceConnector(new RESTValidationStrategy(LOGIN_URL), classList, deserializerList);
     }
 
-    protected HttpMethod createMethod(final String type, final String uri) throws NiciraNvpApiException {
-        String url;
-        try {
-            url = new URL(protocol, host, uri).toString();
-        } catch (final MalformedURLException e) {
-            s_logger.error("Unable to build Nicira API URL", e);
-            throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
-        }
+    public NiciraNvpApi(final String address, final String username, final String password) {
+        this();
+        restConnector.setControllerAddress(address);
+        restConnector.setAdminCredentials(username, password);
+    }
 
-        if (POST_METHOD_TYPE.equalsIgnoreCase(type)) {
-            return new PostMethod(url);
-        } else if (GET_METHOD_TYPE.equalsIgnoreCase(type)) {
-            return new GetMethod(url);
-        } else if (DELETE_METHOD_TYPE.equalsIgnoreCase(type)) {
-            return new DeleteMethod(url);
-        } else if (PUT_METHOD_TYPE.equalsIgnoreCase(type)) {
-            return new PutMethod(url);
-        } else {
-            throw new NiciraNvpApiException("Requesting unknown method type");
-        }
+    public void setControllerAddress(final String address) {
+        restConnector.setControllerAddress(address);
     }
 
-    public NiciraNvpApi() {
-        client = createHttpClient();
-        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+    public void setAdminCredentials(final String username, final String password) {
+        restConnector.setAdminCredentials(username, password);
+    }
+
+    /**
+     * POST
+     *
+     * @param entity
+     * @return
+     * @throws NiciraNvpApiException
+     */
+    protected <T> T create(final T entity) throws NiciraNvpApiException {
+        final String uri = prefixMap.get(entity.getClass());
+        return createWithUri(entity, uri);
+    }
 
+    /**
+     * POST
+     *
+     * @param entity
+     * @return
+     * @throws NiciraNvpApiException
+     */
+    protected <T> T createWithUri(final T entity, final String uri) throws NiciraNvpApiException {
+        T createdEntity;
         try {
-            // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
-            Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)new TrustingProtocolSocketFactory(), HTTPS_PORT));
-        } catch (final IOException e) {
-            s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
+            createdEntity = restConnector.executeCreateObject(entity, new TypeToken<T>() {
+            }.getType(), uri, Collections.<String, String> emptyMap());
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
         }
 
-        gson = new GsonBuilder().registerTypeAdapter(NatRule.class, new NatRuleAdapter()).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
-    }
-
-    public void setControllerAddress(final String address) {
-        host = address;
+        return createdEntity;
     }
 
-    public void setAdminCredentials(final String username, final String password) {
-        adminuser = username;
-        adminpass = password;
+    /**
+     * GET list of items
+     *
+     * @return
+     * @throws NiciraNvpApiException
+     */
+    protected <T> NiciraNvpList<T> find(final Class<T> clazz) throws NiciraNvpApiException {
+        return find(null, clazz);
     }
 
     /**
-     * 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.
+     * GET list of items
      *
+     * @param uuid
+     * @return
+     * @throws NiciraNvpApiException
      */
-    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");
+    public <T> NiciraNvpList<T> find(final String uuid, final Class<T> clazz) throws NiciraNvpApiException {
+        final String uri = prefixMap.get(clazz);
+        Map<String, String> params = defaultListParams;
+        if (uuid != null) {
+            params = new HashMap<String, String>(defaultListParams);
+            params.put("uuid", uuid);
         }
 
+        NiciraNvpList<T> entities;
         try {
-            url = new URL(protocol, host, "/ws.v1/login").toString();
-        } catch (final MalformedURLException e) {
-            s_logger.error("Unable to build Nicira API URL", e);
-            throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
+            entities = restConnector.executeRetrieveObject(listTypeMap.get(clazz), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
         }
 
-        final PostMethod pm = new PostMethod(url);
-        pm.addParameter("username", adminuser);
-        pm.addParameter("password", adminpass);
+        if (entities == null) {
+            throw new NiciraNvpApiException("Unexpected response from API");
+        }
 
+        return entities;
+    }
+
+    /**
+     * PUT item given a UUID as key and an item object
+     * with the new data
+     *
+     * @param item
+     * @param uuid
+     * @throws NiciraNvpApiException
+     */
+    public <T> void update(final T item, final String uuid)
+                    throws NiciraNvpApiException {
+        final String uri = prefixMap.get(item.getClass()) + "/" + uuid;
+        updateWithUri(item, uri);
+    }
+
+    /**
+     * PUT item given a UUID as key and an item object
+     * with the new data
+     *
+     * @param item
+     * @param uuid
+     * @throws NiciraNvpApiException
+     */
+    public <T> void updateWithUri(final T item, final String uri)
+                    throws NiciraNvpApiException {
         try {
-            client.executeMethod(pm);
-        } catch (final HttpException e) {
-            throw new NiciraNvpApiException("Nicira NVP API login failed ", e);
-        } catch (final IOException e) {
-            throw new NiciraNvpApiException("Nicira NVP API login failed ", e);
-        } finally {
-            pm.releaseConnection();
+            restConnector.executeUpdateObject(item, uri, Collections.<String, String> emptyMap());
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
         }
+    }
 
-        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());
-        }
+    /**
+     * DELETE Security Profile given a UUID as key
+     *
+     * @param securityProfileUuid
+     * @throws NiciraNvpApiException
+     */
+    public <T> void delete(final String uuid, final Class<T> clazz)
+            throws NiciraNvpApiException {
+        final String uri = prefixMap.get(clazz) + "/" + uuid;
+        deleteWithUri(uri);
+    }
 
-        // Extract the version for later use
-        if (pm.getResponseHeader("Server") != null) {
-            nvpVersion = pm.getResponseHeader("Server").getValue();
-            s_logger.debug("NVP Controller reports version " + nvpVersion);
+    /**
+     * DELETE Security Profile given a UUID as key
+     *
+     * @param securityProfileUuid
+     * @throws NiciraNvpApiException
+     */
+    public <T> void deleteWithUri(final String uri)
+            throws NiciraNvpApiException {
+        try {
+            restConnector.executeDeleteObject(uri);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
         }
-
-        // Success; the cookie required for login is kept in _client
     }
 
     /**
@@ -341,111 +350,68 @@ public class NiciraNvpApi {
         delete(aclUuid, Acl.class);
     }
 
-    /**
-     * POST
-     *
-     * @param entity
-     * @return
-     * @throws NiciraNvpApiException
-     */
-    protected <T> T create(final T entity) throws NiciraNvpApiException {
-        final String uri = prefixMap.get(entity.getClass());
-        final T createdEntity = executeCreateObject(entity, new TypeToken<T>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
-
-        return createdEntity;
+    public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
+        return create(logicalSwitch);
     }
 
     /**
-     * GET list of items
+     * GET list of {@link LogicalSwitch}
      *
      * @return
      * @throws NiciraNvpApiException
      */
-    protected <T> NiciraNvpList<T> find(final Class<T> clazz) throws NiciraNvpApiException {
-        return find(null, clazz);
+    public NiciraNvpList<LogicalSwitch> findLogicalSwitch() throws NiciraNvpApiException {
+        return findLogicalSwitch(null);
     }
 
     /**
-     * GET list of items
+     * GET list of {@link LogicalSwitch} filtered by UUID
      *
      * @param uuid
      * @return
      * @throws NiciraNvpApiException
      */
-    public <T> NiciraNvpList<T> find(final String uuid, final Class<T> clazz) throws NiciraNvpApiException {
-        final String uri = prefixMap.get(clazz);
-        Map<String, String> params = defaultListParams;
-        if (uuid != null) {
-            params = new HashMap<String, String>(defaultListParams);
-            params.put("uuid", uuid);
-        }
-
-        final NiciraNvpList<T> entities = executeRetrieveObject(listTypeMap.get(clazz), uri, params);
-
-        if (entities == null) {
-            throw new NiciraNvpApiException("Unexpected response from API");
-        }
-
-        return entities;
+    public NiciraNvpList<LogicalSwitch> findLogicalSwitch(final String uuid) throws NiciraNvpApiException {
+        return find(uuid, LogicalSwitch.class);
     }
 
     /**
-     * PUT item given a UUID as key and an item object
+     * PUT {@link LogicalSwitch} given a UUID as key and a {@link LogicalSwitch}
      * with the new data
      *
-     * @param item
-     * @param uuid
+     * @param logicalSwitch
+     * @param logicalSwitchUuid
      * @throws NiciraNvpApiException
      */
-    public <T> void update(final T item,
-            final String uuid)
+    public void updateLogicalSwitch(final LogicalSwitch logicalSwitch,
+            final String logicalSwitchUuid)
                     throws NiciraNvpApiException {
-        final String uri = prefixMap.get(item.getClass()) + "/" + uuid;
-        executeUpdateObject(item, uri, Collections.<String, String> emptyMap());
-    }
-
-    /**
-     * DELETE Security Profile given a UUID as key
-     *
-     * @param securityProfileUuid
-     * @throws NiciraNvpApiException
-     */
-    public <T> void delete(final String uuid, final Class<T> clazz)
-            throws NiciraNvpApiException {
-        final String uri = prefixMap.get(clazz) + "/" + uuid;
-        executeDeleteObject(uri);
-    }
-
-    public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
-        final String uri = SWITCH_URI_PREFIX;
-        final LogicalSwitch createdLogicalSwitch = executeCreateObject(logicalSwitch, new TypeToken<LogicalSwitch>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
-
-        return createdLogicalSwitch;
+        update(logicalSwitch, logicalSwitchUuid);
     }
 
     public void deleteLogicalSwitch(final String uuid) throws NiciraNvpApiException {
-        final String uri = SWITCH_URI_PREFIX + "/" + uuid;
-        executeDeleteObject(uri);
+        delete(uuid, LogicalSwitch.class);
     }
 
     public LogicalSwitchPort createLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
         final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport";
-        final LogicalSwitchPort createdLogicalSwitchPort = executeCreateObject(logicalSwitchPort, new TypeToken<LogicalSwitchPort>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
+        return createWithUri(logicalSwitchPort, uri);
+    }
 
-        return createdLogicalSwitchPort;
+    public void updateLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
+        final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPort.getUuid();
+        updateWithUri(logicalSwitchPort, uri);
     }
 
-    public void modifyLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid, final Attachment attachment) throws NiciraNvpApiException {
+    public void updateLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid,
+            final Attachment attachment) throws NiciraNvpApiException {
         final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment";
-        executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap());
+        updateWithUri(attachment, uri);
     }
 
     public void deleteLogicalSwitchPort(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException {
         final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid;
-        executeDeleteObject(uri);
+        deleteWithUri(uri);
     }
 
     public String findLogicalSwitchPortUuidByVifAttachmentUuid(final String logicalSwitchUuid, final String vifAttachmentUuid) throws NiciraNvpApiException {
@@ -454,8 +420,13 @@ public class NiciraNvpApi {
         params.put("attachment_vif_uuid", vifAttachmentUuid);
         params.put("fields", "uuid");
 
-        final NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
-        }.getType(), uri, params);
+        NiciraNvpList<LogicalSwitchPort> lspl;
+        try {
+            lspl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
 
         if (lspl == null || lspl.getResultCount() != 1) {
             throw new NiciraNvpApiException("Unexpected response from API");
@@ -467,8 +438,13 @@ public class NiciraNvpApi {
 
     public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException {
         final String uri = "/ws.v1/control-cluster/status";
-        final ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
-        }.getType(), uri, null);
+        ControlClusterStatus ccs;
+        try {
+            ccs = restConnector.executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
+            }.getType(), uri, null);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
 
         return ccs;
     }
@@ -479,8 +455,13 @@ public class NiciraNvpApi {
         params.put("uuid", logicalSwitchPortUuid);
         params.put("fields", "uuid");
 
-        final NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
-        }.getType(), uri, params);
+        NiciraNvpList<LogicalSwitchPort> lspl;
+        try {
+            lspl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
 
         if (lspl == null) {
             throw new NiciraNvpApiException("Unexpected response from API");
@@ -489,64 +470,101 @@ public class NiciraNvpApi {
         return lspl;
     }
 
-    public LogicalRouterConfig createLogicalRouter(final LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
-        final String uri = ROUTER_URI_PREFIX;
+    public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortsByUuid(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException {
+        final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport";
+        final Map<String, String> params = new HashMap<String, String>();
+        params.put("uuid", logicalRouterPortUuid);
+        params.put("fields", "uuid");
+
+        NiciraNvpList<LogicalRouterPort> lrpl;
+        try {
+            lrpl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
+
+        if (lrpl == null) {
+            throw new NiciraNvpApiException("Unexpected response from API");
+        }
+
+        return lrpl;
+    }
+
+    public LogicalRouter createLogicalRouter(final LogicalRouter logicalRouter) throws NiciraNvpApiException {
+        return create(logicalRouter);
+    }
+
+    /**
+     * GET list of {@link LogicalRouter}
+     *
+     * @return
+     * @throws NiciraNvpApiException
+     */
+    public NiciraNvpList<LogicalRouter> findLogicalRouter() throws NiciraNvpApiException {
+        return findLogicalRouter(null);
+    }
+
+    /**
+     * GET list of {@link LogicalRouter} filtered by UUID
+     *
+     * @param uuid
+     * @return
+     * @throws NiciraNvpApiException
+     */
+    public NiciraNvpList<LogicalRouter> findLogicalRouter(final String uuid) throws NiciraNvpApiException {
+        return find(uuid, LogicalRouter.class);
+    }
 
-        final LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
+    public LogicalRouter findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
+        return findLogicalRouter(logicalRouterUuid).getResults().get(0);
+    }
 
-        return lrc;
+    public void updateLogicalRouter(final LogicalRouter logicalRouter,
+            final String logicalRouterUuid)
+                    throws NiciraNvpApiException {
+        update(logicalRouter, logicalRouterUuid);
     }
 
     public void deleteLogicalRouter(final String logicalRouterUuid) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid;
-
-        executeDeleteObject(uri);
+        deleteWithUri(uri);
     }
 
     public LogicalRouterPort createLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport";
-
-        final LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
-        return lrp;
+        return createWithUri(logicalRouterPort, uri);
     }
 
     public void deleteLogicalRouterPort(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid;
-
-        executeDeleteObject(uri);
+        deleteWithUri(uri);
     }
 
-    public void modifyLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
+    public void updateLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPort.getUuid();
-
-        executeUpdateObject(logicalRouterPort, uri, Collections.<String, String> emptyMap());
+        updateWithUri(logicalRouterPort, uri);
     }
 
-    public void modifyLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid, final Attachment attachment)
+    public void updateLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid, final Attachment attachment)
             throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid + "/attachment";
-        executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap());
+        updateWithUri(attachment, uri);
     }
 
     public NatRule createLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat";
-
-        return executeCreateObject(natRule, new TypeToken<NatRule>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
+        return createWithUri(natRule, uri);
     }
 
-    public void modifyLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
+    public void updateLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
-
-        executeUpdateObject(natRule, uri, Collections.<String, String> emptyMap());
+        updateWithUri(natRule, uri);
     }
 
     public void deleteLogicalRouterNatRule(final String logicalRouterUuid, final UUID natRuleUuid) throws NiciraNvpApiException {
         final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
-
-        executeDeleteObject(uri);
+        deleteWithUri(uri);
     }
 
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(final String logicalRouterUuid, final String gatewayServiceUuid,
@@ -557,21 +575,12 @@ public class NiciraNvpApi {
         params.put("attachment_vlan", "0");
         params.put("fields", "*");
 
-        return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
-        }.getType(), uri, params);
-    }
-
-    public LogicalRouterConfig findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
-        final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid;
-
-        return executeRetrieveObject(new TypeToken<LogicalRouterConfig>() {
-        }.getType(), uri, Collections.<String, String> emptyMap());
-    }
-
-    public void updateLogicalRouterPortConfig(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-        final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
-
-        executeUpdateObject(logicalRouterPort, uri, Collections.<String, String> emptyMap());
+        try {
+            return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
     }
 
     public NiciraNvpList<NatRule> findNatRulesByLogicalRouterUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
@@ -579,8 +588,12 @@ public class NiciraNvpApi {
         final Map<String, String> params = new HashMap<String, String>();
         params.put("fields", "*");
 
-        return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>() {
-        }.getType(), uri, params);
+        try {
+            return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
+            throw new NiciraNvpApiException(e);
+        }
     }
 
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(final String logicalRouterUuid, final String l3GatewayServiceUuid)
@@ -590,231 +603,11 @@ public class NiciraNvpApi {
         params.put("fields", "*");
         params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
 
-        return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
-        }.getType(), uri, params);
-    }
-
-    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");
-        }
-
-        final PutMethod pm = (PutMethod)createMethod(PUT_METHOD_TYPE, uri);
-        pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
         try {
-            pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
-        } catch (final UnsupportedEncodingException e) {
-            throw new NiciraNvpApiException("Failed to encode json request body", e);
-        }
-
-        executeMethod(pm);
-
-        if (pm.getStatusCode() != HttpStatus.SC_OK) {
-            final String errorMessage = responseToErrorMessage(pm);
-            pm.releaseConnection();
-            s_logger.error("Failed to update object : " + errorMessage);
-            throw new NiciraNvpApiException("Failed to update object : " + errorMessage);
-        }
-        pm.releaseConnection();
-    }
-
-    @SuppressWarnings("unchecked")
-    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");
-        }
-
-        final PostMethod pm = (PostMethod)createMethod(POST_METHOD_TYPE, uri);
-        pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
-        try {
-            pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
-        } catch (final UnsupportedEncodingException e) {
-            throw new NiciraNvpApiException("Failed to encode json request body", e);
-        }
-
-        executeMethod(pm);
-
-        if (pm.getStatusCode() != HttpStatus.SC_CREATED) {
-            final 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());
-        } catch (final IOException e) {
-            throw new NiciraNvpApiException("Failed to decode json response body", e);
-        } finally {
-            pm.releaseConnection();
-        }
-
-        return result;
-    }
-
-    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");
-        }
-
-        final DeleteMethod dm = (DeleteMethod)createMethod(DELETE_METHOD_TYPE, uri);
-        dm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
-
-        executeMethod(dm);
-
-        if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
-            final String errorMessage = responseToErrorMessage(dm);
-            dm.releaseConnection();
-            s_logger.error("Failed to delete object : " + errorMessage);
-            throw new NiciraNvpApiException("Failed to delete object : " + errorMessage);
-        }
-        dm.releaseConnection();
-    }
-
-    @SuppressWarnings("unchecked")
-    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");
-        }
-
-        final GetMethod gm = (GetMethod)createMethod(GET_METHOD_TYPE, uri);
-        gm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
-        if (parameters != null && !parameters.isEmpty()) {
-            final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
-            for (final 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) {
-            final 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);
-        } catch (final IOException e) {
-            s_logger.error("IOException while retrieving response body", e);
+            return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+            }.getType(), uri, params);
+        } catch (final CloudstackRESTException e) {
             throw new NiciraNvpApiException(e);
-        } finally {
-            gm.releaseConnection();
-        }
-        return returnValue;
-    }
-
-    protected void executeMethod(final HttpMethodBase method) throws NiciraNvpApiException {
-        try {
-            client.executeMethod(method);
-            if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
-                method.releaseConnection();
-                // login and try again
-                login();
-                client.executeMethod(method);
-            }
-        } catch (final HttpException e) {
-            s_logger.error("HttpException caught while trying to connect to the Nicira NVP Controller", e);
-            method.releaseConnection();
-            throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);
-        } catch (final 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);
-        }
-    }
-
-    private String responseToErrorMessage(final HttpMethodBase method) {
-        assert method.isRequestSent() : "no use getting an error message unless the request is sent";
-
-        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(BODY_RESP_MAX_LEN);
-            } catch (final IOException e) {
-                s_logger.debug("Error while loading response body", e);
-            }
-        }
-
-        // The default
-        return method.getStatusText();
-    }
-
-    /* The Nicira controller uses a self-signed certificate. The
-     * TrustingProtocolSocketFactory will accept any provided
-     * 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
-            final TrustManager[] trustAllCerts = new TrustManager[] {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 {
-                // Install the all-trusting trust manager
-                final SSLContext sc = SSLContext.getInstance("SSL");
-                sc.init(null, trustAllCerts, new java.security.SecureRandom());
-                ssf = sc.getSocketFactory();
-            } catch (final KeyManagementException e) {
-                throw new IOException(e);
-            } catch (final NoSuchAlgorithmException e) {
-                throw new IOException(e);
-            }
-        }
-
-        @Override
-        public Socket createSocket(final String host, final int port) throws IOException {
-            return ssf.createSocket(host, port);
-        }
-
-        @Override
-        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(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(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params)
-                throws IOException, UnknownHostException, ConnectTimeoutException {
-            final int timeout = params.getConnectionTimeout();
-            if (timeout == 0) {
-                return createSocket(host, port, localAddress, localPort);
-            } else {
-                final Socket s = ssf.createSocket();
-                s.bind(new InetSocketAddress(localAddress, localPort));
-                s.connect(new InetSocketAddress(host, port), timeout);
-                return s;
-            }
         }
     }
 
@@ -837,6 +630,24 @@ public class NiciraNvpApi {
 
             throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\"");
         }
+    }
+
+    public static class RoutingConfigAdapter implements JsonDeserializer<RoutingConfig> {
 
+        @Override
+        public RoutingConfig deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException {
+            final JsonObject jsonObject = jsonElement.getAsJsonObject();
+
+            if (!jsonObject.has("type")) {
+                throw new JsonParseException("Deserializing as a RoutingConfig, but no type present in the json object");
+            }
+
+            final String routingConfigType = jsonObject.get("type").getAsString();
+            if ("SingleDefaultRouteImplicitRoutingConfig".equals(routingConfigType)) {
+                return context.deserialize(jsonElement, SingleDefaultRouteImplicitRoutingConfig.class);
+            }
+
+            throw new JsonParseException("Failed to deserialize type \"" + routingConfigType + "\"");
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
new file mode 100644
index 0000000..ea5df2c
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
@@ -0,0 +1,40 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// 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,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.nicira;
+
+/**
+ *
+ */
+public class SingleDefaultRouteImplicitRoutingConfig extends RoutingConfig {
+    public RouterNextHop defaultRouteNextHop;
+    public final String type = "SingleDefaultRouteImplicitRoutingConfig";
+
+    public SingleDefaultRouteImplicitRoutingConfig(final RouterNextHop routerNextHop) {
+        defaultRouteNextHop = routerNextHop;
+    }
+
+    public RouterNextHop getDefaultRouteNextHop() {
+        return defaultRouteNextHop;
+    }
+
+    public void setDefaultRouteNextHop(final RouterNextHop defaultRouteNextHop) {
+        this.defaultRouteNextHop = defaultRouteNextHop;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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
deleted file mode 100644
index 0533579..0000000
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// 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,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-
-package com.cloud.network.nicira;
-
-/**
- *
- */
-public class SingleDefaultRouteImplictRoutingConfig extends RoutingConfig {
-    public RouterNextHop defaultRouteNextHop;
-    public final String type = "SingleDefaultRouteImplicitRoutingConfig";
-
-    public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
-        defaultRouteNextHop = routerNextHop;
-    }
-
-    public RouterNextHop getDefaultRouteNextHop() {
-        return defaultRouteNextHop;
-    }
-
-    public void setDefaultRouteNextHop(RouterNextHop defaultRouteNextHop) {
-        this.defaultRouteNextHop = defaultRouteNextHop;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 87765be..fe7d93a 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,6 +19,11 @@
 
 package com.cloud.network.nicira;
 
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
 public class VifAttachment extends Attachment {
     private final String type = "VifAttachment";
     private String vifUuid;
@@ -34,7 +39,7 @@ public class VifAttachment extends Attachment {
         return vifUuid;
     }
 
-    public void setVifUuid(String vifUuid) {
+    public void setVifUuid(final String vifUuid) {
         this.vifUuid = vifUuid;
     }
 
@@ -42,4 +47,32 @@ public class VifAttachment extends Attachment {
         return type;
     }
 
+
+    @Override
+    public String toString() {
+        return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 31)
+                .append(this.getClass())
+                .append(vifUuid)
+                .toHashCode();
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (!(this.getClass().isInstance(obj))) {
+            return false;
+        }
+        final VifAttachment another = (VifAttachment) obj;
+        return new EqualsBuilder().append(vifUuid, another.vifUuid).isEquals();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 c228b08..ec95ea5 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
@@ -66,7 +66,7 @@ import com.cloud.host.Host.Type;
 import com.cloud.network.nicira.ControlClusterStatus;
 import com.cloud.network.nicira.DestinationNatRule;
 import com.cloud.network.nicira.L3GatewayAttachment;
-import com.cloud.network.nicira.LogicalRouterConfig;
+import com.cloud.network.nicira.LogicalRouter;
 import com.cloud.network.nicira.LogicalRouterPort;
 import com.cloud.network.nicira.LogicalSwitch;
 import com.cloud.network.nicira.LogicalSwitchPort;
@@ -78,7 +78,7 @@ import com.cloud.network.nicira.NiciraNvpList;
 import com.cloud.network.nicira.NiciraNvpTag;
 import com.cloud.network.nicira.PatchAttachment;
 import com.cloud.network.nicira.RouterNextHop;
-import com.cloud.network.nicira.SingleDefaultRouteImplictRoutingConfig;
+import com.cloud.network.nicira.SingleDefaultRouteImplicitRoutingConfig;
 import com.cloud.network.nicira.SourceNatRule;
 import com.cloud.network.nicira.TransportZoneBinding;
 import com.cloud.network.nicira.VifAttachment;
@@ -294,7 +294,7 @@ 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.updateLogicalSwitchPortAttachment(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());
@@ -334,7 +334,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.updateLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
             return new UpdateLogicalSwitchPortAnswer(cmd, true, "Attachment for  " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid);
         } catch (NiciraNvpApiException e) {
             if (numRetries > 0) {
@@ -383,10 +383,10 @@ public class NiciraNvpResource implements ServerResource {
 
         try {
             // Create the Router
-            LogicalRouterConfig lrc = new LogicalRouterConfig();
+            LogicalRouter lrc = new LogicalRouter();
             lrc.setDisplayName(truncate(routerName, NAME_MAX_LEN));
             lrc.setTags(tags);
-            lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(new RouterNextHop(publicNetworkNextHopIp)));
+            lrc.setRoutingConfig(new SingleDefaultRouteImplicitRoutingConfig(new RouterNextHop(publicNetworkNextHopIp)));
             lrc = niciraNvpApi.createLogicalRouter(lrc);
 
             // store the switchport for rollback
@@ -408,7 +408,7 @@ public class NiciraNvpResource implements ServerResource {
                 if (cmd.getVlanId() != 0) {
                     attachment.setVlanId(cmd.getVlanId());
                 }
-                niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
+                niciraNvpApi.updateLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
 
                 // Create the inside port for the router
                 LogicalRouterPort lrpi = new LogicalRouterPort();
@@ -425,10 +425,10 @@ public class NiciraNvpResource implements ServerResource {
                 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()));
+                niciraNvpApi.updateLogicalRouterPortAttachment(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()));
+                niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), new PatchAttachment(lrpi.getUuid()));
 
                 // Setup the source nat rule
                 SourceNatRule snr = new SourceNatRule();
@@ -484,7 +484,7 @@ public class NiciraNvpResource implements ServerResource {
             }
             LogicalRouterPort lrp = ports.getResults().get(0);
             lrp.setIpAddresses(cmd.getPublicCidrs());
-            niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
+            niciraNvpApi.updateLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
 
             return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + " ip addresses on logical router uuid " +
                 cmd.getLogicalRouterUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/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 822c8c7..bf8ce18 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
@@ -104,7 +104,7 @@ public class NiciraNvpElementTest {
 
     @Test
     public void canHandleTest() {
-        Network net = mock(Network.class);
+        final Network net = mock(Network.class);
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
         when(net.getId()).thenReturn(NETWORK_ID);
 
@@ -134,43 +134,43 @@ public class NiciraNvpElementTest {
 
     @Test
     public void implementTest() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
-        Network network = mock(Network.class);
+        final Network network = mock(Network.class);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
         when(network.getId()).thenReturn(NETWORK_ID);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
         mock(DeployDestination.class);
 
-        Domain dom = mock(Domain.class);
+        final Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");
-        Account acc = mock(Account.class);
+        final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
-        ReservationContext context = mock(ReservationContext.class);
+        final ReservationContext context = mock(ReservationContext.class);
         when(context.getDomain()).thenReturn(dom);
         when(context.getAccount()).thenReturn(acc);
     }
 
     @Test
     public void applyIpTest() throws ResourceUnavailableException {
-        Network network = mock(Network.class);
+        final Network network = mock(Network.class);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
         when(network.getId()).thenReturn(NETWORK_ID);
         when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        List<PublicIpAddress> ipAddresses = new ArrayList<PublicIpAddress>();
-        PublicIpAddress pipReleased = mock(PublicIpAddress.class);
-        PublicIpAddress pipAllocated = mock(PublicIpAddress.class);
-        Ip ipReleased = new Ip("42.10.10.10");
-        Ip ipAllocated = new Ip("10.10.10.10");
+        final List<PublicIpAddress> ipAddresses = new ArrayList<PublicIpAddress>();
+        final PublicIpAddress pipReleased = mock(PublicIpAddress.class);
+        final PublicIpAddress pipAllocated = mock(PublicIpAddress.class);
+        final Ip ipReleased = new Ip("42.10.10.10");
+        final Ip ipAllocated = new Ip("10.10.10.10");
         when(pipAllocated.getState()).thenReturn(IpAddress.State.Allocated);
         when(pipAllocated.getAddress()).thenReturn(ipAllocated);
         when(pipAllocated.getNetmask()).thenReturn("255.255.255.0");
@@ -180,25 +180,25 @@ public class NiciraNvpElementTest {
         ipAddresses.add(pipAllocated);
         ipAddresses.add(pipReleased);
 
-        Set<Service> services = new HashSet<Service>();
+        final Set<Service> services = new HashSet<Service>();
         services.add(Service.SourceNat);
         services.add(Service.StaticNat);
         services.add(Service.PortForwarding);
 
-        List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
-        NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
-        NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
+        final List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
+        final NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
         when(niciraNvpRouterMappingDao.findByNetworkId(NETWORK_ID)).thenReturn(nnrmVO);
         when(nnrmVO.getLogicalRouterUuid()).thenReturn("abcde");
         when(nndVO.getHostId()).thenReturn(NETWORK_ID);
-        HostVO hvo = mock(HostVO.class);
+        final HostVO hvo = mock(HostVO.class);
         when(hvo.getId()).thenReturn(NETWORK_ID);
         when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
         when(hostDao.findById(NETWORK_ID)).thenReturn(hvo);
         deviceList.add(nndVO);
         when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(deviceList);
 
-        ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
+        final ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);
 
@@ -206,8 +206,8 @@ public class NiciraNvpElementTest {
 
         verify(agentManager, atLeast(1)).easySend(eq(NETWORK_ID), argThat(new ArgumentMatcher<ConfigurePublicIpsOnLogicalRouterCommand>() {
             @Override
-            public boolean matches(Object argument) {
-                ConfigurePublicIpsOnLogicalRouterCommand command = (ConfigurePublicIpsOnLogicalRouterCommand)argument;
+            public boolean matches(final Object argument) {
+                final ConfigurePublicIpsOnLogicalRouterCommand command = (ConfigurePublicIpsOnLogicalRouterCommand)argument;
                 if (command.getPublicCidrs().size() == 1)
                     return true;
                 return false;


Mime
View raw message