Skip to content

Commit

Permalink
Merge pull request moby#14127 from vbatts/vbatts-dm-active-external
Browse files Browse the repository at this point in the history
pkg/devicemapper: external device activation
  • Loading branch information
vbatts committed Jul 6, 2015
2 parents 26a35dd + 8861d65 commit c749212
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/devicemapper/devmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,25 @@ func DeleteDevice(poolName string, deviceId int) error {
}

func ActivateDevice(poolName string, name string, deviceId int, size uint64) error {
return activateDevice(poolName, name, deviceId, size, "")
}

func ActivateDeviceWithExternal(poolName string, name string, deviceId int, size uint64, external string) error {
return activateDevice(poolName, name, deviceId, size, external)
}

func activateDevice(poolName string, name string, deviceId int, size uint64, external string) error {
task, err := TaskCreateNamed(DeviceCreate, name)
if task == nil {
return err
}

params := fmt.Sprintf("%s %d", poolName, deviceId)
var params string
if len(external) > 0 {
params = fmt.Sprintf("%s %d %s", poolName, deviceId, external)
} else {
params = fmt.Sprintf("%s %d", poolName, deviceId)
}
if err := task.AddTarget(0, size/512, "thin", params); err != nil {
return fmt.Errorf("Can't add target %s", err)
}
Expand Down

0 comments on commit c749212

Please sign in to comment.