mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Minor formatting
This commit is contained in:
parent
d8bd169cb7
commit
d09b71262a
2 changed files with 24 additions and 20 deletions
|
|
@ -1,17 +1,21 @@
|
||||||
|
|
||||||
function build(){
|
function build(){
|
||||||
go mod tidy && go build -C bin/magellan
|
go mod tidy && go build -C bin/magellan
|
||||||
}
|
}
|
||||||
|
|
||||||
function scan() {
|
function scan() {
|
||||||
./magellan scan --subnet 172.16.0.0 --port 443
|
./magellan scan --subnet 172.16.0.0 --port 443
|
||||||
}
|
}
|
||||||
|
|
||||||
function list(){
|
function list() {
|
||||||
./magellan list
|
./magellan list
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
./magellan update --user admin --pass password --host 172.16.0.109 --component BMC --protocol HTTP --firmware-path ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function collect() {
|
function collect() {
|
||||||
./magellan collect --user admin --pass password
|
./magellan collect --user admin --pass password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func PathExists(path string) (bool, error) {
|
func PathExists(path string) (bool, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err == nil { return true, nil }
|
if err == nil { return true, nil }
|
||||||
if os.IsNotExist(err) { return false, nil }
|
if os.IsNotExist(err) { return false, nil }
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
|
func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
|
||||||
|
|
@ -37,20 +37,20 @@ func MakeRequest(url string, httpMethod string, body []byte, headers map[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeOutputDirectory(path string) (string, error) {
|
func MakeOutputDirectory(path string) (string, error) {
|
||||||
// get the current data + time using Go's stupid formatting
|
// get the current data + time using Go's stupid formatting
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
dirname := t.Format("2006-01-01 15:04:05")
|
dirname := t.Format("2006-01-01 15:04:05")
|
||||||
final := path + "/" + dirname
|
final := path + "/" + dirname
|
||||||
|
|
||||||
// check if path is valid and directory
|
// check if path is valid and directory
|
||||||
pathExists, err := PathExists(final);
|
pathExists, err := PathExists(final);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return final, fmt.Errorf("could not check for existing path: %v", err)
|
return final, fmt.Errorf("could not check for existing path: %v", err)
|
||||||
}
|
}
|
||||||
if pathExists {
|
if pathExists {
|
||||||
// make sure it is directory with 0o644 permissions
|
// make sure it is directory with 0o644 permissions
|
||||||
return final, fmt.Errorf("found existing path: %v", final)
|
return final, fmt.Errorf("found existing path: %v", final)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create directory with data + time
|
// create directory with data + time
|
||||||
err = os.MkdirAll(final, 0766)
|
err = os.MkdirAll(final, 0766)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue