cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [04/16] git commit: updated refs/heads/master to 67b753c
Date Mon, 28 Dec 2015 10:22:28 GMT
CLOUDSTACK-9074: API Changes: Add nsxLogicalSwitch and nsxLogicalSwitchPort to listNics


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

Branch: refs/heads/master
Commit: 8149081658738a2d4d9ee088241310460b2d9077
Parents: 46f9fba
Author: nvazquez <nicolas.m.vazquez@gmail.com>
Authored: Tue Dec 1 11:48:27 2015 -0800
Committer: nvazquez <nicovazquez90@gmail.com>
Committed: Thu Dec 24 16:07:06 2015 -0300

----------------------------------------------------------------------
 .../cloudstack/api/response/NicResponse.java    | 16 ++++++++++++++
 engine/schema/src/com/cloud/vm/NicVO.java       | 23 ++++++++++++++++++++
 .../cloud/network/nicira/NiciraRestClient.java  |  6 +++--
 server/src/com/cloud/api/ApiResponseHelper.java |  9 ++++++++
 .../cloud/utils/rest/HttpStatusCodeHelper.java  |  4 ++++
 5 files changed, 56 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81490816/api/src/org/apache/cloudstack/api/response/NicResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/NicResponse.java b/api/src/org/apache/cloudstack/api/response/NicResponse.java
index 2f79d7f..7335836 100644
--- a/api/src/org/apache/cloudstack/api/response/NicResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NicResponse.java
@@ -102,6 +102,14 @@ public class NicResponse extends BaseResponse {
     @Param(description = "Id of the vm to which the nic belongs")
     private String vmId;
 
+    @SerializedName("nsxlogicalswitch")
+    @Param(description = "Id of the NSX Logical Switch (if NSX based), null otherwise", since="4.6.0")
+    private String nsxLogicalSwitch;
+
+    @SerializedName("nsxlogicalswitchport")
+    @Param(description = "Id of the NSX Logical Switch Port (if NSX based), null otherwise",
since="4.6.0")
+    private String nsxLogicalSwitchPort;
+
     public void setVmId(String vmId) {
         this.vmId = vmId;
     }
@@ -205,4 +213,12 @@ public class NicResponse extends BaseResponse {
         this.secondaryIps = ipList;
     }
 
+    public void setNsxLogicalSwitch(String nsxLogicalSwitch) {
+        this.nsxLogicalSwitch = nsxLogicalSwitch;
+    }
+
+    public void setNsxLogicalSwitchPort(String nsxLogicalSwitchPort) {
+        this.nsxLogicalSwitchPort = nsxLogicalSwitchPort;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81490816/engine/schema/src/com/cloud/vm/NicVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/NicVO.java b/engine/schema/src/com/cloud/vm/NicVO.java
index 8154297..2a7c696 100644
--- a/engine/schema/src/com/cloud/vm/NicVO.java
+++ b/engine/schema/src/com/cloud/vm/NicVO.java
@@ -28,6 +28,7 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
+import javax.persistence.Transient;
 
 import com.cloud.network.Networks.AddressFormat;
 import com.cloud.network.Networks.Mode;
@@ -123,6 +124,12 @@ public class NicVO implements Nic {
     @Column(name = "secondary_ip")
     boolean secondaryIp;
 
+    @Transient
+    transient String nsxLogicalSwitchUuid;
+
+    @Transient
+    transient String nsxLogicalSwitchPortUuid;
+
     public NicVO(String reserver, Long instanceId, long configurationId, VirtualMachine.Type
vmType) {
         this.reserver = reserver;
         this.instanceId = instanceId;
@@ -371,4 +378,20 @@ public class NicVO implements Nic {
     public void setVmType(VirtualMachine.Type vmType) {
         this.vmType = vmType;
     }
+
+    public String getNsxLogicalSwitchUuid() {
+        return nsxLogicalSwitchUuid;
+    }
+
+    public void setNsxLogicalSwitchUuid(String nsxLogicalSwitchUuid) {
+        this.nsxLogicalSwitchUuid = nsxLogicalSwitchUuid;
+    }
+
+    public String getNsxLogicalSwitchPortUuid() {
+        return nsxLogicalSwitchPortUuid;
+    }
+
+    public void setNsxLogicalSwitchPortUuid(String nsxLogicalSwitchPortUuid) {
+        this.nsxLogicalSwitchPortUuid = nsxLogicalSwitchPortUuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81490816/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java
b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java
index de58a42..b850c4b 100644
--- a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java
+++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java
@@ -91,8 +91,10 @@ public class NiciraRestClient extends BasicRestClient {
             return handleUnauthorizedResponse(request, previousStatusCode, response, statusCode);
         } else if (HttpStatusCodeHelper.isSuccess(statusCode)) {
             return handleSuccessResponse(request, response);
+        } else if (HttpStatusCodeHelper.isConflict(statusCode)) {
+            throw new CloudstackRESTException("Conflict: " + statusLine.getReasonPhrase());
         } else {
-            throw new CloudstackRESTException("Unexpecetd status code: " + statusCode);
+            throw new CloudstackRESTException("Unexpected status code: " + statusCode);
         }
     }
 
@@ -201,4 +203,4 @@ public class NiciraRestClient extends BasicRestClient {
         }
 
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81490816/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 5d691c6..8c9e437 100644
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -3467,6 +3467,15 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setDeviceId(String.valueOf(result.getDeviceId()));
 
         response.setIsDefault(result.isDefaultNic());
+
+        if (result instanceof NicVO){
+            if (((NicVO)result).getNsxLogicalSwitchUuid() != null){
+                response.setNsxLogicalSwitch(((NicVO)result).getNsxLogicalSwitchUuid());
+            }
+            if (((NicVO)result).getNsxLogicalSwitchPortUuid() != null){
+                response.setNsxLogicalSwitchPort(((NicVO)result).getNsxLogicalSwitchPortUuid());
+            }
+        }
         return response;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81490816/utils/src/main/java/com/cloud/utils/rest/HttpStatusCodeHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/com/cloud/utils/rest/HttpStatusCodeHelper.java b/utils/src/main/java/com/cloud/utils/rest/HttpStatusCodeHelper.java
index 9492920..98c88ba 100644
--- a/utils/src/main/java/com/cloud/utils/rest/HttpStatusCodeHelper.java
+++ b/utils/src/main/java/com/cloud/utils/rest/HttpStatusCodeHelper.java
@@ -31,4 +31,8 @@ public class HttpStatusCodeHelper {
         return statusCode == HttpStatus.SC_UNAUTHORIZED;
     }
 
+    public static boolean isConflict(final int statusCode){
+        return statusCode == HttpStatus.SC_CONFLICT;
+    }
+
 }


Mime
View raw message