vagrant-hyperkit 0.4.3

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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +20 -0
  5. data/Gemfile +14 -0
  6. data/LICENSE +9 -0
  7. data/README.md +221 -0
  8. data/Rakefile +22 -0
  9. data/lib/vagrant-hyperkit.rb +22 -0
  10. data/lib/vagrant-hyperkit/action.rb +195 -0
  11. data/lib/vagrant-hyperkit/action/boot.rb +185 -0
  12. data/lib/vagrant-hyperkit/action/import.rb +69 -0
  13. data/lib/vagrant-hyperkit/action/is_created.rb +18 -0
  14. data/lib/vagrant-hyperkit/action/is_stopped.rb +18 -0
  15. data/lib/vagrant-hyperkit/action/message_already_created.rb +16 -0
  16. data/lib/vagrant-hyperkit/action/message_not_created.rb +16 -0
  17. data/lib/vagrant-hyperkit/action/message_will_not_destroy.rb +16 -0
  18. data/lib/vagrant-hyperkit/action/read_ssh_info.rb +27 -0
  19. data/lib/vagrant-hyperkit/action/read_state.rb +53 -0
  20. data/lib/vagrant-hyperkit/action/stop_instance.rb +49 -0
  21. data/lib/vagrant-hyperkit/action/terminate_instance.rb +31 -0
  22. data/lib/vagrant-hyperkit/action/timed_provision.rb +21 -0
  23. data/lib/vagrant-hyperkit/action/wait_for_state.rb +41 -0
  24. data/lib/vagrant-hyperkit/config.rb +83 -0
  25. data/lib/vagrant-hyperkit/errors.rb +19 -0
  26. data/lib/vagrant-hyperkit/plugin.rb +73 -0
  27. data/lib/vagrant-hyperkit/provider.rb +67 -0
  28. data/lib/vagrant-hyperkit/util/timer.rb +17 -0
  29. data/lib/vagrant-hyperkit/util/vagrant-hyperkit.rb +79 -0
  30. data/lib/vagrant-hyperkit/version.rb +5 -0
  31. data/locales/en.yml +83 -0
  32. data/spec/spec_helper.rb +1 -0
  33. data/spec/vagrant-hyperkit/config_spec.rb +33 -0
  34. data/templates/metadata.json.erb +3 -0
  35. data/templates/vagrant-aws_package_Vagrantfile.erb +5 -0
  36. data/vagrant-hyperkit.gemspec +61 -0
  37. data/vendor/xhyve-ruby/.gitignore +8 -0
  38. data/vendor/xhyve-ruby/.travis.yml +10 -0
  39. data/vendor/xhyve-ruby/Gemfile +3 -0
  40. data/vendor/xhyve-ruby/README.md +33 -0
  41. data/vendor/xhyve-ruby/Rakefile +42 -0
  42. data/vendor/xhyve-ruby/example/test.rb +17 -0
  43. data/vendor/xhyve-ruby/lib/rubygems_plugin.rb +7 -0
  44. data/vendor/xhyve-ruby/lib/xhyve.rb +4 -0
  45. data/vendor/xhyve-ruby/lib/xhyve/dhcp.rb +54 -0
  46. data/vendor/xhyve-ruby/lib/xhyve/guest.rb +92 -0
  47. data/vendor/xhyve-ruby/lib/xhyve/vendor/xhyve +0 -0
  48. data/vendor/xhyve-ruby/lib/xhyve/version.rb +4 -0
  49. data/vendor/xhyve-ruby/spec/fixtures/dhcpd_leases.txt +42 -0
  50. data/vendor/xhyve-ruby/spec/fixtures/guest/README.md +33 -0
  51. data/vendor/xhyve-ruby/spec/fixtures/guest/initrd +0 -0
  52. data/vendor/xhyve-ruby/spec/fixtures/guest/vmlinuz +0 -0
  53. data/vendor/xhyve-ruby/spec/lib/dhcp_spec.rb +35 -0
  54. data/vendor/xhyve-ruby/spec/lib/guest_spec.rb +51 -0
  55. data/vendor/xhyve-ruby/spec/spec_helper.rb +52 -0
  56. data/vendor/xhyve-ruby/xhyve-ruby.gemspec +23 -0
  57. metadata +192 -0
