-
Notifications
You must be signed in to change notification settings - Fork 0
/
agentRequestHandler.go
94 lines (86 loc) · 2.52 KB
/
agentRequestHandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package appmanager
import (
cisAgent "github.com/F5Networks/k8s-bigip-ctlr/pkg/agent"
. "github.com/F5Networks/k8s-bigip-ctlr/pkg/resource"
)
// Method to deploy resources on configured agent
func (appMgr *Manager) deployResource() error {
// Generate Agent Request
// Prepare Custom Profiles Copy
Profs := map[SecretKey]CustomProfile{}
appMgr.customProfiles.Lock()
for k, v := range appMgr.customProfiles.Profs {
Profs[k] = v
}
appMgr.customProfiles.Unlock()
// Prepare copy of InternalDataGroupMap
appMgr.intDgMutex.Lock()
idgMap := make(InternalDataGroupMap)
for nameRef, dgnMap := range appMgr.intDgMap {
dataGroupNamespaceMap := make(map[string]*InternalDataGroup)
for k, v := range dgnMap {
dg := &InternalDataGroup{}
idrgs := InternalDataGroupRecords{}
for _, record := range v.Records {
idrgs = append(idrgs, record)
}
dg.Records = idrgs
dg.Name = v.Name
dg.Partition = v.Partition
dataGroupNamespaceMap[k] = dg
}
idgMap[nameRef] = dataGroupNamespaceMap
}
appMgr.intDgMutex.Unlock()
// prepare copy of iRuleMap
iRulesMap := make(IRulesMap)
for key, value := range appMgr.irulesMap {
iRule := IRule{}
iRule.Name = value.Name
iRule.Partition = value.Partition
iRule.Code = value.Code
iRulesMap[key] = &iRule
}
// Prepare copy of RsMap
appMgr.resources.Lock()
resourceConfigMap := make(ResourceConfigMap)
for key, value := range appMgr.resources.RsMap {
rsConfig := ResourceConfig{}
rsConfig.CopyConfig(value)
resourceConfigMap[key] = &rsConfig
}
resourceConfigs := appMgr.resources.GetAllResources()
appMgr.resources.Unlock()
// Prepare InternalF5ResourcesGroup Copy
intF5Res := InternalF5ResourcesGroup{}
for k, v := range appMgr.intF5Res {
intF5Res[k] = v
}
// Initialize cfgMap context
agentCfgMapLst := []*AgentCfgMap{}
for _, cm := range appMgr.agentCfgMap {
agentCfgMapLst = append(agentCfgMapLst, cm)
}
deployCfg := ResourceRequest{
Resources: &AgentResources{
RsMap: resourceConfigMap,
RsCfgs: resourceConfigs,
},
Profs: Profs,
IrulesMap: iRulesMap,
IntDgMap: idgMap,
IntF5Res: intF5Res,
AgentCfgmaps: agentCfgMapLst,
}
agentReq := MessageRequest{MsgType: cisAgent.MsgTypeSendDecl, ResourceRequest: deployCfg}
// Handle resources to agent and deploy to BIG-IP
appMgr.AgentCIS.Deploy(agentReq)
go appMgr.TeemData.PostTeemsData()
// Initialize cfgMap context if CfgMaps are removed
for key, cm := range appMgr.agentCfgMap {
if cm.Operation == OprTypeDelete {
delete(appMgr.agentCfgMap, key)
}
}
return nil
}