From a9e3d8b1b00e04291e2b36fa1c750f691bc32a1f Mon Sep 17 00:00:00 2001 From: "James C.J Chung" <66383484+cj-chung@users.noreply.github.com> Date: Tue, 27 Apr 2021 14:29:11 -0700 Subject: [PATCH] [Data Plane Mgr] Add new ResourceOperation list to NetworkConfig (#602) --- .../service/impl/DpmServiceImpl.java | 38 ++++++------- .../service/impl/NeighborService.java | 2 +- .../entity/dataplane/ResourceOperation.java | 54 +++++++++++++++++++ .../dataplane/v2/NetworkConfiguration.java | 11 ++-- 4 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 web/src/main/java/com/futurewei/alcor/web/entity/dataplane/ResourceOperation.java diff --git a/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/DpmServiceImpl.java b/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/DpmServiceImpl.java index 792f0cde9..6391b85be 100644 --- a/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/DpmServiceImpl.java +++ b/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/DpmServiceImpl.java @@ -387,25 +387,27 @@ private InternalDPMResultList buildResult(NetworkConfiguration networkConfig, Li private InternalDPMResultList processNetworkConfiguration(NetworkConfiguration networkConfig) throws Exception { long startTime = System.currentTimeMillis(); - List failedHosts; - - switch (networkConfig.getRsType()) { - case PORT: - failedHosts = processPortConfiguration(networkConfig); - break; - case NEIGHBOR: - failedHosts = processNeighborConfiguration(networkConfig); - break; - case SECURITYGROUP: - failedHosts = processSecurityGroupConfiguration(networkConfig); - break; - case ROUTER: - failedHosts = processRouterConfiguration(networkConfig); - break; - default: - throw new UnknownResourceType(); + List failedHosts = new ArrayList<>(); + List rsopTypes = networkConfig.getRsOpTypes(); + + for (ResourceOperation rsopType : rsopTypes) { + switch (rsopType.getRsType()) { + case PORT: + failedHosts.addAll(processPortConfiguration(networkConfig)); + break; + case NEIGHBOR: + failedHosts.addAll(processNeighborConfiguration(networkConfig)); + break; + case SECURITYGROUP: + failedHosts.addAll(processSecurityGroupConfiguration(networkConfig)); + break; + case ROUTER: + failedHosts.addAll(processRouterConfiguration(networkConfig)); + break; + default: + throw new UnknownResourceType(); + } } - return buildResult(networkConfig, failedHosts, startTime); } diff --git a/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/NeighborService.java b/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/NeighborService.java index 9905528c5..641d9fa1b 100644 --- a/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/NeighborService.java +++ b/services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/impl/NeighborService.java @@ -36,7 +36,7 @@ public class NeighborService extends ResourceService { public Neighbor.NeighborState buildNeighborState(NeighborEntry.NeighborType type, NeighborInfo neighborInfo, Common.OperationType operationType) { Neighbor.NeighborConfiguration.Builder neighborConfigBuilder = Neighbor.NeighborConfiguration.newBuilder(); neighborConfigBuilder.setRevisionNumber(FORMAT_REVISION_NUMBER); - //neighborConfigBuilder.setId(); // TODO: We are going to need this per latest ACA change + neighborConfigBuilder.setId(neighborInfo.getPortId()); // TODO: We are going to need this per latest ACA change neighborConfigBuilder.setVpcId(neighborInfo.getVpcId()); //neighborConfigBuilder.setName(); neighborConfigBuilder.setMacAddress(neighborInfo.getPortMac()); diff --git a/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/ResourceOperation.java b/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/ResourceOperation.java new file mode 100644 index 000000000..c15d8716b --- /dev/null +++ b/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/ResourceOperation.java @@ -0,0 +1,54 @@ +/* +MIT License +Copyright(c) 2020 Futurewei Cloud + + Permission is hereby granted, + free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons + to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +package com.futurewei.alcor.web.entity.dataplane; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.futurewei.alcor.schema.Common.ResourceType; +import com.futurewei.alcor.schema.Common.OperationType; +import lombok.Data; + +@Data +public class ResourceOperation { + @JsonProperty("rs_Type") + private ResourceType rsType; + + @JsonProperty("op_Type") + private OperationType opType; + + public ResourceOperation() { + } + + public ResourceType getRsType() { + return this.rsType; + } + + public void setRsType(ResourceType rsType) { + this.rsType = rsType; + } + + public OperationType getOpType() { + return this.opType; + } + + public void setHostId(OperationType opType) { + this.opType = opType; + } + + public ResourceOperation(ResourceType rsType, OperationType opType) { + this.rsType = rsType; + this.opType = opType; + } +} diff --git a/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/v2/NetworkConfiguration.java b/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/v2/NetworkConfiguration.java index d05212557..2e00681a2 100644 --- a/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/v2/NetworkConfiguration.java +++ b/web/src/main/java/com/futurewei/alcor/web/entity/dataplane/v2/NetworkConfiguration.java @@ -18,13 +18,9 @@ free of charge, to any person obtaining a copy of this software and associated d import com.fasterxml.jackson.annotation.JsonProperty; import com.futurewei.alcor.schema.Common.OperationType; import com.futurewei.alcor.schema.Common.ResourceType; -import com.futurewei.alcor.web.entity.dataplane.InternalPortEntity; -import com.futurewei.alcor.web.entity.dataplane.InternalSubnetEntity; -import com.futurewei.alcor.web.entity.dataplane.NeighborEntry; -import com.futurewei.alcor.web.entity.dataplane.NeighborInfo; +import com.futurewei.alcor.web.entity.dataplane.*; import com.futurewei.alcor.web.entity.route.InternalRouterInfo; import com.futurewei.alcor.web.entity.securitygroup.SecurityGroup; -import com.futurewei.alcor.web.entity.subnet.InternalSubnetPorts; import com.futurewei.alcor.web.entity.vpc.VpcEntity; import lombok.Data; @@ -35,6 +31,7 @@ free of charge, to any person obtaining a copy of this software and associated d @Data public class NetworkConfiguration { + private List rsopTypes; private ResourceType rsType; private OperationType opType; @@ -99,6 +96,10 @@ public void addSecurityGroupEntity(SecurityGroup securityGroup) { this.securityGroups.add(securityGroup); } + public List getRsOpTypes() { return rsopTypes; } + + public void setRsOpTypes(List rsopTypes) { this.rsopTypes = rsopTypes; } + public ResourceType getRsType() { return rsType; }