Skip to content
Closed
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
10 changes: 5 additions & 5 deletions 11_register_hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ function make_bm_masters() {
-address "$address" \
-password "$password" \
-user "$user" \
-machine-namespace openshift-machine-api \
-machine "$(echo $name | sed s/openshift/${CLUSTER_NAME}/)" \
-consumer-namespace openshift-machine-api \
-consumer "$(echo $name | sed s/openshift/${CLUSTER_NAME}/)" \
-boot-mac "$mac" \
"$name"
done
}

function list_workers() {
# Includes -machine and -machine-namespace
# Includes -consumer and -consumer-namespace
cat $NODES_FILE | \
jq '.nodes[] | select(.name | contains("worker")) | {
name,
Expand All @@ -57,10 +57,10 @@ function list_workers() {
| sed 's/"//g'
}

# Register the workers without a machine reference so they are
# Register the workers without a consumer reference so they are
# available for provisioning.
function make_bm_workers() {
# Does not include -machine or -machine-namespace
# Does not include -consumer or -consumer-namespace
while read name address user password mac; do
go run $SCRIPTDIR/make-bm-worker/main.go \
-address "$address" \
Expand Down
60 changes: 28 additions & 32 deletions make-bm-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,25 @@ spec:
image:
url: "{{ .ImageSourceURL }}"
checksum: "{{ .Checksum }}"
{{ end -}}{{ if .WithMachine }}
machineRef:
name: {{ .Machine }}
namespace: {{ .MachineNamespace }}
{{ end -}}{{ if .Consumer }}
consumerRef:
name: {{ .Consumer }}
namespace: {{ .ConsumerNamespace }}
{{ end }}
`

// TemplateArgs holds the arguments to pass to the template.
type TemplateArgs struct {
Name string
BMCAddress string
MAC string
EncodedUsername string
EncodedPassword string
WithImage bool
Checksum string
ImageSourceURL string
WithMachine bool
Machine string
MachineNamespace string
Name string
BMCAddress string
MAC string
EncodedUsername string
EncodedPassword string
WithImage bool
Checksum string
ImageSourceURL string
Consumer string
ConsumerNamespace string
}

func encodeToSecret(input string) string {
Expand All @@ -75,10 +74,10 @@ func main() {
var bmcAddress = flag.String("address", "", "address URL for BMC")
var verbose = flag.Bool("v", false, "turn on verbose output")
var withImage = flag.Bool("image", false, "include the image settings to trigger deployment")
var machine = flag.String(
"machine", "", "specify name of a related, existing, machine to link")
var machineNamespace = flag.String(
"machine-namespace", "", "specify namespace of a related, existing, machine to link")
var consumer = flag.String(
"consumer", "", "specify name of a related, existing, consumer to link")
var consumerNamespace = flag.String(
"consumer-namespace", "", "specify namespace of a related, existing, consumer to link")
var bootMAC = flag.String(
"boot-mac", "", "specify boot MAC address of host")

Expand All @@ -103,19 +102,16 @@ func main() {
}

args := TemplateArgs{
Name: strings.Replace(hostName, "_", "-", -1),
BMCAddress: *bmcAddress,
MAC: *bootMAC,
EncodedUsername: encodeToSecret(*username),
EncodedPassword: encodeToSecret(*password),
WithImage: *withImage,
Checksum: instanceImageChecksumURL,
ImageSourceURL: instanceImageSource,
Machine: strings.TrimSpace(*machine),
MachineNamespace: strings.TrimSpace(*machineNamespace),
}
if args.Machine != "" {
args.WithMachine = true
Name: strings.Replace(hostName, "_", "-", -1),
BMCAddress: *bmcAddress,
MAC: *bootMAC,
EncodedUsername: encodeToSecret(*username),
EncodedPassword: encodeToSecret(*password),
WithImage: *withImage,
Checksum: instanceImageChecksumURL,
ImageSourceURL: instanceImageSource,
Consumer: strings.TrimSpace(*consumer),
ConsumerNamespace: strings.TrimSpace(*consumerNamespace),
}
if *verbose {
fmt.Fprintf(os.Stderr, "%v", args)
Expand Down