MCPcopy Index your code
hub / github.com/deepflowio/deepflow / RegisterCloudCommand

Function RegisterCloudCommand

cli/ctl/cloud.go:30–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28)
29
30func RegisterCloudCommand() *cobra.Command {
31 cloud := &cobra.Command{
32 Use: "cloud",
33 Short: "debug cloud data commands",
34 Run: func(cmd *cobra.Command, args []string) {
35 fmt.Printf("please run with 'info | task | trigger'.\n")
36 },
37 }
38
39 var domainLcuuid string
40 var domainName string
41 var infoResource string
42 info := &cobra.Command{
43 Use: "info",
44 Short: "get cloud info of one domain, must specify one of domain-lcuuid, domain-name",
45 Example: "deepflow-ctl cloud info --domain-lcuuid bcb21453-0833-5d94-b4cf-adb3879400c9 -r VMs,VPCs",
46 Run: func(cmd *cobra.Command, args []string) {
47 getInfo(cmd, domainLcuuid, domainName, infoResource)
48 },
49 }
50 info.Flags().StringVarP(
51 &domainLcuuid, "domain-lcuuid", "l", "", fmt.Sprintf("specify domain lcuuid to get resources info"),
52 )
53 info.Flags().StringVarP(
54 &domainName, "domain-name", "n", "", fmt.Sprintf("specify domain name to get resources info"),
55 )
56 info.Flags().StringVarP(
57 &infoResource, "resource-type", "r", "", fmt.Sprintf("only get specified resources info, split by comma.Supported choices: %v", common.RESOURCE_TYPES),
58 )
59 cloud.AddCommand(info)
60
61 task := &cobra.Command{
62 Use: "task [domain-lcuuid]",
63 Short: "get cloud task",
64 Example: "deepflow-ctl cloud task",
65 Run: func(cmd *cobra.Command, args []string) {
66 getTask(cmd, args)
67 },
68 }
69 cloud.AddCommand(task)
70
71 trigger := &cobra.Command{
72 Use: "trigger domain-lcuuid",
73 Short: "trigger domain",
74 Example: "deepflow-ctl cloud trigger domain-lcuuid",
75 Run: func(cmd *cobra.Command, args []string) {
76 triggerDomain(cmd, args)
77 },
78 }
79 cloud.AddCommand(trigger)
80
81 return cloud
82}
83
84func getInfo(cmd *cobra.Command, domainLcuuid, domainName, resource string) {
85 if domainLcuuid == "" && domainName == "" {

Callers 1

ExecuteFunction · 0.85

Calls 3

getInfoFunction · 0.85
getTaskFunction · 0.85
triggerDomainFunction · 0.70

Tested by

no test coverage detected