Пример #1
0
func Delete(name string) error {
	var err error
	instanceName, instancePlatform := util.SearchInstance(name)
	if instanceName == "" {
		fmt.Printf("Instance: %s not found\n", name)
		return nil
	}

	switch instancePlatform {
	case "qemu":
		qemu.StopVM(name)
		err = qemu.DeleteVM(name)
	case "vbox":
		vbox.StopVM(name)
		err = vbox.DeleteVM(name)
	case "vmw":
		vmw.StopVM(name)
		err = vmw.DeleteVM(name)
	case "gce":
		gce.StopVM(name)
		err = gce.DeleteVM(name)
	}
	if err != nil {
		fmt.Printf("Failed to delete instance: %s\n", name)
		return err
	}

	fmt.Printf("Deleted instance: %s\n", name)
	return nil
}
Пример #2
0
func deleteInstance(name string) error {
	instanceName, instancePlatform := util.SearchInstance(name)
	if instanceName == "" {
		return nil
	}
	var err error
	switch instancePlatform {
	case "qemu":
		err = qemu.DeleteVM(name)
	case "vbox":
		err = vbox.DeleteVM(name)
	case "vmw":
		err = vmw.DeleteVM(name)
	case "gce":
		err = gce.DeleteVM(name)
	}
	return err
}