Socket
Socket
Sign inDemoInstall

github.com/contiv/remotessh

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/contiv/remotessh

Package remotessh provides host connectivity in go for system/integration testing in a multi host environment. It supports two testbed environments viz. baremetal and vagrant Use this library to do remote testing with baremetal or vagrant nodes. For example, To setup a baremetal setup with a host node with ssh reachability '1.2.3.4' and port '22' for user 'foo', you can initialize the setup as: Or to auto connect to a vagrant based setup you can initialize the setup as: Once you have your favorite setup initialized, this will select the "mynode" node and run "ls" on it. If you want to walk nodes, you have a few options: Sequentially: In Parallel: Copyright 2014 Cisco Systems Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Version published

Readme

Source

remotessh: Test your remote files through SSH with a simple library.

godoc is here

Use this library to do remote testing of vagrant nodes.

For example, this will select the "mynode" node and run "ls" on it.

    vagrant := &Vagrant{}
    vagrant.Setup(false, "", 3) // 3 node cluster, do not run `vagrant up`.
    out, err := vagrant.GetNode("mynode").RunCommandWithOutput("ls")
    if err != nil {
      // exit status != 0
      panic(err)
    }

    fmt.Println(out) // already a string

Similarly for a Baremetal node:

hosts := []HostInfo{
		{
			Name:        "self",
			SSHAddr:     "127.0.0.1",
			SSHPort:     "22",
			User:        "vagrant",
			PrivKeyFile: "/vagrant/testdata/insecure_private_key",
		},
		{
			Name:        "self1",
			SSHAddr:     "127.0.0.1",
			SSHPort:     "22",
			User:        "vagrant",
			PrivKeyFile: "/vagrant/testdata/insecure_private_key",
		},
	}
	bm := &Baremetal{}
	c.Assert(bm.Setup(hosts), IsNil)
    out, err := bm.GetNode("mynode").RunCommandWithOutput("ls")
    if err != nil {
      // exit status != 0
      panic(err)
    }

    fmt.Println(out) // already a string

If you want to walk nodes, you have a few options:

Sequentially:

    vagrant := &remotessh.Vagrant{}
    vagrant.Setup(false, "", 3)
    for _, node := range vagrant.GetNodes() {
      node.RunCommand("something")
    }

In Parallel:

    vagrant := &remotessh.Vagrant{}
    vagrant.Setup(false, "", 3)
    err := vagrant.IterateNodes(func (node remotessh.TestbedNode) error {
      return node.RunCommand("docker ps -aq | xargs docker rm")
    })

    if err != nil {
      // one or more nodes failed
      panic(err)
    }

Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FAQs

Last updated on 30 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc