Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/base/list_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,17 @@ func (o *AttachedSubnetworksOption[T]) ApplyToCollection(collection serverscom.C
collection.SetParam("attached", "true")
}
}

type RackIDOption[T any] struct {
rackID string
}

func (o *RackIDOption[T]) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.rackID, "rack-id", "", "Filter results by rack ID where host is deployed")
}

func (o *RackIDOption[T]) ApplyToCollection(collection serverscom.Collection[T]) {
if o.rackID != "" {
collection.SetParam("rack_id", o.rackID)
}
}
7 changes: 4 additions & 3 deletions cmd/entities/hosts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
newGetDSNetworkCmd,
newAddDSNetworkCmd,
newDeleteDSNetworkCmd,
newListDSCmd,
},
},
{
Expand All @@ -69,6 +70,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
},
extraCmds: []func(*base.CmdContext) *cobra.Command{
newUpdateKBMCmd,
newListKBMCmd,
},
},
{
Expand All @@ -85,6 +87,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
newAddSBMCmd,
newUpdateSBMCmd,
newSBMReleaseCmd,
newListSBMCmd,
},
},
}
Expand All @@ -102,7 +105,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
}

// hosts list cmd
cmd.AddCommand(newListCmd(cmdContext, nil))
cmd.AddCommand(newListCmd(cmdContext))

for _, ht := range hostTypeCmds {
cmd.AddCommand(newHostTypeCmd(cmdContext, ht))
Expand All @@ -121,7 +124,6 @@ func newHostTypeCmd(cmdContext *base.CmdContext, hostTypeCmd HostTypeCmd) *cobra
Run: base.UsageRun,
}

hostCmd.AddCommand(newListCmd(cmdContext, &hostTypeCmd))
hostCmd.AddCommand(newGetCmd(cmdContext, &hostTypeCmd))

if hostTypeCmd.managers.powerMgr != nil {
Expand All @@ -146,7 +148,6 @@ func getHostsEntities() (map[string]entities.EntityInterface, error) {
return nil, err
}
result["hosts"] = hostsEntity
result["list"] = hostsEntity

dsEntity, err := entities.Registry.GetEntityFromValue(serverscom.DedicatedServer{})
if err != nil {
Expand Down
Loading
Loading