forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_persistent_disk.go
53 lines (41 loc) · 1.35 KB
/
add_persistent_disk.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
package action
import (
"errors"
boshsettings "github.com/cloudfoundry/bosh-agent/settings"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type AddPersistentDiskAction struct {
settingsService boshsettings.Service
}
func NewAddPersistentDiskAction(settingsService boshsettings.Service) AddPersistentDiskAction {
return AddPersistentDiskAction{
settingsService: settingsService,
}
}
func (a AddPersistentDiskAction) Run(diskCID string, diskHint interface{}) (interface{}, error) {
err := a.settingsService.LoadSettings()
if err != nil {
return nil, bosherr.WrapError(err, "Refreshing the settings")
}
currentSettings := a.settingsService.GetSettings()
diskSetting := currentSettings.PersistentDiskSettingsFromHint(diskCID, diskHint)
if err := a.settingsService.SavePersistentDiskSettings(diskSetting); err != nil {
return "", bosherr.WrapError(err, "Saving persistent disk hints")
}
return map[string]string{}, nil
}
func (a AddPersistentDiskAction) IsAsynchronous(_ ProtocolVersion) bool {
return true
}
func (a AddPersistentDiskAction) IsPersistent() bool {
return false
}
func (a AddPersistentDiskAction) IsLoggable() bool {
return true
}
func (a AddPersistentDiskAction) Resume() (interface{}, error) {
return nil, errors.New("not supported")
}
func (a AddPersistentDiskAction) Cancel() error {
return errors.New("not supported")
}