You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/01/10 01:48:36 UTC
[40/52] [partial] Summary: Fixes for api_refactoring
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteIpForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteIpForwardingRuleCmd.java b/api/src/com/cloud/api/commands/DeleteIpForwardingRuleCmd.java
deleted file mode 100644
index 475e09a..0000000
--- a/api/src/com/cloud/api/commands/DeleteIpForwardingRuleCmd.java
+++ /dev/null
@@ -1,123 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes an ip forwarding rule", responseObject=SuccessResponse.class)
-public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteIpForwardingRuleCmd.class.getName());
-
- private static final String s_name = "deleteipforwardingruleresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="firewall_rules")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the forwarding rule")
- private Long id;
-
-
- // unexposed parameter needed for events logging
- @IdentityMapper(entityTableName="account")
- @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
- private Long ownerId;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Rule Id: "+id);
- boolean result = _firewallService.revokeRelatedFirewallRule(id, true);
- result = result && _rulesService.revokeStaticNatRule(id, true);
-
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete ip forwarding rule");
- }
- }
-
- @Override
- public long getEntityOwnerId() {
- if (ownerId == null) {
- FirewallRule rule = _entityMgr.findById(FirewallRule.class, id);
- if (rule == null) {
- throw new InvalidParameterValueException("Unable to find static nat rule by id: " + id);
- } else {
- ownerId = rule.getAccountId();
- }
- }
- return ownerId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NET_RULE_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return ("Deleting an ipforwarding 1:1 NAT rule id:"+id);
- }
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return _rulesService.getFirewallRule(id).getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteIsoCmd.java b/api/src/com/cloud/api/commands/DeleteIsoCmd.java
deleted file mode 100755
index 70ce731..0000000
--- a/api/src/com/cloud/api/commands/DeleteIsoCmd.java
+++ /dev/null
@@ -1,117 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes an ISO file.", responseObject=SuccessResponse.class)
-public class DeleteIsoCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteIsoCmd.class.getName());
- private static final String s_name = "deleteisosresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="vm_template")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the ISO file")
- private Long id;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of the zone of the ISO file. If not specified, the ISO will be deleted from all the zones")
- private Long zoneId;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getStaticName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- VirtualMachineTemplate iso = _entityMgr.findById(VirtualMachineTemplate.class, getId());
- if (iso != null) {
- return iso.getAccountId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_ISO_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting iso " + getId();
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Iso;
- }
-
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("ISO Id: "+getId());
- boolean result = _templateService.deleteIso(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete iso");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java b/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
deleted file mode 100644
index 55195f7..0000000
--- a/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
+++ /dev/null
@@ -1,116 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since="3.0.0")
-public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteLBStickinessPolicyCmd.class.getName());
- private static final String s_name = "deleteLBstickinessrruleresponse";
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="load_balancer_stickiness_policies")
- @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the LB stickiness policy")
- private Long id;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_LB_STICKINESSPOLICY_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "deleting load balancer stickiness policy: " + getId();
- }
-
- @Override
- public void execute() {
- UserContext.current().setEventDetails("Load balancer stickiness policy Id: " + getId());
- boolean result = _lbService.deleteLBStickinessPolicy(getId(), true);
-
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer stickiness policy");
- }
- }
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class,
- getId());
- if (policy == null) {
- throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
- }
- LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
- if (lb == null) {
- throw new InvalidParameterValueException("Unable to find load balancer rule for stickiness rule: " + id);
- }
- return lb.getNetworkId();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
deleted file mode 100644
index 72330c2..0000000
--- a/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,118 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a load balancer rule.", responseObject=SuccessResponse.class)
-public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerRuleCmd.class.getName());
- private static final String s_name = "deleteloadbalancerruleresponse";
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="firewall_rules")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the load balancer rule")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getId());
- if (lb != null) {
- return lb.getAccountId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_LOAD_BALANCER_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "deleting load balancer: " + getId();
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Load balancer Id: "+getId());
- boolean result = _firewallService.revokeRelatedFirewallRule(id, true);
- result = result && _lbService.deleteLoadBalancerRule(id, true);
-
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer");
- }
- }
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- LoadBalancer lb = _lbService.findById(id);
- if(lb == null){
- throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
- }
- return lb.getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkACLCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkACLCmd.java
deleted file mode 100644
index 0499f53..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkACLCmd.java
+++ /dev/null
@@ -1,121 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a Network ACL", responseObject=SuccessResponse.class)
-public class DeleteNetworkACLCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLCmd.class.getName());
- private static final String s_name = "deletenetworkaclresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="firewall_rules")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network ACL")
- private Long id;
-
- // unexposed parameter needed for events logging
- @IdentityMapper(entityTableName="account")
- @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
- private Long ownerId;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_FIREWALL_CLOSE;
- }
-
- @Override
- public String getEventDescription() {
- return ("Deleting Network ACL id=" + id);
- }
-
- @Override
- public long getEntityOwnerId() {
- if (ownerId == null) {
- FirewallRule rule = _networkACLService.getNetworkACL(id);
- if (rule == null) {
- throw new InvalidParameterValueException("Unable to find network ACL by id=" + id);
- } else {
- ownerId = rule.getAccountId();
- }
- }
- return ownerId;
- }
-
- @Override
- public void execute() throws ResourceUnavailableException {
- UserContext.current().setEventDetails("Network ACL Id: " + id);
- boolean result = _networkACLService.revokeNetworkACL(id, true);
-
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network ACL");
- }
- }
-
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return _firewallService.getFirewallRule(id).getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkCmd.java
deleted file mode 100644
index 5e1350f..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkCmd.java
+++ /dev/null
@@ -1,108 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.Network;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a network", responseObject=SuccessResponse.class)
-public class DeleteNetworkCmd extends BaseAsyncCmd{
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
- private static final String s_name = "deletenetworkresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="networks")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Network Id: " + id);
- boolean result = _networkService.deleteNetwork(id);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network");
- }
- }
-
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return id;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NETWORK_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting network: " + id;
- }
-
- @Override
- public long getEntityOwnerId() {
- Network network = _networkService.getNetwork(id);
- if (network == null) {
- throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
- } else {
- return _networkService.getNetwork(id).getAccountId();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
deleted file mode 100644
index 9d60e34..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
+++ /dev/null
@@ -1,77 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a network offering.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteNetworkOfferingCmd extends BaseCmd{
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
- private static final String s_name = "deletenetworkofferingresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="network_offerings")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network offering")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- boolean result = _configService.deleteNetworkOffering(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
deleted file mode 100644
index 815657b..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
+++ /dev/null
@@ -1,108 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a Network Service Provider.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkServiceProviderCmd.class.getName());
-
- private static final String s_name = "deletenetworkserviceproviderresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network_service_providers")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network service provider")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- try{
- boolean result = _networkService.deleteNetworkServiceProvider(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
- }
- } catch (ResourceUnavailableException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- } catch (ConcurrentOperationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
- }
- }
-
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SERVICE_PROVIDER_DELETE;
- }
-
-
- @Override
- public String getEventDescription() {
- return "Deleting Physical network ServiceProvider: " + getId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PhysicalNetworkServiceProvider;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java b/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
deleted file mode 100644
index c281438..0000000
--- a/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
+++ /dev/null
@@ -1,98 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a Physical Network.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePhysicalNetworkCmd.class.getName());
-
- private static final String s_name = "deletephysicalnetworkresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Physical network")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Physical Network Id: " + id);
- boolean result = _networkService.deletePhysicalNetwork(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete physical network");
- }
- }
-
-
- @Override
- public String getEventDescription() {
- return "Deleting Physical network: " + getId();
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_PHYSICAL_NETWORK_DELETE;
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PhysicalNetwork;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeletePodCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePodCmd.java b/api/src/com/cloud/api/commands/DeletePodCmd.java
deleted file mode 100644
index ed95124..0000000
--- a/api/src/com/cloud/api/commands/DeletePodCmd.java
+++ /dev/null
@@ -1,76 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a Pod.", responseObject=SuccessResponse.class)
-public class DeletePodCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePodCmd.class.getName());
-
- private static final String s_name = "deletepodresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="host_pod_ref")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Pod")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- boolean result = _configService.deletePod(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete pod");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeletePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePoolCmd.java b/api/src/com/cloud/api/commands/DeletePoolCmd.java
deleted file mode 100644
index ba2f73f..0000000
--- a/api/src/com/cloud/api/commands/DeletePoolCmd.java
+++ /dev/null
@@ -1,90 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.user.Account;
-
-@Implementation(description = "Deletes a storage pool.", responseObject = SuccessResponse.class)
-public class DeletePoolCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
- private static final String s_name = "deletestoragepoolresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="storage_pool")
- @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "Storage pool id")
- private Long id;
-
- @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force destroy storage pool " +
- "(force expunge volumes in Destroyed state as a part of pool removal)")
- private Boolean forced;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public boolean isForced() {
- return (forced != null) ? forced : false;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute() {
- boolean result = _storageService.deletePool(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- StoragePool pool = _storageService.getStoragePool(id);
- if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeletePortForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePortForwardingRuleCmd.java b/api/src/com/cloud/api/commands/DeletePortForwardingRuleCmd.java
deleted file mode 100644
index ed2c32a..0000000
--- a/api/src/com/cloud/api/commands/DeletePortForwardingRuleCmd.java
+++ /dev/null
@@ -1,122 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.PortForwardingRule;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a port forwarding rule", responseObject=SuccessResponse.class)
-public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName());
- private static final String s_name = "deleteportforwardingruleresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="firewall_rules")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the port forwarding rule")
- private Long id;
-
- // unexposed parameter needed for events logging
- @IdentityMapper(entityTableName="account")
- @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
- private Long ownerId;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NET_RULE_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return ("Deleting port forwarding rule for id=" + id);
- }
-
- @Override
- public long getEntityOwnerId() {
- if (ownerId == null) {
- PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, id);
- if (rule == null) {
- throw new InvalidParameterValueException("Unable to find port forwarding rule by id=" + id);
- } else {
- ownerId = _entityMgr.findById(PortForwardingRule.class, id).getAccountId();
- }
-
- }
- return ownerId;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Rule Id: "+id);
- //revoke corresponding firewall rule first
- boolean result = _firewallService.revokeRelatedFirewallRule(id, true);
- result = result && _rulesService.revokePortForwardingRule(id, true);
-
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete port forwarding rule");
- }
- }
-
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return _rulesService.getPortForwardigRule(id).getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java b/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
deleted file mode 100644
index 2767efd..0000000
--- a/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
+++ /dev/null
@@ -1,114 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.vpc.VpcGateway;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a Private gateway", responseObject=SuccessResponse.class)
-public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePrivateGatewayCmd.class.getName());
- private static final String s_name = "deleteprivategatewayresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="vpc_gateways")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the private gateway")
- private Long id;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_PRIVATE_GATEWAY_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return ("Deleting private gateway id=" + id);
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
- UserContext.current().setEventDetails("Network ACL Id: " + id);
- boolean result = _vpcService.deleteVpcPrivateGateway(id);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete private gateway");
- }
- }
-
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.vpcSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- VpcGateway gateway = _vpcService.getVpcPrivateGateway(getId());
- if (gateway == null) {
- throw new InvalidParameterValueException("Invalid private gateway id");
- }
- return gateway.getVpcId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PrivateGateway;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteProjectCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteProjectCmd.java b/api/src/com/cloud/api/commands/DeleteProjectCmd.java
deleted file mode 100644
index fb1b508..0000000
--- a/api/src/com/cloud/api/commands/DeleteProjectCmd.java
+++ /dev/null
@@ -1,99 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.projects.Project;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a project", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteProjectCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteProjectCmd.class.getName());
-
- private static final String s_name = "deleteprojectresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of the project to be deleted")
- private Long id;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
-
- public Long geId() {
- return id;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Project Id: " + id);
- boolean result = _projectService.deleteProject(id);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete project");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_PROJECT_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting project: " + id;
- }
-
- @Override
- public long getEntityOwnerId() {
- Project project= _projectService.getProject(id);
- //verify input parameters
- if (project == null) {
- throw new InvalidParameterValueException("Unable to find project by id " + id);
- }
-
- return _projectService.getProjectOwner(id).getId();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteProjectInvitationCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteProjectInvitationCmd.java b/api/src/com/cloud/api/commands/DeleteProjectInvitationCmd.java
deleted file mode 100644
index a13bbda..0000000
--- a/api/src/com/cloud/api/commands/DeleteProjectInvitationCmd.java
+++ /dev/null
@@ -1,89 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Accepts or declines project invitation", responseObject = SuccessResponse.class, since = "3.0.0")
-public class DeleteProjectInvitationCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteProjectInvitationCmd.class.getName());
- private static final String s_name = "deleteprojectinvitationresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
- @IdentityMapper(entityTableName = "project_invitations")
- @Parameter(name = ApiConstants.ID, required = true, type = CommandType.LONG, description = "id of the invitation")
- private Long id;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
- public Long getId() {
- return id;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
- @Override
- public long getEntityOwnerId() {
- // TODO - return project entity ownerId
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
-// tracked
- }
-
- @Override
- public void execute() {
- UserContext.current().setEventDetails("Project invitation id " + id);
- boolean result = _projectService.deleteProjectInvitation(id);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete the project invitation");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_PROJECT_INVITATION_REMOVE;
- }
-
- @Override
- public String getEventDescription() {
- return "Project invitatino id " + id + " is being removed";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteRemoteAccessVpnCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteRemoteAccessVpnCmd.java b/api/src/com/cloud/api/commands/DeleteRemoteAccessVpnCmd.java
deleted file mode 100644
index 899142b..0000000
--- a/api/src/com/cloud/api/commands/DeleteRemoteAccessVpnCmd.java
+++ /dev/null
@@ -1,100 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.RemoteAccessVpn;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Destroys a l2tp/ipsec remote access vpn", responseObject=SuccessResponse.class)
-public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteRemoteAccessVpnCmd.class.getName());
-
- private static final String s_name = "deleteremoteaccessvpnresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
- @IdentityMapper(entityTableName="user_ip_address")
- @Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn server")
- private Long publicIpId;
-
- // unexposed parameter needed for events logging
- @IdentityMapper(entityTableName="account")
- @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
- private Long ownerId;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- if (ownerId == null) {
- RemoteAccessVpn vpnEntity = _entityMgr.findById(RemoteAccessVpn.class, publicIpId);
- if(vpnEntity != null)
- return vpnEntity.getAccountId();
-
- throw new InvalidParameterValueException("The specified public ip is not allocated to any account");
- }
- return ownerId;
- }
-
- @Override
- public String getEventDescription() {
- return "Delete Remote Access VPN for account " + getEntityOwnerId() + " for ip id=" + publicIpId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_REMOTE_ACCESS_VPN_DESTROY;
- }
-
- @Override
- public void execute() throws ResourceUnavailableException {
- _ravService.destroyRemoteAccessVpn(publicIpId, UserContext.current().getCaller());
- }
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return _ravService.getRemoteAccessVpn(publicIpId).getNetworkId();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java b/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java
deleted file mode 100644
index d4f6b47..0000000
--- a/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java
+++ /dev/null
@@ -1,109 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a keypair by name", responseObject=SuccessResponse.class)
-public class DeleteSSHKeyPairCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName());
- private static final String s_name = "deletesshkeypairresponse";
-
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="Name of the keypair")
- private String name;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the keypair. Must be used with the domainId parameter.")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the keypair")
- private Long domainId;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="the project associated with keypair")
- private Long projectId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getName() {
- return name;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public Long getProjectId() {
- return projectId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() {
- boolean result = _mgr.deleteSSHKeyPair(this);
- SuccessResponse response = new SuccessResponse(getCommandName());
- response.setSuccess(result);
- this.setResponseObject(response);
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if ((account == null) || isAdmin(account.getType())) {
- if ((domainId != null) && (accountName != null)) {
- Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
- if (userAccount != null) {
- return userAccount.getId();
- }
- }
- }
-
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteSecurityGroupCmd.java b/api/src/com/cloud/api/commands/DeleteSecurityGroupCmd.java
deleted file mode 100644
index 924e8a8..0000000
--- a/api/src/com/cloud/api/commands/DeleteSecurityGroupCmd.java
+++ /dev/null
@@ -1,131 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceInUseException;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes security group", responseObject=SuccessResponse.class)
-public class DeleteSecurityGroupCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteSecurityGroupCmd.class.getName());
- private static final String s_name = "deletesecuritygroupresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account of the security group. Must be specified with domain ID")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of account owning the security group")
- private Long domainId;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="the project of the security group")
- private Long projectId;
-
- @IdentityMapper(entityTableName="security_group")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with name parameter")
- private Long id;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="The ID of the security group. Mutually exclusive with id parameter")
- private String name;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getAccountName() {
- return accountName;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public Long getProjectId() {
- return projectId;
- }
-
- public Long getId() {
- if (id != null && name != null) {
- throw new InvalidParameterValueException("name and id parameters are mutually exclusive");
- }
-
- if (name != null) {
- id = _responseGenerator.getSecurityGroupId(name, getEntityOwnerId());
- if (id == null) {
- throw new InvalidParameterValueException("Unable to find security group by name " + name + " for the account id=" + getEntityOwnerId());
- }
- }
-
- if (id == null) {
- throw new InvalidParameterValueException("Either id or name parameter is requred by deleteSecurityGroup command");
- }
-
- return id;
- }
-
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public void execute(){
- try{
- boolean result = _securityGroupService.deleteSecurityGroup(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete security group");
- }
- } catch (ResourceInUseException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteServiceOfferingCmd.java b/api/src/com/cloud/api/commands/DeleteServiceOfferingCmd.java
deleted file mode 100644
index b76ad0c..0000000
--- a/api/src/com/cloud/api/commands/DeleteServiceOfferingCmd.java
+++ /dev/null
@@ -1,77 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a service offering.", responseObject=SuccessResponse.class)
-public class DeleteServiceOfferingCmd extends BaseCmd{
- public static final Logger s_logger = Logger.getLogger(DeleteServiceOfferingCmd.class.getName());
- private static final String s_name = "deleteserviceofferingresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="disk_offering")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the service offering")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- boolean result = _configService.deleteServiceOffering(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java b/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java
deleted file mode 100644
index 97c25a5..0000000
--- a/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java
+++ /dev/null
@@ -1,105 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.storage.Snapshot;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a snapshot of a disk volume.", responseObject=SuccessResponse.class)
-public class DeleteSnapshotCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteSnapshotCmd.class.getName());
- private static final String s_name = "deletesnapshotresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="snapshots")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the snapshot")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Snapshot snapshot = _entityMgr.findById(Snapshot.class, getId());
- if (snapshot != null) {
- return snapshot.getAccountId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SNAPSHOT_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "deleting snapshot: " + getId();
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Snapshot;
- }
-
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Snapshot Id: "+getId());
- boolean result = _snapshotService.deleteSnapshot(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete snapshot");
- }
- }
-}