Пример #1
0
func CreateVM(c *cli.Context) {
	name := c.String("name")
	image := c.String("image")
	cpus := c.Int("CPUs")
	ram := c.Int("RAM") * 1024
	diskSize := c.String("diskSize")
	network := c.String("network")

	// TODO: If file does not exist, the default cloudConfigFile
	cloudConfigFile, _ := ioutil.ReadFile(c.String("cloudConfigFile"))
	cloudConfig := string(cloudConfigFile)

	VM, _ := buki.CreateBasicVM(image, name, cpus, ram, diskSize, network, cloudConfig)
	fmt.Printf("Created VM from image '%s' : %s \n", name, VM)
}
Пример #2
0
func main() {
	/*
		net, err := buki.CreateBridgedNetwork("br0-bridge", "br0")

		fmt.Printf("%+v \n", net)
		fmt.Printf("%+v \n", err)
	*/

	var cloudConfig = `#cloud-config
password: mustafa
chpasswd: { expire: False }
ssh_pwauth: True
hostname: dq
`
	image := "trusty-server-cloudimg-amd64-disk1"
	name := "deneme4"
	cpus := 2
	ram := 2048
	disk := "50G"
	network := "vmbr0"

	vm, err := buki.CreateBasicVM(image, name, cpus, ram*1024, disk, network, cloudConfig)

	fmt.Printf("%+v \n", vm)
	fmt.Printf("%+v \n", err)

	/*
		VM := buki.GetVM("myubuntu")
		fmt.Printf("%+v", VM.Active)

		buki.StartVM("myubuntu")

		VM = buki.GetVM("myubuntu")
		fmt.Printf("%+v", VM.Active)
	*/
	vm = buki.GetVM(name)
	fmt.Println(vm)

}