You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/05 18:17:49 UTC
[3/4] git commit: api_refactor: refactor network apis for admin pkg
api_refactor: refactor network apis for admin pkg
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/2121fbd4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2121fbd4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2121fbd4
Branch: refs/heads/api_refactoring
Commit: 2121fbd4698342bd5b14f9b5ec086a541d259dd8
Parents: feb342a
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Dec 4 11:38:40 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Dec 4 11:38:40 2012 -0800
----------------------------------------------------------------------
.../api/commands/AddNetworkServiceProviderCmd.java | 138 ---------
.../api/commands/CreateNetworkOfferingCmd.java | 234 ---------------
.../api/commands/DeleteNetworkOfferingCmd.java | 77 -----
.../commands/DeleteNetworkServiceProviderCmd.java | 108 -------
.../api/commands/DeletePhysicalNetworkCmd.java | 98 ------
.../commands/DeleteStorageNetworkIpRangeCmd.java | 91 ------
.../commands/ListNetworkServiceProvidersCmd.java | 105 -------
.../api/commands/ListPhysicalNetworksCmd.java | 106 -------
.../commands/ListSupportedNetworkServicesCmd.java | 115 -------
.../api/commands/UpdateNetworkOfferingCmd.java | 112 -------
.../commands/UpdateNetworkServiceProviderCmd.java | 111 -------
.../api/commands/UpdatePhysicalNetworkCmd.java | 119 --------
.../commands/UpdateStorageNetworkIpRangeCmd.java | 120 --------
.../api/commands/listStorageNetworkIpRangeCmd.java | 108 -------
.../cloud/configuration/ConfigurationService.java | 6 +-
.../com/cloud/network/StorageNetworkService.java | 8 +-
.../command/AddNetworkServiceProviderCmd.java | 138 +++++++++
.../network/command/CreateNetworkOfferingCmd.java | 234 +++++++++++++++
.../network/command/DeleteNetworkOfferingCmd.java | 77 +++++
.../command/DeleteNetworkServiceProviderCmd.java | 108 +++++++
.../network/command/DeletePhysicalNetworkCmd.java | 98 ++++++
.../command/DeleteStorageNetworkIpRangeCmd.java | 91 ++++++
.../command/ListNetworkServiceProvidersCmd.java | 105 +++++++
.../network/command/ListPhysicalNetworksCmd.java | 106 +++++++
.../command/ListSupportedNetworkServicesCmd.java | 115 +++++++
.../network/command/UpdateNetworkOfferingCmd.java | 112 +++++++
.../command/UpdateNetworkServiceProviderCmd.java | 111 +++++++
.../network/command/UpdatePhysicalNetworkCmd.java | 119 ++++++++
.../command/UpdateStorageNetworkIpRangeCmd.java | 120 ++++++++
.../command/listStorageNetworkIpRangeCmd.java | 108 +++++++
.../api/user/network/command/DeleteNetworkCmd.java | 2 +-
.../test/AddNetworkServiceProviderCmdTest.java | 2 +-
client/tomcatconf/commands.properties.in | 28 +-
.../configuration/ConfigurationManagerImpl.java | 6 +-
.../cloud/network/StorageNetworkManagerImpl.java | 8 +-
.../cloud/vpc/MockConfigurationManagerImpl.java | 6 +-
36 files changed, 1675 insertions(+), 1675 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/AddNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/AddNetworkServiceProviderCmd.java
deleted file mode 100644
index 30f054f..0000000
--- a/api/src/com/cloud/api/commands/AddNetworkServiceProviderCmd.java
+++ /dev/null
@@ -1,138 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCreateCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ProviderResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class, since="3.0.0")
-public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
- public static final Logger s_logger = Logger.getLogger(AddNetworkServiceProviderCmd.class.getName());
-
- private static final String s_name = "addnetworkserviceproviderresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID to add the provider to")
- private Long physicalNetworkId;
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.DEST_PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the destination Physical Network ID to bridge to")
- private Long destinationPhysicalNetworkId;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the physical network service provider")
- private String name;
-
- @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;
-
- @Override
- public String getEntityTable() {
- return "physical_network_service_providers";
- }
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getPhysicalNetworkId() {
- return physicalNetworkId;
- }
-
- public String getProviderName() {
- return name;
- }
-
- public Long getDestinationPhysicalNetworkId() {
- return destinationPhysicalNetworkId;
- }
-
- 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(){
- UserContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
- PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
- if (result != null) {
- ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
- }
- }
-
- @Override
- public void create() throws ResourceAllocationException {
- PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId(), getEnabledServices());
- if (result != null) {
- setEntityId(result.getId());
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
- }
-
- @Override
- public String getEventDescription() {
- return "Adding physical network ServiceProvider: " + getEntityId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PhysicalNetworkServiceProvider;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
deleted file mode 100644
index 447a5fb..0000000
--- a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
+++ /dev/null
@@ -1,234 +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.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.NetworkOfferingResponse;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.Network.Capability;
-import com.cloud.network.Network.Service;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.offering.NetworkOffering.Availability;
-import com.cloud.user.Account;
-
-@Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class, since="3.0.0")
-public class CreateNetworkOfferingCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(CreateNetworkOfferingCmd.class.getName());
- private static final String _name = "createnetworkofferingresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network offering")
- private String networkOfferingName;
-
- @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
- private String displayText;
-
- @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, required=true, description="the traffic type for the network offering. Supported type in current release is GUEST only")
- private String traffictype;
-
- @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the network offering.", length=4096)
- private String tags;
-
- @Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="true if network offering supports vlans")
- private Boolean specifyVlan;
-
- @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Optional")
- private String availability;
-
- @Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed")
- private Integer networkRate;
-
- @Parameter(name=ApiConstants.CONSERVE_MODE, type=CommandType.BOOLEAN, description="true if the network offering is IP conserve mode enabled")
- private Boolean conserveMode;
-
- @IdentityMapper(entityTableName="disk_offering")
- @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, description="the service offering ID used by virtual router provider")
- private Long serviceOfferingId;
-
- @Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated")
- private String guestIptype;
-
- @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, required=true, collectionType=CommandType.STRING, description="services supported by the network offering")
- private List<String> supportedServices;
-
- @Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
- private Map serviceProviderList;
-
- @Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering")
- private Map serviceCapabilitystList;
-
- @Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if network offering supports specifying ip ranges; defaulted to false if not specified")
- private Boolean specifyIpRanges;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getNetworkOfferingName() {
- return networkOfferingName;
- }
-
- public String getDisplayText() {
- return displayText;
- }
-
- public String getTags() {
- return tags;
- }
-
- public String getTraffictype() {
- return traffictype;
- }
-
- public Boolean getSpecifyVlan() {
- return specifyVlan == null ? false : specifyVlan;
- }
-
- public String getAvailability() {
- return availability == null ? Availability.Optional.toString() : availability;
- }
-
- public Integer getNetworkRate() {
- return networkRate;
- }
-
- public static String getName() {
- return _name;
- }
-
- public Long getServiceOfferingId() {
- return serviceOfferingId;
- }
-
- public List<String> getSupportedServices() {
- return supportedServices;
- }
-
- public String getGuestIpType() {
- return guestIptype;
- }
-
- public Boolean getSpecifyIpRanges() {
- return specifyIpRanges == null ? false : specifyIpRanges;
- }
-
- public Boolean getConserveMode() {
- if (conserveMode == null) {
- return true;
- }
- return conserveMode;
- }
-
- public Map<String, List<String>> getServiceProviders() {
- Map<String, List<String>> serviceProviderMap = null;
- if (serviceProviderList != null && !serviceProviderList.isEmpty()) {
- serviceProviderMap = new HashMap<String, List<String>>();
- Collection servicesCollection = serviceProviderList.values();
- Iterator iter = servicesCollection.iterator();
- while (iter.hasNext()) {
- HashMap<String, String> services = (HashMap<String, String>) iter.next();
- String service = services.get("service");
- String provider = services.get("provider");
- List<String> providerList = null;
- if (serviceProviderMap.containsKey(service)) {
- providerList = serviceProviderMap.get(service);
- } else {
- providerList = new ArrayList<String>();
- }
- providerList.add(provider);
- serviceProviderMap.put(service, providerList);
- }
- }
-
- return serviceProviderMap;
- }
-
- public Map<Capability, String> getServiceCapabilities(Service service) {
- Map<Capability, String> capabilityMap = null;
-
- if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
- capabilityMap = new HashMap <Capability, String>();
- Collection serviceCapabilityCollection = serviceCapabilitystList.values();
- Iterator iter = serviceCapabilityCollection.iterator();
- while (iter.hasNext()) {
- HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
- Capability capability = null;
- String svc = (String) svcCapabilityMap.get("service");
- String capabilityName = (String) svcCapabilityMap.get("capabilitytype");
- String capabilityValue = (String) svcCapabilityMap.get("capabilityvalue");
-
- if (capabilityName != null) {
- capability = Capability.getCapability(capabilityName);
- }
-
- if ((capability == null) || (capabilityName == null) || (capabilityValue == null) ) {
- throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
- }
-
- if (svc.equalsIgnoreCase(service.getName())) {
- capabilityMap.put(capability, capabilityValue);
- } else {
- //throw new InvalidParameterValueException("Service is not equal ")
- }
- }
- }
-
- return capabilityMap;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
- @Override
- public String getCommandName() {
- return _name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- NetworkOffering result = _configService.createNetworkOffering(this);
- if (result != null) {
- NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network offering");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
deleted file mode 100644
index 8feede4..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a network offering.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteNetworkOfferingCmd extends BaseCmd{
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
- private static final String s_name = "deletenetworkofferingresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="network_offerings")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network offering")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- boolean result = _configService.deleteNetworkOffering(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
deleted file mode 100644
index c30b2cb..0000000
--- a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a Network Service Provider.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteNetworkServiceProviderCmd.class.getName());
-
- private static final String s_name = "deletenetworkserviceproviderresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network_service_providers")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network service provider")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- try{
- boolean result = _networkService.deleteNetworkServiceProvider(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
- }
- } catch (ResourceUnavailableException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- } catch (ConcurrentOperationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
- }
- }
-
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SERVICE_PROVIDER_DELETE;
- }
-
-
- @Override
- public String getEventDescription() {
- return "Deleting Physical network ServiceProvider: " + getId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PhysicalNetworkServiceProvider;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java b/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
deleted file mode 100644
index 0a036b8..0000000
--- a/api/src/com/cloud/api/commands/DeletePhysicalNetworkCmd.java
+++ /dev/null
@@ -1,98 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a Physical Network.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePhysicalNetworkCmd.class.getName());
-
- private static final String s_name = "deletephysicalnetworkresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Physical network")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("Physical Network Id: " + id);
- boolean result = _networkService.deletePhysicalNetwork(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete physical network");
- }
- }
-
-
- @Override
- public String getEventDescription() {
- return "Deleting Physical network: " + getId();
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_PHYSICAL_NETWORK_DELETE;
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.PhysicalNetwork;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/DeleteStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteStorageNetworkIpRangeCmd.java b/api/src/com/cloud/api/commands/DeleteStorageNetworkIpRangeCmd.java
deleted file mode 100755
index 6b50add..0000000
--- a/api/src/com/cloud/api/commands/DeleteStorageNetworkIpRangeCmd.java
+++ /dev/null
@@ -1,91 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-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;
-
-@Implementation(description="Deletes a storage network IP Range.", responseObject=SuccessResponse.class, since="3.0.0")
-public class DeleteStorageNetworkIpRangeCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteStorageNetworkIpRangeCmd.class);
-
- private static final String s_name = "deletestoragenetworkiprangeresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="dc_storage_network_ip_range")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the uuid of the storage network ip range")
- private Long id;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_STORAGE_IP_RANGE_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting storage ip range " + getId();
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
- ResourceAllocationException {
- try {
- _storageNetworkService.deleteIpRange(this);
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } catch (Exception e) {
- s_logger.warn("Failed to delete storage network ip range " + getId(), 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/2121fbd4/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java b/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
deleted file mode 100644
index 9818842..0000000
--- a/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
+++ /dev/null
@@ -1,105 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.ProviderResponse;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.user.Account;
-import com.cloud.utils.Pair;
-
-
-@Implementation(description="Lists network serviceproviders for a given physical network.", responseObject=ProviderResponse.class, since="3.0.0")
-public class ListNetworkServiceProvidersCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListNetworkServiceProvidersCmd.class.getName());
- private static final String _name = "listnetworkserviceprovidersresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID")
- private Long physicalNetworkId;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list providers by name")
- private String name;
-
- @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list providers by state")
- private String state;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public void setPhysicalNetworkId(Long physicalNetworkId) {
- this.physicalNetworkId = physicalNetworkId;
- }
-
- public Long getPhysicalNetworkId() {
- return physicalNetworkId;
- }
-
- public String getName() {
- return name;
- }
-
- public String getState() {
- return state;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
- @Override
- public String getCommandName() {
- return _name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(),
- getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
- ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
- List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
- for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders.first()) {
- ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
- serviceProvidersResponses.add(serviceProviderResponse);
- }
-
- response.setResponses(serviceProvidersResponses, serviceProviders.second());
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java b/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
deleted file mode 100644
index 69b00af..0000000
--- a/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
+++ /dev/null
@@ -1,106 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.PhysicalNetworkResponse;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.user.Account;
-import com.cloud.utils.Pair;
-
-@Implementation(description="Lists physical networks", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
-public class ListPhysicalNetworksCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListPhysicalNetworksCmd.class.getName());
-
- private static final String s_name = "listphysicalnetworksresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list physical network by id")
- private Long id;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the physical network")
- private Long zoneId;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="search by name")
- private String networkName;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public String getNetworkName() {
- return networkName;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- Pair<List<? extends PhysicalNetwork>, Integer> result = _networkService.searchPhysicalNetworks(getId(),getZoneId(),
- this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
- if (result != null) {
- ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
- List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
- for (PhysicalNetwork network : result.first()) {
- PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
- networkResponses.add(networkResponse);
- }
- response.setResponses(networkResponses, result.second());
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/api/commands/ListSupportedNetworkServicesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListSupportedNetworkServicesCmd.java b/api/src/com/cloud/api/commands/ListSupportedNetworkServicesCmd.java
deleted file mode 100644
index 83462bb..0000000
--- a/api/src/com/cloud/api/commands/ListSupportedNetworkServicesCmd.java
+++ /dev/null
@@ -1,115 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.ServiceResponse;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Service;
-import com.cloud.user.Account;
-
-
-@Implementation(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/2121fbd4/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java
deleted file mode 100755
index 0c3f829..0000000
--- a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.NetworkOfferingResponse;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.user.Account;
-
-@Implementation(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 /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="network_offerings")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, 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/2121fbd4/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
deleted file mode 100644
index fb34038..0000000
--- a/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
+++ /dev/null
@@ -1,111 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ProviderResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.user.Account;
-
-@Implementation(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;
-
- @IdentityMapper(entityTableName="physical_network_service_providers")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, 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/2121fbd4/api/src/com/cloud/api/commands/UpdatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdatePhysicalNetworkCmd.java b/api/src/com/cloud/api/commands/UpdatePhysicalNetworkCmd.java
deleted file mode 100644
index 32c29a4..0000000
--- a/api/src/com/cloud/api/commands/UpdatePhysicalNetworkCmd.java
+++ /dev/null
@@ -1,119 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.PhysicalNetworkResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.user.Account;
-
-@Implementation(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 /////////////////////
- /////////////////////////////////////////////////////
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, 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/2121fbd4/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java b/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java
deleted file mode 100755
index ec162b6..0000000
--- a/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java
+++ /dev/null
@@ -1,120 +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 org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.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;
-
-@Implementation(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 /////////////////////
- /////////////////////////////////////////////////////
- @IdentityMapper(entityTableName="dc_storage_network_ip_range")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, 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/2121fbd4/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java b/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java
deleted file mode 100755
index 12d9709..0000000
--- a/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.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;
-
-@Implementation(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 /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="dc_storage_network_ip_range")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="optional parameter. Storaget network IP range uuid, if specicied, using it to search the range.")
- private Long rangeId;
-
- @IdentityMapper(entityTableName="host_pod_ref")
- @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="optional parameter. Pod uuid, if specicied and range uuid is absent, using it to search the range.")
- private Long podId;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, 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/2121fbd4/api/src/com/cloud/configuration/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java
index 098d280..c27e6c7 100644
--- a/api/src/com/cloud/configuration/ConfigurationService.java
+++ b/api/src/com/cloud/configuration/ConfigurationService.java
@@ -21,12 +21,12 @@ import java.util.List;
import javax.naming.NamingException;
import com.cloud.api.commands.CreateDiskOfferingCmd;
-import com.cloud.api.commands.CreateNetworkOfferingCmd;
+import org.apache.cloudstack.api.admin.network.command.CreateNetworkOfferingCmd;
import com.cloud.api.commands.CreateServiceOfferingCmd;
import com.cloud.api.commands.CreateVlanIpRangeCmd;
import com.cloud.api.commands.CreateZoneCmd;
import com.cloud.api.commands.DeleteDiskOfferingCmd;
-import com.cloud.api.commands.DeleteNetworkOfferingCmd;
+import org.apache.cloudstack.api.admin.network.command.DeleteNetworkOfferingCmd;
import com.cloud.api.commands.DeletePodCmd;
import com.cloud.api.commands.DeleteServiceOfferingCmd;
import com.cloud.api.commands.DeleteVlanIpRangeCmd;
@@ -36,7 +36,7 @@ import com.cloud.api.commands.LDAPRemoveCmd;
import org.apache.cloudstack.api.user.network.command.ListNetworkOfferingsCmd;
import com.cloud.api.commands.UpdateCfgCmd;
import com.cloud.api.commands.UpdateDiskOfferingCmd;
-import com.cloud.api.commands.UpdateNetworkOfferingCmd;
+import org.apache.cloudstack.api.admin.network.command.UpdateNetworkOfferingCmd;
import com.cloud.api.commands.UpdatePodCmd;
import com.cloud.api.commands.UpdateServiceOfferingCmd;
import com.cloud.api.commands.UpdateZoneCmd;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/com/cloud/network/StorageNetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/StorageNetworkService.java b/api/src/com/cloud/network/StorageNetworkService.java
index 86a8352..1cc92ed 100755
--- a/api/src/com/cloud/network/StorageNetworkService.java
+++ b/api/src/com/cloud/network/StorageNetworkService.java
@@ -20,9 +20,9 @@ import java.sql.SQLException;
import java.util.List;
import com.cloud.api.commands.CreateStorageNetworkIpRangeCmd;
-import com.cloud.api.commands.DeleteStorageNetworkIpRangeCmd;
-import com.cloud.api.commands.UpdateStorageNetworkIpRangeCmd;
-import com.cloud.api.commands.listStorageNetworkIpRangeCmd;
+import org.apache.cloudstack.api.admin.network.command.DeleteStorageNetworkIpRangeCmd;
+import org.apache.cloudstack.api.admin.network.command.UpdateStorageNetworkIpRangeCmd;
+import org.apache.cloudstack.api.admin.network.command.ListStorageNetworkIpRangeCmd;
import com.cloud.dc.StorageNetworkIpRange;
public interface StorageNetworkService {
@@ -30,7 +30,7 @@ public interface StorageNetworkService {
void deleteIpRange(DeleteStorageNetworkIpRangeCmd cmd);
- List<StorageNetworkIpRange> listIpRange(listStorageNetworkIpRangeCmd cmd);
+ List<StorageNetworkIpRange> listIpRange(ListStorageNetworkIpRangeCmd cmd);
StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2121fbd4/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkServiceProviderCmd.java b/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkServiceProviderCmd.java
new file mode 100644
index 0000000..542f8dd
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkServiceProviderCmd.java
@@ -0,0 +1,138 @@
+// 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.admin.network.command;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ProviderResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class, since="3.0.0")
+public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
+ public static final Logger s_logger = Logger.getLogger(AddNetworkServiceProviderCmd.class.getName());
+
+ private static final String s_name = "addnetworkserviceproviderresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @IdentityMapper(entityTableName="physical_network")
+ @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID to add the provider to")
+ private Long physicalNetworkId;
+
+ @IdentityMapper(entityTableName="physical_network")
+ @Parameter(name=ApiConstants.DEST_PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the destination Physical Network ID to bridge to")
+ private Long destinationPhysicalNetworkId;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the physical network service provider")
+ private String name;
+
+ @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;
+
+ @Override
+ public String getEntityTable() {
+ return "physical_network_service_providers";
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getPhysicalNetworkId() {
+ return physicalNetworkId;
+ }
+
+ public String getProviderName() {
+ return name;
+ }
+
+ public Long getDestinationPhysicalNetworkId() {
+ return destinationPhysicalNetworkId;
+ }
+
+ 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(){
+ UserContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
+ PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
+ if (result != null) {
+ ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
+ }
+ }
+
+ @Override
+ public void create() throws ResourceAllocationException {
+ PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId(), getEnabledServices());
+ if (result != null) {
+ setEntityId(result.getId());
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Adding physical network ServiceProvider: " + getEntityId();
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.PhysicalNetworkServiceProvider;
+ }
+}