Browse code

pkg/devicemapper: external device activation

Reported-by: Sheng Yang <shend.yang@rancher.com>
Signed-off-by: Vincent Batts <vbatts@redhat.com>

Vincent Batts authored on 2015/06/23 09:28:15
Showing 1 changed files
... ...
@@ -686,12 +686,25 @@ func DeleteDevice(poolName string, deviceId int) error {
686 686
 }
687 687
 
688 688
 func ActivateDevice(poolName string, name string, deviceId int, size uint64) error {
689
+	return activateDevice(poolName, name, deviceId, size, "")
690
+}
691
+
692
+func ActivateDeviceWithExternal(poolName string, name string, deviceId int, size uint64, external string) error {
693
+	return activateDevice(poolName, name, deviceId, size, external)
694
+}
695
+
696
+func activateDevice(poolName string, name string, deviceId int, size uint64, external string) error {
689 697
 	task, err := TaskCreateNamed(DeviceCreate, name)
690 698
 	if task == nil {
691 699
 		return err
692 700
 	}
693 701
 
694
-	params := fmt.Sprintf("%s %d", poolName, deviceId)
702
+	var params string
703
+	if len(external) > 0 {
704
+		params = fmt.Sprintf("%s %d %s", poolName, deviceId, external)
705
+	} else {
706
+		params = fmt.Sprintf("%s %d", poolName, deviceId)
707
+	}
695 708
 	if err := task.AddTarget(0, size/512, "thin", params); err != nil {
696 709
 		return fmt.Errorf("Can't add target %s", err)
697 710
 	}