diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java index f3cde3cce76..f84a8b0c76a 100644 --- a/api/src/com/cloud/network/NetworkModel.java +++ b/api/src/com/cloud/network/NetworkModel.java @@ -270,4 +270,6 @@ public interface NetworkModel { List getUsedIpsInNetwork(Network network); Map getNtwkOffDetails(long offId); + + Networks.IsolationType[] listNetworkIsolationMethods(); } \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java index 3454139674b..8d66a8327f0 100644 --- a/api/src/org/apache/cloudstack/api/BaseCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseCmd.java @@ -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; diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index 334fe36b73e..8db784cbca0 100644 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -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); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkIsolationMethodsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkIsolationMethodsCmd.java new file mode 100644 index 00000000000..7eef22a78b4 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkIsolationMethodsCmd.java @@ -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 response = new ListResponse(); + List isolationResponses = new ArrayList(); + 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; + } + +} diff --git a/api/src/org/apache/cloudstack/api/response/IsolationMethodResponse.java b/api/src/org/apache/cloudstack/api/response/IsolationMethodResponse.java new file mode 100644 index 00000000000..3aaa7a4a1ab --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/IsolationMethodResponse.java @@ -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; + } +} diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index bf9b5aaa7fd..726426d75e2 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -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 diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 492aa1c21e5..5af67b0dc45 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -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; } } diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java index 01fa2522638..85fa170e044 100755 --- a/server/src/com/cloud/network/NetworkModelImpl.java +++ b/server/src/com/cloud/network/NetworkModelImpl.java @@ -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 getNtwkOffDetails(long offId) { return _ntwkOffDetailsDao.getNtwkOffDetails(offId); } + + @Override + public Networks.IsolationType[] listNetworkIsolationMethods() { + return Networks.IsolationType.values(); + } } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 0b20d252c89..48924ef5c85 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -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; } diff --git a/server/test/com/cloud/network/MockNetworkModelImpl.java b/server/test/com/cloud/network/MockNetworkModelImpl.java index 7ebd0b82598..c3a0d6c5ae9 100644 --- a/server/test/com/cloud/network/MockNetworkModelImpl.java +++ b/server/test/com/cloud/network/MockNetworkModelImpl.java @@ -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 getNtwkOffDetails(long offId) { + return null; + } + + public IsolationType[] listNetworkIsolationMethods() { // TODO Auto-generated method stub return null; } diff --git a/server/test/com/cloud/vpc/MockNetworkModelImpl.java b/server/test/com/cloud/vpc/MockNetworkModelImpl.java index 9fc1f8c4067..d9e33b75616 100644 --- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java @@ -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 getNtwkOffDetails(long offId) { + return null; + } + + public IsolationType[] listNetworkIsolationMethods() { // TODO Auto-generated method stub return null; }