@@ -33,82 +33,33 @@ import (
33
33
34
34
//function CREATE
35
35
/* save the part of gw creation and mac learning for future requirment, comment the related code now*/
36
- func Create (k8client * kubernetes.Clientset , topo_id string , aca_num uint32 , rack_num uint32 , aca_per_rack uint32 , cgw_num uint32 , data_plane_cidr string , returnMessage * pb.ReturnTopologyMessage ) error {
36
+ func Create (k8client * kubernetes.Clientset , topo_id string , aca_num uint32 , rack_num uint32 , aca_per_rack uint32 , cgw_num uint32 , data_plane_cidr string , ports_per_vswitch uint32 , images [] * pb. InternalTopologyImage , returnMessage * pb.ReturnTopologyMessage ) error {
37
37
38
- var topo database.TopologyData
39
-
40
- var ovs_tor_device = []string {"core-0" }
41
- ip_num := int (aca_num ) + int (cgw_num )
42
-
43
- log .Println ("=== parse done == " )
44
- log .Printf ("Core switch is: %v \n " , ovs_tor_device [0 ])
45
- log .Printf ("Vswitch number is: %v\n " , rack_num )
38
+ log .Println ("=== Parse gRPC message === " )
46
39
log .Printf ("Vhost number is: %v\n " , aca_num )
40
+ log .Printf ("Rack number is: %v\n " , rack_num )
41
+ log .Printf ("Vhosts per rack is: %v\n " , aca_per_rack )
47
42
48
- fmt .Println ("======== Generate device list ==== " )
49
- rack_device := Pod_name (int (rack_num ), "vswitch" )
50
- aca_device := Pod_name (int (aca_num ), "vhost" )
51
- // ngw_device := Pod_name(int(cgw_num), "cgw") /*comment gw creation function*/
52
-
53
- fmt .Printf ("Vswitch_device: %v\n " , rack_device )
54
- fmt .Printf ("Vhost_device: %v\n " , aca_device )
55
- // fmt.Printf("Cgw_device: %v\n", ngw_device) /*comment gw creation function*/
56
-
57
- fmt .Println ("======== Generate device nodes ==== " )
58
- rack_intf_num := int (aca_per_rack ) + 1
59
- tor_intf_num := int (rack_num ) + int (cgw_num )
60
- aca_intf_num := 1
61
- // ngw_intf_num := 1 /*comment gw creation function*/
43
+ log .Printf ("Ports per vswitch is: %v\n " , ports_per_vswitch )
62
44
63
- log .Println ("=== Generate ip addresses == " )
45
+ log .Println ("=== Generate topology data = == " )
64
46
65
- ips := Ips_gen (topo_id , ip_num , data_plane_cidr )
66
-
67
- err := database .SetValue (topo_id + ":ips" , ips )
68
- if err != nil {
69
- return fmt .Errorf ("fail to save ips in DB %s" , err )
47
+ err_create , topo := Create_multiple_layers_vswitches (int (aca_num ), int (rack_num ), int (aca_per_rack ), int (ports_per_vswitch ), data_plane_cidr )
48
+ if err_create != nil {
49
+ return fmt .Errorf ("create multiple layers vswitches error %s" , err_create )
70
50
}
71
51
72
- fmt .Println ("======== Generate topology data ==== " )
73
-
74
52
topo .Topology_id = topo_id
75
53
76
- topo_nodes , _ := Node_port_gen (aca_intf_num , aca_device , ips , true )
77
- // nodes, _ := Node_port_gen(ngw_intf_num, ngw_device, ips_1, true) /*comment gw creation function*/
78
- // topo_nodes = append(topo_nodes, nodes...)
79
- nodes_s , _ := Node_port_gen (rack_intf_num , rack_device , ips , false )
80
- topo_nodes = append (topo_nodes , nodes_s ... )
81
- nodes_t , _ := Node_port_gen (tor_intf_num , ovs_tor_device , ips , false )
82
- topo_nodes = append (topo_nodes , nodes_t ... )
83
-
84
- fmt .Printf ("The topology nodes are : %+v. \n " , topo_nodes )
85
-
86
- topo .Vnodes = topo_nodes
87
-
88
- fmt .Println ("======== Pairing links ==== " )
89
-
90
- topo_links := Links_gen (topo_nodes )
91
-
92
- fmt .Printf ("The topology links are : %v. \n " , topo_links )
93
-
94
- fmt .Printf ("The topology total links are : %v. \n " , len (topo_links ))
95
- topo .Vlinks = topo_links
96
-
97
- fmt .Println ("======== Save topo to redis =====" )
54
+ log .Println ("=== Save topology to redis ===" )
98
55
err1 := Topo_save (topo )
99
56
if err1 != nil {
100
- return fmt .Errorf ("save topo to redis error %s" , err1 )
57
+ return fmt .Errorf ("save topology to redis error %s" , err1 )
101
58
}
102
59
103
- fmt .Println ("======== Topology Deployment ==== " )
104
-
105
- err_deploy := Topo_deploy (k8client , topo )
60
+ log .Printf ("topology details: %v" , topo )
106
61
107
- if err_deploy != nil {
108
- return fmt .Errorf ("topology deployment error %s" , err_deploy )
109
- }
110
-
111
- fmt .Println ("========= Get k8s host nodes information after deployment=====" )
62
+ log .Println ("=== Get k8s host nodes information ===" )
112
63
113
64
k8s_nodes , err1 := k8client .CoreV1 ().Nodes ().List (context .TODO (), metav1.ListOptions {})
114
65
@@ -145,7 +96,7 @@ func Create(k8client *kubernetes.Clientset, topo_id string, aca_num uint32, rack
145
96
146
97
}
147
98
148
- fmt .Println ("========= Return deployed compute nodes information == ===" )
99
+ log .Println ("=== Return deployed compute nodes information ===" )
149
100
150
101
for _ , node := range topo .Vnodes {
151
102
var cnode pb_common.InternalComputeInfo
@@ -156,26 +107,45 @@ func Create(k8client *kubernetes.Clientset, topo_id string, aca_num uint32, rack
156
107
cnode .Veth = node .Nics [len (node .Nics )- 1 ].Intf
157
108
}
158
109
159
- log .Printf ("get compute nodes IP and Veth" )
110
+ log .Println ("get compute nodes IP and Veth" )
160
111
161
112
cnode .OperationType = pb_common .OperationType_CREATE
162
113
cnode .Status = pb_common .Status_DEPLOYING
163
114
164
- log .Printf ("get compute nodes status" )
115
+ log .Println ("get compute nodes status" )
165
116
166
117
returnMessage .ComputeNodes = append (returnMessage .ComputeNodes , & cnode )
167
118
168
- log .Printf ("generate returnMessage for compute nodes" )
119
+ log .Println ("generate returnMessage for compute nodes" )
169
120
170
121
}
171
122
172
123
err_db2 := database .SetPbReturnValue (topo_id + ":initialreturn" , returnMessage )
173
124
if err_db2 != nil {
174
- log . Printf ( "fail to save return msg to DB %s" , err_db2 . Error ())
125
+
175
126
return fmt .Errorf ("fail to save return msg to DB %s" , err_db2 )
176
127
}
177
128
129
+ log .Println ("=== Topology Deployment === " )
130
+ var aca_image string
131
+ var ovs_image string
132
+
133
+ for _ , img := range images {
134
+ if strings .Contains (img .Name , "ACA" ) {
135
+ aca_image = img .Registry
136
+ } else if strings .Contains (img .Name , "OVS" ) {
137
+ ovs_image = img .Registry
138
+ }
139
+ }
140
+
141
+ err_deploy := Topo_deploy (k8client , aca_image , ovs_image , topo )
142
+
143
+ if err_deploy != nil {
144
+ return fmt .Errorf ("topology deployment error %s" , err_deploy )
145
+ }
146
+
178
147
return nil
148
+
179
149
}
180
150
181
151
func UpdateComputenodeInfo (client * kubernetes.Clientset , topo_id string , returnMessage * pb.ReturnTopologyMessage ) error {
0 commit comments