Skip to content

Commit

Permalink
feat: group SMD and BSS commands
Browse files Browse the repository at this point in the history
Group "low-level" commands, commands that send a single request to
SMD/BSS and return the result directly, under the respective service
metacommand. Commands that send a request to BSS are prefixed with 'bss'
while commands that send a request to SMD are prefixed with 'smd'.

This will save room for the more "high level" commands, commands that a
sysadmin is more likely to use that abstract away the calls like
'discover'.
  • Loading branch information
synackd committed Nov 15, 2024
1 parent db92995 commit 6cb6d90
Show file tree
Hide file tree
Showing 33 changed files with 114 additions and 116 deletions.
12 changes: 6 additions & 6 deletions cmd/boot-params-add.go → cmd/bss-boot-params-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsAddCmd represents the add command
// bootParamsAddCmd represents the bss-boot-params-add command
var bootParamsAddCmd = &cobra.Command{
Use: "add",
Args: cobra.NoArgs,
Expand All @@ -23,15 +23,15 @@ Alternatively, pass -f to pass a file (optionally specifying --payload-format, J
but the rules above still apply for the payload.
This command sends a POST to BSS. An access token is required.`,
Example: ` ochami boot params add \
Example: ` ochami bss boot params add \
--mac 00:de:ad:be:ef:00 \
--kernel https://example.com/kernel \
--initrd https://example.com/initrd \
--params 'quiet nosplash'
ochami boot params add --mac 00:de:ad:be:ef:00,00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami boot params add --mac 00:de:ad:be:ef:00 --mac 00:c0:ff:ee:00:00 --kernel https://example.com/kernel
ochami boot params add -f payload.json
ochami boot params add -f payload.yaml --payload-format yaml`,
ochami bss boot params add --mac 00:de:ad:be:ef:00,00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami bss boot params add --mac 00:de:ad:be:ef:00 --mac 00:c0:ff:ee:00:00 --kernel https://example.com/kernel
ochami bss boot params add -f payload.json
ochami bss boot params add -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// cmd.LocalFlags().NFlag() doesn't seem to work, so we check every flag
if len(args) == 0 &&
Expand Down
10 changes: 5 additions & 5 deletions cmd/boot-params-delete.go → cmd/bss-boot-params-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsDeleteCmd represents the bss-bootparams-delete command
// bootParamsDeleteCmd represents the bss-boot-params-delete command
var bootParamsDeleteCmd = &cobra.Command{
Use: "delete",
Args: cobra.NoArgs,
Expand All @@ -25,10 +25,10 @@ boot parameters by config (kernel URI, initrd URI, or kernel command line) or by
JSON by default), but the rules above still apply for the payload.
This command sends a DELETE to BSS. An access token is required.`,
Example: ` ochami boot params delete --kernel https://example.com/kernel
ochami boot params delete --kernel https://example.com/kernel --initrd https://example.com/initrd
ochami boot params delete -f payload.json
ochami boot params delete -f payload.yaml --payload-format yaml`,
Example: ` ochami bss boot params delete --kernel https://example.com/kernel
ochami bss boot params delete --kernel https://example.com/kernel --initrd https://example.com/initrd
ochami bss boot params delete -f payload.json
ochami bss boot params delete -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// cmd.LocalFlags().NFlag() doesn't seem to work, so we check every flag
if len(args) == 0 &&
Expand Down
10 changes: 5 additions & 5 deletions cmd/boot-params-get.go → cmd/bss-boot-params-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsGetCmd represents the boot-params-get command
// bootParamsGetCmd represents the bss-boot-params-get command
var bootParamsGetCmd = &cobra.Command{
Use: "get",
Args: cobra.NoArgs,
Expand All @@ -23,10 +23,10 @@ parameters are returned. Optionally, --mac, --xname, and/or --nid can be passed
to get boot parameters for specific components.
This command sends a GET to BSS. An access token is required.`,
Example: ` ochami bss bootparams get
ochami bss bootparams get --mac 00:de:ad:be:ef:00
ochami bss bootparams get --mac 00:de:ad:be:ef:00,00:c0:ff:ee:00:00
ochami bss bootparams get --mac 00:de:ad:be:ef:00 --mac 00:c0:ff:ee:00:00`,
Example: ` ochami bss boot params get
ochami bss boot params get --mac 00:de:ad:be:ef:00
ochami bss boot params get --mac 00:de:ad:be:ef:00,00:c0:ff:ee:00:00
ochami bss boot params get --mac 00:de:ad:be:ef:00 --mac 00:c0:ff:ee:00:00`,
Run: func(cmd *cobra.Command, args []string) {
// Without a base URI, we cannot do anything
bssBaseURI, err := getBaseURI(cmd)
Expand Down
14 changes: 7 additions & 7 deletions cmd/boot-params-set.go → cmd/bss-boot-params-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsSetCmd represents the boot-params-set command
// bootParamsSetCmd represents the bss-boot-params-set command
var bootParamsSetCmd = &cobra.Command{
Use: "set",
Args: cobra.NoArgs,
Expand All @@ -25,12 +25,12 @@ to pass a file (optionally specifying --payload-format, JSON by default), but th
still apply for the payload.
This command sends a PUT to BSS. An access token is required.`,
Example: ` ochami boot params set --xname x1000c1s7b0 --kernel https://example.com/kernel
ochami boot params set --xname x1000c1s7b0,x1000c1s7b1 --kernel https://example.com/kernel
ochami boot params set --xname x1000c1s7b0 --xname x1000c1s7b1 --kernel https://example.com/kernel
ochami boot params set --xname x1000c1s7b0 --nid 1 --mac 00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami boot params set -f payload.json
ochami boot params set -f payload.yaml --payload-format yaml`,
Example: ` ochami bss boot params set --xname x1000c1s7b0 --kernel https://example.com/kernel
ochami bss boot params set --xname x1000c1s7b0,x1000c1s7b1 --kernel https://example.com/kernel
ochami bss boot params set --xname x1000c1s7b0 --xname x1000c1s7b1 --kernel https://example.com/kernel
ochami bss boot params set --xname x1000c1s7b0 --nid 1 --mac 00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami bss boot params set -f payload.json
ochami bss boot params set -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// cmd.LocalFlags().NFlag() doesn't seem to work, so we check every flag
if len(args) == 0 &&
Expand Down
14 changes: 7 additions & 7 deletions cmd/boot-params-update.go → cmd/bss-boot-params-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsUpdateCmd represents the bss-bootparams-update command
// bootParamsUpdateCmd represents the bss-boot-params-update command
var bootParamsUpdateCmd = &cobra.Command{
Use: "update",
Args: cobra.NoArgs,
Expand All @@ -23,12 +23,12 @@ var bootParamsUpdateCmd = &cobra.Command{
default), but the rules above still apply for the payload.
This command sends a PATCH to BSS. An access token is required.`,
Example: ` ochami boot params update --xname x1000c1s7b0 --kernel https://example.com/kernel
ochami boot params update --xname x1000c1s7b0,x1000c1s7b1 --kernel https://example.com/kernel
ochami boot params update --xname x1000c1s7b0 --xname x1000c1s7b1 --kernel https://example.com/kernel
ochami boot params update --xname x1000c1s7b0 --nid 1 --mac 00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami boot params update -f payload.json
ochami boot params update -f payload.yaml --payload-format yaml`,
Example: ` ochami bss boot params update --xname x1000c1s7b0 --kernel https://example.com/kernel
ochami bss boot params update --xname x1000c1s7b0,x1000c1s7b1 --kernel https://example.com/kernel
ochami bss boot params update --xname x1000c1s7b0 --xname x1000c1s7b1 --kernel https://example.com/kernel
ochami bss boot params update --xname x1000c1s7b0 --nid 1 --mac 00:c0:ff:ee:00:00 --params 'quiet nosplash'
ochami bss boot params update -f payload.json
ochami bss boot params update -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// cmd.LocalFlags().NFlag() doesn't seem to work, so we check every flag
if len(args) == 0 &&
Expand Down
2 changes: 1 addition & 1 deletion cmd/boot-params.go → cmd/bss-boot-params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootParamsCmd represents the boot-params command
// bootParamsCmd represents the bss-boot-params command
var bootParamsCmd = &cobra.Command{
Use: "params",
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cmd/boot-script-get.go → cmd/bss-boot-script-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootScriptGetCmd represents the bss-bootscript-get command
// bootScriptGetCmd represents the bss-boot-script-get command
var bootScriptGetCmd = &cobra.Command{
Use: "get",
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cmd/boot-script.go → cmd/bss-boot-script.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootScriptCmd represents the boot-script command
// bootScriptCmd represents the bss-boot-script command
var bootScriptCmd = &cobra.Command{
Use: "script",
Args: cobra.NoArgs,
Expand Down
4 changes: 2 additions & 2 deletions cmd/boot.go → cmd/bss-boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// bootCmd represents the boot command
// bootCmd represents the bss-boot command
var bootCmd = &cobra.Command{
Use: "boot",
Args: cobra.NoArgs,
Expand All @@ -29,5 +29,5 @@ under this one interact with the Boot Script Service (BSS).`,
}

func init() {
rootCmd.AddCommand(bootCmd)
bssCmd.AddCommand(bootCmd)
}
10 changes: 5 additions & 5 deletions cmd/compep-delete.go → cmd/smd-compep-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// compepDeleteCmd represents the compep-delete command
// compepDeleteCmd represents the smd-compep-delete command
var compepDeleteCmd = &cobra.Command{
Use: "delete -f <payload_file> | --all | <xname>...",
Short: "Delete one or more component endpoints",
Long: `Delete one or more component endpoints. These can be specified by one or more xnames.
This command sends a DELETE to SMD. An access token is required.`,
Example: ` ochami compep delete x3000c1s7b56n0 x3000c1s7b56n1
ochami compep delete --all
ochami compep delete -f payload.json
ochami compep delete -f payload.yaml --payload-format yaml`,
Example: ` ochami smd compep delete x3000c1s7b56n0 x3000c1s7b56n1
ochami smd compep delete --all
ochami smd compep delete -f payload.json
ochami smd compep delete -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// With options, only one of:
// - A payload file with -f
Expand Down
2 changes: 1 addition & 1 deletion cmd/compep-get.go → cmd/smd-compep-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// compepGetCmd represents the compep-get command
// compepGetCmd represents the smd-compep-get command
var compepGetCmd = &cobra.Command{
Use: "get [<xname>...]",
Short: "Get all component endpoints or one identified by an xname",
Expand Down
4 changes: 2 additions & 2 deletions cmd/compep.go → cmd/smd-compep.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// compepCmd represents the compep command
// compepCmd represents the smd-compep command
var compepCmd = &cobra.Command{
Use: "compep",
Args: cobra.NoArgs,
Expand All @@ -29,5 +29,5 @@ interact with the State Management Database (SMD).`,
}

func init() {
rootCmd.AddCommand(compepCmd)
smdCmd.AddCommand(compepCmd)
}
10 changes: 5 additions & 5 deletions cmd/component-add.go → cmd/smd-component-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// componentAddCmd represents the component-add command
// componentAddCmd represents the smd-component-add command
var componentAddCmd = &cobra.Command{
Use: "add -f <payload_file> | (<xname> <node_id>)",
Short: "Add new component(s)",
Expand All @@ -20,10 +20,10 @@ var componentAddCmd = &cobra.Command{
other flags of this command.
This command sends a POST to SMD. An access token is required.`,
Example: ` ochami component add x3000c1s7b56n0 56
ochami component add --state Ready --enabled --role Compute --arch X86 x3000c1s7b56n0 56
ochami component add -f payload.json
ochami component add -f payload.yaml --payload-format yaml`,
Example: ` ochami smd component add x3000c1s7b56n0 56
ochami smd component add --state Ready --enabled --role Compute --arch X86 x3000c1s7b56n0 56
ochami smd component add -f payload.json
ochami smd component add -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// Check that all required args are passed
if len(args) == 0 && !cmd.Flag("payload").Changed {
Expand Down
12 changes: 6 additions & 6 deletions cmd/component-delete.go → cmd/smd-component-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// componentDeleteCmd represents the component-delete command
// componentDeleteCmd represents the smd-component-delete command
var componentDeleteCmd = &cobra.Command{
Use: "delete -f <payload_file> | --all | <xname>...",
Short: "Delete one or more components",
Long: `Delete one or more components. These can be specified by one or more xnames, one
or more NIDs, or a combination of both.
This command sends a DELETE to SMD. An access token is required.`,
Example: ` ochami component delete x3000c1s7b56n0
ochami component delete x3000c1s7b56n0 x3000c1s7b56n1
ochami component delete --all
ochami component delete -f payload.json
ochami component delete -f payload.yaml --payload-format yaml`,
Example: ` ochami smd component delete x3000c1s7b56n0
ochami smd component delete x3000c1s7b56n0 x3000c1s7b56n1
ochami smd component delete --all
ochami smd component delete -f payload.json
ochami smd component delete -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// With options, only one of:
// - A payload file with -f
Expand Down
2 changes: 1 addition & 1 deletion cmd/component-get.go → cmd/smd-component-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// componentGetCmd represents the component-get command
// componentGetCmd represents the smd-component-get command
var componentGetCmd = &cobra.Command{
Use: "get",
Args: cobra.NoArgs,
Expand Down
4 changes: 2 additions & 2 deletions cmd/component.go → cmd/smd-component.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// componentCmd represents the component command
// componentCmd represents the smd-component command
var componentCmd = &cobra.Command{
Use: "component",
Args: cobra.NoArgs,
Expand All @@ -29,5 +29,5 @@ interact with the State Management Database (SMD).`,
}

func init() {
rootCmd.AddCommand(componentCmd)
smdCmd.AddCommand(componentCmd)
}
14 changes: 7 additions & 7 deletions cmd/group-add.go → cmd/smd-group-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupAddCmd represents the group-add command
// groupAddCmd represents the smd-group-add command
var groupAddCmd = &cobra.Command{
Use: "add -f <payload_file> | <group_label>",
Short: "Add new group",
Expand All @@ -20,17 +20,17 @@ Specifying -f also is mutually exclusive with the other flags of this commands
and its arguments.
This command sends a POST to SMD. An access token is required.`,
Example: ` ochami group add computes
ochami group add -d "Compute group" computes
ochami group add -d "Compute group" --tag tag1,tag2 --m x3000c1s7b0n1,x3000c1s7b1n1 computes
ochami group add \
Example: ` ochami smd group add computes
ochami smd group add -d "Compute group" computes
ochami smd group add -d "Compute group" --tag tag1,tag2 --m x3000c1s7b0n1,x3000c1s7b1n1 computes
ochami smd group add \
--description "ARM64 group" \
--tag arm,64-bit \
--member x3000c1s7b0n1,x3000c1s7b1n1 \
--exclusive-group amd64 \
arm64
ochami group add -f payload.json
ochami group add -f payload.yaml --payload-format yaml`,
ochami smd group add -f payload.json
ochami smd group add -f payload.yaml --payload-format yaml`,
Run: func(cmd *cobra.Command, args []string) {
// Check that all required args are passed
if len(args) == 0 && !cmd.Flag("payload").Changed {
Expand Down
2 changes: 1 addition & 1 deletion cmd/group-delete.go → cmd/smd-group-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupDeleteCmd represents the group-delete command
// groupDeleteCmd represents the smd-group-delete command
var groupDeleteCmd = &cobra.Command{
Use: "delete -f <payload_file> | <group_label>...",
Short: "Delete one or more groups",
Expand Down
16 changes: 8 additions & 8 deletions cmd/group-get.go → cmd/smd-group-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupGetCmd represents the get command
// groupGetCmd represents the smd-group-get command
var groupGetCmd = &cobra.Command{
Use: "get",
Args: cobra.NoArgs,
Short: "Get all groups or group(s) identified by name and/or tag",
Example: ` ochami group get
ochami group get --name group1
ochami group get --tag group1_tag
ochami group get --name group1,group2
ochami group get --name group1 --name group2
ochami group get --name group1,group2 --tag tag1,tag2
ochami group get --name group1 --name group2 --tag tag1 --tag tag2`,
Example: ` ochami smd group get
ochami smd group get --name group1
ochami smd group get --tag group1_tag
ochami smd group get --name group1,group2
ochami smd group get --name group1 --name group2
ochami smd group get --name group1,group2 --tag tag1,tag2
ochami smd group get --name group1 --name group2 --tag tag1 --tag tag2`,
Run: func(cmd *cobra.Command, args []string) {
// Without a base URI, we cannot do anything
smdBaseURI, err := getBaseURI(cmd)
Expand Down
2 changes: 1 addition & 1 deletion cmd/group-member-add.go → cmd/smd-group-member-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupMemberAddCmd represents the group-member-add command
// groupMemberAddCmd represents the smd-group-member-add command
var groupMemberAddCmd = &cobra.Command{
Use: "add <group_label> <component>...",
Args: cobra.MinimumNArgs(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupMemberDeleteCmd represents the group-member-delete command
// groupMemberDeleteCmd represents the smd-group-member-delete command
var groupMemberDeleteCmd = &cobra.Command{
Use: "delete <group_label> <component>...",
Args: cobra.MinimumNArgs(2),
Expand Down
2 changes: 1 addition & 1 deletion cmd/group-member-get.go → cmd/smd-group-member-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenCHAMI/ochami/internal/log"
)

// groupMemberGetCmd represents the group-member-get command
// groupMemberGetCmd represents the smd-group-member-get command
var groupMemberGetCmd = &cobra.Command{
Use: "get <group_label>",
Args: cobra.ExactArgs(1),
Expand Down
Loading

0 comments on commit 6cb6d90

Please sign in to comment.