mirror of
https://github.com/bmc-toolbox/bmclib.git
synced 2025-06-03 05:14:43 +00:00
Updated examples with docs
* Renamed user creation example * Fixed create-user to use the CSV-provided values * ran `go mod tidy` Signed-off-by: Micah Hausler <mhausler@amazon.com>
This commit is contained in:
parent
ec29368a11
commit
cc2ec72571
24
examples/v1/create-users/doc.go
Normal file
24
examples/v1/create-users/doc.go
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
create-users is an example commmand that utilizes the 'v1' bmclib interface
|
||||
methods to create user entries in a BMC using the redfish driver.
|
||||
|
||||
$ go run ./examples/v1/create-users/main.go -h
|
||||
Usage of /tmp/go-build440589615/b001/exe/main:
|
||||
-cert-pool string
|
||||
Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true
|
||||
-dry-run
|
||||
Connect to the BMC but do not create users
|
||||
-host string
|
||||
BMC hostname to connect to
|
||||
-password string
|
||||
Username to login with
|
||||
-port int
|
||||
BMC port to connect to (default 443)
|
||||
-secure-tls
|
||||
Enable secure TLS
|
||||
-user string
|
||||
Username to login with
|
||||
-user-csv string
|
||||
A CSV file of users to create containing 3 columns: username, password, role
|
||||
*/
|
||||
package main
|
@ -53,7 +53,6 @@ func main() {
|
||||
|
||||
cl := bmclib.NewClient(*host, strconv.Itoa(*port), *user, *pass, clientOpts...)
|
||||
cl.Registry.Drivers = cl.Registry.Using("redfish")
|
||||
// cl.Registry.Drivers = cl.Registry.Using("vendorapi")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
@ -85,7 +84,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
if !*dryRun {
|
||||
_, err = cl.CreateUser(ctx, "foobar", "sekurity101", "Administrator")
|
||||
_, err = cl.CreateUser(ctx, record[0], record[1], record[2])
|
||||
if err != nil {
|
||||
l.WithError(err).Error("error creating user")
|
||||
continue
|
24
examples/v1/install-firmware/doc.go
Normal file
24
examples/v1/install-firmware/doc.go
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
install-firmware is an example commmand that utilizes the 'v1' bmclib interface
|
||||
methods to flash a firmware image to a BMC.
|
||||
|
||||
$ go run ./examples/v1/install-firmware/main.go -h
|
||||
Usage of /tmp/go-build2950657412/b001/exe/main:
|
||||
-cert-pool string
|
||||
Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true
|
||||
-firmware string
|
||||
The local path of the firmware to install
|
||||
-host string
|
||||
BMC hostname to connect to
|
||||
-password string
|
||||
Username to login with
|
||||
-port int
|
||||
BMC port to connect to (default 443)
|
||||
-secure-tls
|
||||
Enable secure TLS
|
||||
-user string
|
||||
Username to login with
|
||||
-version string
|
||||
The firmware version being installed
|
||||
*/
|
||||
package main
|
@ -1,9 +1,5 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
This utilizes what is to tbe the 'v1' bmclib interface methods to flash a firmware image
|
||||
*/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
@ -27,7 +23,7 @@ func main() {
|
||||
port := flag.Int("port", 443, "BMC port to connect to")
|
||||
withSecureTLS := flag.Bool("secure-tls", false, "Enable secure TLS")
|
||||
certPoolPath := flag.String("cert-pool", "", "Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true")
|
||||
firmwarePath := flag.String("firmware", "", "The firmware path to read")
|
||||
firmwarePath := flag.String("firmware", "", "The local path of the firmware to install")
|
||||
firmwareVersion := flag.String("version", "", "The firmware version being installed")
|
||||
|
||||
flag.Parse()
|
||||
|
20
examples/v1/inventory/doc.go
Normal file
20
examples/v1/inventory/doc.go
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
inventory is an example commmand that utilizes the 'v1' bmclib interface
|
||||
methods to gather inventory from a BMC using the redfish driver.
|
||||
|
||||
$ go run ./examples/v1/inventory/main.go -h
|
||||
Usage of /tmp/go-build1853609647/b001/exe/main:
|
||||
-cert-pool string
|
||||
Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true
|
||||
-host string
|
||||
BMC hostname to connect to
|
||||
-password string
|
||||
Username to login with
|
||||
-port int
|
||||
BMC port to connect to (default 443)
|
||||
-secure-tls
|
||||
Enable secure TLS
|
||||
-user string
|
||||
Username to login with
|
||||
*/
|
||||
package main
|
@ -69,5 +69,4 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Println(string(b))
|
||||
|
||||
}
|
21
examples/v1/status/doc.go
Normal file
21
examples/v1/status/doc.go
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
status is an example commmand that utilizes the 'v1' bmclib interface methods
|
||||
to gather the BMC version, power state, and bios version from a BMC using the
|
||||
redfish driver.
|
||||
|
||||
$ go run ./examples/v1/status/main.go -h
|
||||
Usage of /tmp/go-build1941100323/b001/exe/main:
|
||||
-cert-pool string
|
||||
Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true
|
||||
-host string
|
||||
BMC hostname to connect to
|
||||
-password string
|
||||
Username to login with
|
||||
-port int
|
||||
BMC port to connect to (default 443)
|
||||
-secure-tls
|
||||
Enable secure TLS
|
||||
-user string
|
||||
Username to login with
|
||||
*/
|
||||
package main
|
@ -48,7 +48,6 @@ func main() {
|
||||
|
||||
cl := bmclib.NewClient(*host, strconv.Itoa(*port), *user, *pass, clientOpts...)
|
||||
cl.Registry.Drivers = cl.Registry.Using("redfish")
|
||||
// cl.Registry.Drivers = cl.Registry.Using("vendorapi")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
|
1
go.mod
1
go.mod
@ -40,7 +40,6 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
|
9
go.sum
9
go.sum
@ -48,8 +48,6 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logr/logr v1.0.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.0 h1:QK40JKJyMdUDz+h+xvCsru/bJhvG0UxvePV0ufL/AcE=
|
||||
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
@ -71,8 +69,6 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
@ -114,8 +110,6 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/jacobweinstock/registrar v0.4.5 h1:rcrgmvJQUBcpi6RpMKItrQeb/tSIvD4dFbhtxUt6GKY=
|
||||
github.com/jacobweinstock/registrar v0.4.5/go.mod h1:EDDfJ/mtb00aUG4k3wThbbUgl74xZjb3SLK2CVeCATk=
|
||||
github.com/jacobweinstock/registrar v0.4.6 h1:0O3g2jT2Lx+Bf+yl4QsMUN48fVZxUpM3kS+NtIJ+ucw=
|
||||
github.com/jacobweinstock/registrar v0.4.6/go.mod h1:IDx65tQ7DLJ2UqiVjE1zo74jMZZfel9YZW8VrC26m6o=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
@ -328,9 +322,6 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
|
Loading…
Reference in New Issue
Block a user