Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
[Data Plane Mgr] Add new ResourceOperation list to NetworkConfig (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
cj-chung authored Apr 27, 2021
1 parent 455181e commit a9e3d8b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,25 +387,27 @@ private InternalDPMResultList buildResult(NetworkConfiguration networkConfig, Li

private InternalDPMResultList processNetworkConfiguration(NetworkConfiguration networkConfig) throws Exception {
long startTime = System.currentTimeMillis();
List<String> 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<String> failedHosts = new ArrayList<>();
List<ResourceOperation> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ResourceOperation> rsopTypes;
private ResourceType rsType;
private OperationType opType;

Expand Down Expand Up @@ -99,6 +96,10 @@ public void addSecurityGroupEntity(SecurityGroup securityGroup) {
this.securityGroups.add(securityGroup);
}

public List<ResourceOperation> getRsOpTypes() { return rsopTypes; }

public void setRsOpTypes(List<ResourceOperation> rsopTypes) { this.rsopTypes = rsopTypes; }

public ResourceType getRsType() {
return rsType;
}
Expand Down

0 comments on commit a9e3d8b

Please sign in to comment.