cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [3/3] git commit: updated refs/heads/opendaylight to a00e50c
Date Sat, 04 Jan 2014 16:03:09 GMT
Add UI interface for managing the OpenDaylight provider and controllers.

Fix several bugs in the code related to the api handling.


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

Branch: refs/heads/opendaylight
Commit: a00e50c6662db2348fc87524131d2e95928c4547
Parents: b29b968
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Sat Jan 4 17:00:42 2014 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Sat Jan 4 17:00:42 2014 +0100

----------------------------------------------------------------------
 client/tomcatconf/commands.properties.in        |    2 +
 .../OpenDaylightControllerResourceManager.java  |    8 +
 ...enDaylightControllerResourceManagerImpl.java |   41 +
 .../ListOpenDaylightControllersCmd.java         |  104 +
 .../OpenDaylightControllerResponse.java         |   47 +
 .../dao/OpenDaylightControllerVO.java           |    3 +-
 ui/scripts/system.js                            | 8947 +++++++++---------
 ui/scripts/ui-custom/zoneWizard.js              |    5 +-
 8 files changed, 4878 insertions(+), 4279 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 9f74fdb..189d087 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -709,3 +709,5 @@ createServiceInstance=1
 
 ### OpenDaylight plugin commands
 addOpenDaylightController=1
+deleteOpenDaylightController=1
+listOpenDaylightControllers=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManager.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManager.java
index 1bc0e82..5f6161a 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManager.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManager.java
@@ -19,8 +19,12 @@
 
 package org.apache.cloudstack.network.opendaylight.agent;
 
+import java.util.List;
+
 import org.apache.cloudstack.network.opendaylight.api.commands.AddOpenDaylightControllerCmd;
 import org.apache.cloudstack.network.opendaylight.api.commands.DeleteOpenDaylightControllerCmd;
+import org.apache.cloudstack.network.opendaylight.api.commands.ListOpenDaylightControllersCmd;
+import org.apache.cloudstack.network.opendaylight.api.responses.OpenDaylightControllerResponse;
 import org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO;
 
 import com.cloud.exception.InvalidParameterValueException;
@@ -31,4 +35,8 @@ public interface OpenDaylightControllerResourceManager extends PluggableService
     public OpenDaylightControllerVO addController(AddOpenDaylightControllerCmd cmd);
 
     public void deleteController(DeleteOpenDaylightControllerCmd cmd) throws InvalidParameterValueException;
+
+    public List<OpenDaylightControllerVO> listControllers(ListOpenDaylightControllersCmd
cmd);
+
+    public OpenDaylightControllerResponse createResponseFromVO(OpenDaylightControllerVO controller);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java
index ad4db15..f4da02b 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java
@@ -33,15 +33,19 @@ import org.apache.log4j.Logger;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
 import org.apache.cloudstack.network.opendaylight.api.commands.AddOpenDaylightControllerCmd;
 import org.apache.cloudstack.network.opendaylight.api.commands.DeleteOpenDaylightControllerCmd;
+import org.apache.cloudstack.network.opendaylight.api.commands.ListOpenDaylightControllersCmd;
+import org.apache.cloudstack.network.opendaylight.api.responses.OpenDaylightControllerResponse;
 import org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerMappingDao;
 import org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO;
 
+import com.cloud.api.ApiDBUtils;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.network.Network;
 import com.cloud.network.Networks;
+import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
@@ -77,6 +81,8 @@ public class OpenDaylightControllerResourceManagerImpl implements OpenDaylightCo
     public List<Class<?>> getCommands() {
         List<Class<?>> commands = new ArrayList<Class<?>>();
         commands.add(AddOpenDaylightControllerCmd.class);
+        commands.add(DeleteOpenDaylightControllerCmd.class);
+        commands.add(ListOpenDaylightControllersCmd.class);
         return commands;
     }
 
@@ -170,4 +176,39 @@ public class OpenDaylightControllerResourceManagerImpl implements OpenDaylightCo
         openDaylightControllerMappingDao.remove(cmd.getId());
     }
 
