fog-vmfusion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +9 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +38 -0
- data/Rakefile +11 -0
- data/fog-vmfusion.gemspec +34 -0
- data/gemfiles/Gemfile.1.9.2- +8 -0
- data/gemfiles/Gemfile.1.9.3+ +7 -0
- data/lib/fog/bin/vmfusion.rb +58 -0
- data/lib/fog/compute/vmfusion.rb +28 -0
- data/lib/fog/compute/vmfusion/server.rb +256 -0
- data/lib/fog/compute/vmfusion/servers.rb +33 -0
- data/lib/fog/vmfusion.rb +14 -0
- data/lib/fog/vmfusion/version.rb +5 -0
- data/spec/minitest_helper.rb +31 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 969e0154053ab8dc1f9d2207c9d48b8ac0d23057
|
4
|
+
data.tar.gz: 0f4d36b5b87428d8c6c2799fa3ba33b2a9b3b75c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3da261b28bf05b06c690a6eccf87ab6687acc92702fa5f4633078949a93cae3b70fd3c95ba2cc6f2b0be727698c39e8be90fcdfb8f1296b708d882409b4d6ce4
|
7
|
+
data.tar.gz: bbc8a25367826f9e3305342d332ef0f4a3d285bc118481cfd38f242675b98ea2e857a7ee01d6866bf37ae25b5ddc5973c34cce70746fe98605a905c33eaf372f
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
gemfiles/*.lock
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/EachWithObject:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/Encoding:
|
8
|
+
EnforcedStyle: when_needed
|
9
|
+
|
10
|
+
Style/FormatString:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/HashSyntax:
|
14
|
+
EnforcedStyle: hash_rockets
|
15
|
+
|
16
|
+
Style/SignalException:
|
17
|
+
EnforcedStyle: only_raise
|
18
|
+
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fog-vmfusion
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
matrix:
|
2
|
+
include:
|
3
|
+
- rvm: 1.8.7
|
4
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
5
|
+
- rvm: 1.9.2
|
6
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
7
|
+
- rvm: 1.9.3
|
8
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
9
|
+
- rvm: 2.0.0
|
10
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
11
|
+
- rvm: 2.1.4
|
12
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
13
|
+
env: COVERAGE=true
|
14
|
+
- rvm: ree
|
15
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
16
|
+
- rvm: jruby
|
17
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/fog/fog-vmfusion/pulls).
|
9
|
+
* Review open [issues](https://github.com/fog/fog-vmfusion/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/fog/fog-vmfusion/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `fog/fog-vmfusion` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/fog/fog-vmfusion/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/fog/fog-vmfusion/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
* Carlos Sanchez <csanchez@maestrodev.com>
|
2
|
+
* Cody Herriges <c.a.herriges@gmail.com>
|
3
|
+
* James Herdman <james.herdman@me.com>
|
4
|
+
* Lance Ivy <lance@cainlevy.net>
|
5
|
+
* Kyle Rames <kyle.rames@rackspace.com>
|
6
|
+
* Patrick Debois <Patrick.Debois@jedi.be>
|
7
|
+
* Paul Thornthwaite <paul@brightbox.co.uk>
|
8
|
+
* Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
|
9
|
+
* Wesley Beary <geemus@gmail.com>
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-voxel/blob/master/CONTRIBUTORS.md)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Fog::Vmfusion
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fog-vmfusion.svg)](http://badge.fury.io/rb/fog-vmfusion) [![Build Status](https://travis-ci.org/fog/fog-vmfusion.svg?branch=master)](https://travis-ci.org/fog/fog-vmfusion) [![Dependency Status](https://gemnasium.com/fog/fog-vmfusion.svg)](https://gemnasium.com/fog/fog-vmfusion) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-vmfusion.svg)](https://coveralls.io/r/fog/fog-vmfusion?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-vmfusion.png)](https://codeclimate.com/github/fog/fog-vmfusion)
|
4
|
+
|
5
|
+
Module for the 'fog' gem to support VMWARE Fusion
|
6
|
+
|
7
|
+
## Help Needed
|
8
|
+
|
9
|
+
This gem needs a maintainer. If you want to work on it, please contact
|
10
|
+
[@geemus](mailto:geemus@gmail.com) or [@plribeiro3000](mailto:plribeiro3000@gmail.com)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'fog-vmfusion'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install fog-vmfusion
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
TODO: Write usage instructions here
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/fog/fog-vmfusion/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/vmfusion/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fog-vmfusion"
|
8
|
+
spec.version = Fog::Vmfusion::VERSION
|
9
|
+
spec.authors = %q(Paulo Henrique Lopes Ribeiro)
|
10
|
+
spec.email = %q(plribeiro3000@gmail.com)
|
11
|
+
spec.summary = %q{Module for the 'fog' gem to support VMWARE FUSION.}
|
12
|
+
spec.description = %q{This library can be used as a module for `fog` or as standalone provider
|
13
|
+
to use the VMWARE FUSION in applications.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "fog-core"
|
23
|
+
spec.add_dependency "fission"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "turn"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
|
30
|
+
if RUBY_VERSION.to_f > 1.9
|
31
|
+
spec.add_development_dependency "coveralls"
|
32
|
+
spec.add_development_dependency "rubocop"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vmfusion # deviates from other bin stuff to accomodate gem
|
2
|
+
class << self
|
3
|
+
def class_for(key)
|
4
|
+
case key
|
5
|
+
when :compute
|
6
|
+
Fog::Compute::Vmfusion
|
7
|
+
else
|
8
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](service)
|
13
|
+
@@connections ||= Hash.new do |hash, key|
|
14
|
+
hash[key] = case key
|
15
|
+
when :compute
|
16
|
+
Fog::Logger.warning("Vmfusion[:compute] is not recommended, use Compute[:vmfusion] for portability")
|
17
|
+
Fog::Compute.new(:provider => 'Vmfusion')
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@@connections[service]
|
23
|
+
end
|
24
|
+
|
25
|
+
def available?
|
26
|
+
begin
|
27
|
+
availability=true unless Gem::Specification::find_by_name("fission").nil?
|
28
|
+
rescue Gem::LoadError
|
29
|
+
availability=false
|
30
|
+
rescue
|
31
|
+
availability_gem=Gem.available?("fission")
|
32
|
+
end
|
33
|
+
|
34
|
+
if availability
|
35
|
+
for service in services
|
36
|
+
for collection in self.class_for(service).collections
|
37
|
+
unless self.respond_to?(collection)
|
38
|
+
self.class_eval <<-EOS, __FILE__, __LINE__
|
39
|
+
def self.#{collection}
|
40
|
+
self[:#{service}].#{collection}
|
41
|
+
end
|
42
|
+
EOS
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
availability
|
48
|
+
end
|
49
|
+
|
50
|
+
def collections
|
51
|
+
services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
|
52
|
+
end
|
53
|
+
|
54
|
+
def services
|
55
|
+
Fog::Vmfusion.services
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Vmfusion < Fog::Service
|
4
|
+
autoload :Server, 'fog/compute/vmfusion/server'
|
5
|
+
autoload :Servers, 'fog/compute/vmfusion/servers'
|
6
|
+
|
7
|
+
model_path 'fog/compute/vmfusion'
|
8
|
+
|
9
|
+
model :server
|
10
|
+
collection :servers
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def initialize(_options = {})
|
14
|
+
Fog::Mock.not_implemented
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def initialize(_options = {})
|
20
|
+
require 'fission'
|
21
|
+
rescue LoadError => e
|
22
|
+
retry if require('rubygems')
|
23
|
+
raise e.message
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require 'fog/compute/models/server'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Vmfusion
|
6
|
+
class Server < Fog::Compute::Server
|
7
|
+
identity :name
|
8
|
+
|
9
|
+
attribute :ipaddress
|
10
|
+
attribute :power_state
|
11
|
+
attribute :mac_addresses
|
12
|
+
attribute :path
|
13
|
+
|
14
|
+
attr_accessor :password
|
15
|
+
|
16
|
+
# There is currently no documented model of creating VMs from scratch
|
17
|
+
# sans Fusion's wizard.
|
18
|
+
def save
|
19
|
+
raise Fog::Errors::Error.new('Creating a new vm is not yet supported')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Fussion doesn't have the concept of templates so one just clones
|
23
|
+
# regular VMs.
|
24
|
+
def clone(name)
|
25
|
+
requires :raw
|
26
|
+
|
27
|
+
::Fission::VM.clone(@raw[:fission].name,name)
|
28
|
+
return service.servers.get(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Destroy, deletes the VM from the local disk but only hard stops the VM
|
32
|
+
# before doing so if you set :force to true.
|
33
|
+
def destroy(options = { :force => false })
|
34
|
+
requires :raw
|
35
|
+
|
36
|
+
if ready?
|
37
|
+
if options[:force]
|
38
|
+
stop
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@raw[:fission].delete
|
43
|
+
end
|
44
|
+
|
45
|
+
# Start is pretty self explanatory...if you pass :headless as true you
|
46
|
+
# won't get a console on launch.
|
47
|
+
def start(options = { :headless => false })
|
48
|
+
requires :raw
|
49
|
+
|
50
|
+
unless ready?
|
51
|
+
@raw[:fission].start(:headless => options[:headless])
|
52
|
+
return true
|
53
|
+
else
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# We're covering a lot of bases here with the different ways one can
|
59
|
+
# stop a VM from running.
|
60
|
+
|
61
|
+
# Stop is a hard stop, like pulling out the power cord.
|
62
|
+
def stop
|
63
|
+
requires :raw
|
64
|
+
|
65
|
+
if ready?
|
66
|
+
@raw[:fission].stop(:hard => true)
|
67
|
+
return true
|
68
|
+
else
|
69
|
+
return false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Halt and poweroff are just synonyms for stop.
|
74
|
+
def halt
|
75
|
+
stop
|
76
|
+
end
|
77
|
+
|
78
|
+
def poweroff
|
79
|
+
stop
|
80
|
+
end
|
81
|
+
|
82
|
+
# This is a graceful shutdown but Fusion is only capable of a graceful
|
83
|
+
# shutdown if tools are installed. Fusion does the right thing though
|
84
|
+
# and if graceful can't be initiated it just does a hard stop.
|
85
|
+
def shutdown
|
86
|
+
requires :raw
|
87
|
+
if ready?
|
88
|
+
@raw[:fission].stop
|
89
|
+
return true
|
90
|
+
else
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Attempt a graceful shutdown, wait for the VM to completely shutdown
|
96
|
+
# and then start it again.
|
97
|
+
def reboot
|
98
|
+
if ready?
|
99
|
+
shutdown
|
100
|
+
wait_for { ! ready? }
|
101
|
+
start
|
102
|
+
return true
|
103
|
+
else
|
104
|
+
return false
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Resuming from suspend is the same thing as start to Fusion.
|
109
|
+
def resume
|
110
|
+
start
|
111
|
+
end
|
112
|
+
|
113
|
+
def suspend
|
114
|
+
requires :raw
|
115
|
+
if ready?
|
116
|
+
@raw[:fission].suspend
|
117
|
+
return true
|
118
|
+
else
|
119
|
+
return false
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Fusion VM Metadata.
|
124
|
+
|
125
|
+
# The power state of the VM is commonly going to be three values;
|
126
|
+
# running, not running, or suspended.
|
127
|
+
def power_state
|
128
|
+
requires :raw
|
129
|
+
@raw[:fission].state.data
|
130
|
+
end
|
131
|
+
|
132
|
+
def ready?
|
133
|
+
requires :raw
|
134
|
+
@raw[:fission].running?.data
|
135
|
+
end
|
136
|
+
|
137
|
+
# Path to the VM's vmx file on the local disk.
|
138
|
+
def path
|
139
|
+
requires :raw
|
140
|
+
@raw[:fission].path
|
141
|
+
end
|
142
|
+
|
143
|
+
# We obtain the first ipaddress. This should generally be a safe
|
144
|
+
# assumption for Fusion. Even if an address is provided via NAT,
|
145
|
+
# bridge, or host only it will by accessible from the host machine the
|
146
|
+
# VM resides on.
|
147
|
+
def ipaddress
|
148
|
+
requires :raw
|
149
|
+
ip(@raw[:fission])
|
150
|
+
end
|
151
|
+
|
152
|
+
# Keeping these three methods around for API compatibility reasons.
|
153
|
+
# Makes the vmfusion provider function similar to cloud providers and
|
154
|
+
# the vsphere provider. Future goal is to add an actual private and
|
155
|
+
# public concept. Needs changes to fission and a determination what is
|
156
|
+
# a public or private address here; bridge, nat, host-only.
|
157
|
+
def public_ip_address
|
158
|
+
ipaddress
|
159
|
+
end
|
160
|
+
|
161
|
+
def private_ip_address
|
162
|
+
ipaddress
|
163
|
+
end
|
164
|
+
|
165
|
+
def state
|
166
|
+
power_state
|
167
|
+
end
|
168
|
+
|
169
|
+
# Collecting all mac_addresses the VM has...mostly just because we are
|
170
|
+
# doing the same thing for the vSphere provider.
|
171
|
+
def mac_addresses
|
172
|
+
requires :raw
|
173
|
+
macs(@raw[:fission])
|
174
|
+
end
|
175
|
+
|
176
|
+
# Sets up a conveinent way to SSH into a Fusion VM using credentials
|
177
|
+
# stored in your .fog file.
|
178
|
+
|
179
|
+
# Simply spawn an SSH session.
|
180
|
+
def ssh(commands)
|
181
|
+
super(commands, password ? {:password => password} : {})
|
182
|
+
end
|
183
|
+
|
184
|
+
# SCP something to our VM.
|
185
|
+
def scp(local_path, remote_path, upload_options = {})
|
186
|
+
requires :ssh_ip_address, :username
|
187
|
+
|
188
|
+
scp_options = {}
|
189
|
+
scp_options[:password] = password unless self.password.nil?
|
190
|
+
scp_options[:key_data] = [private_key] if self.private_key
|
191
|
+
|
192
|
+
Fog::SCP.new(ssh_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
|
193
|
+
end
|
194
|
+
|
195
|
+
# Sets up a new SSH key on the VM so one doesn't need to use a password
|
196
|
+
# ever again.
|
197
|
+
def setup(credentials = {})
|
198
|
+
requires :public_key, :ssh_ip_address, :username
|
199
|
+
|
200
|
+
credentials[:password] = password unless self.password.nil?
|
201
|
+
credentails[:key_data] = [private_key] if self.private_key
|
202
|
+
|
203
|
+
commands = [
|
204
|
+
%{mkdir .ssh},
|
205
|
+
]
|
206
|
+
if public_key
|
207
|
+
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
|
208
|
+
end
|
209
|
+
|
210
|
+
# wait for domain to be ready
|
211
|
+
Timeout::timeout(360) do
|
212
|
+
begin
|
213
|
+
Timeout::timeout(8) do
|
214
|
+
Fog::SSH.new(ssh_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
|
215
|
+
end
|
216
|
+
rescue Errno::ECONNREFUSED
|
217
|
+
sleep(2)
|
218
|
+
retry
|
219
|
+
rescue Net::SSH::AuthenticationFailed, Timeout::Error
|
220
|
+
retry
|
221
|
+
end
|
222
|
+
end
|
223
|
+
Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)
|
224
|
+
end
|
225
|
+
|
226
|
+
private
|
227
|
+
def ip(fission)
|
228
|
+
first_int = fission.network_info.data.keys.first
|
229
|
+
fission.network_info.data[first_int]['ip_address']
|
230
|
+
end
|
231
|
+
|
232
|
+
def macs(fission)
|
233
|
+
fission.mac_addresses.data
|
234
|
+
end
|
235
|
+
|
236
|
+
def raw
|
237
|
+
@raw
|
238
|
+
end
|
239
|
+
|
240
|
+
def raw=(new_raw)
|
241
|
+
@raw = new_raw
|
242
|
+
|
243
|
+
raw_attributes = {
|
244
|
+
:name => new_raw[:fission].name,
|
245
|
+
:power_state => new_raw[:state],
|
246
|
+
:ipaddress => ip(new_raw[:fission]),
|
247
|
+
:mac_addresses => macs(new_raw[:fission]),
|
248
|
+
:path => new_raw[:fission].path
|
249
|
+
}
|
250
|
+
|
251
|
+
merge_attributes(raw_attributes)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Vmfusion
|
4
|
+
class Servers < Fog::Collection
|
5
|
+
model Fog::Compute::Vmfusion::Server
|
6
|
+
|
7
|
+
def all(filter = nil)
|
8
|
+
data = []
|
9
|
+
|
10
|
+
states = ::Fission::VM.all_with_status.data
|
11
|
+
|
12
|
+
filter = {} if filter.nil?
|
13
|
+
unless filter.key?(:name)
|
14
|
+
vms=::Fission::VM.all.data
|
15
|
+
vms.each do |vm|
|
16
|
+
data << { :raw => { :fission => vm,
|
17
|
+
:state => states[vm.name] } }
|
18
|
+
end
|
19
|
+
else
|
20
|
+
data << { :raw => { :fission => ::Fission::VM.new(filter[:name]),
|
21
|
+
:state => states[filter[:name]] } }
|
22
|
+
end
|
23
|
+
|
24
|
+
load(data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(name)
|
28
|
+
self.all(:name => name).first
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/fog/vmfusion.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'turn'
|
4
|
+
|
5
|
+
Turn.config do |c|
|
6
|
+
# use one of output formats:
|
7
|
+
# :outline - turn's original case/test outline mode [default]
|
8
|
+
# :progress - indicates progress with progress bar
|
9
|
+
# :dotted - test/unit's traditional dot-progress mode
|
10
|
+
# :pretty - new pretty reporter
|
11
|
+
# :marshal - dump output as YAML (normal run mode only)
|
12
|
+
# :cue - interactive testing
|
13
|
+
# c.format = :outline
|
14
|
+
# turn on invoke/execute tracing, enable full backtrace
|
15
|
+
c.trace = 20
|
16
|
+
# use humanized test names (works only with :outline format)
|
17
|
+
c.natural = true
|
18
|
+
end
|
19
|
+
|
20
|
+
if ENV['COVERAGE']
|
21
|
+
require 'coveralls'
|
22
|
+
require 'simplecov'
|
23
|
+
|
24
|
+
SimpleCov.start do
|
25
|
+
add_filter '/spec/'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require File.join(File.dirname(__FILE__), '../lib/fog/vmfusion.rb')
|
30
|
+
|
31
|
+
Coveralls.wear! if ENV['COVERAGE']
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-vmfusion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paulo Henrique Lopes Ribeiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fission
|
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: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: turn
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: |-
|
126
|
+
This library can be used as a module for `fog` or as standalone provider
|
127
|
+
to use the VMWARE FUSION in applications.
|
128
|
+
email: plribeiro3000@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".ruby-gemset"
|
136
|
+
- ".ruby-version"
|
137
|
+
- ".travis.yml"
|
138
|
+
- CONTRIBUTING.md
|
139
|
+
- CONTRIBUTORS.md
|
140
|
+
- Gemfile
|
141
|
+
- LICENSE.md
|
142
|
+
- README.md
|
143
|
+
- Rakefile
|
144
|
+
- fog-vmfusion.gemspec
|
145
|
+
- gemfiles/Gemfile.1.9.2-
|
146
|
+
- gemfiles/Gemfile.1.9.3+
|
147
|
+
- lib/fog/bin/vmfusion.rb
|
148
|
+
- lib/fog/compute/vmfusion.rb
|
149
|
+
- lib/fog/compute/vmfusion/server.rb
|
150
|
+
- lib/fog/compute/vmfusion/servers.rb
|
151
|
+
- lib/fog/vmfusion.rb
|
152
|
+
- lib/fog/vmfusion/version.rb
|
153
|
+
- spec/minitest_helper.rb
|
154
|
+
homepage: ''
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata: {}
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.4.2
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Module for the 'fog' gem to support VMWARE FUSION.
|
178
|
+
test_files:
|
179
|
+
- spec/minitest_helper.rb
|