chef-winrm-fs 1.4.1 → 1.4.4
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 +4 -4
- data/LICENSE +202 -202
- data/README.md +87 -82
- data/bin/rwinrmcp +87 -87
- data/lib/chef-winrm-fs/core/file_transporter.rb +575 -573
- data/lib/chef-winrm-fs/core/tmp_zip.rb +176 -178
- data/lib/chef-winrm-fs/exceptions.rb +29 -29
- data/lib/chef-winrm-fs/file_manager.rb +193 -171
- data/lib/chef-winrm-fs/scripts/check_files.ps1.erb +49 -49
- data/lib/chef-winrm-fs/scripts/checksum.ps1.erb +13 -13
- data/lib/chef-winrm-fs/scripts/create_dir.ps1.erb +6 -6
- data/lib/chef-winrm-fs/scripts/delete.ps1.erb +6 -6
- data/lib/chef-winrm-fs/scripts/download.ps1.erb +17 -17
- data/lib/chef-winrm-fs/scripts/exists.ps1.erb +10 -10
- data/lib/chef-winrm-fs/scripts/extract_files.ps1.erb +52 -52
- data/lib/chef-winrm-fs/scripts/scripts.rb +54 -47
- data/lib/chef-winrm-fs.rb +28 -29
- metadata +8 -8
data/bin/rwinrmcp
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Copyright 2014 Shawn Neal <sneal@sneal.net>
|
|
6
|
-
#
|
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
# you may not use this file except in compliance with the License.
|
|
9
|
-
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
# See the License for the specific language governing permissions and
|
|
17
|
-
# limitations under the License.
|
|
18
|
-
|
|
19
|
-
# TODO: refactor this
|
|
20
|
-
# rubocop:disable all
|
|
21
|
-
|
|
22
|
-
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
|
23
|
-
|
|
24
|
-
require 'io/console'
|
|
25
|
-
require 'chef-winrm-fs'
|
|
26
|
-
|
|
27
|
-
def help_msg
|
|
28
|
-
puts 'Usage: rwinrmcp sourcefile user@host:directory/targetfile'
|
|
29
|
-
puts ''
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def parse_options
|
|
33
|
-
options = {}
|
|
34
|
-
fail 'Missing required options' unless ARGV.length == 2
|
|
35
|
-
|
|
36
|
-
options[:source_path] = ARGV[0]
|
|
37
|
-
fail "Cannot find source file: #{options[:source_path]}" unless \
|
|
38
|
-
File.exist?(options[:source_path])
|
|
39
|
-
|
|
40
|
-
m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?:{1}(?<file>.+)/i.match(ARGV[1])
|
|
41
|
-
fail "#{ARGV[1]} is an invalid destination" unless m
|
|
42
|
-
options[:user] = m[:user]
|
|
43
|
-
options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
|
|
44
|
-
options[:dest_path] = m[:file]
|
|
45
|
-
|
|
46
|
-
# Get the password
|
|
47
|
-
print 'Password: '
|
|
48
|
-
options[:pass] = STDIN.noecho(&:gets).chomp
|
|
49
|
-
puts
|
|
50
|
-
|
|
51
|
-
# Set some defaults required by WinRM WS
|
|
52
|
-
options[:auth_type] = :plaintext
|
|
53
|
-
options[:basic_auth_only] = true
|
|
54
|
-
|
|
55
|
-
options
|
|
56
|
-
rescue StandardError => e
|
|
57
|
-
puts e.message
|
|
58
|
-
help_msg
|
|
59
|
-
exit 1
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def file_manager(options)
|
|
63
|
-
service = WinRM::WinRMWebService.new(
|
|
64
|
-
options[:endpoint],
|
|
65
|
-
options[:auth_type].to_sym,
|
|
66
|
-
options)
|
|
67
|
-
WinRM::FS::FileManager.new(service)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def run(options)
|
|
71
|
-
bytes = file_manager(options).upload(options[:source_path], options[:dest_path])
|
|
72
|
-
puts "#{bytes} total bytes transfered"
|
|
73
|
-
exit 0
|
|
74
|
-
rescue Interrupt
|
|
75
|
-
puts 'exiting'
|
|
76
|
-
# ctrl-c
|
|
77
|
-
rescue WinRM::WinRMAuthorizationError
|
|
78
|
-
puts 'Authentication failed, bad user name or password'
|
|
79
|
-
exit 1
|
|
80
|
-
rescue StandardError => e
|
|
81
|
-
puts e.message
|
|
82
|
-
exit 1
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
run(parse_options)
|
|
86
|
-
|
|
87
|
-
# rubocop:enable all
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2014 Shawn Neal <sneal@sneal.net>
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
|
|
19
|
+
# TODO: refactor this
|
|
20
|
+
# rubocop:disable all
|
|
21
|
+
|
|
22
|
+
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
|
23
|
+
|
|
24
|
+
require 'io/console'
|
|
25
|
+
require 'chef-winrm-fs'
|
|
26
|
+
|
|
27
|
+
def help_msg
|
|
28
|
+
puts 'Usage: rwinrmcp sourcefile user@host:directory/targetfile'
|
|
29
|
+
puts ''
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def parse_options
|
|
33
|
+
options = {}
|
|
34
|
+
fail 'Missing required options' unless ARGV.length == 2
|
|
35
|
+
|
|
36
|
+
options[:source_path] = ARGV[0]
|
|
37
|
+
fail "Cannot find source file: #{options[:source_path]}" unless \
|
|
38
|
+
File.exist?(options[:source_path])
|
|
39
|
+
|
|
40
|
+
m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?:{1}(?<file>.+)/i.match(ARGV[1])
|
|
41
|
+
fail "#{ARGV[1]} is an invalid destination" unless m
|
|
42
|
+
options[:user] = m[:user]
|
|
43
|
+
options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
|
|
44
|
+
options[:dest_path] = m[:file]
|
|
45
|
+
|
|
46
|
+
# Get the password
|
|
47
|
+
print 'Password: '
|
|
48
|
+
options[:pass] = STDIN.noecho(&:gets).chomp
|
|
49
|
+
puts
|
|
50
|
+
|
|
51
|
+
# Set some defaults required by WinRM WS
|
|
52
|
+
options[:auth_type] = :plaintext
|
|
53
|
+
options[:basic_auth_only] = true
|
|
54
|
+
|
|
55
|
+
options
|
|
56
|
+
rescue StandardError => e
|
|
57
|
+
puts e.message
|
|
58
|
+
help_msg
|
|
59
|
+
exit 1
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def file_manager(options)
|
|
63
|
+
service = WinRM::WinRMWebService.new(
|
|
64
|
+
options[:endpoint],
|
|
65
|
+
options[:auth_type].to_sym,
|
|
66
|
+
options)
|
|
67
|
+
WinRM::FS::FileManager.new(service)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def run(options)
|
|
71
|
+
bytes = file_manager(options).upload(options[:source_path], options[:dest_path])
|
|
72
|
+
puts "#{bytes} total bytes transfered"
|
|
73
|
+
exit 0
|
|
74
|
+
rescue Interrupt
|
|
75
|
+
puts 'exiting'
|
|
76
|
+
# ctrl-c
|
|
77
|
+
rescue WinRM::WinRMAuthorizationError
|
|
78
|
+
puts 'Authentication failed, bad user name or password'
|
|
79
|
+
exit 1
|
|
80
|
+
rescue StandardError => e
|
|
81
|
+
puts e.message
|
|
82
|
+
exit 1
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
run(parse_options)
|
|
86
|
+
|
|
87
|
+
# rubocop:enable all
|