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

Commit

Permalink
[qctl] support listing (nodeport) p2p url. (#103)
Browse files Browse the repository at this point in the history
qctl ls urls --type nodeport --p2p

This is useful for multi-cluster as a reachable p2p URL needs to be
easily obtained.
  • Loading branch information
libby authored Oct 27, 2020
1 parent 2e84a35 commit 2a698a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion qctl/srvcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ var (
Name: "tm",
Usage: "only show the transaction manager URL ",
},
&cli.BoolFlag{
Name: "p2p",
Usage: "only show the p2p URL ",
},
&cli.BoolFlag{
Name: "bare",
Aliases: []string{"b"},
Expand All @@ -61,10 +65,12 @@ var (
isBare := c.Bool("bare")
isGeth := c.Bool("geth")
isTm := c.Bool("tm")
isP2P := c.Bool("p2p")
// if neither geth nor tm flag are set, default to setting both to true
if !isGeth && !isTm {
if !isGeth && !isTm && !isP2P {
isGeth = true
isTm = true
isP2P = true
}

configFile := c.String("config")
Expand Down Expand Up @@ -129,6 +135,9 @@ var (
if isTm {
fmt.Println(nodeIp + ":" + nodeServiceInfo.NodePortTm)
}
if isP2P {
fmt.Println(nodeIp + ":" + nodeServiceInfo.NodePortP2P)
}
} else if urlType == "clusterip" { // the internal IP:Port of the specified node(s)
if isGeth {
fmt.Println(nodeServiceInfo.ClusterIPGethURL)
Expand All @@ -145,6 +154,9 @@ var (
if isTm {
fmt.Println(serviceName + " tessera - " + nodeIp + ":" + nodeServiceInfo.NodePortTm)
}
if isP2P {
fmt.Println(serviceName + " p2p - " + nodeIp + ":" + nodeServiceInfo.NodePortP2P)
}
} else if urlType == "clusterip" { // the internal IP:Port of the specified node(s)
if isGeth {
fmt.Println(serviceName + " geth - " + nodeServiceInfo.ClusterIPGethURL)
Expand All @@ -170,6 +182,7 @@ type NodeServiceInfo struct {

NodePortGeth string
NodePortTm string
NodePortP2P string
NodePortCakeshop string
NodePortPrometheus string
}
Expand Down Expand Up @@ -197,8 +210,10 @@ func serviceInfoByPrefix(prefix, urlType, namespace string) NodeServiceInfo {
if strings.ToLower(urlType) == strings.ToLower(ServiceTypeNodePort) {
nodePortGeth := nodePortFormClusterPort(srvOut, DefaultGethPort)
nodePortTessera := nodePortFormClusterPort(srvOut, DefaultTesseraPort)
nodePortP2P := nodePortFormClusterPort(srvOut, DefaultP2PPort)
nodeServiceInfo.NodePortGeth = nodePortGeth
nodeServiceInfo.NodePortTm = nodePortTessera
nodeServiceInfo.NodePortP2P = nodePortP2P
} else if strings.ToLower(urlType) == strings.ToLower(ServiceTypeClusterIP) { // the internal IP:Port of the specified node(s)
clusterIp := clusterIpForService(srvOut)
nodeServiceInfo.ClusterIP = clusterIp
Expand Down
1 change: 1 addition & 0 deletions qctl/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (

DefaultGethPort = "8545"
DefaultTesseraPort = "9080"
DefaultP2PPort = "30303"

DefaultPrometheusClusterPort = "9090"
DefaultPrometheusNodePort = "31323"
Expand Down

0 comments on commit 2a698a0

Please sign in to comment.