Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from converged-computing/add-state-endpoint
feat: state endpoint
- Loading branch information
Showing
26 changed files
with
1,030 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package update | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/converged-computing/rainbow/pkg/client" | ||
"github.com/converged-computing/rainbow/pkg/config" | ||
) | ||
|
||
// UpdateState updates state for a cluster | ||
func UpdateState( | ||
host, | ||
clusterName, | ||
stateFile, | ||
cfgFile string, | ||
) error { | ||
|
||
c, err := client.NewClient(host) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// A config file is required here | ||
if cfgFile == "" { | ||
return fmt.Errorf("an existing configuration file is required to update an existing cluster") | ||
} | ||
if stateFile == "" { | ||
return fmt.Errorf("a state file (json with key value pairs) is required to update state") | ||
} | ||
// Read in the config, if provided, command line takes preference | ||
cfg, err := config.NewRainbowClientConfig(cfgFile, "", "", "", "", "") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("updating state for cluster: %s", cfg.Scheduler.Name) | ||
|
||
// Last argument is subsystem name, which we can derive from graph | ||
response, err := c.UpdateState( | ||
context.Background(), | ||
cfg.Cluster.Name, | ||
cfg.Cluster.Secret, | ||
stateFile, | ||
) | ||
// If we get here, success! Dump all the stuff. | ||
log.Printf("%s", response) | ||
return err | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"cost-per-node": 12, | ||
"max-jobs": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.