ref: 79803b98b551ad1d924594263038bc901f684233 cisco/csc/cmd/instance/set/size.go -rw-r--r-- 701 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package instanceset

import (
	"cisco/csc/cmd/instance"
	"cisco/sdk"
	"fmt"
	"github.com/spf13/cobra"
	"strconv"
)

var instanceResize = &cobra.Command{
	Use:   "size",
	Short: "Resize an instance",
	Args:  cobra.ExactArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]
		size, err := strconv.Atoi(args[1])

		if err != nil {
			fmt.Printf("Error: %s\n", err.Error())
			return
		}

		err = cisco.ResizeInstance(name, uint(size))

		if err != nil {
			fmt.Printf("Error: %s\n", err.Error())
			return
		}

		fmt.Printf("Done! You need to restart the instance in order to use the new disk space.\n")
	},
}

func init() {
	instance.InstanceSetRootCmd.AddCommand(instanceResize)
}