Merge branch '12863-wb-cr-status'
[arvados.git] / sdk / go / arvados / config.go
index 84e66b39a88e62cf5d1819b3ce232b3043212ffe..9ed0eacf23e6d753c1b6c2a0f781282c96dde8cc 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package arvados
 
 import (
@@ -48,10 +52,20 @@ type Cluster struct {
        ClusterID       string `json:"-"`
        ManagementToken string
        SystemNodes     map[string]SystemNode
+       InstanceTypes   []InstanceType
+}
+
+type InstanceType struct {
+       Name         string
+       ProviderType string
+       VCPUs        int
+       RAM          int64
+       Scratch      int64
+       Price        float64
 }
 
-// GetThisSystemNodeConfig returns a SystemNode for the node we're
-// running on right now.
+// GetThisSystemNode returns a SystemNode for the node we're running
+// on right now.
 func (cc *Cluster) GetThisSystemNode() (*SystemNode, error) {
        hostname, err := os.Hostname()
        if err != nil {
@@ -60,9 +74,9 @@ func (cc *Cluster) GetThisSystemNode() (*SystemNode, error) {
        return cc.GetSystemNode(hostname)
 }
 
-// GetSystemNodeConfig returns a NodeConfig for the given node. An
-// error is returned if the appropriate configuration can't be
-// determined (e.g., this does not appear to be a system node).
+// GetSystemNode returns a SystemNode for the given hostname. An error
+// is returned if the appropriate configuration can't be determined
+// (e.g., this does not appear to be a system node).
 func (cc *Cluster) GetSystemNode(node string) (*SystemNode, error) {
        if cfg, ok := cc.SystemNodes[node]; ok {
                return &cfg, nil
@@ -76,14 +90,30 @@ func (cc *Cluster) GetSystemNode(node string) (*SystemNode, error) {
 }
 
 type SystemNode struct {
-       Health    Health
-       Keepstore Keepstore
+       Health      SystemServiceInstance `json:"arvados-health"`
+       Keepproxy   SystemServiceInstance `json:"keepproxy"`
+       Keepstore   SystemServiceInstance `json:"keepstore"`
+       Keepweb     SystemServiceInstance `json:"keep-web"`
+       Nodemanager SystemServiceInstance `json:"arvados-node-manager"`
+       RailsAPI    SystemServiceInstance `json:"arvados-api-server"`
+       Websocket   SystemServiceInstance `json:"arvados-ws"`
+       Workbench   SystemServiceInstance `json:"arvados-workbench"`
 }
 
-type Health struct {
-       Listen string
+// ServicePorts returns the configured listening address (or "" if
+// disabled) for each service on the node.
+func (sn *SystemNode) ServicePorts() map[string]string {
+       return map[string]string{
+               "arvados-api-server":   sn.RailsAPI.Listen,
+               "arvados-node-manager": sn.Nodemanager.Listen,
+               "arvados-workbench":    sn.Workbench.Listen,
+               "arvados-ws":           sn.Websocket.Listen,
+               "keep-web":             sn.Keepweb.Listen,
+               "keepproxy":            sn.Keepproxy.Listen,
+               "keepstore":            sn.Keepstore.Listen,
+       }
 }
 
-type Keepstore struct {
+type SystemServiceInstance struct {
        Listen string
 }