pantry-exec 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +16 -0
- data/Gemfile +14 -0
- data/LICENSE +20 -0
- data/README.md +38 -0
- data/Rakefile +8 -0
- data/lib/pantry/exec/command.rb +38 -0
- data/lib/pantry/exec/version.rb +5 -0
- data/lib/pantry/init.rb +7 -0
- data/pantry-exec.gemspec +24 -0
- data/test/execute_command_test.rb +17 -0
- data/test/test_helper.rb +5 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d6f9fd948bdd94194236feb0b0481a4317725bc3
|
4
|
+
data.tar.gz: 96c7a1754853cfd3c488adef7e462d71758f533b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 69b4473c85e133dc7a5065b344a7090f2e6baa7707368c396e96d01f37db803833d58d968fc9393c51fb9dbbe3fc9d93e0850ffe15dae4ffd13f9c6c279bbb08
|
7
|
+
data.tar.gz: 419c1081be9915609ece61b763fa404ab47fd05de030ad68aabb758e4e8b8f764a56267a5dfd3d7395b56f34b2e99e953d4dd40d5e2176412085d0efa24f7482
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
before_install:
|
2
|
+
- travis_retry sudo apt-add-repository ppa:bpaquet/zeromq4-precise -y
|
3
|
+
- travis_retry sudo apt-get update
|
4
|
+
- travis_retry sudo apt-get install libzmq-dev -y
|
5
|
+
language: ruby
|
6
|
+
rvm:
|
7
|
+
- 2.0.0
|
8
|
+
- 2.1.0
|
9
|
+
- ruby-head
|
10
|
+
cache:
|
11
|
+
- bundler
|
12
|
+
- apt
|
13
|
+
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Collective Idea
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Pantry Exec
|
2
|
+
|
3
|
+
[](https://travis-ci.org/pantry/pantry-exec) [](https://codeclimate.com/github/pantry/pantry-exec)
|
4
|
+
|
5
|
+
Pantry Exec is a plugin for [Pantry](pantryops.org) that allows running shell commands on a Pantry Client.
|
6
|
+
|
7
|
+
## WARNING
|
8
|
+
|
9
|
+
**This command runs any shell command as the user running Pantry Client**
|
10
|
+
|
11
|
+
**This is a standalone Command because it is DANGEROUS, but useful**
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Install the plugin on all nodes in the Pantry network:
|
16
|
+
|
17
|
+
gem install pantry-exec
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
pantry exec COMMAND [ARGUMENTS]
|
22
|
+
|
23
|
+
## Project Details
|
24
|
+
|
25
|
+
* Built and Maintained by [Collective Idea](http://collectiveidea.com)
|
26
|
+
* Hosted on Github [pantry/pantry-exec](https://github.com/pantry/pantry-exec)
|
27
|
+
* File bug reports on the [Issue tracker](https://github.com/pantry/pantry-exec/issues)
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
* Fork this repository on Github
|
32
|
+
* Make your changes and send us a Pull Request
|
33
|
+
* All Pull Requests must contain tests
|
34
|
+
* Pull Request tests must pass before being accepted
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
Pantry Exec is distributed under the MIT License. See LICENSE for more details.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Pantry
|
2
|
+
module Exec
|
3
|
+
# Execute a Shell command, returning STDOUT, STDERR, and the status code.
|
4
|
+
# Executes as the user the Pantry Client is running under.
|
5
|
+
class Command < Pantry::Command
|
6
|
+
|
7
|
+
command "exec COMMAND [ARGUMENTS]" do
|
8
|
+
description "
|
9
|
+
Run the given COMMAND (and its ARGUMENTS) on the chosen Pantry Clients.
|
10
|
+
"
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(*command_and_args)
|
14
|
+
@command_and_args = command_and_args
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_message
|
18
|
+
message = super
|
19
|
+
message << @command_and_args
|
20
|
+
message
|
21
|
+
end
|
22
|
+
|
23
|
+
def perform(message)
|
24
|
+
command_and_args = message.body[0]
|
25
|
+
stdout, stderr, status = Open3.capture3(*command_and_args)
|
26
|
+
[stdout, stderr, status.to_i]
|
27
|
+
end
|
28
|
+
|
29
|
+
def receive_client_response(response)
|
30
|
+
stdout, stderr, status = response.body
|
31
|
+
Pantry.ui.say("From #{response.from}")
|
32
|
+
Pantry.ui.say(stdout)
|
33
|
+
Pantry.ui.say(stderr)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/pantry/init.rb
ADDED
data/pantry-exec.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "pantry/exec/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "pantry-exec"
|
6
|
+
s.version = Pantry::Exec::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Collective Idea", "Jason Roelofs"]
|
9
|
+
s.email = ["code@collectiveidea.com", "jasongroelofs@gmail.com"]
|
10
|
+
s.license = "MIT"
|
11
|
+
s.homepage = "http://pantryops.org/"
|
12
|
+
|
13
|
+
s.summary = "Run arbitrary shell commands on a Pantry Client."
|
14
|
+
s.description = "Run arbitrary shell commands on a Pantry Client."
|
15
|
+
|
16
|
+
s.required_ruby_version = ">= 2.0.0"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
|
+
s.require_path = "lib"
|
21
|
+
s.bindir = "bin"
|
22
|
+
|
23
|
+
s.add_runtime_dependency "pantry", "~> 0.1", ">= 0.1.0"
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe "Executing the shell command on Clients" do
|
4
|
+
mock_ui!
|
5
|
+
|
6
|
+
it "asks a client for the output (stdout, stderr, and status) of a given command" do
|
7
|
+
set_up_environment(ports_start_at: 11000)
|
8
|
+
|
9
|
+
Pantry::CLI.new(
|
10
|
+
%w(-a pantry exec hostname),
|
11
|
+
identity: "CLI1"
|
12
|
+
).run
|
13
|
+
|
14
|
+
assert_match %r|#{@client1.identity}\n#{`hostname`.strip}|, stdout
|
15
|
+
assert_match %r|#{@client2.identity}\n#{`hostname`.strip}|, stdout
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pantry-exec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Collective Idea
|
8
|
+
- Jason Roelofs
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pantry
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.1'
|
21
|
+
- - '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.0
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.1'
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
description: Run arbitrary shell commands on a Pantry Client.
|
35
|
+
email:
|
36
|
+
- code@collectiveidea.com
|
37
|
+
- jasongroelofs@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- .gitignore
|
43
|
+
- .travis.yml
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- lib/pantry/exec/command.rb
|
49
|
+
- lib/pantry/exec/version.rb
|
50
|
+
- lib/pantry/init.rb
|
51
|
+
- pantry-exec.gemspec
|
52
|
+
- test/execute_command_test.rb
|
53
|
+
- test/test_helper.rb
|
54
|
+
homepage: http://pantryops.org/
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.0.0
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.2.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Run arbitrary shell commands on a Pantry Client.
|
78
|
+
test_files:
|
79
|
+
- test/execute_command_test.rb
|
80
|
+
- test/test_helper.rb
|