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

Commit

Permalink
[Test Controller] On-demand workflow testing with NCM and ACA (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxgzgz authored May 10, 2021
1 parent e6f8d42 commit 1639de4
Show file tree
Hide file tree
Showing 5 changed files with 671 additions and 18 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Copyright(c) 2020 Futurewei Cloud
<module>services/network_acl_manager</module>
<module>services/network_config_manager</module>
<module>services/gateway_manager</module>
<module>services/pseudo_controller</module>
</modules>
<packaging>pom</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public void requestGoalStates(Goalstateprovisioner.HostRequest request, StreamOb
// Step 2: Send GS down to target ACA
//TODO: Populate hostGoalStates based on M2 and M3
Map<String, HostGoalState> hostGoalStates = new HashMap<>();
DemoUtil.populateHostGoalState(hostGoalStates);
String destination_ip = request.getStateRequests(0).getDestinationIp();
String source_ip = request.getStateRequests(0).getSourceIp();
DemoUtil.populateHostGoalState(hostGoalStates, source_ip, destination_ip);
logger.log(Level.INFO, "requestGoalStates : send GS to ACA " + DemoUtil.aca_node_one_ip + " | ",
hostGoalStates.get(DemoUtil.aca_node_one_ip).getGoalState().toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,130 @@ free of charge, to any person obtaining a copy of this software and associated d
import com.futurewei.alcor.netwconfigmanager.entity.HostGoalState;
import com.futurewei.alcor.schema.*;

import java.util.HashMap;
import java.util.Map;

public class DemoUtil {

//final public static String aca_node_one_ip = "192.168.20.92";
//final public static String aca_node_two_ip = "192.168.20.93";
final public static String aca_node_one_ip = "10.213.43.92";
final public static String aca_node_two_ip = "10.213.43.93";
// only considering the 20 ports in total, 10 ports on each host's scenario.
final public static String mac_prefix = "6c:dd:ee:00:00:0";
final public static String vpc_id_1 = "2b08a5bc-b718-11ea-b3de-111111111112";
final public static String port_ip_1 = "10.0.0.2";
final public static String port_ip_2 = "10.0.0.3";
final public static String port_ip_3 = "10.0.0.4";
final public static String port_ip_4 = "10.0.0.5";
final public static String port_ip_5 = "10.0.0.6";
final public static String port_ip_6 = "10.0.0.7";
final public static String port_ip_7 = "10.0.0.8";
final public static String port_ip_8 = "10.0.0.9";
final public static String port_ip_9 = "10.0.0.10";
final public static String port_ip_10 = "10.0.0.11";
final public static String port_ip_11 = "10.0.0.12";
final public static String port_ip_12 = "10.0.0.13";
final public static String port_ip_13 = "10.0.0.14";
final public static String port_ip_14 = "10.0.0.15";
final public static String port_ip_15 = "10.0.0.16";
final public static String port_ip_16 = "10.0.0.17";
final public static String port_ip_17 = "10.0.0.18";
final public static String port_ip_18 = "10.0.0.19";
final public static String port_ip_19 = "10.0.0.20";
final public static String port_ip_20 = "10.0.0.21";

final public static String port_mac_1 = "6c:dd:ee:0:0:2";
final public static String port_mac_2 = "6c:dd:ee:0:0:3";
final public static String port_mac_3 = "6c:dd:ee:0:0:4";
final public static String port_mac_4 = "6c:dd:ee:0:0:5";
final public static String port_mac_5 = "6c:dd:ee:0:0:6";
final public static String port_mac_6 = "6c:dd:ee:0:0:7";
final public static String port_mac_7 = "6c:dd:ee:0:0:8";
final public static String port_mac_8 = "6c:dd:ee:0:0:9";
final public static String port_mac_9 = "6c:dd:ee:0:0:10";
final public static String port_mac_10 = "6c:dd:ee:0:0:11";
final public static String port_mac_11= "6c:dd:ee:0:0:12";
final public static String port_mac_12 = "6c:dd:ee:0:0:13";
final public static String port_mac_13 = "6c:dd:ee:0:0:14";
final public static String port_mac_14 = "6c:dd:ee:0:0:15";
final public static String port_mac_15 = "6c:dd:ee:0:0:16";
final public static String port_mac_16 = "6c:dd:ee:0:0:17";
final public static String port_mac_17 = "6c:dd:ee:0:0:18";
final public static String port_mac_18 = "6c:dd:ee:0:0:19";
final public static String port_mac_19 = "6c:dd:ee:0:0:20";
final public static String port_mac_20 = "6c:dd:ee:0:0:21";

final public static String port_id_1 = "11111111-b718-11ea-b3de-111111111112";
final public static String port_id_2 = "13333333-b718-11ea-b3de-111111111114";
final public static String subnet_id_1 = "27330ae4-b718-11ea-b3df-111111111113";
final public static String port_id_2 = "11111111-b718-11ea-b3de-111111111113";
final public static String port_id_3 = "11111111-b718-11ea-b3de-111111111114";
final public static String port_id_4 = "11111111-b718-11ea-b3de-111111111115";
final public static String port_id_5 = "11111111-b718-11ea-b3de-111111111116";
final public static String port_id_6 = "11111111-b718-11ea-b3de-111111111117";
final public static String port_id_7 = "11111111-b718-11ea-b3de-111111111118";
final public static String port_id_8 = "11111111-b718-11ea-b3de-111111111119";
final public static String port_id_9 = "11111111-b718-11ea-b3de-1111111111110";
final public static String port_id_10 = "11111111-b718-11ea-b3de-1111111111111";
final public static String port_id_11 = "11111111-b718-11ea-b3de-1111111111112";
final public static String port_id_12 = "11111111-b718-11ea-b3de-1111111111113";
final public static String port_id_13 = "11111111-b718-11ea-b3de-1111111111114";
final public static String port_id_14 = "11111111-b718-11ea-b3de-1111111111115";
final public static String port_id_15 = "11111111-b718-11ea-b3de-1111111111116";
final public static String port_id_16 = "11111111-b718-11ea-b3de-1111111111117";
final public static String port_id_17 = "11111111-b718-11ea-b3de-1111111111118";
final public static String port_id_18 = "11111111-b718-11ea-b3de-1111111111119";
final public static String port_id_19 = "11111111-b718-11ea-b3de-1111111111120";
final public static String port_id_20 = "11111111-b718-11ea-b3de-1111111111121";

public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStates){
final public static String subnet_id_1 = "27330ae4-b718-11ea-b3df-111111111113";
final public static Map<String, String> port_ip_port_id_map = new HashMap<>();
final public static Map<String, String> port_ip_port_mac_map = new HashMap<>();


public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStates, String source_ip, String destination_ip){
// port IP - ID pairs
port_ip_port_id_map.put(port_ip_1, port_id_1);
port_ip_port_id_map.put(port_ip_2, port_id_2);
port_ip_port_id_map.put(port_ip_3, port_id_3);
port_ip_port_id_map.put(port_ip_4, port_id_4);
port_ip_port_id_map.put(port_ip_5, port_id_5);
port_ip_port_id_map.put(port_ip_6, port_id_6);
port_ip_port_id_map.put(port_ip_7, port_id_7);
port_ip_port_id_map.put(port_ip_8, port_id_8);
port_ip_port_id_map.put(port_ip_9, port_id_9);
port_ip_port_id_map.put(port_ip_10, port_id_10);
port_ip_port_id_map.put(port_ip_11, port_id_11);
port_ip_port_id_map.put(port_ip_12, port_id_12);
port_ip_port_id_map.put(port_ip_13, port_id_13);
port_ip_port_id_map.put(port_ip_14, port_id_14);
port_ip_port_id_map.put(port_ip_15, port_id_15);
port_ip_port_id_map.put(port_ip_16, port_id_16);
port_ip_port_id_map.put(port_ip_17, port_id_17);
port_ip_port_id_map.put(port_ip_18, port_id_18);
port_ip_port_id_map.put(port_ip_19, port_id_19);
port_ip_port_id_map.put(port_ip_20, port_id_20);

// port IP - MAC pairs
port_ip_port_mac_map.put(port_ip_1, port_mac_1);
port_ip_port_mac_map.put(port_ip_2, port_mac_2);
port_ip_port_mac_map.put(port_ip_3, port_mac_3);
port_ip_port_mac_map.put(port_ip_4, port_mac_4);
port_ip_port_mac_map.put(port_ip_5, port_mac_5);
port_ip_port_mac_map.put(port_ip_6, port_mac_6);
port_ip_port_mac_map.put(port_ip_7, port_mac_7);
port_ip_port_mac_map.put(port_ip_8, port_mac_8);
port_ip_port_mac_map.put(port_ip_9, port_mac_9);
port_ip_port_mac_map.put(port_ip_10, port_mac_10);
port_ip_port_mac_map.put(port_ip_11, port_mac_11);
port_ip_port_mac_map.put(port_ip_12, port_mac_12);
port_ip_port_mac_map.put(port_ip_13, port_mac_13);
port_ip_port_mac_map.put(port_ip_14, port_mac_14);
port_ip_port_mac_map.put(port_ip_15, port_mac_15);
port_ip_port_mac_map.put(port_ip_16, port_mac_16);
port_ip_port_mac_map.put(port_ip_17, port_mac_17);
port_ip_port_mac_map.put(port_ip_18, port_mac_18);
port_ip_port_mac_map.put(port_ip_19, port_mac_19);
port_ip_port_mac_map.put(port_ip_20, port_mac_20);

System.out.println("Trying to build the GoalStateV2");

Expand All @@ -49,14 +161,15 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
config.
setRevisionNumber(2).
setUpdateType(Common.UpdateType.FULL).
setId(port_id_1).
setId(port_ip_port_id_map.get(source_ip)).
setVpcId(vpc_id_1).
setName(("tap" + port_id_1).substring(0, 14)).
setName(("tap" + port_ip_port_id_map.get
(source_ip)).substring(0, 14)).
setAdminStateUp(true).
setMacAddress("6c:dd:ee:00:00:02");
setMacAddress(port_ip_port_mac_map.get(source_ip));
Port.PortConfiguration.FixedIp.Builder fixedIpBuilder = Port.PortConfiguration.FixedIp.newBuilder();
fixedIpBuilder.setSubnetId(subnet_id_1);
fixedIpBuilder.setIpAddress("10.10.0.2");
fixedIpBuilder.setIpAddress(source_ip);
config.addFixedIps(fixedIpBuilder.build());
Port.PortConfiguration.SecurityGroupId securityGroupId = Port.PortConfiguration.SecurityGroupId.newBuilder().setId("2").build();
config.addSecurityGroupIds(securityGroupId);
Expand Down Expand Up @@ -111,14 +224,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
Neighbor.NeighborConfiguration.Builder NeighborConfiguration_builder = Neighbor.NeighborConfiguration.newBuilder();
NeighborConfiguration_builder.setRevisionNumber(2);
NeighborConfiguration_builder.setVpcId(vpc_id_1);
NeighborConfiguration_builder.setId(port_id_2);
NeighborConfiguration_builder.setMacAddress("6c:dd:ee:00:00:03");
NeighborConfiguration_builder.setId(port_ip_port_id_map.get(destination_ip));
NeighborConfiguration_builder.setMacAddress(port_ip_port_mac_map.get(destination_ip));
NeighborConfiguration_builder.setHostIpAddress(aca_node_two_ip);

Neighbor.NeighborConfiguration.FixedIp.Builder neighbor_fixed_ip_builder = Neighbor.NeighborConfiguration.FixedIp.newBuilder();
neighbor_fixed_ip_builder.setNeighborType(Neighbor.NeighborType.L2);
neighbor_fixed_ip_builder.setSubnetId(subnet_id_1);
neighbor_fixed_ip_builder.setIpAddress("10.0.0.3");
neighbor_fixed_ip_builder.setIpAddress(destination_ip);

NeighborConfiguration_builder.addFixedIps(neighbor_fixed_ip_builder.build());

Expand All @@ -143,14 +256,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
config_2.
setRevisionNumber(2).
setUpdateType(Common.UpdateType.FULL).
setId(port_id_2).
setId(port_ip_port_id_map.get(destination_ip)).
setVpcId(vpc_id_1).
setName(("tap" + port_id_2).substring(0, 14)).
setName(("tap" + port_ip_port_id_map.get(destination_ip)).substring(0, 14)).
setAdminStateUp(true).
setMacAddress("6c:dd:ee:00:00:03");
setMacAddress(port_ip_port_mac_map.get(destination_ip));
Port.PortConfiguration.FixedIp.Builder fixedIpBuilder_port_2 = Port.PortConfiguration.FixedIp.newBuilder();
fixedIpBuilder_port_2.setSubnetId(subnet_id_1);
fixedIpBuilder_port_2.setIpAddress("10.10.0.3");
fixedIpBuilder_port_2.setIpAddress(destination_ip);
config_2.addFixedIps(fixedIpBuilder_port_2.build());
Port.PortConfiguration.SecurityGroupId securityGroupId_port_2 = Port.PortConfiguration.SecurityGroupId.newBuilder().setId("2").build();
config_2.addSecurityGroupIds(securityGroupId_port_2);
Expand All @@ -175,14 +288,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
Neighbor.NeighborConfiguration.Builder NeighborConfiguration_builder_node_2 = Neighbor.NeighborConfiguration.newBuilder();
NeighborConfiguration_builder_node_2.setRevisionNumber(2);
NeighborConfiguration_builder_node_2.setVpcId(vpc_id_1);
NeighborConfiguration_builder_node_2.setId(port_id_1);
NeighborConfiguration_builder_node_2.setMacAddress("6c:dd:ee:00:00:02");
NeighborConfiguration_builder_node_2.setId(port_ip_port_id_map.get(source_ip));
NeighborConfiguration_builder_node_2.setMacAddress(port_ip_port_mac_map.get(source_ip));
NeighborConfiguration_builder_node_2.setHostIpAddress(aca_node_one_ip);

Neighbor.NeighborConfiguration.FixedIp.Builder neighbor_fixed_ip_builder_node_2 = Neighbor.NeighborConfiguration.FixedIp.newBuilder();
neighbor_fixed_ip_builder_node_2.setNeighborType(Neighbor.NeighborType.L2);
neighbor_fixed_ip_builder_node_2.setSubnetId(subnet_id_1);
neighbor_fixed_ip_builder_node_2.setIpAddress("10.0.0.2");
neighbor_fixed_ip_builder_node_2.setIpAddress(source_ip);

NeighborConfiguration_builder_node_2.addFixedIps(neighbor_fixed_ip_builder_node_2.build());

Expand Down
60 changes: 60 additions & 0 deletions services/pseudo_controller/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.futurewei.alcor</groupId>
<artifactId>pseudo_controller</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>com.futurewei.alcor</groupId>
<artifactId>common</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.futurewei.alcor</groupId>
<artifactId>web</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.futurewei.alcor</groupId>
<artifactId>schema</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.futurewei.alcor.pseudo_controller.pseudo_controller</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 1639de4

Please sign in to comment.