Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
[qctl] support external nodes (#106)
Browse files Browse the repository at this point in the history
* add external_nodes to configyaml used by qctl, so qctl can interact with it, 
   e.g. add, delete, ls
* add support for listing the external nodes in a network:
    > qctl ls extnodes --all
* add support for adding an external node:
  > qctl add extnode --enode="enode://[email protected]:7000" --tmurl=http://1.2.3.4:9000  --nodekeyaddr=0x1234334
*  add support deleting external nodes:
    >  qctl delete external-node
* allow the external_node `Node_Acct_Addr` field to be set to a hex without quotes
   or a string hex in the qubernetes yaml. If it is set as a hex without quotes, the hex value will 
   be converted to a BigNum, cover both cases in `istanbul-validator.toml.erb`. 
   the yaml parser (https://godoc.org/gopkg.in/yaml.v2) used does not preserve double 
   quotes around the hex  mikefarah/yq#19
  • Loading branch information
libby authored Oct 28, 2020
1 parent b52c09e commit b022f18
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 40 deletions.
16 changes: 14 additions & 2 deletions qctl/configyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
)

var (
Expand Down Expand Up @@ -48,6 +48,17 @@ type NodeEntry struct {
GethEntry GethEntry `yaml:"geth"`
}

type ExternalNodeEntry struct {
NodeUserIdent string `yaml:"Node_UserIdent"`
EnodeUrl string `yaml:"Enode_Url"`
TmUrl string `yaml:"Tm_Url"`
// must be set in the yaml without quotes.
// The hex number will be evaluted to a BigNum and
// template/istanbul-validator.toml.erb will convert back to hex
// https://github.com/mikefarah/yq/issues/19
NodekeyAddress string `yaml:"Node_Acct_Addr,omitempty"`
}

type Prometheus struct {
//#monitor_params_geth: --metrics --metrics.expensive --pprof --pprofaddr=0.0.0.0
//monitorParamsGeth string `yaml:"monitor_params_geth"`
Expand Down Expand Up @@ -87,7 +98,8 @@ type QConfig struct {
Cakeshop Cakeshop `yaml:"cakeshop,omitempty"`
K8s K8s `yaml:"k8s,omitempty"`

Nodes []NodeEntry
Nodes []NodeEntry
ExternalNodes []ExternalNodeEntry `yaml:"external_nodes,omitempty"`
}

func GetYamlConfig() QConfig {
Expand Down
10 changes: 5 additions & 5 deletions qctl/networkcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
Usage: "delete a quorum k8s network given the dir holding the k8s yaml resources.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "k8s-dir",
Name: "k8sdir",
Usage: "the path of the dir containing the K8s resource yaml.",
EnvVars: []string{"QUBE_K8S_DIR"},
Required: true,
Expand All @@ -32,7 +32,7 @@ var (
Usage: "create a quorum k8s network given the dir holding the k8s yaml resources.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "k8s-dir",
Name: "k8sdir",
Usage: "the path of the dir containing the K8s resource yaml.",
EnvVars: []string{"QUBE_K8S_DIR"},
Required: true,
Expand Down Expand Up @@ -74,7 +74,7 @@ var (
Usage: "list the status of the running network.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "k8s-dir",
Name: "k8sdir",
Usage: "the path of the dir containing the K8s resource yaml.",
EnvVars: []string{"QUBE_K8S_DIR"},
Required: true,
Expand Down Expand Up @@ -294,10 +294,10 @@ var (
)

func k8sCreateDeleteCluster(c *cli.Context, action string) error {
k8sdir := c.String("k8s-dir")
k8sdir := c.String("k8sdir")
// if the passed in k8s dir does not exit, tell the user and do not proceed.
if _, err := os.Stat(k8sdir); os.IsNotExist(err) {
log.Error("the --k8s-dir [%v] does not exist!", k8sdir)
log.Error("the --k8sdir [%v] does not exist!", k8sdir)
return err
}
namespace := c.String("namespace")
Expand Down
Loading

0 comments on commit b022f18

Please sign in to comment.