cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject [48/55] [abbrv] git commit: updated refs/heads/cs2163 to 8d53b1e
Date Mon, 13 May 2013 11:08:40 GMT
CLOUDSTACK-763: Added API updateNetworkACLItem to update an existing ACL Item


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

Branch: refs/heads/cs2163
Commit: 257789dd54ceb89ed9bc46f4ba8b3414e321b29b
Parents: 14e992e
Author: Kishan Kavala <kishan@cloud.com>
Authored: Tue May 7 11:45:45 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Mon May 13 12:03:39 2013 +0530

----------------------------------------------------------------------
 .../user/network/UpdateNetworkACLItemCmd.java      |  173 +++++++++++++++
 1 files changed, 173 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/257789dd/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
new file mode 100644
index 0000000..1ea815a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
@@ -0,0 +1,173 @@
+// 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.api.command.user.network;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.utils.net.NetUtils;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.NetworkACLItemResponse;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified
Id",
+responseObject = NetworkACLItemResponse.class)
+public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLItemCmd.class.getName());
+
+    private static final String s_name = "createnetworkaclresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLItemResponse.class,
+            required=true, description="the ID of the network ACL Item")
+    private Long id;
+
+    @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description =
+            "the protocol for the ACL rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol
number")
+    private String protocol;
+
+    @Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description =
"the starting port of ACL")
+    private Integer publicStartPort;
+
+    @Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the
ending port of ACL")
+    private Integer publicEndPort;
+
+    @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
+            description = "the cidr list to allow traffic from/to")
+    private List<String> cidrlist;
+
+    @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type
of the icmp message being sent")
+    private Integer icmpType;
+
+    @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error
code for this icmp message")
+    private Integer icmpCode;
+
+    @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="the
traffic type for the ACL," +
+            "can be Ingress or Egress, defaulted to Ingress if not specified")
+    private String trafficType;
+
+    @Parameter(name=ApiConstants.NUMBER, type=CommandType.INTEGER, description="The network
of the vm the ACL will be created for")
+    private Integer number;
+
+    @Parameter(name=ApiConstants.ACTION, type=CommandType.STRING, description="scl entry
action, allow or deny")
+    private String action;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getProtocol() {
+        if(protocol != null){
+            return protocol.trim();
+        } else
+            return null;
+    }
+
+    public List<String> getSourceCidrList() {
+        return cidrlist;
+    }
+
+    public NetworkACLItem.TrafficType getTrafficType() {
+        if (trafficType != null) {
+            for (NetworkACLItem.TrafficType type : NetworkACLItem.TrafficType.values()) {
+                if (type.toString().equalsIgnoreCase(trafficType)) {
+                    return type;
+                }
+            }
+        }
+        return null;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public Integer getSourcePortStart() {
+        return publicStartPort;
+    }
+
+    public Integer getSourcePortEnd() {
+        return publicEndPort;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account caller = UserContext.current().getCaller();
+        return caller.getAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_NETWORK_ACL_ITEM_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Updating Network ACL Item";
+    }
+
+    public Integer getIcmpCode() {
+        return icmpCode;
+    }
+
+    public Integer getIcmpType() {
+        return icmpType;
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException {
+        UserContext.current().setEventDetails("Rule Id: " + getId());
+        NetworkACLItem aclItem = _networkACLService.updateNetworkACLItem(getId(), getProtocol(),
getSourceCidrList(), getTrafficType(),
+                getAction(), getNumber(), getSourcePortStart(), getSourcePortEnd(), getIcmpCode(),
getIcmpType());
+        if (aclItem == null) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network
ACL Item");
+        }
+        NetworkACLItemResponse aclResponse = _responseGenerator.createNetworkACLItemResponse(aclItem);
+        setResponseObject(aclResponse);
+        aclResponse.setResponseName(getCommandName());
+    }
+
+}
+


Mime
View raw message