+    @Override
+    public List<OpenDaylightControllerVO> listControllers(ListOpenDaylightControllersCmd
cmd) {
+        if (cmd.getId() != null) {
+            List<OpenDaylightControllerVO> foundControllers = new ArrayList<OpenDaylightControllerVO>();
+            OpenDaylightControllerVO controller = openDaylightControllerMappingDao.findById(cmd.getId());
+            if (controller != null) {
+                foundControllers.add(controller);
+            }
+            return foundControllers;
+        } else if (cmd.getPhysicalNetworkId() != null) {
+            return openDaylightControllerMappingDao.listByPhysicalNetwork(cmd.getPhysicalNetworkId());
+        }
+        return openDaylightControllerMappingDao.listAll();
+    }
+
+    @Override
+    public OpenDaylightControllerResponse createResponseFromVO(OpenDaylightControllerVO controller)
{
+        OpenDaylightControllerResponse response = new OpenDaylightControllerResponse();
+        HostVO controllerHost = hostDao.findById(controller.getHostId());
+        hostDao.loadDetails(controllerHost);
+
+        PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(controller.getPhysicalNetworkId());
+        if (pnw != null) {
+            response.setPhysicalNetworkId(pnw.getUuid());
+        }
+
+        response.setObjectName("opendaylightcontroller");
+        response.setId(controller.getUuid());
+        response.setUrl(controllerHost.getDetail("url"));
+        response.setName(controllerHost.getDetail("name"));
+        response.setUsername(controllerHost.getDetail("username"));
+
+        return response;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/commands/ListOpenDaylightControllersCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/commands/ListOpenDaylightControllersCmd.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/commands/ListOpenDaylightControllersCmd.java
new file mode 100644
index 0000000..11f196b
--- /dev/null
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/commands/ListOpenDaylightControllersCmd.java
@@ -0,0 +1,104 @@
+//
+// 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 org.apache.cloudstack.network.opendaylight.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.network.opendaylight.agent.OpenDaylightControllerResourceManager;
+import org.apache.cloudstack.network.opendaylight.api.responses.OpenDaylightControllerResponse;
+import org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+
+@APICommand(name = "listOpenDaylightControllers", responseObject = OpenDaylightControllerResponse.class,
description = "Lists OpenDyalight controllers")
+public class ListOpenDaylightControllersCmd extends BaseCmd {
+    @Inject
+    private OpenDaylightControllerResourceManager resourceManager;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType
= PhysicalNetworkResponse.class, required = false,
+            description = "the Physical Network ID")
+    private Long physicalNetworkId;
+
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = OpenDaylightControllerResponse.class,
required = false,
+            description = "the ID of a OpenDaylight Controller")
+    private Long Id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return "listOpenDaylightControllers";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccount().getId();
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public Long getId() {
+        return Id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+    NetworkRuleConflictException {
+        List<OpenDaylightControllerVO> controllers = resourceManager.listControllers(this);
+
+        List<OpenDaylightControllerResponse> controllerList = new ArrayList<OpenDaylightControllerResponse>();
+        for (OpenDaylightControllerVO controller: controllers) {
+            OpenDaylightControllerResponse responseObject = resourceManager.createResponseFromVO(controller);
+            controllerList.add(responseObject);
+        }
+        ListResponse<OpenDaylightControllerResponse> responseList = new ListResponse<OpenDaylightControllerResponse>();
+        responseList.setResponseName(getCommandName());
+        responseList.setResponses(controllerList);
+        setResponseObject(responseList);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/responses/OpenDaylightControllerResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/responses/OpenDaylightControllerResponse.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/responses/OpenDaylightControllerResponse.java
index 98c644a..10c6f28 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/responses/OpenDaylightControllerResponse.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/responses/OpenDaylightControllerResponse.java
@@ -19,8 +19,55 @@
 
 package org.apache.cloudstack.network.opendaylight.api.responses;
 
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO;
+
+import com.cloud.serializer.Param;
 
+@EntityReference(value = OpenDaylightControllerVO.class)
 public class OpenDaylightControllerResponse extends BaseResponse {
+    @SerializedName(ApiConstants.ID)
+    @Param(description = "device id of the controller")
+    private String id;
+
+    @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
+    @Param(description = "the physical network to which this controller belongs to")
+    private String physicalNetworkId;
+
+    @SerializedName(ApiConstants.NAME)
+    @Param(description = "the name assigned to the controller")
+    private String name;
+
+    @SerializedName(ApiConstants.URL)
+    @Param(description = "the url of the controller api")
+    private String url;
+
+    @SerializedName(ApiConstants.USERNAME)
+    @Param(description = "the username to authenticate to the controller")
+    private String username;
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setPhysicalNetworkId(String physicalNetworkId) {
+        this.physicalNetworkId = physicalNetworkId;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a00e50c6/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/dao/OpenDaylightControllerVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/dao/OpenDaylightControllerVO.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/dao/OpenDaylightControllerVO.java
index 61d5682..b50cfda 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/dao/OpenDaylightControllerVO.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/dao/OpenDaylightControllerVO.java
@@ -70,8 +70,7 @@ public class OpenDaylightControllerVO implements InternalIdentity {
 
     @Override
     public long getId() {
-        // TODO Auto-generated method stub
-        return 0;
+        return id;
     }
 
     public String getUuid() {


Mime
View raw message