Skip to content

Commit

Permalink
- add a plugin to support changing VCH config (setting the scope of c…
Browse files Browse the repository at this point in the history
…ommon.name from read-only to hidden) during VCH upgrade

- add a plugin to support changing container config (setting the scope of common.name from read-only to hidden) during VCH upgrade
  • Loading branch information
chengwang86 committed Mar 7, 2017
1 parent cec1963 commit 0e6dfe8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 117 deletions.
14 changes: 8 additions & 6 deletions lib/migration/migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/stretchr/testify/assert"

"strconv"

"github.com/vmware/vic/lib/config"
"github.com/vmware/vic/lib/config/executor"
"github.com/vmware/vic/lib/migration/manager"
Expand All @@ -34,10 +36,10 @@ func setUp() {
// register sample plugin into test
log.SetLevel(log.DebugLevel)
trace.Logger.Level = log.DebugLevel
version.MaxPluginVersion = 1
version.MaxPluginVersion = 3

if err := manager.Migrator.Register(1, manager.ApplianceConfigure, &plugin1.ApplianceStopSignalRename{}); err != nil {
log.Errorf("Failed to register plugin %s:%d, %s", manager.ApplianceConfigure, 1, err)
if err := manager.Migrator.Register(version.MaxPluginVersion, manager.ApplianceConfigure, &plugin1.ApplianceStopSignalRename{}); err != nil {
log.Errorf("Failed to register plugin %s:%d, %s", manager.ApplianceConfigure, version.MaxPluginVersion, err)
}
}

Expand Down Expand Up @@ -72,7 +74,7 @@ func TestMigrateConfigure(t *testing.T) {
assert.True(t, migrated, "should be migrated")

latestVer := newData[manager.ApplianceVersionKey]
assert.Equal(t, "1", latestVer, "upgrade version mismatch")
assert.Equal(t, strconv.Itoa(version.MaxPluginVersion), latestVer, "upgrade version mismatch")

// check new data
var found bool
Expand Down Expand Up @@ -102,7 +104,7 @@ func TestMigrateConfigure(t *testing.T) {
newConf := &config.VirtualContainerHostConfigSpec{}
extraconfig.Decode(extraconfig.MapSource(newData), newConf)

assert.Equal(t, 1, newConf.Version.PluginVersion, "should not be migrated")
assert.Equal(t, version.MaxPluginVersion, newConf.Version.PluginVersion, "should not be migrated")
t.Logf("other version fields: %s", newConf.Version.String())
}

Expand Down Expand Up @@ -139,5 +141,5 @@ func TestIsDataOlder(t *testing.T) {

older, err = ContainerDataIsOlder(mapData)
assert.Equal(t, nil, err, "should not have error")
assert.False(t, older, "Test data should not be older than latest, no container update plugin registered yet")
assert.True(t, older, "Test data should be older than latest since a container update plugin has been registered")
}
1 change: 1 addition & 0 deletions lib/migration/plugins/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ package plugins
// import all plugin packages here to register plugins
import (
_ "github.com/vmware/vic/pkg/version/plugin1"
_ "github.com/vmware/vic/pkg/version/plugin2"
)
110 changes: 0 additions & 110 deletions pkg/version/plugin1/commonSpecForVM.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
State string

// MaxPluginVersion must be increased to add new plugin and make sure the new plugin version is same to this value
MaxPluginVersion = 1
MaxPluginVersion = 2

v bool
)
Expand Down

0 comments on commit 0e6dfe8

Please sign in to comment.