fix
This commit is contained in:
parent
2e30793188
commit
82c297feaa
1 changed files with 22 additions and 2 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -26,11 +27,15 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
apiConfigFile = "api.yaml"
|
|
||||||
userID string // for flag parsing
|
userID string // for flag parsing
|
||||||
outputCTX *outputs.Output
|
outputCTX *outputs.Output
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
uuid = "/proc/sys/kernel/random/uuid"
|
||||||
|
apiConfigFile = "api.yaml"
|
||||||
|
)
|
||||||
|
|
||||||
func dumpCredentials() error {
|
func dumpCredentials() error {
|
||||||
if config.output == "json" {
|
if config.output == "json" {
|
||||||
credsYaml, err := json.Marshal(&outputCTX.API.Creds)
|
credsYaml, err := json.Marshal(&outputCTX.API.Creds)
|
||||||
|
@ -178,6 +183,13 @@ cscli api credentials # Display your API credentials
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get machine id: %s", err)
|
log.Fatalf("failed to get machine id: %s", err)
|
||||||
}
|
}
|
||||||
|
if id == "" {
|
||||||
|
bID, err := ioutil.ReadFile(uuid)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can'get a valid machine_id")
|
||||||
|
}
|
||||||
|
id = string(bID)
|
||||||
|
}
|
||||||
password := generatePassword()
|
password := generatePassword()
|
||||||
|
|
||||||
if err := outputCTX.API.RegisterMachine(id, password); err != nil {
|
if err := outputCTX.API.RegisterMachine(id, password); err != nil {
|
||||||
|
@ -215,6 +227,14 @@ cscli api credentials # Display your API credentials
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get machine id: %s", err)
|
log.Fatalf("failed to get machine id: %s", err)
|
||||||
}
|
}
|
||||||
|
if id == "" {
|
||||||
|
bID, err := ioutil.ReadFile(uuid)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can'get a valid machine_id")
|
||||||
|
}
|
||||||
|
id = string(bID)
|
||||||
|
}
|
||||||
|
|
||||||
password := generatePassword()
|
password := generatePassword()
|
||||||
if err := outputCTX.API.ResetPassword(id, password); err != nil {
|
if err := outputCTX.API.ResetPassword(id, password); err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
|
|
Loading…
Add table
Reference in a new issue