-
Notifications
You must be signed in to change notification settings - Fork 55
/
vmid.go
40 lines (34 loc) · 939 Bytes
/
vmid.go
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
39
40
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package subnetcmd
import (
"fmt"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-network-runner/utils"
"github.com/spf13/cobra"
)
// avalanche subnet create
func vmidCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vmid [vmName]",
Short: "Prints the VMID of a VM",
Long: `The subnet vmid command prints the virtual machine ID (VMID) for the given Subnet.`,
Args: cobrautils.ExactArgs(1),
RunE: printVMID,
}
return cmd
}
func printVMID(_ *cobra.Command, args []string) error {
chains, err := ValidateSubnetNameAndGetChains(args)
if err != nil {
return err
}
chain := chains[0]
vmID, err := utils.VMID(chain)
if err != nil {
return err
}
ux.Logger.PrintToUser(fmt.Sprintf("VM ID : %s", vmID.String()))
return nil
}