CLOUDSTACK-129: added new API - listNetworkIsolationMethods - for displaying isolation methods supported by the cloudStack

This commit is contained in:
Alena Prokharchyk 2013-05-06 11:45:19 -07:00
parent 46f59cd49e
commit a153373c7e
11 changed files with 141 additions and 37 deletions

View File

@ -270,4 +270,6 @@ public interface NetworkModel {
List<String> getUsedIpsInNetwork(Network network);
Map<Detail, String> getNtwkOffDetails(long offId);
Networks.IsolationType[] listNetworkIsolationMethods();
}

View File

@ -143,12 +143,11 @@ public abstract class BaseCmd {
@Inject public DataStoreProviderApiService dataStoreProviderApiService;
@Inject public VpcProvisioningService _vpcProvSvc;
@Inject public ApplicationLoadBalancerService _newLbSvc;
@Inject public NetworkModel _ntwkModel;
@Inject public ApplicationLoadBalancerService _appLbService;
@Inject public AffinityGroupService _affinityGroupService;
@Inject public InternalLoadBalancerElementService _internalLbElementSvc;
@Inject public InternalLoadBalancerVMService _internalLbSvc;
@Inject public NetworkModel _ntwkModel;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;

View File

@ -55,6 +55,7 @@ import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.LDAPConfigResponse;
@ -142,6 +143,8 @@ import com.cloud.network.as.AutoScaleVmGroup;
import com.cloud.network.as.AutoScaleVmProfile;
import com.cloud.network.as.Condition;
import com.cloud.network.as.Counter;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.as.*;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.HealthCheckPolicy;
@ -428,4 +431,6 @@ public interface ResponseGenerator {
Long getAffinityGroupId(String name, long entityOwnerId);
InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result);
IsolationMethodResponse createIsolationMethodResponse(IsolationType method);
}

View File

@ -0,0 +1,58 @@
// 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.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.network.Networks;
@APICommand(name = "listNetworkIsolationMethods", description="Lists supported methods of network isolation",
responseObject=IsolationMethodResponse.class, since="4.2.0")
public class ListNetworkIsolationMethodsCmd extends BaseListCmd{
private static final String s_name = "listnetworkisolationmethodsresponse";
@Override
public void execute() {
Networks.IsolationType[] methods = _ntwkModel.listNetworkIsolationMethods();
ListResponse<IsolationMethodResponse> response = new ListResponse<IsolationMethodResponse>();
List<IsolationMethodResponse> isolationResponses = new ArrayList<IsolationMethodResponse>();
if (methods != null) {
for (Networks.IsolationType method : methods) {
IsolationMethodResponse isolationMethod = _responseGenerator.createIsolationMethodResponse(method);
isolationResponses.add(isolationMethod);
}
}
response.setResponses(isolationResponses, methods.length);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
@Override
public String getCommandName() {
return s_name;
}
}

View File

@ -0,0 +1,33 @@
// 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.response;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class IsolationMethodResponse extends BaseResponse{
@SerializedName(ApiConstants.NAME) @Param(description="Network isolation method name")
private String name;
public void setIsolationMethodName(String isolationMethodName) {
this.name = isolationMethodName;
}
}

View File

@ -602,8 +602,10 @@ addCiscoAsa1000vResource=1
deleteCiscoAsa1000vResource=1
listCiscoAsa1000vResources=1
#### Internal LB VM commands
stopInternalLoadBalancerVM=1
startInternalLoadBalancerVM=1
listInternalLoadBalancerVMs=1
### Network Isolation methods listing
listNetworkIsolationMethods=1

View File

@ -34,7 +34,6 @@ import java.util.TimeZone;
import javax.inject.Inject;
import com.cloud.vm.*;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroup;
@ -70,13 +69,15 @@ import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse;
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
@ -187,15 +188,15 @@ import com.cloud.event.Event;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.dao.AccountGuestVlanMapVO;
import com.cloud.network.IpAddress;
import com.cloud.network.GuestVlan;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkModel;
import com.cloud.network.NetworkProfile;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.PhysicalNetworkServiceProvider;
@ -278,40 +279,18 @@ import com.cloud.utils.Pair;
import com.cloud.utils.StringUtils;
import com.cloud.utils.net.Ip;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.InstanceGroup;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.NicVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.dao.NicSecondaryIpVO;
import com.cloud.vm.snapshot.VMSnapshot;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.usage.Usage;
import org.apache.cloudstack.usage.UsageService;
import org.apache.cloudstack.usage.UsageTypes;
import com.cloud.vm.dao.UserVmData;
import com.cloud.vm.dao.UserVmData.NicData;
import com.cloud.vm.dao.UserVmData.SecurityGroupData;
import com.cloud.vm.snapshot.VMSnapshot;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.response.VMSnapshotResponse;
import org.apache.log4j.Logger;
import java.text.DecimalFormat;
import java.util.*;
import javax.inject.Inject;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
@Component
public class ApiResponseHelper implements ResponseGenerator {
@ -3828,6 +3807,7 @@ public class ApiResponseHelper implements ResponseGenerator {
return ag.getId();
}
}
@Override
public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) {
@ -3843,6 +3823,14 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setEnabled(result.isEnabled());
response.setObjectName("internalloadbalancerelement");
}
@Override
public IsolationMethodResponse createIsolationMethodResponse(IsolationType method) {
IsolationMethodResponse response = new IsolationMethodResponse();
response.setIsolationMethodName(method.toString());
response.setObjectName("isolationmethod");
return response;
}
}

View File

@ -59,6 +59,7 @@ import com.cloud.network.Network.Capability;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.addr.PublicIp;
import com.cloud.network.dao.FirewallRulesDao;
@ -2080,4 +2081,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
public Map<Detail, String> getNtwkOffDetails(long offId) {
return _ntwkOffDetailsDao.getNtwkOffDetails(offId);
}
@Override
public Networks.IsolationType[] listNetworkIsolationMethods() {
return Networks.IsolationType.values();
}
}

View File

@ -2945,6 +2945,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
cmdList.add(StopInternalLBVMCmd.class);
cmdList.add(StartInternalLBVMCmd.class);
cmdList.add(ListInternalLBVMsCmd.class);
cmdList.add(ListNetworkIsolationMethodsCmd.class);
return cmdList;
}

View File

@ -33,6 +33,7 @@ import com.cloud.network.Network.Capability;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.IPAddressVO;
import com.cloud.network.dao.NetworkVO;
@ -866,6 +867,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
@Override
public Map<Detail, String> getNtwkOffDetails(long offId) {
return null;
}
public IsolationType[] listNetworkIsolationMethods() {
// TODO Auto-generated method stub
return null;
}

View File

@ -37,6 +37,7 @@ import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkModel;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.PhysicalNetworkSetupInfo;
@ -878,6 +879,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
@Override
public Map<Detail, String> getNtwkOffDetails(long offId) {
return null;
}
public IsolationType[] listNetworkIsolationMethods() {
// TODO Auto-generated method stub
return null;
}