Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new skywire visor flag #1113

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.7.0

### Changed


### Added
- added `add-rhv` and `disable-rhv` flags to `skywire-visor` for adding remote hypervisor PK and disable remote hypervisor PK(s) on config file

## 0.6.0

### Changed
Expand Down
42 changes: 32 additions & 10 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/pkg/profile"
"github.com/skycoin/dmsg/buildinfo"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/cmdutil"
"github.com/skycoin/skycoin/src/util/logging"
"github.com/spf13/cobra"
Expand All @@ -41,16 +42,18 @@ const (
)

var (
tag string
syslogAddr string
pprofMode string
pprofAddr string
confPath string
delay string
launchBrowser bool
hypervisorUI bool
stopVisorFn func() // nolint:unused
stopVisorWg sync.WaitGroup
tag string
syslogAddr string
pprofMode string
pprofAddr string
confPath string
delay string
launchBrowser bool
hypervisorUI bool
remoteHypervisorPKs string
disableHypervisorPKs bool
stopVisorFn func() // nolint:unused
stopVisorWg sync.WaitGroup
)

var rootCmd = &cobra.Command{
Expand All @@ -72,6 +75,8 @@ func init() {
rootCmd.Flags().StringVar(&delay, "delay", "0ns", "start delay (deprecated)") // deprecated
rootCmd.Flags().BoolVarP(&hypervisorUI, "with-hypervisor-ui", "f", false, "run visor with hypervisor UI config.")
rootCmd.Flags().BoolVar(&launchBrowser, "launch-browser", false, "open hypervisor web ui (hypervisor only) with system browser")
rootCmd.Flags().StringVar(&remoteHypervisorPKs, "add-rhv", "", "add remote hypervisor PKs in runtime")
rootCmd.Flags().BoolVar(&disableHypervisorPKs, "disable-rhv", false, "disable remote hypervisor PKs on config file")
extraFlags()
}

Expand Down Expand Up @@ -128,6 +133,23 @@ func runVisor(args []string) {
conf.Flush() //nolint
}

if disableHypervisorPKs {
conf.Hypervisors = []cipher.PubKey{}
}

if remoteHypervisorPKs != "" {
hypervisorPKsSlice := strings.Split(remoteHypervisorPKs, ",")
for _, pubkeyString := range hypervisorPKsSlice {
pubkey := cipher.PubKey{}
if err := pubkey.Set(pubkeyString); err != nil {
log.Warnf("Cannot add %s PK as remote hypervisor PK due to: %s", pubkeyString, err)
continue
}
log.Infof("%s PK added as remote hypervisor PK", pubkeyString)
conf.Hypervisors = append(conf.Hypervisors, pubkey)
}
}

vis, ok := visor.NewVisor(conf, restartCtx)
if !ok {
log.Errorln("Failed to start visor.")
Expand Down