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
[45/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/AssignVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AssignVMCmd.java b/api/src/com/cloud/api/commands/AssignVMCmd.java
deleted file mode 100644
index be28cc0..0000000
--- a/api/src/com/cloud/api/commands/AssignVMCmd.java
+++ /dev/null
@@ -1,132 +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 java.util.ArrayList;
-import java.util.List;
-
-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.BaseCmd.CommandType;
-import com.cloud.api.response.UserVmResponse;
-import com.cloud.api.response.ZoneResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-
-@Implementation(description="Move a user VM to another user under same domain.", responseObject=UserVmResponse.class, since="3.0.0")
-public class AssignVMCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(AssignVMCmd.class.getName());
-
- private static final String s_name = "moveuservmresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="vm_instance")
- @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="the vm ID of the user VM to be moved")
- private Long virtualMachineId;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true, description="account name of the new VM owner.")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, required=true, description="domain id of the new VM owner.")
- private Long domainId;
-
- //Network information
- @IdentityMapper(entityTableName="networks")
- @Parameter(name=ApiConstants.NETWORK_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, description="list of network ids that will be part of VM network after move in advanced network setting.")
- private List<Long> networkIds;
-
- @IdentityMapper(entityTableName="security_group")
- @Parameter(name=ApiConstants.SECURITY_GROUP_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, description="comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is moved in a zone with Basic Network support.")
- private List<Long> securityGroupIdList;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getVmId() {
- return virtualMachineId;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public List<Long> getNetworkIds() {
- return networkIds;
- }
-
- public List<Long> getSecurityGroupIdList() {
- return securityGroupIdList;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute(){
- try {
- UserVm userVm = _userVmService.moveVMToUser(this);
- if (userVm == null){
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to move vm");
- }
- UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);
- response.setResponseName(DeployVMCmd.getResultObjectName());
- this.setResponseObject(response);
- }catch (Exception e){
- e.printStackTrace();
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to move vm " + e.getMessage());
- }
-
- }
-
- @Override
- public long getEntityOwnerId() {
- UserVm vm = _responseGenerator.findUserVmById(getVmId());
- if (vm != null) {
- return vm.getAccountId();
- }
-
- 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/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java
deleted file mode 100644
index 878a9fc..0000000
--- a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java
+++ /dev/null
@@ -1,274 +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 java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseAsyncCreateCmd;
-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.IPAddressResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
-import com.cloud.network.Network;
-import com.cloud.network.vpc.Vpc;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Acquires and associates a public IP to an account.", responseObject=IPAddressResponse.class)
-public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
- public static final Logger s_logger = Logger.getLogger(AssociateIPAddrCmd.class.getName());
- private static final String s_name = "associateipaddressresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING,
- description="the account to associate with this IP address")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG,
- description="the ID of the domain to associate with this IP address")
- private Long domainId;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG,
- description="the ID of the availability zone you want to acquire an public IP address from")
- private Long zoneId;
-
- @IdentityMapper(entityTableName="networks")
- @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
- description="The network this ip address should be associated to.")
- private Long networkId;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG,
- description="Deploy vm for the project")
- private Long projectId;
-
- @IdentityMapper(entityTableName="vpc")
- @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="the VPC you want the ip address to " +
- "be associated with")
- private Long vpcId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getEntityTable() {
- return "user_ip_address";
- }
-
- public String getAccountName() {
- if (accountName != null) {
- return accountName;
- }
- return UserContext.current().getCaller().getAccountName();
- }
-
- public long getDomainId() {
- if (domainId != null) {
- return domainId;
- }
- return UserContext.current().getCaller().getDomainId();
- }
-
- private long getZoneId() {
- if (zoneId != null) {
- return zoneId;
- } else if (vpcId != null) {
- Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
- if (vpc != null) {
- return vpc.getZoneId();
- }
- } else if (networkId != null) {
- Network ntwk = _entityMgr.findById(Network.class, networkId);
- if (ntwk != null) {
- return ntwk.getDataCenterId();
- }
- }
-
- throw new InvalidParameterValueException("Unable to figure out zone to assign ip to");
- }
-
- public Long getVpcId() {
- return vpcId;
- }
-
- public Long getNetworkId() {
- if (vpcId != null) {
- return null;
- }
-
- if (networkId != null) {
- return networkId;
- }
- Long zoneId = getZoneId();
-
- if (zoneId == null) {
- return null;
- }
-
- DataCenter zone = _configService.getZone(zoneId);
- if (zone.getNetworkType() == NetworkType.Advanced) {
- List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
- _accountService.getAccount(getEntityOwnerId()));
- if (networks.size() == 0) {
- String domain = _domainService.getDomain(getDomainId()).getName();
- throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain +
- " doesn't have virtual networks in zone=" + zone.getName());
- }
-
- if (networks.size() < 1) {
- throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
- } else if (networks.size() > 1) {
- throw new InvalidParameterValueException("Account has more than one Isolated network in the zone");
- }
-
- return networks.get(0).getId();
- } else {
- Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId);
- if (defaultGuestNetwork == null) {
- throw new InvalidParameterValueException("Unable to find a default Guest network for account " +
- getAccountName() + " in domain id=" + getDomainId());
- } else {
- return defaultGuestNetwork.getId();
- }
- }
- }
-
- @Override
- public long getEntityOwnerId() {
- Account caller = UserContext.current().getCaller();
- if (accountName != null && domainId != null) {
- Account account = _accountService.finalizeOwner(caller, accountName, domainId, projectId);
- return account.getId();
- } else if (networkId != null){
- Network network = _networkService.getNetwork(networkId);
- return network.getAccountId();
- } else if (vpcId != null) {
- Vpc vpc = _vpcService.getVpc(getVpcId());
- if (vpc == null) {
- throw new InvalidParameterValueException("Can't find Enabled vpc by id specified");
- }
- return vpc.getAccountId();
- }
-
- return caller.getAccountId();
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NET_IP_ASSIGN;
- }
-
- @Override
- public String getEventDescription() {
- return "associating ip to network id: " + getNetworkId() + " in zone " + getZoneId();
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "addressinfo";
- }
-
- @Override
- public void create() throws ResourceAllocationException{
- try {
- IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId());
-
- if (ip != null) {
- this.setEntityId(ip.getId());
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to allocate ip address");
- }
- } catch (ConcurrentOperationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
- } catch (InsufficientAddressCapacityException ex) {
- s_logger.info(ex);
- s_logger.trace(ex);
- throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
- }
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, ResourceAllocationException,
- ConcurrentOperationException, InsufficientCapacityException {
- UserContext.current().setEventDetails("Ip Id: " + getEntityId());
-
- IpAddress result = null;
-
- if (getVpcId() != null) {
- result = _vpcService.associateIPToVpc(getEntityId(), getVpcId());
- } else if (getNetworkId() != null) {
- result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId());
- }
-
- if (result != null) {
- IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
- ipResponse.setResponseName(getCommandName());
- this.setResponseObject(ipResponse);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign ip address");
- }
- }
-
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.IpAddress;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/AttachIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AttachIsoCmd.java b/api/src/com/cloud/api/commands/AttachIsoCmd.java
deleted file mode 100755
index 75f2ac7..0000000
--- a/api/src/com/cloud/api/commands/AttachIsoCmd.java
+++ /dev/null
@@ -1,112 +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.UserVmResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.user.UserContext;
-import com.cloud.uservm.UserVm;
-
-@Implementation(description="Attaches an ISO to a virtual machine.", responseObject=UserVmResponse.class)
-public class AttachIsoCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(AttachIsoCmd.class.getName());
-
- private static final String s_name = "attachisoresponse";
-
- /////////////////////////////////////////////////////
- //////////////// 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="vm_instance")
- @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="the ID of the virtual machine")
- private Long virtualMachineId;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Long getVirtualMachineId() {
- return virtualMachineId;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- UserVm vm = _entityMgr.findById(UserVm.class, getVirtualMachineId());
- if (vm == null) {
- throw new InvalidParameterValueException("Unable to find virtual machine by id " + getVirtualMachineId());
- }
-
- return vm.getAccountId();
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_ISO_ATTACH;
- }
-
- @Override
- public String getEventDescription() {
- return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId();
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Vm Id: " +getVirtualMachineId()+ " ISO Id: "+getId());
- boolean result = _templateService.attachIso(id, virtualMachineId);
- if (result) {
- UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId);
- if (userVm != null) {
- UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);
- response.setResponseName(DeployVMCmd.getResultObjectName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach iso");
- }
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach iso");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/AttachVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AttachVolumeCmd.java b/api/src/com/cloud/api/commands/AttachVolumeCmd.java
deleted file mode 100755
index bfd1a84..0000000
--- a/api/src/com/cloud/api/commands/AttachVolumeCmd.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.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.VolumeResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.storage.Volume;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Attaches a disk volume to a virtual machine.", responseObject=VolumeResponse.class)
-public class AttachVolumeCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName());
- private static final String s_name = "attachvolumeresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.DEVICE_ID, type=CommandType.LONG, description="the ID of the device to map the volume to within the guest OS. " +
- "If no deviceId is passed in, the next available deviceId will be chosen. " +
- "Possible values for a Linux OS are:" +
- "* 1 - /dev/xvdb" +
- "* 2 - /dev/xvdc" +
- "* 4 - /dev/xvde" +
- "* 5 - /dev/xvdf" +
- "* 6 - /dev/xvdg" +
- "* 7 - /dev/xvdh" +
- "* 8 - /dev/xvdi" +
- "* 9 - /dev/xvdj")
- private Long deviceId;
-
- @IdentityMapper(entityTableName="volumes")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the disk volume")
- private Long id;
-
- @IdentityMapper(entityTableName="vm_instance")
- @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description=" the ID of the virtual machine")
- private Long virtualMachineId;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getDeviceId() {
- return deviceId;
- }
-
- public Long getId() {
- return id;
- }
-
- public Long getVirtualMachineId() {
- return virtualMachineId;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Volume;
- }
-
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public long getEntityOwnerId() {
- Volume volume = _responseGenerator.findVolumeById(getId());
- if (volume == null) {
- return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
- }
- return volume.getAccountId();
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_VOLUME_ATTACH;
- }
-
- @Override
- public String getEventDescription() {
- return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId();
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
- Volume result = _userVmService.attachVolumeToVM(this);
- if (result != null) {
- VolumeResponse response = _responseGenerator.createVolumeResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach volume");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
deleted file mode 100644
index a6088d0..0000000
--- a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
+++ /dev/null
@@ -1,228 +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 java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-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.SecurityGroupRuleResponse;
-import com.cloud.api.response.SecurityGroupResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.security.SecurityRule;
-import com.cloud.user.UserContext;
-import com.cloud.utils.StringUtils;
-
-@Implementation(responseObject = SecurityGroupRuleResponse.class, description = "Authorizes a particular egress rule for this security group", since="3.0.0")
-@SuppressWarnings("rawtypes")
-public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressCmd.class.getName());
-
- private static final String s_name = "authorizesecuritygroupegressresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "TCP is default. UDP is the other supported protocol")
- private String protocol;
-
- @Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description = "start port for this egress rule")
- private Integer startPort;
-
- @Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "end port for this egress rule")
- private Integer endPort;
-
- @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.CIDR_LIST, type=CommandType.LIST, collectionType=CommandType.STRING, description="the cidr list associated")
- private List<String> cidrList;
-
- @Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = CommandType.MAP, description = "user to security group mapping")
- private Map userSecurityGroupList;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
- private String accountName;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project of the security group")
- private Long projectId;
-
- @IdentityMapper(entityTableName="security_group")
- @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with securityGroupName parameter")
- private Long securityGroupId;
-
- @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter")
- private String securityGroupName;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getAccountName() {
- return accountName;
- }
-
- public List<String> getCidrList() {
- return cidrList;
- }
-
- public Integer getEndPort() {
- return endPort;
- }
-
- public Integer getIcmpCode() {
- return icmpCode;
- }
-
- public Integer getIcmpType() {
- return icmpType;
- }
-
- public Long getSecurityGroupId() {
- if (securityGroupId != null && securityGroupName != null) {
- throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive");
- }
-
- if (securityGroupName != null) {
- securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId());
- if (securityGroupId == null) {
- throw new InvalidParameterValueException("Unable to find security group " + securityGroupName + " for account id=" + getEntityOwnerId());
- }
- securityGroupName = null;
- }
-
- if (securityGroupId == null) {
- throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command");
- }
-
- return securityGroupId;
- }
-
- public String getProtocol() {
- if (protocol == null) {
- return "all";
- }
- return protocol;
- }
-
- public Integer getStartPort() {
- return startPort;
- }
-
- public Map getUserSecurityGroupList() {
- return userSecurityGroupList;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "securitygroup";
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SECURITY_GROUP_AUTHORIZE_EGRESS;
- }
-
- @Override
- public String getEventDescription() {
- StringBuilder sb = new StringBuilder();
- if (getUserSecurityGroupList() != null) {
- sb.append("group list(group/account): ");
- Collection userGroupCollection = getUserSecurityGroupList().values();
- Iterator iter = userGroupCollection.iterator();
-
- HashMap userGroup = (HashMap) iter.next();
- String group = (String) userGroup.get("group");
- String authorizedAccountName = (String) userGroup.get("account");
- sb.append(group + "/" + authorizedAccountName);
-
- while (iter.hasNext()) {
- userGroup = (HashMap) iter.next();
- group = (String) userGroup.get("group");
- authorizedAccountName = (String) userGroup.get("account");
- sb.append(", " + group + "/" + authorizedAccountName);
- }
- } else if (getCidrList() != null) {
- sb.append("cidr list: ");
- sb.append(StringUtils.join(getCidrList(), ", "));
- } else {
- sb.append("<error: no egress parameters>");
- }
-
- return "authorizing egress to group: " + getSecurityGroupId() + " to " + sb.toString();
- }
-
- @Override
- public void execute() {
- List<? extends SecurityRule> egressRules = _securityGroupService.authorizeSecurityGroupEgress(this);
- if (egressRules != null && !egressRules.isEmpty()) {
- SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(egressRules);
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to authorize security group egress rule(s)");
- }
-
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.SecurityGroup;
- }
-
- @Override
- public Long getInstanceId() {
- return getSecurityGroupId();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
deleted file mode 100644
index e8f8b98..0000000
--- a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
+++ /dev/null
@@ -1,237 +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 java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.SecurityGroupResponse;
-import com.cloud.api.response.SecurityGroupRuleResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.security.SecurityRule;
-import com.cloud.user.UserContext;
-import com.cloud.utils.StringUtils;
-import com.cloud.utils.net.NetUtils;
-
-@Implementation(responseObject = SecurityGroupRuleResponse.class, description = "Authorizes a particular ingress rule for this security group")
-@SuppressWarnings("rawtypes")
-public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressCmd.class.getName());
-
- private static final String s_name = "authorizesecuritygroupingressresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "TCP is default. UDP is the other supported protocol")
- private String protocol;
-
- @Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description = "start port for this ingress rule")
- private Integer startPort;
-
- @Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "end port for this ingress rule")
- private Integer endPort;
-
- @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.CIDR_LIST, type=CommandType.LIST, collectionType=CommandType.STRING, description="the cidr list associated")
- private List<String> cidrList;
-
- @Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = CommandType.MAP, description = "user to security group mapping")
- private Map userSecurityGroupList;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
- private String accountName;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project of the security group")
- private Long projectId;
-
- @IdentityMapper(entityTableName="security_group")
- @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with securityGroupName parameter")
- private Long securityGroupId;
-
- @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter")
- private String securityGroupName;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getAccountName() {
- return accountName;
- }
-
- public List<String> getCidrList() {
- return cidrList;
- }
-
- public Integer getEndPort() {
- return endPort;
- }
-
- public Integer getIcmpCode() {
- return icmpCode;
- }
-
- public Integer getIcmpType() {
- return icmpType;
- }
-
- public Long getSecurityGroupId() {
- if (securityGroupId != null && securityGroupName != null) {
- throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive");
- }
-
- if (securityGroupName != null) {
- securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId());
- if (securityGroupId == null) {
- throw new InvalidParameterValueException("Unable to find security group " + securityGroupName + " for account id=" + getEntityOwnerId());
- }
- securityGroupName = null;
- }
-
- if (securityGroupId == null) {
- throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command");
- }
-
- return securityGroupId;
- }
-
- public String getProtocol() {
- if (protocol == null) {
- return "all";
- }
- return protocol;
- }
-
- public Integer getStartPort() {
- return startPort;
- }
-
- public Map getUserSecurityGroupList() {
- return userSecurityGroupList;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "securitygroup";
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SECURITY_GROUP_AUTHORIZE_INGRESS;
- }
-
- @Override
- public String getEventDescription() {
- StringBuilder sb = new StringBuilder();
- if (getUserSecurityGroupList() != null) {
- sb.append("group list(group/account): ");
- Collection userGroupCollection = getUserSecurityGroupList().values();
- Iterator iter = userGroupCollection.iterator();
-
- HashMap userGroup = (HashMap) iter.next();
- String group = (String) userGroup.get("group");
- String authorizedAccountName = (String) userGroup.get("account");
- sb.append(group + "/" + authorizedAccountName);
-
- while (iter.hasNext()) {
- userGroup = (HashMap) iter.next();
- group = (String) userGroup.get("group");
- authorizedAccountName = (String) userGroup.get("account");
- sb.append(", " + group + "/" + authorizedAccountName);
- }
- } else if (getCidrList() != null) {
- sb.append("cidr list: ");
- sb.append(StringUtils.join(getCidrList(), ", "));
- } else {
- sb.append("<error: no ingress parameters>");
- }
-
- return "authorizing ingress to group: " + getSecurityGroupId() + " to " + sb.toString();
- }
-
- @Override
- public void execute() {
- if(cidrList != null){
- for(String cidr : cidrList ){
- if (!NetUtils.isValidCIDR(cidr)){
- throw new ServerApiException(BaseCmd.PARAM_ERROR, cidr + " is an Invalid CIDR ");
- }
- }
- }
- List<? extends SecurityRule> ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this);
- if (ingressRules != null && !ingressRules.isEmpty()) {
- SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules);
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to authorize security group ingress rule(s)");
- }
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.SecurityGroup;
- }
-
- @Override
- public Long getInstanceId() {
- return getSecurityGroupId();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
deleted file mode 100644
index def0c2d..0000000
--- a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
+++ /dev/null
@@ -1,113 +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.HostResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Cancels host maintenance.", responseObject=HostResponse.class)
-public class CancelMaintenanceCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName());
-
- private static final String s_name = "cancelhostmaintenanceresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="host")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "host";
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_MAINTENANCE_CANCEL;
- }
-
- @Override
- public String getEventDescription() {
- return "canceling maintenance for host: " + getId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Host;
- }
-
- @Override
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public void execute(){
- Host result = _resourceService.cancelMaintenance(this);
- if (result != null) {
- HostResponse response = _responseGenerator.createHostResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
deleted file mode 100644
index c4d97ae..0000000
--- a/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.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.StoragePoolResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.StoragePool;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
-public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
-
- private static final String s_name = "cancelprimarystoragemaintenanceresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="storage_pool")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the primary storage ID")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "primarystorage";
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.StoragePool;
- }
-
- @Override
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE;
- }
-
- @Override
- public String getEventDescription() {
- return "canceling maintenance for primary storage pool: " + getId();
- }
-
- @Override
- public void execute() throws ResourceUnavailableException{
- StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
- if (result != null) {
- StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
deleted file mode 100644
index 9679940..0000000
--- a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
+++ /dev/null
@@ -1,128 +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.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.VirtualRouterProviderResponse;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.element.VirtualRouterElementService;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
-public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName());
- private static final String s_name = "configurevirtualrouterelementresponse";
-
- @PlugService
- private VirtualRouterElementService _service;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName = "virtual_router_providers")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the virtual router provider")
- private Long id;
-
- @IdentityMapper(entityTableName = "physical_network_service_providers")
- @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
- private Boolean enabled;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "boolean";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
- }
-
- @Override
- public String getEventDescription() {
- return "configuring virtual router provider: " + id;
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.None;
- }
-
- public Long getInstanceId() {
- return id;
- }
-
- @Override
- public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
- UserContext.current().setEventDetails("Virtual router element: " + id);
- VirtualRouterProvider result = _service.configure(this);
- if (result != null){
- VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
- routerResponse.setResponseName(getCommandName());
- this.setResponseObject(routerResponse);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the virtual router provider");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CopyTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CopyTemplateCmd.java b/api/src/com/cloud/api/commands/CopyTemplateCmd.java
deleted file mode 100755
index d825bbc..0000000
--- a/api/src/com/cloud/api/commands/CopyTemplateCmd.java
+++ /dev/null
@@ -1,143 +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 java.util.List;
-
-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.TemplateResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.StorageUnavailableException;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Copies a template from one zone to another.", responseObject=TemplateResponse.class)
-public class CopyTemplateCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName());
- private static final String s_name = "copytemplateresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.DESTINATION_ZONE_ID, type=CommandType.LONG, required=true, description="ID of the zone the template is being copied to.")
- private Long destZoneId;
-
- @IdentityMapper(entityTableName="vm_template")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="Template ID.")
- private Long id;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.SOURCE_ZONE_ID, type=CommandType.LONG, required=true, description="ID of the zone the template is currently hosted on.")
- private Long sourceZoneId;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getDestinationZoneId() {
- return destZoneId;
- }
-
- public Long getId() {
- return id;
- }
-
- public Long getSourceZoneId() {
- return sourceZoneId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getStaticName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId());
- if (template != null) {
- return template.getAccountId();
- }
-
- // bad id given, parent this command to SYSTEM so ERROR events are tracked
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_TEMPLATE_COPY;
- }
-
- @Override
- public String getEventDescription() {
- return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Template;
- }
-
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public void execute() throws ResourceAllocationException{
- try {
- UserContext.current().setEventDetails(getEventDescription());
- VirtualMachineTemplate template = _templateService.copyTemplate(this);
-
- if (template != null){
- List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(template.getId(), getDestinationZoneId(), false);
- TemplateResponse response = new TemplateResponse();
- if (listResponse != null && !listResponse.isEmpty()) {
- response = listResponse.get(0);
- }
-
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy template");
- }
- } catch (StorageUnavailableException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAccountCmd.java b/api/src/com/cloud/api/commands/CreateAccountCmd.java
deleted file mode 100755
index 00e8776..0000000
--- a/api/src/com/cloud/api/commands/CreateAccountCmd.java
+++ /dev/null
@@ -1,159 +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 java.util.Collection;
-import java.util.Map;
-
-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.AccountResponse;
-import com.cloud.api.response.UserResponse;
-import com.cloud.user.Account;
-import com.cloud.user.UserAccount;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Creates an account", responseObject=UserResponse.class)
-public class CreateAccountCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(CreateAccountCmd.class.getName());
-
- private static final String s_name = "createaccountresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
- private String accountName;
-
- @Parameter(name=ApiConstants.ACCOUNT_TYPE, type=CommandType.SHORT, required=true, description="Type of the account. Specify 0 for user, 1 for root admin, and 2 for domain admin")
- private Short accountType;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.EMAIL, type=CommandType.STRING, required=true, description="email")
- private String email;
-
- @Parameter(name=ApiConstants.FIRSTNAME, type=CommandType.STRING, required=true, description="firstname")
- private String firstName;
-
- @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, required=true, description="lastname")
- private String lastName;
-
- @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.")
- private String password;
-
- @Parameter(name=ApiConstants.TIMEZONE, type=CommandType.STRING, description="Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.")
- private String timeZone;
-
- @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="Unique username.")
- private String userName;
-
- @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks")
- private String networkDomain;
-
- @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
- private Map<String, String> details;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getAccountName() {
- return accountName;
- }
-
- public Short getAccountType() {
- return accountType;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public String getEmail() {
- return email;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getTimeZone() {
- return timeZone;
- }
-
- public String getUsername() {
- return userName;
- }
-
- public String getNetworkDomain() {
- return networkDomain;
- }
-
- public Map<String, String> getDetails() {
- if (details == null || details.isEmpty()) {
- return null;
- }
-
- Collection<String> paramsCollection = details.values();
- Map<String, String> params = (Map<String, String>) (paramsCollection.toArray())[0];
- return params;
- }
-
- /////////////////////////////////////////////////////
- /////////////// 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("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
- UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails());
- if (userAccount != null) {
- AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java b/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
deleted file mode 100644
index 4d93747..0000000
--- a/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
+++ /dev/null
@@ -1,170 +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 java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCreateCmd;
-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.AutoScalePolicyResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.domain.Domain;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.network.as.AutoScalePolicy;
-import com.cloud.network.as.Condition;
-import com.cloud.user.Account;
-
-@Implementation(description = "Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.", responseObject = AutoScalePolicyResponse.class)
-public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
- public static final Logger s_logger = Logger.getLogger(CreateAutoScalePolicyCmd.class.getName());
-
- private static final String s_name = "autoscalepolicyresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, required = true, description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
- private String action;
-
- @Parameter(name = ApiConstants.DURATION, type = CommandType.INTEGER, required = true, description = "the duration for which the conditions have to be true before action is taken")
- private int duration;
-
- @Parameter(name = ApiConstants.QUIETTIME, type = CommandType.INTEGER, description = "the cool down period for which the policy should not be evaluated after the action has been taken")
- private Integer quietTime;
-
- @IdentityMapper(entityTableName = "conditions")
- @Parameter(name = ApiConstants.CONDITION_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, required = true, description = "the list of IDs of the conditions that are being evaluated on every interval")
- private List<Long> conditionIds;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- private Long conditionDomainId;
- private Long conditionAccountId;
-
- @Override
- public String getEntityTable() {
- return "autoscale_policies";
- }
-
- public int getDuration() {
- return duration;
- }
-
- public Integer getQuietTime() {
- return quietTime;
- }
-
- public String getAction() {
- return action;
- }
-
- public List<Long> getConditionIds() {
- return conditionIds;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "autoscalepolicy";
- }
-
- public long getAccountId()
- {
- if (conditionAccountId == null)
- getEntityOwnerId();
- return conditionAccountId;
- }
-
- public long getDomainId()
- {
- if (conditionDomainId == null) {
- getEntityOwnerId();
- }
-
- return conditionDomainId;
- }
-
- @Override
- public long getEntityOwnerId() {
- if (conditionAccountId != null) {
- return conditionAccountId;
- }
- long conditionId = getConditionIds().get(0);
- Condition condition = _entityMgr.findById(Condition.class, conditionId);
- if(condition == null) {
- // it is an invalid condition, return system acccount, error will be thrown later.
- conditionDomainId = Domain.ROOT_DOMAIN;
- conditionAccountId = Account.ACCOUNT_ID_SYSTEM;
- } else {
- conditionDomainId = condition.getDomainId();
- conditionAccountId = condition.getAccountId();
- }
-
- return conditionAccountId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_AUTOSCALEPOLICY_CREATE;
- }
-
- @Override
- public String getEventDescription() {
- return "creating AutoScale Policy";
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.AutoScalePolicy;
- }
-
- @Override
- public void execute() {
- AutoScalePolicy result = _entityMgr.findById(AutoScalePolicy.class, getEntityId());
- AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-
- @Override
- public void create() throws ResourceAllocationException {
- AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this);
- if (result != null) {
- this.setEntityId(result.getId());
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create AutoScale Policy");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
deleted file mode 100644
index 83d7607..0000000
--- a/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,194 +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 java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCreateCmd;
-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.AutoScaleVmGroupResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.network.as.AutoScaleVmGroup;
-import com.cloud.network.rules.LoadBalancer;
-
-@Implementation(description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = AutoScaleVmGroupResponse.class)
-public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
- public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmGroupCmd.class.getName());
-
- private static final String s_name = "autoscalevmgroupresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName = "firewall_rules")
- @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
- private long lbRuleId;
-
- @Parameter(name = ApiConstants.MIN_MEMBERS, type = CommandType.INTEGER, required = true, description = "the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.")
- private int minMembers;
-
- @Parameter(name = ApiConstants.MAX_MEMBERS, type = CommandType.INTEGER, required = true, description = "the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.")
- private int maxMembers;
-
- @Parameter(name = ApiConstants.INTERVAL, type = CommandType.INTEGER, description = "the frequency at which the conditions have to be evaluated")
- private Integer interval;
-
- @IdentityMapper(entityTableName = "autoscale_policies")
- @Parameter(name = ApiConstants.SCALEUP_POLICY_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, required = true, description = "list of scaleup autoscale policies")
- private List<Long> scaleUpPolicyIds;
-
- @IdentityMapper(entityTableName = "autoscale_policies")
- @Parameter(name = ApiConstants.SCALEDOWN_POLICY_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, required = true, description = "list of scaledown autoscale policies")
- private List<Long> scaleDownPolicyIds;
-
- @IdentityMapper(entityTableName = "autoscale_vmprofiles")
- @Parameter(name = ApiConstants.VMPROFILE_ID, type = CommandType.LONG, required = true, description = "the autoscale profile that contains information about the vms in the vm group.")
- private long profileId;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getEntityTable() {
- return "autoscale_vmgroups";
- }
-
- public int getMinMembers() {
- return minMembers;
- }
-
- public int getMaxMembers() {
- return maxMembers;
- }
-
- public Integer getInterval() {
- return interval;
- }
-
- public long getProfileId() {
- return profileId;
- }
-
- public List<Long> getScaleUpPolicyIds() {
- return scaleUpPolicyIds;
- }
-
- public List<Long> getScaleDownPolicyIds() {
- return scaleDownPolicyIds;
- }
-
- public long getLbRuleId() {
- return lbRuleId;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "autoscalevmgroup";
- }
-
- @Override
- public long getEntityOwnerId() {
- LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLbRuleId());
- if (lb == null) {
- throw new InvalidParameterValueException("Unable to find loadbalancer by lbRuleId");
- }
- return lb.getAccountId();
- }
-
- public void setLbRuleId(Long lbRuleId) {
- this.lbRuleId = lbRuleId;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE;
- }
-
- @Override
- public String getCreateEventType() {
- return EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE;
- }
-
- @Override
- public String getCreateEventDescription() {
- return "creating AutoScale Vm Group";
- }
-
- @Override
- public String getEventDescription() {
- return "configuring AutoScale Vm Group. Vm Group Id: " + getEntityId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.AutoScaleVmGroup;
- }
-
- @Override
- public void create() throws ResourceAllocationException {
- AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this);
- if (result != null) {
- this.setEntityId(result.getId());
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
- }
- }
-
- @Override
- public void execute() {
- boolean success = false;
- AutoScaleVmGroup vmGroup = null;
- try
- {
- success = _autoScaleService.configureAutoScaleVmGroup(this);
- if (success) {
- vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
- AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
- setResponseObject(responseObject);
- responseObject.setResponseName(getCommandName());
- }
- } catch (Exception ex) {
- // TODO what will happen if Resource Layer fails in a step inbetween
- s_logger.warn("Failed to create autoscale vm group", ex);
- } finally {
- if (!success || vmGroup == null) {
- _autoScaleService.deleteAutoScaleVmGroup(getEntityId());
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
- }
- }
- }
-}