Skip to content

Commit

Permalink
add mctl cmd for APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alva8756 committed Sep 21, 2023
1 parent 929cc67 commit f2a7270
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 0 deletions.
47 changes: 47 additions & 0 deletions cmd/get/aoc-mac-address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package get

import (
"log"

mctl "github.com/metal-toolbox/mctl/cmd"
"github.com/metal-toolbox/mctl/internal/app"
"github.com/spf13/cobra"
)

type getBomInfoByAocMacAddressFlags struct {
macAddr string
}

var (
flagsGetBomByAocMacAddress *getBomInfoByAocMacAddressFlags
)

var getBomInfoByAocMacAddress = &cobra.Command{
Use: "aocmacaddress",
Short: "Get bom object by aocMacAddr",
Run: func(cmd *cobra.Command, args []string) {
theApp := mctl.MustCreateApp(cmd.Context())

client, err := app.NewServerserviceClient(cmd.Context(), theApp.Config.Serverservice, theApp.Reauth)
if err != nil {
log.Fatal(err)
}

bomInfo, _, err := client.GetBomInfoByAOCMacAddr(cmd.Context(), flagsGetBomByAocMacAddress.macAddr)
if err != nil {
log.Fatal(err)
}

writeResults(bomInfo)
},
}

func init() {
flagsGetBomByAocMacAddress = &getBomInfoByAocMacAddressFlags{}

getBomInfoByAocMacAddress.PersistentFlags().StringVar(&flagsGetBomByAocMacAddress.macAddr, "get-bom-by-aoc-mac-address", "", "get bom info by aocMacAddr")

if err := getBomInfoByAocMacAddress.MarkPersistentFlagRequired("get-bom-by-aoc-mac-address"); err != nil {
log.Fatal(err)
}
}
47 changes: 47 additions & 0 deletions cmd/get/bmc-mac-address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package get

import (
"log"

mctl "github.com/metal-toolbox/mctl/cmd"
"github.com/metal-toolbox/mctl/internal/app"
"github.com/spf13/cobra"
)

type getBomInfoByBmcMacAddressFlags struct {
macAddr string
}

var (
flagsGetBomByBmcMacAddress *getBomInfoByBmcMacAddressFlags
)

var getBomInfoByBmcMacAddress = &cobra.Command{
Use: "bmcmacaddress",
Short: "Get bom object by bmcMacAddr",
Run: func(cmd *cobra.Command, args []string) {
theApp := mctl.MustCreateApp(cmd.Context())

client, err := app.NewServerserviceClient(cmd.Context(), theApp.Config.Serverservice, theApp.Reauth)
if err != nil {
log.Fatal(err)
}

bomInfo, _, err := client.GetBomInfoByBMCMacAddr(cmd.Context(), flagsGetBomByBmcMacAddress.macAddr)
if err != nil {
log.Fatal(err)
}

writeResults(bomInfo)
},
}

func init() {
flagsGetBomByBmcMacAddress = &getBomInfoByBmcMacAddressFlags{}

getBomInfoByBmcMacAddress.PersistentFlags().StringVar(&flagsGetBomByBmcMacAddress.macAddr, "get-bom-by-bmc-mac-address", "", "get bom info by bmcMacAddr")

if err := getBomInfoByBmcMacAddress.MarkPersistentFlagRequired("get-bom-by-bmc-mac-address"); err != nil {
log.Fatal(err)
}
}
2 changes: 2 additions & 0 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func init() {
cmdGet.AddCommand(getFirmware)
cmdGet.AddCommand(getFirmwareSet)
cmdGet.AddCommand(getBiosConfig)
cmdGet.AddCommand(getBomInfoByAocMacAddress)
cmdGet.AddCommand(getBomInfoByBmcMacAddress)

cmdGet.PersistentFlags().StringVarP(&output, "output", "o", "json", "{json|text}")
}
2 changes: 2 additions & 0 deletions docs/mctl_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ mctl get [flags]
### SEE ALSO

* [mctl](mctl.md) - mctl is a CLI utility to interact with metal toolbox services
* [mctl get aocmacaddress](mctl_get_aocmacaddress.md) - Get bom object by aocMacAddr
* [mctl get bios-config](mctl_get_bios-config.md) - Get bios configuration information for a server
* [mctl get bmcmacaddress](mctl_get_bmcmacaddress.md) - Get bom object by bmcMacAddr
* [mctl get component](mctl_get_component.md) - get server components
* [mctl get condition](mctl_get_condition.md) - get server condition
* [mctl get firmware](mctl_get_firmware.md) - Get information for given firmware identifier
Expand Down
29 changes: 29 additions & 0 deletions docs/mctl_get_aocMacAddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Auto generated by spf13/cobra]: <>

## mctl get aocmacaddress

Get bom object by aocMacAddr

```
mctl get aocmacaddress [flags]
```

### Options

```
--get-bom-by-aoc-mac-address string get bom info by aocMacAddr
-h, --help help for aocmacaddress
```

### Options inherited from parent commands

```
--config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml)
-o, --output string {json|text} (default "json")
--reauth re-authenticate with oauth services
```

### SEE ALSO

* [mctl get](mctl_get.md) - Get resource

29 changes: 29 additions & 0 deletions docs/mctl_get_bmcmacaddr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Auto generated by spf13/cobra]: <>

## mctl get bmcmacaddr

Gets bom object by bmcMacAddr

```
mctl get bmcmacaddr [flags]
```

### Options

```
--get-bom-by-bmc-mac-address string get bom info by bmcMacAddr
-h, --help help for bmcmacaddr
```

### Options inherited from parent commands

```
--config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml)
-o, --output string {json|text} (default "json")
--reauth re-authenticate with oauth services
```

### SEE ALSO

* [mctl get](mctl_get.md) - Get resource

29 changes: 29 additions & 0 deletions docs/mctl_get_bmcmacaddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Auto generated by spf13/cobra]: <>

## mctl get bmcmacaddress

Get bom object by bmcMacAddr

```
mctl get bmcmacaddress [flags]
```

### Options

```
--get-bom-by-bmc-mac-address string get bom info by bmcMacAddr
-h, --help help for bmcmacaddress
```

### Options inherited from parent commands

```
--config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml)
-o, --output string {json|text} (default "json")
--reauth re-authenticate with oauth services
```

### SEE ALSO

* [mctl get](mctl_get.md) - Get resource

0 comments on commit f2a7270

Please sign in to comment.