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

Commit 1639de4

Browse files
authored
[Test Controller] On-demand workflow testing with NCM and ACA (#560)
1 parent e6f8d42 commit 1639de4

5 files changed

Lines changed: 671 additions & 18 deletions

File tree

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Copyright(c) 2020 Futurewei Cloud
6161
<module>services/network_acl_manager</module>
6262
<module>services/network_config_manager</module>
6363
<module>services/gateway_manager</module>
64+
<module>services/pseudo_controller</module>
6465
</modules>
6566
<packaging>pom</packaging>
6667

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/server/grpc/GoalStateProvisionerServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ public void requestGoalStates(Goalstateprovisioner.HostRequest request, StreamOb
188188
// Step 2: Send GS down to target ACA
189189
//TODO: Populate hostGoalStates based on M2 and M3
190190
Map<String, HostGoalState> hostGoalStates = new HashMap<>();
191-
DemoUtil.populateHostGoalState(hostGoalStates);
191+
String destination_ip = request.getStateRequests(0).getDestinationIp();
192+
String source_ip = request.getStateRequests(0).getSourceIp();
193+
DemoUtil.populateHostGoalState(hostGoalStates, source_ip, destination_ip);
192194
logger.log(Level.INFO, "requestGoalStates : send GS to ACA " + DemoUtil.aca_node_one_ip + " | ",
193195
hostGoalStates.get(DemoUtil.aca_node_one_ip).getGoalState().toString());
194196

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/util/DemoUtil.java

Lines changed: 130 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,130 @@ free of charge, to any person obtaining a copy of this software and associated d
1818
import com.futurewei.alcor.netwconfigmanager.entity.HostGoalState;
1919
import com.futurewei.alcor.schema.*;
2020

21+
import java.util.HashMap;
2122
import java.util.Map;
2223

2324
public class DemoUtil {
2425

26+
//final public static String aca_node_one_ip = "192.168.20.92";
27+
//final public static String aca_node_two_ip = "192.168.20.93";
2528
final public static String aca_node_one_ip = "10.213.43.92";
2629
final public static String aca_node_two_ip = "10.213.43.93";
30+
// only considering the 20 ports in total, 10 ports on each host's scenario.
31+
final public static String mac_prefix = "6c:dd:ee:00:00:0";
2732
final public static String vpc_id_1 = "2b08a5bc-b718-11ea-b3de-111111111112";
33+
final public static String port_ip_1 = "10.0.0.2";
34+
final public static String port_ip_2 = "10.0.0.3";
35+
final public static String port_ip_3 = "10.0.0.4";
36+
final public static String port_ip_4 = "10.0.0.5";
37+
final public static String port_ip_5 = "10.0.0.6";
38+
final public static String port_ip_6 = "10.0.0.7";
39+
final public static String port_ip_7 = "10.0.0.8";
40+
final public static String port_ip_8 = "10.0.0.9";
41+
final public static String port_ip_9 = "10.0.0.10";
42+
final public static String port_ip_10 = "10.0.0.11";
43+
final public static String port_ip_11 = "10.0.0.12";
44+
final public static String port_ip_12 = "10.0.0.13";
45+
final public static String port_ip_13 = "10.0.0.14";
46+
final public static String port_ip_14 = "10.0.0.15";
47+
final public static String port_ip_15 = "10.0.0.16";
48+
final public static String port_ip_16 = "10.0.0.17";
49+
final public static String port_ip_17 = "10.0.0.18";
50+
final public static String port_ip_18 = "10.0.0.19";
51+
final public static String port_ip_19 = "10.0.0.20";
52+
final public static String port_ip_20 = "10.0.0.21";
53+
54+
final public static String port_mac_1 = "6c:dd:ee:0:0:2";
55+
final public static String port_mac_2 = "6c:dd:ee:0:0:3";
56+
final public static String port_mac_3 = "6c:dd:ee:0:0:4";
57+
final public static String port_mac_4 = "6c:dd:ee:0:0:5";
58+
final public static String port_mac_5 = "6c:dd:ee:0:0:6";
59+
final public static String port_mac_6 = "6c:dd:ee:0:0:7";
60+
final public static String port_mac_7 = "6c:dd:ee:0:0:8";
61+
final public static String port_mac_8 = "6c:dd:ee:0:0:9";
62+
final public static String port_mac_9 = "6c:dd:ee:0:0:10";
63+
final public static String port_mac_10 = "6c:dd:ee:0:0:11";
64+
final public static String port_mac_11= "6c:dd:ee:0:0:12";
65+
final public static String port_mac_12 = "6c:dd:ee:0:0:13";
66+
final public static String port_mac_13 = "6c:dd:ee:0:0:14";
67+
final public static String port_mac_14 = "6c:dd:ee:0:0:15";
68+
final public static String port_mac_15 = "6c:dd:ee:0:0:16";
69+
final public static String port_mac_16 = "6c:dd:ee:0:0:17";
70+
final public static String port_mac_17 = "6c:dd:ee:0:0:18";
71+
final public static String port_mac_18 = "6c:dd:ee:0:0:19";
72+
final public static String port_mac_19 = "6c:dd:ee:0:0:20";
73+
final public static String port_mac_20 = "6c:dd:ee:0:0:21";
74+
2875
final public static String port_id_1 = "11111111-b718-11ea-b3de-111111111112";
29-
final public static String port_id_2 = "13333333-b718-11ea-b3de-111111111114";
30-
final public static String subnet_id_1 = "27330ae4-b718-11ea-b3df-111111111113";
76+
final public static String port_id_2 = "11111111-b718-11ea-b3de-111111111113";
77+
final public static String port_id_3 = "11111111-b718-11ea-b3de-111111111114";
78+
final public static String port_id_4 = "11111111-b718-11ea-b3de-111111111115";
79+
final public static String port_id_5 = "11111111-b718-11ea-b3de-111111111116";
80+
final public static String port_id_6 = "11111111-b718-11ea-b3de-111111111117";
81+
final public static String port_id_7 = "11111111-b718-11ea-b3de-111111111118";
82+
final public static String port_id_8 = "11111111-b718-11ea-b3de-111111111119";
83+
final public static String port_id_9 = "11111111-b718-11ea-b3de-1111111111110";
84+
final public static String port_id_10 = "11111111-b718-11ea-b3de-1111111111111";
85+
final public static String port_id_11 = "11111111-b718-11ea-b3de-1111111111112";
86+
final public static String port_id_12 = "11111111-b718-11ea-b3de-1111111111113";
87+
final public static String port_id_13 = "11111111-b718-11ea-b3de-1111111111114";
88+
final public static String port_id_14 = "11111111-b718-11ea-b3de-1111111111115";
89+
final public static String port_id_15 = "11111111-b718-11ea-b3de-1111111111116";
90+
final public static String port_id_16 = "11111111-b718-11ea-b3de-1111111111117";
91+
final public static String port_id_17 = "11111111-b718-11ea-b3de-1111111111118";
92+
final public static String port_id_18 = "11111111-b718-11ea-b3de-1111111111119";
93+
final public static String port_id_19 = "11111111-b718-11ea-b3de-1111111111120";
94+
final public static String port_id_20 = "11111111-b718-11ea-b3de-1111111111121";
3195

32-
public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStates){
96+
final public static String subnet_id_1 = "27330ae4-b718-11ea-b3df-111111111113";
97+
final public static Map<String, String> port_ip_port_id_map = new HashMap<>();
98+
final public static Map<String, String> port_ip_port_mac_map = new HashMap<>();
99+
100+
101+
public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStates, String source_ip, String destination_ip){
102+
// port IP - ID pairs
103+
port_ip_port_id_map.put(port_ip_1, port_id_1);
104+
port_ip_port_id_map.put(port_ip_2, port_id_2);
105+
port_ip_port_id_map.put(port_ip_3, port_id_3);
106+
port_ip_port_id_map.put(port_ip_4, port_id_4);
107+
port_ip_port_id_map.put(port_ip_5, port_id_5);
108+
port_ip_port_id_map.put(port_ip_6, port_id_6);
109+
port_ip_port_id_map.put(port_ip_7, port_id_7);
110+
port_ip_port_id_map.put(port_ip_8, port_id_8);
111+
port_ip_port_id_map.put(port_ip_9, port_id_9);
112+
port_ip_port_id_map.put(port_ip_10, port_id_10);
113+
port_ip_port_id_map.put(port_ip_11, port_id_11);
114+
port_ip_port_id_map.put(port_ip_12, port_id_12);
115+
port_ip_port_id_map.put(port_ip_13, port_id_13);
116+
port_ip_port_id_map.put(port_ip_14, port_id_14);
117+
port_ip_port_id_map.put(port_ip_15, port_id_15);
118+
port_ip_port_id_map.put(port_ip_16, port_id_16);
119+
port_ip_port_id_map.put(port_ip_17, port_id_17);
120+
port_ip_port_id_map.put(port_ip_18, port_id_18);
121+
port_ip_port_id_map.put(port_ip_19, port_id_19);
122+
port_ip_port_id_map.put(port_ip_20, port_id_20);
123+
124+
// port IP - MAC pairs
125+
port_ip_port_mac_map.put(port_ip_1, port_mac_1);
126+
port_ip_port_mac_map.put(port_ip_2, port_mac_2);
127+
port_ip_port_mac_map.put(port_ip_3, port_mac_3);
128+
port_ip_port_mac_map.put(port_ip_4, port_mac_4);
129+
port_ip_port_mac_map.put(port_ip_5, port_mac_5);
130+
port_ip_port_mac_map.put(port_ip_6, port_mac_6);
131+
port_ip_port_mac_map.put(port_ip_7, port_mac_7);
132+
port_ip_port_mac_map.put(port_ip_8, port_mac_8);
133+
port_ip_port_mac_map.put(port_ip_9, port_mac_9);
134+
port_ip_port_mac_map.put(port_ip_10, port_mac_10);
135+
port_ip_port_mac_map.put(port_ip_11, port_mac_11);
136+
port_ip_port_mac_map.put(port_ip_12, port_mac_12);
137+
port_ip_port_mac_map.put(port_ip_13, port_mac_13);
138+
port_ip_port_mac_map.put(port_ip_14, port_mac_14);
139+
port_ip_port_mac_map.put(port_ip_15, port_mac_15);
140+
port_ip_port_mac_map.put(port_ip_16, port_mac_16);
141+
port_ip_port_mac_map.put(port_ip_17, port_mac_17);
142+
port_ip_port_mac_map.put(port_ip_18, port_mac_18);
143+
port_ip_port_mac_map.put(port_ip_19, port_mac_19);
144+
port_ip_port_mac_map.put(port_ip_20, port_mac_20);
33145

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

@@ -49,14 +161,15 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
49161
config.
50162
setRevisionNumber(2).
51163
setUpdateType(Common.UpdateType.FULL).
52-
setId(port_id_1).
164+
setId(port_ip_port_id_map.get(source_ip)).
53165
setVpcId(vpc_id_1).
54-
setName(("tap" + port_id_1).substring(0, 14)).
166+
setName(("tap" + port_ip_port_id_map.get
167+
(source_ip)).substring(0, 14)).
55168
setAdminStateUp(true).
56-
setMacAddress("6c:dd:ee:00:00:02");
169+
setMacAddress(port_ip_port_mac_map.get(source_ip));
57170
Port.PortConfiguration.FixedIp.Builder fixedIpBuilder = Port.PortConfiguration.FixedIp.newBuilder();
58171
fixedIpBuilder.setSubnetId(subnet_id_1);
59-
fixedIpBuilder.setIpAddress("10.10.0.2");
172+
fixedIpBuilder.setIpAddress(source_ip);
60173
config.addFixedIps(fixedIpBuilder.build());
61174
Port.PortConfiguration.SecurityGroupId securityGroupId = Port.PortConfiguration.SecurityGroupId.newBuilder().setId("2").build();
62175
config.addSecurityGroupIds(securityGroupId);
@@ -111,14 +224,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
111224
Neighbor.NeighborConfiguration.Builder NeighborConfiguration_builder = Neighbor.NeighborConfiguration.newBuilder();
112225
NeighborConfiguration_builder.setRevisionNumber(2);
113226
NeighborConfiguration_builder.setVpcId(vpc_id_1);
114-
NeighborConfiguration_builder.setId(port_id_2);
115-
NeighborConfiguration_builder.setMacAddress("6c:dd:ee:00:00:03");
227+
NeighborConfiguration_builder.setId(port_ip_port_id_map.get(destination_ip));
228+
NeighborConfiguration_builder.setMacAddress(port_ip_port_mac_map.get(destination_ip));
116229
NeighborConfiguration_builder.setHostIpAddress(aca_node_two_ip);
117230

118231
Neighbor.NeighborConfiguration.FixedIp.Builder neighbor_fixed_ip_builder = Neighbor.NeighborConfiguration.FixedIp.newBuilder();
119232
neighbor_fixed_ip_builder.setNeighborType(Neighbor.NeighborType.L2);
120233
neighbor_fixed_ip_builder.setSubnetId(subnet_id_1);
121-
neighbor_fixed_ip_builder.setIpAddress("10.0.0.3");
234+
neighbor_fixed_ip_builder.setIpAddress(destination_ip);
122235

123236
NeighborConfiguration_builder.addFixedIps(neighbor_fixed_ip_builder.build());
124237

@@ -143,14 +256,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
143256
config_2.
144257
setRevisionNumber(2).
145258
setUpdateType(Common.UpdateType.FULL).
146-
setId(port_id_2).
259+
setId(port_ip_port_id_map.get(destination_ip)).
147260
setVpcId(vpc_id_1).
148-
setName(("tap" + port_id_2).substring(0, 14)).
261+
setName(("tap" + port_ip_port_id_map.get(destination_ip)).substring(0, 14)).
149262
setAdminStateUp(true).
150-
setMacAddress("6c:dd:ee:00:00:03");
263+
setMacAddress(port_ip_port_mac_map.get(destination_ip));
151264
Port.PortConfiguration.FixedIp.Builder fixedIpBuilder_port_2 = Port.PortConfiguration.FixedIp.newBuilder();
152265
fixedIpBuilder_port_2.setSubnetId(subnet_id_1);
153-
fixedIpBuilder_port_2.setIpAddress("10.10.0.3");
266+
fixedIpBuilder_port_2.setIpAddress(destination_ip);
154267
config_2.addFixedIps(fixedIpBuilder_port_2.build());
155268
Port.PortConfiguration.SecurityGroupId securityGroupId_port_2 = Port.PortConfiguration.SecurityGroupId.newBuilder().setId("2").build();
156269
config_2.addSecurityGroupIds(securityGroupId_port_2);
@@ -175,14 +288,14 @@ public static void populateHostGoalState(Map<String, HostGoalState> hostGoalStat
175288
Neighbor.NeighborConfiguration.Builder NeighborConfiguration_builder_node_2 = Neighbor.NeighborConfiguration.newBuilder();
176289
NeighborConfiguration_builder_node_2.setRevisionNumber(2);
177290
NeighborConfiguration_builder_node_2.setVpcId(vpc_id_1);
178-
NeighborConfiguration_builder_node_2.setId(port_id_1);
179-
NeighborConfiguration_builder_node_2.setMacAddress("6c:dd:ee:00:00:02");
291+
NeighborConfiguration_builder_node_2.setId(port_ip_port_id_map.get(source_ip));
292+
NeighborConfiguration_builder_node_2.setMacAddress(port_ip_port_mac_map.get(source_ip));
180293
NeighborConfiguration_builder_node_2.setHostIpAddress(aca_node_one_ip);
181294

182295
Neighbor.NeighborConfiguration.FixedIp.Builder neighbor_fixed_ip_builder_node_2 = Neighbor.NeighborConfiguration.FixedIp.newBuilder();
183296
neighbor_fixed_ip_builder_node_2.setNeighborType(Neighbor.NeighborType.L2);
184297
neighbor_fixed_ip_builder_node_2.setSubnetId(subnet_id_1);
185-
neighbor_fixed_ip_builder_node_2.setIpAddress("10.0.0.2");
298+
neighbor_fixed_ip_builder_node_2.setIpAddress(source_ip);
186299

187300
NeighborConfiguration_builder_node_2.addFixedIps(neighbor_fixed_ip_builder_node_2.build());
188301

services/pseudo_controller/pom.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.futurewei.alcor</groupId>
8+
<artifactId>pseudo_controller</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>11</maven.compiler.source>
13+
<maven.compiler.target>11</maven.compiler.target>
14+
</properties>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.futurewei.alcor</groupId>
19+
<artifactId>common</artifactId>
20+
<version>0.1.0-SNAPSHOT</version>
21+
<scope>compile</scope>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.futurewei.alcor</groupId>
25+
<artifactId>web</artifactId>
26+
<version>0.1.0-SNAPSHOT</version>
27+
<scope>compile</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>com.futurewei.alcor</groupId>
31+
<artifactId>schema</artifactId>
32+
<version>0.1.0-SNAPSHOT</version>
33+
<scope>compile</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.jcraft</groupId>
37+
<artifactId>jsch</artifactId>
38+
<version>0.1.54</version>
39+
</dependency>
40+
</dependencies>
41+
<build>
42+
<plugins>
43+
<plugin>
44+
<!-- Build an executable JAR -->
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-jar-plugin</artifactId>
47+
<version>3.0.0</version>
48+
<configuration>
49+
<archive>
50+
<manifest>
51+
<addClasspath>true</addClasspath>
52+
<classpathPrefix>lib/</classpathPrefix>
53+
<mainClass>com.futurewei.alcor.pseudo_controller.pseudo_controller</mainClass>
54+
</manifest>
55+
</archive>
56+
</configuration>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
</project>

0 commit comments

Comments
 (0)