Skip to content

Commit 76ca8ba

Browse files
committed
Add a tool to modify cfg objects
fix a typo add usage to cfgtool
1 parent 98d865e commit 76ca8ba

File tree

5 files changed

+423
-19
lines changed

5 files changed

+423
-19
lines changed

netmaster/docknet/docknet.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const (
3838
var netDriverName = "netplugin"
3939
var ipamDriverName = "netplugin"
4040

41-
// OperState has oper state of docker network
42-
type OperState struct {
41+
// DnetOperState has oper state of docker network
42+
type DnetOperState struct {
4343
core.CommonState
4444
TenantName string `json:"tenantName"`
4545
NetworkName string `json:"networkName"`
@@ -48,30 +48,30 @@ type OperState struct {
4848
}
4949

5050
// Write the state.
51-
func (s *OperState) Write() error {
51+
func (s *DnetOperState) Write() error {
5252
key := fmt.Sprintf(docknetOperPath, s.ID)
5353
return s.StateDriver.WriteState(key, s, json.Marshal)
5454
}
5555

5656
// Read the state for a given identifier
57-
func (s *OperState) Read(id string) error {
57+
func (s *DnetOperState) Read(id string) error {
5858
key := fmt.Sprintf(docknetOperPath, id)
5959
return s.StateDriver.ReadState(key, s, json.Unmarshal)
6060
}
6161

6262
// ReadAll state and return the collection.
63-
func (s *OperState) ReadAll() ([]core.State, error) {
63+
func (s *DnetOperState) ReadAll() ([]core.State, error) {
6464
return s.StateDriver.ReadAllState(docknetOperPrefix, s, json.Unmarshal)
6565
}
6666

6767
// WatchAll state transitions and send them through the channel.
68-
func (s *OperState) WatchAll(rsps chan core.WatchState) error {
68+
func (s *DnetOperState) WatchAll(rsps chan core.WatchState) error {
6969
return s.StateDriver.WatchAllState(docknetOperPrefix, s, json.Unmarshal,
7070
rsps)
7171
}
7272

7373
// Clear removes the state.
74-
func (s *OperState) Clear() error {
74+
func (s *DnetOperState) Clear() error {
7575
key := fmt.Sprintf(docknetOperPath, s.ID)
7676
return s.StateDriver.ClearState(key)
7777
}
@@ -186,7 +186,7 @@ func CreateDockNet(tenantName, networkName, serviceName string, nwCfg *mastercfg
186186
}
187187

188188
// save docknet oper state
189-
dnetOper := OperState{
189+
dnetOper := DnetOperState{
190190
TenantName: tenantName,
191191
NetworkName: networkName,
192192
ServiceName: serviceName,
@@ -233,7 +233,7 @@ func DeleteDockNet(tenantName, networkName, serviceName string) error {
233233
}
234234

235235
// save docknet oper state
236-
dnetOper := OperState{}
236+
dnetOper := DnetOperState{}
237237
dnetOper.ID = fmt.Sprintf("%s.%s.%s", tenantName, networkName, serviceName)
238238
dnetOper.StateDriver = stateDriver
239239

@@ -247,15 +247,15 @@ func DeleteDockNet(tenantName, networkName, serviceName string) error {
247247
}
248248

249249
// FindDocknetByUUID find the docknet by UUID
250-
func FindDocknetByUUID(dnetID string) (*OperState, error) {
250+
func FindDocknetByUUID(dnetID string) (*DnetOperState, error) {
251251
// Get the state driver
252252
stateDriver, err := utils.GetStateDriver()
253253
if err != nil {
254254
log.Warnf("Couldn't read global config %v", err)
255255
return nil, err
256256
}
257257

258-
tmpDnet := OperState{}
258+
tmpDnet := DnetOperState{}
259259
tmpDnet.StateDriver = stateDriver
260260
dnetOperList, err := tmpDnet.ReadAll()
261261
if err != nil {
@@ -265,8 +265,8 @@ func FindDocknetByUUID(dnetID string) (*OperState, error) {
265265

266266
// Walk all dnets and find the matching UUID
267267
for _, dnet := range dnetOperList {
268-
if dnet.(*OperState).DocknetUUID == dnetID {
269-
return dnet.(*OperState), nil
268+
if dnet.(*DnetOperState).DocknetUUID == dnetID {
269+
return dnet.(*DnetOperState), nil
270270
}
271271
}
272272

netmaster/docknet/docknet_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func initStateDriver() (core.StateDriver, error) {
3636
}
3737

3838
// getDocknetState gets docknet oper state
39-
func getDocknetState(tenantName, networkName, serviceName string) *OperState {
39+
func getDocknetState(tenantName, networkName, serviceName string) *DnetOperState {
4040
// Get the state driver
4141
stateDriver, err := utils.GetStateDriver()
4242
if err != nil {
@@ -45,7 +45,7 @@ func getDocknetState(tenantName, networkName, serviceName string) *OperState {
4545
}
4646

4747
// save docknet oper state
48-
dnetOper := OperState{}
48+
dnetOper := DnetOperState{}
4949
dnetOper.StateDriver = stateDriver
5050

5151
// write the dnet oper state

0 commit comments

Comments
 (0)