@@ -0,0 +1,4 @@
1
+ # Common Xhyve functionality nampesace
2
+ module Xhyve
3
+ VERSION = '0.0.6'
4
+ end
@@ -0,0 +1,42 @@
1
+ {
2
+ name=boxt
3
+ ip_address=192.168.64.35
4
+ hw_address=1,9a:65:1b:12:cf:f
5
+ identifier=1,9a:65:1b:12:cf:f
6
+ lease=0x56551008
7
+ }
8
+ {
9
+ name=box
10
+ ip_address=192.168.64.34
11
+ hw_address=1,9a:65:1b:12:cf:32
12
+ identifier=1,9a:65:1b:12:cf:32
13
+ lease=0x56551009
14
+ }
15
+ {
16
+ name=localhost
17
+ ip_address=192.168.64.5
18
+ hw_address=1,a6:84:b2:34:cf:32
19
+ identifier=1,a6:84:b2:34:cf:32
20
+ lease=0x5653f52c
21
+ }
22
+ {
23
+ name=localhost
24
+ ip_address=192.168.64.4
25
+ hw_address=1,ea:28:a:33:cf:32
26
+ identifier=1,ea:28:a:33:cf:32
27
+ lease=0x5653f4eb
28
+ }
29
+ {
30
+ name=localhost
31
+ ip_address=192.168.64.3
32
+ hw_address=1,e2:ff:e:70:cf:32
33
+ identifier=1,e2:ff:e:70:cf:32
34
+ lease=0x5653f496
35
+ }
36
+ {
37
+ name=localhost
38
+ ip_address=192.168.64.2
39
+ hw_address=1,5a:90:52:13:cf:32
40
+ identifier=1,5a:90:52:13:cf:32
41
+ lease=0x5653f3c5
42
+ }
@@ -0,0 +1,33 @@
1
+ #
2
+
3
+ We use tinycore linux, with a small persistence volume that just has openssh.
4
+
5
+ To regenerate this persistence volume (on osx):
6
+
7
+ ```
8
+ # Create a sparse filesystem
9
+
10
+ dd if=/dev/zero of=loop.img bs=1 count=0 seek=10m
11
+
12
+ # Mount the image in xhyve, (without opt=vda1) then create a partition table and mkfs.ext4 it.
13
+ # It will likely be /dev/vda
14
+ # Then reboot with opt=vda
15
+ # confirm it's mounted over /opt, then make your changes as per
16
+ # http://myblog-kenton.blogspot.ca/2012/03/install-openssh-server-on-tiny-core.html
17
+
18
+ tce-load -iw openssh.tcz
19
+ sudo cp /usr/local/etc/ssh/sshd_config_example /usr/local/etc/ssh/sshd_config
20
+ cat >> /opt/.filetool.lst <<EOF
21
+ /usr/local/etc/ssh
22
+ /etc/passwd
23
+ /etc/shadow
24
+ EOF
25
+
26
+ echo "/usr/local/etc/init.d/openssh start" >> /opt/bootlocal.sh
27
+
28
+ sudo /usr/local/etc/init.d/openssh start
29
+ sudo filetool.sh -b
30
+
31
+ ```
32
+
33
+ When booting set user=console boot flag, and it will create the console user with password defaulting to 'tcuser'
@@ -0,0 +1,35 @@
1
+ require File.expand_path('../../spec_helper.rb', __FILE__)
2
+
3
+ RSpec.describe Xhyve::DHCP do
4
+ let(:leases) do
5
+ {
6
+ '9a:65:1b:12:cf:0f' => '192.168.64.35',
7
+ '9a:65:1b:12:cf:32' => '192.168.64.34',
8
+ 'a6:84:b2:34:cf:32' => '192.168.64.5',
9
+ 'ea:28:a:33:cf:32' => '192.168.64.4',
10
+ 'e2:ff:e:70:cf:32' => '192.168.64.3',
11
+ '5a:90:52:13:cf:32' => '192.168.64.2'
12
+ }
13
+ end
14
+
15
+ before :all do
16
+ ENV['LEASES_FILE'] = File.join(FIXTURE_PATH, 'dhcpd_leases.txt')
17
+ ENV['MAX_IP_WAIT'] = '1'
18
+ end
19
+
20
+ after :all do
21
+ ENV.delete('LEASES_FILE')
22
+ ENV.delete('MAX_IP_WAIT')
23
+ end
24
+
25
+ it 'parses the leases file to get an IP from a MAC' do
26
+ leases.each do |mac, ip|
27
+ expect(Xhyve::DHCP.get_ip_for_mac(mac)).to_not be_nil
28
+ expect(Xhyve::DHCP.get_ip_for_mac(mac)).to eq(ip)
29
+ end
30
+ end
31
+
32
+ it 'returns nil if no lease is found' do
33
+ expect(Xhyve::DHCP.get_ip_for_mac('fakemac')).to be_nil
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path('../../spec_helper.rb', __FILE__)
2
+
3
+ RSpec.describe Xhyve::Guest do
4
+ before :all do
5
+ kernel = File.join(FIXTURE_PATH, 'guest', 'vmlinuz')
6
+ initrd = File.join(FIXTURE_PATH, 'guest', 'initrd')
7
+ blockdev = File.join(FIXTURE_PATH, 'guest', 'loop.img')
8
+ cmdline = 'earlyprintk=true console=ttyS0 user=console opt=vda tce=vda'
9
+ uuid = SecureRandom.uuid # '32e54269-d1e2-4bdf-b4ff-bbe0eb42572d' #
10
+
11
+ @guest = Xhyve::Guest.new(kernel: kernel, initrd: initrd, cmdline: cmdline, blockdevs: blockdev, uuid: uuid, serial: 'com1')
12
+ @guest.start
13
+ end
14
+
15
+ after :all do
16
+ @guest.stop
17
+ end
18
+
19
+ it 'Can start a guest' do
20
+ expect(@guest.pid).to_not be_nil
21
+ expect(@guest.pid).to be > 0
22
+ expect(@guest.running?).to eq(true)
23
+ end
24
+
25
+ it 'Can get the MAC of a guest' do
26
+ expect(@guest.mac).to_not be_nil
27
+ expect(@guest.mac).to_not be_empty
28
+ expect(@guest.mac).to match(/\w\w:\w\w:\w\w:\w\w:\w\w:\w\w/)
29
+ end
30
+
31
+ it 'Can get the IP of a guest' do
32
+ expect(@guest.ip).to_not be_nil
33
+ expect(@guest.ip).to match(/\d+\.+\d+\.\d+\.\d+/)
34
+ end
35
+
36
+ it 'Can ping the guest' do
37
+ expect(ping(@guest.ip)).to eq(true)
38
+ end
39
+
40
+ it 'Can ssh to the guest' do
41
+ expect(on_guest(@guest.ip, 'hostname')).to eq('box')
42
+ end
43
+
44
+ it 'Correctly sets processors' do
45
+ expect(on_guest(@guest.ip, "cat /proc/cpuinfo | grep 'cpu cores' | awk '{print $4}'")).to eq('1')
46
+ end
47
+
48
+ it 'Correctly sets memory' do
49
+ expect(on_guest(@guest.ip, "free -mm | grep 'Mem:' | awk '{print $2}'").to_i).to be_within(50).of(500)
50
+ end
51
+ end unless ENV['TRAVIS']
@@ -0,0 +1,52 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'securerandom'
5
+ require 'net/ssh'
6
+ require 'net/ping'
7
+ require File.expand_path('../../lib/xhyve.rb', __FILE__)
8
+
9
+ FIXTURE_PATH = File.expand_path('../../spec/fixtures', __FILE__)
10
+
11
+ # def self.append_features(mod)
12
+ # mod.class_eval %[
13
+ # around(:each) do |example|
14
+ # example.run
15
+ # end
16
+ # ]
17
+ # end
18
+ # end
19
+
20
+ def ping(ip)
21
+ attempts = 0
22
+ max_attempts = 60
23
+ sleep_time = 1
24
+
25
+ while attempts < max_attempts
26
+ attempts += 1
27
+ sleep(sleep_time)
28
+ begin
29
+ return true if Net::Ping::ICMP.new(ip).ping
30
+ rescue
31
+ end
32
+ end
33
+ end
34
+
35
+ def on_guest(ip, command)
36
+ output = ''
37
+ Net::SSH.start(ip, 'console', password: 'tcuser') do |ssh|
38
+ output = ssh.exec!(command)
39
+ end
40
+ output.strip
41
+ end
42
+
43
+ RSpec.configure do |config|
44
+ config.order = :defined
45
+ config.expect_with :rspec do |expectations|
46
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
47
+ end
48
+
49
+ config.mock_with :rspec do |mocks|
50
+ mocks.verify_partial_doubles = true
51
+ end
52
+ end
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'xhyve/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'xhyve-ruby'
7
+ s.version = Xhyve::VERSION
8
+ s.date = '2015-11-23'
9
+ s.summary = 'Ruby wrapper for xhyve'
10
+ s.description = 'Provides a means of interacting with xhyve from ruby'
11
+ s.authors = ['Dale Hamel']
12
+ s.email = 'dale.hamel@srvthe.net'
13
+ s.files = Dir['lib/**/*']
14
+ s.homepage =
15
+ 'https://github.com/dalehamel/xhyve-ruby'
16
+ s.license = 'MIT'
17
+ s.add_development_dependency 'simplecov', ['=0.10.0']
18
+ s.add_development_dependency 'rspec', ['=3.2.0']
19
+ s.add_development_dependency 'net-ssh', ['=3.0.1']
20
+ s.add_development_dependency 'net-ping', ['=1.7.8']
21
+ s.add_development_dependency 'rake', ['=10.4.2']
22
+ s.add_development_dependency 'rake-compiler', ['=0.9.5']
23
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-hyperkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.3
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Armstrong, Steve Glover (Accanto Systems Ltd)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xhyve-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-ssh
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: iniparse
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.4.2
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.4'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.4'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec-its
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: Enables Vagrant to manage machines in hyperkit.
104
+ email: pat@oldpatricka.com, steve.glover@accantosystems.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - CHANGELOG.md
112
+ - Gemfile
113
+ - LICENSE
114
+ - README.md
115
+ - Rakefile
116
+ - example_box/README.md
117
+ - example_box/initrd.gz
118
+ - example_box/metadata.json
119
+ - example_box/vmlinuz
120
+ - lib/vagrant-hyperkit.rb
121
+ - lib/vagrant-hyperkit/action.rb
122
+ - lib/vagrant-hyperkit/action/boot.rb
123
+ - lib/vagrant-hyperkit/action/import.rb
124
+ - lib/vagrant-hyperkit/action/is_created.rb
125
+ - lib/vagrant-hyperkit/action/is_stopped.rb
126
+ - lib/vagrant-hyperkit/action/message_already_created.rb
127
+ - lib/vagrant-hyperkit/action/message_not_created.rb
128
+ - lib/vagrant-hyperkit/action/message_will_not_destroy.rb
129
+ - lib/vagrant-hyperkit/action/read_ssh_info.rb
130
+ - lib/vagrant-hyperkit/action/read_state.rb
131
+ - lib/vagrant-hyperkit/action/stop_instance.rb
132
+ - lib/vagrant-hyperkit/action/terminate_instance.rb
133
+ - lib/vagrant-hyperkit/action/timed_provision.rb
134
+ - lib/vagrant-hyperkit/action/wait_for_state.rb
135
+ - lib/vagrant-hyperkit/config.rb
136
+ - lib/vagrant-hyperkit/errors.rb
137
+ - lib/vagrant-hyperkit/plugin.rb
138
+ - lib/vagrant-hyperkit/provider.rb
139
+ - lib/vagrant-hyperkit/util/timer.rb
140
+ - lib/vagrant-hyperkit/util/vagrant-hyperkit.rb
141
+ - lib/vagrant-hyperkit/version.rb
142
+ - locales/en.yml
143
+ - spec/spec_helper.rb
144
+ - spec/vagrant-hyperkit/config_spec.rb
145
+ - templates/metadata.json.erb
146
+ - templates/vagrant-aws_package_Vagrantfile.erb
147
+ - vagrant-hyperkit.gemspec
148
+ - vendor/xhyve-ruby/.gitignore
149
+ - vendor/xhyve-ruby/.travis.yml
150
+ - vendor/xhyve-ruby/Gemfile
151
+ - vendor/xhyve-ruby/README.md
152
+ - vendor/xhyve-ruby/Rakefile
153
+ - vendor/xhyve-ruby/example/test.rb
154
+ - vendor/xhyve-ruby/lib/rubygems_plugin.rb
155
+ - vendor/xhyve-ruby/lib/xhyve.rb
156
+ - vendor/xhyve-ruby/lib/xhyve/dhcp.rb
157
+ - vendor/xhyve-ruby/lib/xhyve/guest.rb
158
+ - vendor/xhyve-ruby/lib/xhyve/vendor/xhyve
159
+ - vendor/xhyve-ruby/lib/xhyve/version.rb
160
+ - vendor/xhyve-ruby/spec/fixtures/dhcpd_leases.txt
161
+ - vendor/xhyve-ruby/spec/fixtures/guest/README.md
162
+ - vendor/xhyve-ruby/spec/fixtures/guest/initrd
163
+ - vendor/xhyve-ruby/spec/fixtures/guest/vmlinuz
164
+ - vendor/xhyve-ruby/spec/lib/dhcp_spec.rb
165
+ - vendor/xhyve-ruby/spec/lib/guest_spec.rb
166
+ - vendor/xhyve-ruby/spec/spec_helper.rb
167
+ - vendor/xhyve-ruby/xhyve-ruby.gemspec
168
+ homepage: http://github.com/oldpatricka/vagrant-xhyve
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: 1.3.6
186
+ requirements: []
187
+ rubyforge_project: vagrant-hyperkit
188
+ rubygems_version: 2.5.2.3
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: Enables Vagrant to manage machines in hyperkit.
192
+ test_files: []