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:37 UTC
[16/52] [partial] Summary: Fixes for api_refactoring
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java
new file mode 100644
index 0000000..8fcaf49
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java
@@ -0,0 +1,105 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
+import com.cloud.dc.StorageNetworkIpRange;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+@APICommand(name = "listStorageNetworkIpRange", description="List a storage network IP range.", responseObject=StorageNetworkIpRangeResponse.class, since="3.0.0")
+public class ListStorageNetworkIpRangeCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListStorageNetworkIpRangeCmd.class);
+
+ String s_name = "liststoragenetworkiprangeresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=StorageNetworkIpRangeResponse.class,
+ description="optional parameter. Storaget network IP range uuid, if specicied, using it to search the range.")
+ private Long rangeId;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+ description="optional parameter. Pod uuid, if specicied and range uuid is absent, using it to search the range.")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+ description="optional parameter. Zone uuid, if specicied and both pod uuid and range uuid are absent, using it to search the range.")
+ private Long zoneId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getRangeId() {
+ return rangeId;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException {
+ try {
+ List<StorageNetworkIpRange> results = _storageNetworkService.listIpRange(this);
+ ListResponse<StorageNetworkIpRangeResponse> response = new ListResponse<StorageNetworkIpRangeResponse>();
+ List<StorageNetworkIpRangeResponse> resList = new ArrayList<StorageNetworkIpRangeResponse>(results.size());
+ for (StorageNetworkIpRange r : results) {
+ StorageNetworkIpRangeResponse resp = _responseGenerator.createStorageNetworkIpRangeResponse(r);
+ resList.add(resp);
+ }
+ response.setResponses(resList);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } catch (Exception e) {
+ s_logger.warn("Failed to list storage network ip range for rangeId=" + getRangeId() + " podId=" + getPodId() + " zoneId=" + getZoneId());
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java
new file mode 100644
index 0000000..f7407a1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ServiceResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.Network;
+import com.cloud.network.Network.Service;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "listSupportedNetworkServices", description="Lists all network services provided by CloudStack or for the given Provider.", responseObject=ServiceResponse.class, since="3.0.0")
+public class ListSupportedNetworkServicesCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListSupportedNetworkServicesCmd.class.getName());
+ private static final String _name = "listsupportednetworkservicesresponse";
+
+ @Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING, description="network service provider name")
+ private String providerName;
+
+ @Parameter(name=ApiConstants.SERVICE, type=CommandType.STRING, description="network service name to list providers and capabilities of")
+ private String serviceName;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ public String getProviderName() {
+ return providerName;
+ }
+
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return _name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ List<? extends Network.Service> services;
+ if(getServiceName() != null){
+ Network.Service service = null;
+ if(serviceName != null){
+ service = Network.Service.getService(serviceName);
+ if(service == null){
+ throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
+ }
+ }
+ List<Network.Service> serviceList = new ArrayList<Network.Service>();
+ serviceList.add(service);
+ services = serviceList;
+ }else{
+ services = _networkService.listNetworkServices(getProviderName());
+ }
+
+ ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>();
+ List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>();
+ for (Network.Service service : services) {
+ //skip gateway service
+ if (service == Service.Gateway) {
+ continue;
+ }
+ ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
+ servicesResponses.add(serviceResponse);
+ }
+
+ response.setResponses(servicesResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java
new file mode 100644
index 0000000..dc2f309
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.NetworkOfferingResponse;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateNetworkOffering", description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)
+public class UpdateNetworkOfferingCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateNetworkOfferingCmd.class.getName());
+ private static final String _name = "updatenetworkofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=NetworkOfferingResponse.class,
+ description="the id of the network offering")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the network offering")
+ private String networkOfferingName;
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the network offering")
+ private String displayText;
+
+ @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering." +
+ " Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
+ private String availability;
+
+ @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the network offering, integer")
+ private Integer sortKey;
+
+ @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the network offering")
+ private String state;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getNetworkOfferingName() {
+ return networkOfferingName;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAvailability() {
+ return availability;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Integer getSortKey() {
+ return sortKey;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return _name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ NetworkOffering result = _configService.updateNetworkOffering(this);
+ if (result != null) {
+ NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java
new file mode 100644
index 0000000..b770ea2
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ProviderResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateNetworkServiceProvider", description="Updates a network serviceProvider of a physical network", responseObject=ProviderResponse.class, since="3.0.0")
+public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateNetworkServiceProviderCmd.class.getName());
+
+ private static final String s_name = "updatenetworkserviceproviderresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="Enabled/Disabled/Shutdown the physical network service provider")
+ private String state;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=ProviderResponse.class,
+ required=true, description="network service provider id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.SERVICE_LIST, type=CommandType.LIST, collectionType = CommandType.STRING, description="the list of services to be enabled for this physical network service provider")
+ private List<String> enabledServices;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getState() {
+ return state;
+ }
+
+ private Long getId() {
+ return id;
+ }
+
+ public List<String> getEnabledServices() {
+ return enabledServices;
+ }
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), getState(), getEnabledServices());
+ if (result != null) {
+ ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_SERVICE_PROVIDER_UPDATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Updating 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/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
new file mode 100644
index 0000000..d9a3e04
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
@@ -0,0 +1,118 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.user.Account;
+
+@APICommand(name = "updatePhysicalNetwork", description="Updates a physical network", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
+public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdatePhysicalNetworkCmd.class.getName());
+
+ private static final String s_name = "updatephysicalnetworkresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=PhysicalNetworkResponse.class,
+ required=true, description="physical network id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NETWORK_SPEED, type=CommandType.STRING, description="the speed for the physical network[1G/10G]")
+ private String speed;
+
+ @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
+ private List<String> tags;
+
+ @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="Enabled/Disabled")
+ private String state;
+
+ @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the physical network")
+ private String vlan;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public List<String> getTags() {
+ return tags;
+ }
+
+ public String getNetworkSpeed() {
+ return speed;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getVlan() {
+ return vlan;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getTags(), getVlan(), getState());
+ PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Updating Physical network: " + getId();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE;
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.PhysicalNetwork;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java
new file mode 100644
index 0000000..d6d0b92
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.network;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
+import com.cloud.dc.StorageNetworkIpRange;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateStorageNetworkIpRange", description="Update a Storage network IP range, only allowed when no IPs in this range have been allocated.", responseObject=StorageNetworkIpRangeResponse.class, since="3.0.0")
+public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateStorageNetworkIpRangeCmd.class);
+ private static final String s_name = "updatestoragenetworkiprangeresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=StorageNetworkIpRangeResponse.class,
+ required=true, description="UUID of storage network ip range")
+ private Long id;
+
+ @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address")
+ private String startIp;
+
+ @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address")
+ private String endIp;
+
+ @Parameter(name=ApiConstants.VLAN, type=CommandType.INTEGER, description="Optional. the vlan the ip range sits on")
+ private Integer vlan;
+
+ @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask for storage network")
+ private String netmask;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+ public String getEndIp() {
+ return endIp;
+ }
+
+ public String getStartIp() {
+ return startIp;
+ }
+
+ public Integer getVlan() {
+ return vlan;
+ }
+
+ public String getNetmask() {
+ return netmask;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_STORAGE_IP_RANGE_UPDATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Update storage ip range " + getId() + " [StartIp=" + getStartIp() + ", EndIp=" + getEndIp() + ", vlan=" + getVlan() + ", netmask=" + getNetmask() + ']';
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException {
+ try {
+ StorageNetworkIpRange result = _storageNetworkService.updateIpRange(this);
+ StorageNetworkIpRangeResponse response = _responseGenerator.createStorageNetworkIpRangeResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } catch (Exception e) {
+ s_logger.warn("Update storage network IP range failed", e);
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
+ }
+
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
new file mode 100644
index 0000000..08101dc
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
@@ -0,0 +1,121 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.user.Account;
+
+@APICommand(name = "createDiskOffering", description="Creates a disk offering.", responseObject=DiskOfferingResponse.class)
+public class CreateDiskOfferingCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateDiskOfferingCmd.class.getName());
+
+ private static final String s_name = "creatediskofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.DISK_SIZE, type=CommandType.LONG, required=false, description="size of the disk offering in GB")
+ private Long diskSize;
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="alternate display text of the disk offering", length=4096)
+ private String displayText;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the disk offering")
+ private String offeringName;
+
+ @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="tags for the disk offering", length=4096)
+ private String tags;
+
+ @Parameter(name=ApiConstants.CUSTOMIZED, type=CommandType.BOOLEAN, description="whether disk offering is custom or not")
+ private Boolean customized;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="the ID of the containing domain, null for public offerings")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
+ private String storageType = ServiceOffering.StorageType.shared.toString();
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getDiskSize() {
+ return diskSize;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public String getOfferingName() {
+ return offeringName;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public Boolean isCustomized(){
+ return customized;
+ }
+
+ public Long getDomainId(){
+ return domainId;
+ }
+
+ public String getStorageType() {
+ return storageType;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ DiskOffering offering = _configService.createDiskOffering(this);
+ if (offering != null) {
+ DiskOfferingResponse response = _responseGenerator.createDiskOfferingResponse(offering);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
new file mode 100644
index 0000000..f93c2a8
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
@@ -0,0 +1,168 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.user.Account;
+
+@APICommand(name = "createServiceOffering", description="Creates a service offering.", responseObject=ServiceOfferingResponse.class)
+public class CreateServiceOfferingCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateServiceOfferingCmd.class.getName());
+ private static final String _name = "createserviceofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.CPU_NUMBER, type=CommandType.LONG, required=true, description="the CPU number of the service offering")
+ private Long cpuNumber;
+
+ @Parameter(name=ApiConstants.CPU_SPEED, type=CommandType.LONG, required=true, description="the CPU speed of the service offering in MHz.")
+ private Long cpuSpeed;
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the service offering")
+ private String displayText;
+
+ @Parameter(name=ApiConstants.MEMORY, type=CommandType.LONG, required=true, description="the total memory of the service offering in MB")
+ private Long memory;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the service offering")
+ private String serviceOfferingName;
+
+ @Parameter(name=ApiConstants.OFFER_HA, type=CommandType.BOOLEAN, description="the HA for the service offering")
+ private Boolean offerHa;
+
+ @Parameter(name=ApiConstants.LIMIT_CPU_USE, type=CommandType.BOOLEAN, description="restrict the CPU usage to committed service offering")
+ private Boolean limitCpuUse;
+
+ @Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the service offering. Values are local and shared.")
+ private String storageType;
+
+ @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for this service offering.")
+ private String tags;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="the ID of the containing domain, null for public offerings")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.HOST_TAGS, type=CommandType.STRING, description="the host tag for this service offering.")
+ private String hostTag;
+
+ @Parameter(name=ApiConstants.IS_SYSTEM_OFFERING, type=CommandType.BOOLEAN, description="is this a system vm offering")
+ private Boolean isSystem;
+
+ @Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"domainrouter\", \"consoleproxy\" and \"secondarystoragevm\".")
+ private String systemVmType;
+
+ @Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed. Supported only for non-System offering and system offerings having \"domainrouter\" systemvmtype")
+ private Integer networkRate;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getCpuNumber() {
+ return cpuNumber;
+ }
+
+ public Long getCpuSpeed() {
+ return cpuSpeed;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public Long getMemory() {
+ return memory;
+ }
+
+ public String getServiceOfferingName() {
+ return serviceOfferingName;
+ }
+
+ public Boolean getOfferHa() {
+ return offerHa;
+ }
+
+ public Boolean GetLimitCpuUse() {
+ return limitCpuUse;
+ }
+
+ public String getStorageType() {
+ return storageType;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getHostTag() {
+ return hostTag;
+ }
+
+ public Boolean getIsSystem() {
+ return isSystem == null ? false : isSystem;
+ }
+
+ public String getSystemVmType() {
+ return systemVmType;
+ }
+
+ public Integer getNetworkRate() {
+ return networkRate;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return _name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ ServiceOffering result = _configService.createServiceOffering(this);
+ if (result != null) {
+ ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create service offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java
new file mode 100644
index 0000000..85e034f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteDiskOffering", description="Updates a disk offering.", responseObject=SuccessResponse.class)
+public class DeleteDiskOfferingCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteDiskOfferingCmd.class.getName());
+ private static final String s_name = "deletediskofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DiskOfferingResponse.class,
+ required=true, description="ID of the disk offering")
+ 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.deleteDiskOffering(this);
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete disk offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java
new file mode 100644
index 0000000..d1ea4de
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteServiceOffering", 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 /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class,
+ 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/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
new file mode 100644
index 0000000..8db731d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import com.cloud.offering.DiskOffering;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateDiskOffering", description="Updates a disk offering.", responseObject=DiskOfferingResponse.class)
+public class UpdateDiskOfferingCmd extends BaseCmd{
+ public static final Logger s_logger = Logger.getLogger(UpdateDiskOfferingCmd.class.getName());
+ private static final String s_name = "updatediskofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="updates alternate display text of the disk offering with this value", length=4096)
+ private String displayText;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DiskOfferingResponse.class,
+ required=true, description="ID of the disk offering")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates name of the disk offering with this value")
+ private String diskOfferingName;
+
+ @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the disk offering, integer")
+ private Integer sortKey;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getDiskOfferingName() {
+ return diskOfferingName;
+ }
+
+ public Integer getSortKey() {
+ return sortKey;
+ }
+
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ DiskOffering result = _configService.updateDiskOffering(this);
+ if (result != null){
+ DiskOfferingResponse response = _responseGenerator.createDiskOfferingResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update disk offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java
new file mode 100644
index 0000000..38220b9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java
@@ -0,0 +1,95 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.offering;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateServiceOffering", description="Updates a service offering.", responseObject=ServiceOfferingResponse.class)
+public class UpdateServiceOfferingCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateServiceOfferingCmd.class.getName());
+ private static final String s_name = "updateserviceofferingresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class,
+ required=true, description="the ID of the service offering to be updated")
+ private Long id;
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the service offering to be updated")
+ private String displayText;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the service offering to be updated")
+ private String serviceOfferingName;
+
+ @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the service offering, integer")
+ private Integer sortKey;
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getServiceOfferingName() {
+ return serviceOfferingName;
+ }
+
+ public Integer getSortKey() {
+ return sortKey;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ //Note
+ //Once an offering is created, we cannot update the domainId field (keeping consistent with zones logic)
+ ServiceOffering result = _configService.updateServiceOffering(this);
+ if (result != null){
+ ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service offering");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java
new file mode 100644
index 0000000..331968b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java
@@ -0,0 +1,117 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.pod;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+
+import com.cloud.dc.Pod;
+import com.cloud.user.Account;
+
+@APICommand(name = "createPod", description="Creates a new Pod.", responseObject=PodResponse.class)
+public class CreatePodCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreatePodCmd.class.getName());
+
+ private static final String s_name = "createpodresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the Pod")
+ private String podName;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+ required=true, description="the Zone ID in which the Pod will be created")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the starting IP address for the Pod")
+ private String startIp;
+
+ @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod")
+ private String endIp;
+
+ @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for the Pod")
+ private String netmask;
+
+ @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for the Pod")
+ private String gateway;
+
+ @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Pod for allocation of new resources")
+ private String allocationState;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getNetmask() {
+ return netmask;
+ }
+
+ public String getEndIp() {
+ return endIp;
+ }
+
+ public String getGateway() {
+ return gateway;
+ }
+
+ public String getPodName() {
+ return podName;
+ }
+
+ public String getStartIp() {
+ return startIp;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public String getAllocationState() {
+ return allocationState;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState());
+ if (result != null) {
+ PodResponse response = _responseGenerator.createPodResponse(result, false);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create pod");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java
new file mode 100644
index 0000000..8c64a8d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.pod;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+
+import com.cloud.user.Account;
+
+@APICommand(name = "deletePod", 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 /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=PodResponse.class,
+ 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/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
new file mode 100644
index 0000000..a64ecdd
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.pod;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+
+import com.cloud.dc.Pod;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listPods", description="Lists all Pods.", responseObject=PodResponse.class)
+public class ListPodsByCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListPodsByCmd.class.getName());
+
+ private static final String s_name = "listpodsresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=PodResponse.class,
+ description="list Pods by ID")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list Pods by name")
+ private String podName;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+ description="list Pods by Zone ID")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="list pods by allocation state")
+ private String allocationState;
+
+ @Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the pods")
+ private Boolean showCapacities;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getPodName() {
+ return podName;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public String getAllocationState() {
+ return allocationState;
+ }
+
+ public Boolean getShowCapacities() {
+ return showCapacities;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute(){
+ Pair<List<? extends Pod>, Integer> result = _mgr.searchForPods(this);
+ ListResponse<PodResponse> response = new ListResponse<PodResponse>();
+ List<PodResponse> podResponses = new ArrayList<PodResponse>();
+ for (Pod pod : result.first()) {
+ PodResponse podResponse = _responseGenerator.createPodResponse(pod, showCapacities);
+ podResponse.setObjectName("pod");
+ podResponses.add(podResponse);
+ }
+
+ response.setResponses(podResponses, result.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java
new file mode 100644
index 0000000..ca5e039
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.pod;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.PodResponse;
+
+import com.cloud.dc.Pod;
+import com.cloud.user.Account;
+
+@APICommand(name = "updatePod", description="Updates a Pod.", responseObject=PodResponse.class)
+public class UpdatePodCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdatePodCmd.class.getName());
+
+ private static final String s_name = "updatepodresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=PodResponse.class,
+ required=true, description="the ID of the Pod")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Pod")
+ private String podName;
+
+ @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the starting IP address for the Pod")
+ private String startIp;
+
+ @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod")
+ private String endIp;
+
+ @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the Pod")
+ private String netmask;
+
+ @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway for the Pod")
+ private String gateway;
+
+ @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this cluster for allocation of new resources")
+ private String allocationState;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getNetmask() {
+ return netmask;
+ }
+
+ public String getEndIp() {
+ return endIp;
+ }
+
+ public String getGateway() {
+ return gateway;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getPodName() {
+ return podName;
+ }
+
+ public String getStartIp() {
+ return startIp;
+ }
+
+ public String getAllocationState() {
+ return allocationState;
+ }
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ Pod result = _configService.editPod(this);
+ if (result != null) {
+ PodResponse response = _responseGenerator.createPodResponse(result,false);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update pod");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
new file mode 100644
index 0000000..db7a20b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
@@ -0,0 +1,92 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.resource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.log4j.Logger;
+
+import com.cloud.alert.Alert;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AlertResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listAlerts", description = "Lists all alerts.", responseObject = AlertResponse.class)
+public class ListAlertsCmd extends BaseListCmd {
+
+ public static final Logger s_logger = Logger.getLogger(ListAlertsCmd.class.getName());
+
+ private static final String s_name = "listalertsresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AlertResponse.class,
+ description = "the ID of the alert")
+ private Long id;
+
+ @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "list by alert type")
+ private String type;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute() {
+ Pair<List<? extends Alert>, Integer> result = _mgr.searchForAlerts(this);
+ ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
+ List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
+ for (Alert alert : result.first()) {
+ AlertResponse alertResponse = new AlertResponse();
+ alertResponse.setId(alert.getUuid());
+ alertResponse.setAlertType(alert.getType());
+ alertResponse.setDescription(alert.getSubject());
+ alertResponse.setLastSent(alert.getLastSent());
+
+ alertResponse.setObjectName("alert");
+ alertResponseList.add(alertResponse);
+ }
+
+ response.setResponses(alertResponseList, result.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
new file mode 100644
index 0000000..ce20a3e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
@@ -0,0 +1,140 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.resource;
+
+import java.text.DecimalFormat;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.CapacityResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import com.cloud.capacity.Capacity;
+import com.cloud.exception.InvalidParameterValueException;
+
+@APICommand(name = "listCapacity", description="Lists all the system wide capacities.", responseObject=CapacityResponse.class)
+public class ListCapacityCmd extends BaseListCmd {
+
+ public static final Logger s_logger = Logger.getLogger(ListCapacityCmd.class.getName());
+ private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
+
+ private static final String s_name = "listcapacityresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
+ description="lists capacity by the Zone ID")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
+ description="lists capacity by the Pod ID")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
+ since="3.0.0", description="lists capacity by the Cluster ID")
+ private Long clusterId;
+
+ @Parameter(name=ApiConstants.FETCH_LATEST, type=CommandType.BOOLEAN, since="3.0.0", description="recalculate capacities and fetch the latest")
+ private Boolean fetchLatest;
+
+ @Parameter(name=ApiConstants.TYPE, type=CommandType.INTEGER, description="lists capacity by type" +
+ "* CAPACITY_TYPE_MEMORY = 0" +
+ "* CAPACITY_TYPE_CPU = 1" +
+ "* CAPACITY_TYPE_STORAGE = 2" +
+ "* CAPACITY_TYPE_STORAGE_ALLOCATED = 3" +
+ "* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4" +
+ "* CAPACITY_TYPE_PRIVATE_IP = 5" +
+ "* CAPACITY_TYPE_SECONDARY_STORAGE = 6" +
+ "* CAPACITY_TYPE_VLAN = 7" +
+ "* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8" +
+ "* CAPACITY_TYPE_LOCAL_STORAGE = 9.")
+
+ private Integer type;
+
+ @Parameter(name=ApiConstants.SORT_BY, type=CommandType.STRING, since="3.0.0", description="Sort the results. Available values: Usage")
+ private String sortBy;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public Boolean getFetchLatest() {
+ return fetchLatest;
+ }
+
+ public Integer getType() {
+ return type;
+ }
+
+ public String getSortBy() {
+ if (sortBy != null) {
+ if (sortBy.equalsIgnoreCase("usage")) {
+ return sortBy;
+ } else {
+ throw new InvalidParameterValueException("Only value supported for sortBy parameter is : usage");
+ }
+ }
+
+ return null;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute(){
+ List<? extends Capacity> result = null;
+ if (getSortBy() != null) {
+ result = _mgr.listTopConsumedResources(this);
+ } else {
+ result = _mgr.listCapacities(this);
+ }
+
+ ListResponse<CapacityResponse> response = new ListResponse<CapacityResponse>();
+ List<CapacityResponse> capacityResponses = _responseGenerator.createCapacityResponse(result, s_percentFormat);
+ response.setResponses(capacityResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}