-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add network options with cluster + teleporter deploy cmd * fix e2e v1 * point to correct branch * increase time of cli setup from source for e2e * force 10 min cli setup from source if e2e * lint * add basic relayer commands * partial work * awm relayer host selection working * nits * add cchain teleporter info to cluster * nits * nits * partial work * nits * almost * relayer working * nits * all good except receipt * add -y flag to node destroy * nit * add clusters to key list network options * add flag to key list to have a shortest way to specify chains to show info about * add tx hash for failed msg at destination * partial work * bump golang * add trace to teleporter msg is receipt status is wrong * enable first creating a subnet then creating a blockchain * improve add subnet validators speed * nit * seems pretty well * seems pretty weel * add proposer vm setup simil teleporter e2e * just create subnet/blockchain on one subnet deploy * working! * nit * nit * nit * nit * subnet join to not fail if blockchain was not deployed yet * local stop almost working * nit * start accessing node related functions from teleportercmd * basic remote start/stop without check for process status * add node lib * disable cli setup from source * nit * nit * lint * address PR comments * addres PR comments
- Loading branch information
1 parent
15d0746
commit 690e734
Showing
6 changed files
with
259 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
package teleportercmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ava-labs/avalanche-cli/pkg/models" | ||
"github.com/ava-labs/avalanche-cli/pkg/networkoptions" | ||
"github.com/ava-labs/avalanche-cli/pkg/node" | ||
"github.com/ava-labs/avalanche-cli/pkg/ssh" | ||
"github.com/ava-labs/avalanche-cli/pkg/teleporter" | ||
"github.com/ava-labs/avalanche-cli/pkg/ux" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var startRelayerNetworkOptions = []networkoptions.NetworkOption{networkoptions.Local, networkoptions.Cluster} | ||
|
||
// avalanche teleporter relayer start | ||
func newStartRelayerCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "starts AWM relayer", | ||
Long: `Starts AWM relayer on the specified network (Currently only for local network).`, | ||
SilenceUsage: true, | ||
RunE: startRelayer, | ||
Args: cobra.ExactArgs(0), | ||
} | ||
networkoptions.AddNetworkFlagsToCmd(cmd, &globalNetworkFlags, true, startRelayerNetworkOptions) | ||
return cmd | ||
} | ||
|
||
func startRelayer(_ *cobra.Command, _ []string) error { | ||
network, err := networkoptions.GetNetworkFromCmdLineFlags( | ||
app, | ||
globalNetworkFlags, | ||
false, | ||
startRelayerNetworkOptions, | ||
"", | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
switch { | ||
case network.Kind == models.Local: | ||
if relayerIsUp, _, _, err := teleporter.RelayerIsUp( | ||
app.GetAWMRelayerRunPath(), | ||
); err != nil { | ||
return err | ||
} else if relayerIsUp { | ||
return fmt.Errorf("local AWM relayer is already running") | ||
} | ||
if err := teleporter.DeployRelayer( | ||
app.GetAWMRelayerBinDir(), | ||
app.GetAWMRelayerConfigPath(), | ||
app.GetAWMRelayerLogPath(), | ||
app.GetAWMRelayerRunPath(), | ||
app.GetAWMRelayerStorageDir(), | ||
); err != nil { | ||
return err | ||
} | ||
ux.Logger.GreenCheckmarkToUser("Local AWM Relayer successfully started") | ||
ux.Logger.PrintToUser("Logs can be found at %s", app.GetAWMRelayerLogPath()) | ||
case network.ClusterName != "": | ||
host, err := node.GetAWMRelayerHost(app, network.ClusterName) | ||
if err != nil { | ||
return err | ||
} | ||
if err := ssh.RunSSHStartAWMRelayerService(host); err != nil { | ||
return err | ||
} | ||
ux.Logger.GreenCheckmarkToUser("Remote AWM Relayer on %s successfully started", host.GetCloudID()) | ||
} | ||
return nil | ||
} |
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,74 @@ | ||
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
package teleportercmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ava-labs/avalanche-cli/pkg/models" | ||
"github.com/ava-labs/avalanche-cli/pkg/networkoptions" | ||
"github.com/ava-labs/avalanche-cli/pkg/node" | ||
"github.com/ava-labs/avalanche-cli/pkg/ssh" | ||
"github.com/ava-labs/avalanche-cli/pkg/teleporter" | ||
"github.com/ava-labs/avalanche-cli/pkg/ux" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var stopRelayerNetworkOptions = []networkoptions.NetworkOption{networkoptions.Local, networkoptions.Cluster} | ||
|
||
// avalanche teleporter relayer stop | ||
func newStopRelayerCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "stop", | ||
Short: "stops AWM relayer", | ||
Long: `Stops AWM relayer on the specified network (Currently only for local network, cluster).`, | ||
SilenceUsage: true, | ||
RunE: stopRelayer, | ||
Args: cobra.ExactArgs(0), | ||
} | ||
networkoptions.AddNetworkFlagsToCmd(cmd, &globalNetworkFlags, true, stopRelayerNetworkOptions) | ||
return cmd | ||
} | ||
|
||
func stopRelayer(_ *cobra.Command, _ []string) error { | ||
network, err := networkoptions.GetNetworkFromCmdLineFlags( | ||
app, | ||
globalNetworkFlags, | ||
false, | ||
stopRelayerNetworkOptions, | ||
"", | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
switch { | ||
case network.Kind == models.Local: | ||
b, _, _, err := teleporter.RelayerIsUp( | ||
app.GetAWMRelayerRunPath(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if !b { | ||
return fmt.Errorf("there is no CLI-managed local AWM relayer running") | ||
} | ||
if err := teleporter.RelayerCleanup( | ||
app.GetAWMRelayerRunPath(), | ||
app.GetAWMRelayerStorageDir(), | ||
); err != nil { | ||
return err | ||
} | ||
ux.Logger.GreenCheckmarkToUser("Local AWM Relayer successfully stopped") | ||
case network.ClusterName != "": | ||
host, err := node.GetAWMRelayerHost(app, network.ClusterName) | ||
if err != nil { | ||
return err | ||
} | ||
if err := ssh.RunSSHStopAWMRelayerService(host); err != nil { | ||
return err | ||
} | ||
ux.Logger.GreenCheckmarkToUser("Remote AWM Relayer on %s successfully stopped", host.GetCloudID()) | ||
} | ||
return nil | ||
} |
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,47 @@ | ||
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
package node | ||
|
||
import ( | ||
"github.com/ava-labs/avalanche-cli/pkg/ansible" | ||
"github.com/ava-labs/avalanche-cli/pkg/application" | ||
"github.com/ava-labs/avalanche-cli/pkg/models" | ||
"github.com/ava-labs/avalanche-cli/pkg/utils" | ||
) | ||
|
||
func GetHostWithCloudID(app *application.Avalanche, clusterName string, cloudID string) (*models.Host, error) { | ||
hosts, err := ansible.GetInventoryFromAnsibleInventoryFile(app.GetAnsibleInventoryDirPath(clusterName)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
monitoringInventoryFile := app.GetMonitoringInventoryDir(clusterName) | ||
if utils.FileExists(monitoringInventoryFile) { | ||
monitoringHosts, err := ansible.GetInventoryFromAnsibleInventoryFile(monitoringInventoryFile) | ||
if err != nil { | ||
return nil, err | ||
} | ||
hosts = append(hosts, monitoringHosts...) | ||
} | ||
for _, host := range hosts { | ||
if host.GetCloudID() == cloudID { | ||
return host, nil | ||
} | ||
} | ||
return nil, nil | ||
} | ||
|
||
func GetAWMRelayerHost(app *application.Avalanche, clusterName string) (*models.Host, error) { | ||
clusterConfig, err := app.GetClusterConfig(clusterName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
relayerCloudID := "" | ||
for _, cloudID := range clusterConfig.GetCloudIDs() { | ||
if nodeConfig, err := app.LoadClusterNodeConfig(cloudID); err != nil { | ||
return nil, err | ||
} else if nodeConfig.IsAWMRelayer { | ||
relayerCloudID = nodeConfig.NodeID | ||
} | ||
} | ||
return GetHostWithCloudID(app, clusterName, relayerCloudID) | ||
} |
Oops, something went wrong.