|
|
|
|
@ -60,6 +60,44 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(c.SnapshotRegions) > 0 {
|
|
|
|
|
regionSet := make(map[string]struct{})
|
|
|
|
|
regions := make([]string, 0, len(c.SnapshotRegions))
|
|
|
|
|
|
|
|
|
|
for _, region := range c.SnapshotRegions {
|
|
|
|
|
// If we already saw the region, then don't look again
|
|
|
|
|
if _, ok := regionSet[region]; ok {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mark that we saw the region
|
|
|
|
|
regionSet[region] = struct{}{}
|
|
|
|
|
|
|
|
|
|
regions = append(regions, region)
|
|
|
|
|
}
|
|
|
|
|
c.SnapshotRegions = regions
|
|
|
|
|
for transfer := range c.SnapshotRegions {
|
|
|
|
|
transferRequest := &godo.ActionRequest{
|
|
|
|
|
"type": "transfer",
|
|
|
|
|
"region": c.SnapshotRegions[transfer],
|
|
|
|
|
}
|
|
|
|
|
imageTransfer, _, err := client.ImageActions.Transfer(context.TODO(), images[0].ID, transferRequest)
|
|
|
|
|
if err != nil {
|
|
|
|
|
err := fmt.Errorf("Error transfering snapshot: %s", err)
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
ui.Say(fmt.Sprintf("Transfering Snapshot ID: %d", imageTransfer.ID))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.Say(fmt.Sprintf("Snapshot region: %d", len(regions)))
|
|
|
|
|
// ui.Say(fmt.Sprintf("Snapshot regions: %s", strings.Join(c.SnapshotRegions[:], ",")))
|
|
|
|
|
|
|
|
|
|
//client.ImageActions.Transfer(context.TODO(), )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var imageId int
|
|
|
|
|
if len(images) == 1 {
|
|
|
|
|
imageId = images[0].ID
|
|
|
|
|
|