Ejemplo n.º 1
0
// Remove will remove a remote volume
func (driver *Driver) Remove(volumeName string) error {
	if volumeName == "" {
		return errors.New("Missing volume name")
	}

	instances, err := storage.GetInstance()
	if err != nil {
		return err
	}

	switch {
	case len(instances) == 0:
		return errors.New("No instances")
	case len(instances) > 1:
		return errors.New("Too many instances returned, limit the storagedrivers")
	}

	volumes, err := storage.GetVolume("", volumeName)
	if err != nil {
		return err
	}

	switch {
	case len(volumes) == 0:
		return errors.New("No volumes returned by name")
	case len(volumes) > 1:
		return errors.New("Multiple volumes returned by name")
	}

	err = driver.Unmount("", volumes[0].VolumeID)
	if err != nil {
		return err
	}

	err = storage.RemoveVolume(volumes[0].VolumeID)
	if err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 2
0
			log.Fatal(err)
		}
		fmt.Printf(string(yamlOutput))

	},
}

var removevolumeCmd = &cobra.Command{
	Use: "remove-volume",
	Run: func(cmd *cobra.Command, args []string) {

		if volumeID == "" {
			log.Fatalf("missing --volumeid")
		}

		err := storage.RemoveVolume(volumeID)
		if err != nil {
			log.Fatal(err)
		}

	},
}

var attachvolumeCmd = &cobra.Command{
	Use: "attach-volume",
	Run: func(cmd *cobra.Command, args []string) {

		if volumeID == "" {
			log.Fatalf("missing --volumeid")
		}