Skip to content

Commit

Permalink
[CONTROLLER/RECORDER] splits big file
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengya authored and SongZhen0704 committed Jul 3, 2023
1 parent c040510 commit a83d83c
Show file tree
Hide file tree
Showing 45 changed files with 2,562 additions and 1,559 deletions.
55 changes: 55 additions & 0 deletions server/controller/recorder/cache/az.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2023 Yunshan Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cache

import (
cloudmodel "github.com/deepflowio/deepflow/server/controller/cloud/model"
"github.com/deepflowio/deepflow/server/controller/db/mysql"
. "github.com/deepflowio/deepflow/server/controller/recorder/common"
)

func (b *DiffBaseDataSet) addAZ(dbItem *mysql.AZ, seq int) {
b.AZs[dbItem.Lcuuid] = &AZ{
DiffBase: DiffBase{
Sequence: seq,
Lcuuid: dbItem.Lcuuid,
},
Name: dbItem.Name,
Label: dbItem.Label,
RegionLcuuid: dbItem.Region,
}
b.GetLogFunc()(addDiffBase(RESOURCE_TYPE_AZ_EN, b.AZs[dbItem.Lcuuid]))
}

func (b *DiffBaseDataSet) deleteAZ(lcuuid string) {
delete(b.AZs, lcuuid)
log.Info(deleteDiffBase(RESOURCE_TYPE_AZ_EN, lcuuid))
}

type AZ struct {
DiffBase
Name string `json:"name"`
Label string `json:"label"`
RegionLcuuid string `json:"region_lcuuid"`
}

func (a *AZ) Update(cloudItem *cloudmodel.AZ) {
a.Name = cloudItem.Name
a.Label = cloudItem.Label
a.RegionLcuuid = cloudItem.RegionLcuuid
log.Info(updateDiffBase(RESOURCE_TYPE_AZ_EN, a))
}
59 changes: 59 additions & 0 deletions server/controller/recorder/cache/cen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) 2023 Yunshan Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cache

import (
cloudmodel "github.com/deepflowio/deepflow/server/controller/cloud/model"
"github.com/deepflowio/deepflow/server/controller/db/mysql"
. "github.com/deepflowio/deepflow/server/controller/recorder/common"
)

func (b *DiffBaseDataSet) addCEN(dbItem *mysql.CEN, seq int, toolDataSet *ToolDataSet) {
vpcLcuuids := []string{}
for _, vpcID := range StringToIntArray(dbItem.VPCIDs) {
vpcLcuuid, exists := toolDataSet.GetVPCLcuuidByID(vpcID)
if exists {
vpcLcuuids = append(vpcLcuuids, vpcLcuuid)
}
}
b.CENs[dbItem.Lcuuid] = &CEN{
DiffBase: DiffBase{
Sequence: seq,
Lcuuid: dbItem.Lcuuid,
},
Name: dbItem.Name,
VPCLcuuids: vpcLcuuids,
}
b.GetLogFunc()(addDiffBase(RESOURCE_TYPE_CEN_EN, b.CENs[dbItem.Lcuuid]))
}

func (b *DiffBaseDataSet) deleteCEN(lcuuid string) {
delete(b.CENs, lcuuid)
log.Info(deleteDiffBase(RESOURCE_TYPE_CEN_EN, lcuuid))
}

type CEN struct {
DiffBase
Name string `json:"name"`
VPCLcuuids []string `json:"vpc_lcuuids"`
}

func (c *CEN) Update(cloudItem *cloudmodel.CEN) {
c.Name = cloudItem.Name
c.VPCLcuuids = cloudItem.VPCLcuuids
log.Info(updateDiffBase(RESOURCE_TYPE_CEN_EN, c))
}
59 changes: 59 additions & 0 deletions server/controller/recorder/cache/dhcp_port.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) 2023 Yunshan Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cache

import (
cloudmodel "github.com/deepflowio/deepflow/server/controller/cloud/model"
"github.com/deepflowio/deepflow/server/controller/db/mysql"
. "github.com/deepflowio/deepflow/server/controller/recorder/common"
)

func (b *DiffBaseDataSet) addDHCPPort(dbItem *mysql.DHCPPort, seq int, toolDataSet *ToolDataSet) {
vpcLcuuid, _ := toolDataSet.GetVPCLcuuidByID(dbItem.VPCID)
b.DHCPPorts[dbItem.Lcuuid] = &DHCPPort{
DiffBase: DiffBase{
Sequence: seq,
Lcuuid: dbItem.Lcuuid,
},
Name: dbItem.Name,
RegionLcuuid: dbItem.Region,
AZLcuuid: dbItem.AZ,
VPCLcuuid: vpcLcuuid,
}
b.GetLogFunc()(addDiffBase(RESOURCE_TYPE_DHCP_PORT_EN, b.DHCPPorts[dbItem.Lcuuid]))
}

func (b *DiffBaseDataSet) deleteDHCPPort(lcuuid string) {
delete(b.DHCPPorts, lcuuid)
log.Info(deleteDiffBase(RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))
}

type DHCPPort struct {
DiffBase
Name string `json:"name"`
RegionLcuuid string `json:"region_lcuuid"`
AZLcuuid string `json:"az_lcuuid"`
VPCLcuuid string `json:"vpc_lcuuid"`
}

func (d *DHCPPort) Update(cloudItem *cloudmodel.DHCPPort) {
d.Name = cloudItem.Name
d.RegionLcuuid = cloudItem.RegionLcuuid
d.AZLcuuid = cloudItem.AZLcuuid
d.VPCLcuuid = cloudItem.VPCLcuuid
log.Info(updateDiffBase(RESOURCE_TYPE_DHCP_PORT_EN, d))
}
Loading

0 comments on commit a83d83c

Please sign in to comment.