vagrant-winrmcli 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40cc973fee7770692b38aa5b8dbbbd1e36980b75
4
+ data.tar.gz: fbc9fa1938213f410527cea62df836ef0a7dfafa
5
+ SHA512:
6
+ metadata.gz: 4e6edda30673b7d4fee6c5f590b3c3200ac462a2df2a8148025520deecd14cc005c57f23b8843b873e6dc8a89b3db4b59b2ece95905ca821b3228377a94001dc
7
+ data.tar.gz: 175650a98417545c0e4cea612c665fc5ca6f8ad24eeef1f4c11b5454a25f0ff0db014e84163f1b6ac81d117fd14352a9f5fafad48b6d67c706dd9ec154093ad8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "winrm"
4
+
5
+ # Specify your gem's dependencies in vagrant-winrm.gemspec
6
+ group :development do
7
+ # We depend on Vagrant for development, but we don't add it as a
8
+ # gem dependency because we expect to be installed within the
9
+ # Vagrant environment itself using `vagrant plugin`.
10
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
11
+ end
12
+
13
+ group :plugins do
14
+ gem "vagrant-winrmcli", path: "."
15
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Tim Cameron Ryan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Vagrant::Winrm::Cli::Plugin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'vagrant-winrm-cli-plugin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install vagrant-winrm-cli-plugin
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,75 @@
1
+ require 'winrm'
2
+ require 'json'
3
+
4
+ module VagrantPlugins
5
+ module WinrmCli
6
+ class Command < Vagrant.plugin(2, :command)
7
+
8
+ def self.synopsis
9
+ 'connects to a machine via WinRM'
10
+ end
11
+
12
+ def execute
13
+ mode = parse_args
14
+
15
+ endpoint = "https://104.197.0.231:5986/wsman"
16
+ username = "tim"
17
+ password = "($*rh28HS48!"
18
+
19
+ # Execute the actual SSH
20
+ with_target_vms(nil, single_target: true) do |vm|
21
+ username = vm.config.winrm.username
22
+ password = vm.config.winrm.password
23
+ port = vm.config.winrm.port
24
+ host = vm.driver.read_guest_bridged_ip
25
+ endpoint = 'https://' + host.to_s + ':' + port.to_s + '/wsman'
26
+ winrm = WinRM::WinRMWebService.new(endpoint, :ssl, :user => username, :pass => password, :basic_auth_only => true, :no_ssl_peer_verification => true)
27
+ while true do
28
+ cmd = @env.ui.ask "PS> "
29
+ if mode == 'ps'
30
+ cmd = 'PowerShell -Command "& {' + cmd.strip.to_json + '}"'
31
+ else
32
+ cmd = cmd.strip
33
+ end
34
+ winrm.cmd(cmd) do |stdout, stderr|
35
+ STDOUT.print stdout
36
+ STDERR.print stderr
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def parse_args
45
+ opts = OptionParser.new do |o|
46
+ o.banner = 'Usage: vagrant winrm [options]'
47
+ o.separator ''
48
+
49
+ o.on('-h', '--help', 'Print this help') do
50
+ safe_puts(opts.help)
51
+ end
52
+
53
+ o.on('--cmd', 'Runs commands in cmd.exe instead of powershell')
54
+ end
55
+
56
+ argv = split_main_and_subcommand(@argv.dup)
57
+ exec_args, cmd, cmd_args = argv[0], argv[1], argv[2]
58
+
59
+ # # generate binstubs
60
+ if exec_args.include?('--cmd')
61
+ return 'cmd'
62
+ end
63
+
64
+ # # show help
65
+ if exec_args.any? { |a| a == '-h' || a == '--help' }
66
+ safe_puts(opts.help)
67
+ return nil
68
+ end
69
+
70
+ return 'ps'
71
+ end
72
+
73
+ end # Command
74
+ end # Exec
75
+ end # VagrantPlugins
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module WinrmCli
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "Vagrant WinRM CLI Plugin"
5
+ description 'Plugin allows to execute commands within the context of synced folder.'
6
+
7
+ command "winrm" do
8
+ require_relative "command"
9
+ Command
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module WinrmCli
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'vagrant'
2
+
3
+ require 'vagrant-winrmcli/plugin'
4
+ require 'vagrant-winrmcli/command'
5
+ require 'vagrant-winrmcli/version'
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'vagrant-winrmcli/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "vagrant-winrmcli"
7
+ gem.version = VagrantPlugins::WinrmCli::VERSION
8
+ gem.authors = ["Tim Cameron Ryan"]
9
+ gem.email = ["id@timryan.org"]
10
+ gem.description = "Allows winrm shell to Vagrant."
11
+ gem.summary = "Open a Vagrant shell into winrm."
12
+ gem.homepage = ""
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-winrmcli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tim Cameron Ryan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Allows winrm shell to Vagrant.
14
+ email:
15
+ - id@timryan.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/vagrant-winrmcli.rb
26
+ - lib/vagrant-winrmcli/command.rb
27
+ - lib/vagrant-winrmcli/plugin.rb
28
+ - lib/vagrant-winrmcli/version.rb
29
+ - vagrant-winrmcli.gemspec
30
+ homepage: ''
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.4.5
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Open a Vagrant shell into winrm.
53
+ test_files: []