vagrant-memset 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -15
- data/Gemfile +3 -10
- data/LICENSE.txt +16 -19
- data/README.md +54 -22
- data/changelog.txt +3 -0
- data/example_box/README.md +13 -0
- data/example_box/Vagrantfile +119 -0
- data/example_box/memset.box +0 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-memset.rb +17 -0
- data/lib/vagrant-memset/action.rb +111 -0
- data/lib/vagrant-memset/action/cancel_server.rb +28 -0
- data/lib/vagrant-memset/action/connect_memset.rb +23 -0
- data/lib/vagrant-memset/action/create_server.rb +62 -0
- data/lib/vagrant-memset/action/is_created.rb +19 -0
- data/lib/vagrant-memset/action/message_not_created.rb +18 -0
- data/lib/vagrant-memset/action/read_ssh_info.rb +26 -0
- data/lib/vagrant-memset/action/read_state.rb +24 -0
- data/lib/vagrant-memset/action/sync_folders.rb +40 -0
- data/lib/vagrant-memset/config.rb +50 -0
- data/lib/vagrant-memset/plugin.rb +32 -0
- data/lib/vagrant-memset/provider.rb +40 -0
- data/lib/{vagrant/memset → vagrant-memset}/version.rb +1 -1
- data/memset.box +0 -0
- data/vagrant-memset.gemspec +18 -18
- metadata +22 -4
- data/lib/vagrant/memset.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6184595639b1974e6415f96dd8d4987037d11d
|
4
|
+
data.tar.gz: b2fe8095ccc1845d2a20247bf6bf7cff5c9794bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44d88ac2c58c17002398c5c9a4ee824fa7de63b5bb7b2fcd21a531874a353220d2643793838d9bf8a04837655ab83f032e86d5caeaf4992f4d1527b398dbf448
|
7
|
+
data.tar.gz: 7bb2bf01599f3bb7264ec689408213423ce2f71b5b8f4e9c4511ad6777fe2185d73cb9ecc46be75e2639fc0fc3d6a322b6fda63e16f04984399dca3f3366af93
|
data/.gitignore
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
+
.rspec
|
2
|
+
*.iml
|
1
3
|
*.gem
|
2
4
|
*.rbc
|
3
5
|
.bundle
|
4
6
|
.config
|
7
|
+
.vagrant
|
5
8
|
.yardoc
|
6
9
|
Gemfile.lock
|
7
10
|
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
|
data/Gemfile
CHANGED
@@ -1,14 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in vagrant-memset.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
8
|
-
end
|
9
|
-
|
10
3
|
group :plugins do
|
11
|
-
|
12
|
-
gem
|
13
|
-
|
4
|
+
gemspec
|
5
|
+
gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant'
|
14
6
|
end
|
7
|
+
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,19 @@
|
|
1
|
-
Copyright (
|
1
|
+
Copyright (C) 2011-2014 by Memset Ltd. http://www.memset.com/
|
2
2
|
|
3
|
-
|
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:
|
4
9
|
|
5
|
-
|
6
|
-
|
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:
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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.
|
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.
|
data/README.md
CHANGED
@@ -1,29 +1,61 @@
|
|
1
|
-
|
1
|
+
## Vagrant Provider for Memset's Public Cloud
|
2
2
|
|
3
|
-
|
3
|
+
This plugin adds [Vagrant](http://www.vagrantup.com) compatibility for [Memset API](http://www.memset.com/apidocs/) including the following features:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
5
|
+
* Create [cloud instances](http://www.memset.com/cloud/compute/)
|
6
|
+
* Cancel instances.
|
7
|
+
* Authentication via SSH.
|
8
|
+
* Support for sync folders
|
9
|
+
* Provisioning built-in vagrant provisioners.
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
$ gem install vagrant-memset
|
18
|
-
|
19
|
-
## Usage
|
11
|
+
## Installation
|
20
12
|
|
21
|
-
TODO: Write usage instructions here
|
22
13
|
|
14
|
+
## Configuration
|
15
|
+
|
16
|
+
Parameters supported by Vagrant Memset Provider:
|
17
|
+
|
18
|
+
* `api_key` (String) - API key for accessing Memset. It requires access server.info, create.hourly_minisever,job.status,service.cancel methods.
|
19
|
+
* `sku` - The SKU of the service to be provisioned.
|
20
|
+
* `os` (String) - The Operating System. Only linux.
|
21
|
+
* `discount_code` (String) - Promotional discount.
|
22
|
+
* `vlan` (String) - Vlan name to join in when the server is created.
|
23
|
+
* `dry_run` - If True, then the service is not provisioned but the information is still returned.
|
24
|
+
|
25
|
+
This plugin implements [create.hourly_miniserver()](http://www.memset.com/apidocs/methods_create.html#create.hourly_miniserver) method from the Memset API. Please visit the link for detailed list of accepted values for each "sku" and "os" parameters.
|
26
|
+
|
27
|
+
Vagrant file example:
|
28
|
+
```
|
29
|
+
# Path to the private SSH key what Vagrant will use to access the miniserver.
|
30
|
+
Vagrant.configure("2") do |config|
|
31
|
+
|
32
|
+
config.vm.box = "memset"
|
33
|
+
|
34
|
+
config.vm.provider :memset do |mem| # e.g.
|
35
|
+
mem.api_key = "apikeystring"
|
36
|
+
mem.sku = "MS0025"
|
37
|
+
mem.os = "debian_wheezy_64"
|
38
|
+
mem.vlan = "caroraa-vlan1"
|
39
|
+
mem.discount_code = "asdfaspu"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
## SSH configuration
|
44
|
+
|
45
|
+
Memset Provider will automatically install a SSH public key onto the new server if "ssh.private_key_path" is provided. it will be assumed the public key is the same value as "ssh.private_key_path" with ".pub" extension at the end of it.
|
46
|
+
Config line example:
|
47
|
+
```
|
48
|
+
config.ssh.private_key_path = "~/ssh-keys/vagrant"
|
49
|
+
```
|
50
|
+
The plugin will install in the server public key located in "~/ssh-keys/vagrant.pub"
|
51
|
+
## Sync folders
|
52
|
+
|
53
|
+
Memset plugins offer minimal supports for sync folders. It requires sudo package installed so distributions where this is not shipped by default will need manual install before running "vagrant provision" command.
|
54
|
+
Config line example:
|
55
|
+
```
|
56
|
+
config.vm.synced_folder "./provision", "/memset/vagrant-provision"
|
57
|
+
```
|
23
58
|
## Contributing
|
24
59
|
|
25
|
-
|
26
|
-
|
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 a new Pull Request
|
60
|
+
Please send bugs to javier@memset.com
|
61
|
+
|
data/changelog.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Vagrant Memset Cloud Example Box
|
2
|
+
|
3
|
+
Vagrant providers each require a custom provider-specific box format.
|
4
|
+
This folder shows the example contents of a box for the `memset` provider.
|
5
|
+
To turn this into a box:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ tar cvzf memset.box ./metadata.json ./Vagrantfile
|
9
|
+
```
|
10
|
+
|
11
|
+
This box works by using Vagrant's built-in Vagrantfile merging to setup
|
12
|
+
defaults for Memset. These defaults can easily be overwritten by higher-level
|
13
|
+
Vagrantfiles (such as project root Vagrantfiles).
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
5
|
+
VAGRANTFILE_API_VERSION = "2"
|
6
|
+
|
7
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
8
|
+
Vagrant.require_plugin "vagrant-memset"
|
9
|
+
# All Vagrant configuration is done here. The most common configuration
|
10
|
+
# options are documented and commented below. For a complete reference,
|
11
|
+
# please see the online documentation at vagrantup.com.
|
12
|
+
|
13
|
+
# Every Vagrant virtual environment requires a box to build off of.
|
14
|
+
config.vm.box = "memset"
|
15
|
+
|
16
|
+
# The url from where the 'config.vm.box' box will be fetched if it
|
17
|
+
# doesn't already exist on the user's system.
|
18
|
+
# config.vm.box_url = "http://domain.com/path/to/above.box"
|
19
|
+
|
20
|
+
# Create a forwarded port mapping which allows access to a specific port
|
21
|
+
# within the machine from a port on the host machine. In the example below,
|
22
|
+
# accessing "localhost:8080" will access port 80 on the guest machine.
|
23
|
+
# config.vm.network :forwarded_port, guest: 80, host: 8080
|
24
|
+
|
25
|
+
# Create a private network, which allows host-only access to the machine
|
26
|
+
# using a specific IP.
|
27
|
+
# config.vm.network :private_network, ip: "192.168.33.10"
|
28
|
+
|
29
|
+
# Create a public network, which generally matched to bridged network.
|
30
|
+
# Bridged networks make the machine appear as another physical device on
|
31
|
+
# your network.
|
32
|
+
# config.vm.network :public_network
|
33
|
+
|
34
|
+
# If true, then any SSH connections made will enable agent forwarding.
|
35
|
+
# Default value: false
|
36
|
+
# config.ssh.forward_agent = true
|
37
|
+
|
38
|
+
# Share an additional folder to the guest VM. The first argument is
|
39
|
+
# the path on the host to the actual folder. The second argument is
|
40
|
+
# the path on the guest to mount the folder. And the optional third
|
41
|
+
# argument is a set of non-required options.
|
42
|
+
# config.vm.synced_folder "../data", "/vagrant_data"
|
43
|
+
|
44
|
+
# Provider-specific configuration so you can fine-tune various
|
45
|
+
# backing providers for Vagrant. These expose provider-specific options.
|
46
|
+
# Example for VirtualBox:
|
47
|
+
#
|
48
|
+
# config.vm.provider :virtualbox do |vb|
|
49
|
+
# # Don't boot with headless mode
|
50
|
+
# vb.gui = true
|
51
|
+
#
|
52
|
+
# # Use VBoxManage to customize the VM. For example to change memory:
|
53
|
+
# vb.customize ["modifyvm", :id, "--memory", "1024"]
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# View the documentation for the provider you're using for more
|
57
|
+
# information on available options.
|
58
|
+
|
59
|
+
# Enable provisioning with Puppet stand alone. Puppet manifests
|
60
|
+
# are contained in a directory path relative to this Vagrantfile.
|
61
|
+
# You will need to create the manifests directory and a manifest in
|
62
|
+
# the file base.pp in the manifests_path directory.
|
63
|
+
#
|
64
|
+
# An example Puppet manifest to provision the message of the day:
|
65
|
+
#
|
66
|
+
# # group { "puppet":
|
67
|
+
# # ensure => "present",
|
68
|
+
# # }
|
69
|
+
# #
|
70
|
+
# # File { owner => 0, group => 0, mode => 0644 }
|
71
|
+
# #
|
72
|
+
# # file { '/etc/motd':
|
73
|
+
# # content => "Welcome to your Vagrant-built virtual machine!
|
74
|
+
# # Managed by Puppet.\n"
|
75
|
+
# # }
|
76
|
+
#
|
77
|
+
# config.vm.provision :puppet do |puppet|
|
78
|
+
# puppet.manifests_path = "manifests"
|
79
|
+
# puppet.manifest_file = "site.pp"
|
80
|
+
# end
|
81
|
+
|
82
|
+
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
83
|
+
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
84
|
+
# some recipes and/or roles.
|
85
|
+
#
|
86
|
+
# config.vm.provision :chef_solo do |chef|
|
87
|
+
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
88
|
+
# chef.roles_path = "../my-recipes/roles"
|
89
|
+
# chef.data_bags_path = "../my-recipes/data_bags"
|
90
|
+
# chef.add_recipe "mysql"
|
91
|
+
# chef.add_role "web"
|
92
|
+
#
|
93
|
+
# # You may also specify custom JSON attributes:
|
94
|
+
# chef.json = { :mysql_password => "foo" }
|
95
|
+
# end
|
96
|
+
|
97
|
+
# Enable provisioning with chef server, specifying the chef server URL,
|
98
|
+
# and the path to the validation key (relative to this Vagrantfile).
|
99
|
+
#
|
100
|
+
# The Opscode Platform uses HTTPS. Substitute your organization for
|
101
|
+
# ORGNAME in the URL and validation key.
|
102
|
+
#
|
103
|
+
# If you have your own Chef Server, use the appropriate URL, which may be
|
104
|
+
# HTTP instead of HTTPS depending on your configuration. Also change the
|
105
|
+
# validation key to validation.pem.
|
106
|
+
#
|
107
|
+
# config.vm.provision :chef_client do |chef|
|
108
|
+
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
109
|
+
# chef.validation_key_path = "ORGNAME-validator.pem"
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# If you're using the Opscode platform, your validator client is
|
113
|
+
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
114
|
+
#
|
115
|
+
# If you have your own Chef Server, the default validation client name is
|
116
|
+
# chef-validator, unless you changed the configuration.
|
117
|
+
#
|
118
|
+
# chef.validation_client_name = "ORGNAME-validator"
|
119
|
+
end
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-memset/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Memset
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-memset", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
# This returns the path to the source of this plugin.
|
11
|
+
#
|
12
|
+
# @return [Pathname]
|
13
|
+
def self.source_root
|
14
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'vagrant/action/builder'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Memset
|
6
|
+
module Action
|
7
|
+
include Vagrant::Action::Builtin
|
8
|
+
|
9
|
+
# This action creates a new miniserver
|
10
|
+
def self.action_up
|
11
|
+
Vagrant::Action::Builder.new.tap do |b|
|
12
|
+
b.use ConfigValidate
|
13
|
+
b.use Call,IsCreated do |env, b2|
|
14
|
+
if !env[:result]
|
15
|
+
b2.use MessageNotCreated
|
16
|
+
next
|
17
|
+
end
|
18
|
+
b2.use ConnectMemset
|
19
|
+
b2.use CreateServer
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#It cancels a miniserver
|
25
|
+
def self.action_destroy
|
26
|
+
Vagrant::Action::Builder.new.tap do |b|
|
27
|
+
b.use ConfigValidate
|
28
|
+
b.use Call, IsCreated do |env, b2|
|
29
|
+
if !env[:result]
|
30
|
+
b2.use MessageNotCreated
|
31
|
+
next
|
32
|
+
end
|
33
|
+
b2.use ConnectMemset
|
34
|
+
b2.use CancelServer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# It read miniserver state
|
40
|
+
def self.action_read_state
|
41
|
+
Vagrant::Action::Builder.new.tap do |b|
|
42
|
+
b.use ConfigValidate
|
43
|
+
b.use ConnectMemset
|
44
|
+
b.use ReadState
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def self.action_read_ssh_info
|
50
|
+
Vagrant::Action::Builder.new.tap do |b|
|
51
|
+
b.use ConfigValidate
|
52
|
+
b.use ConnectMemset
|
53
|
+
b.use ReadSSHInfo
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def self.action_ssh
|
59
|
+
Vagrant::Action::Builder.new.tap do |b|
|
60
|
+
b.use ConfigValidate
|
61
|
+
b.use Call, IsCreated do |env, b2|
|
62
|
+
if !env[:result]
|
63
|
+
b2.use MessageNotCreated
|
64
|
+
next
|
65
|
+
end
|
66
|
+
b2.use SSHExec
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.action_ssh_run
|
72
|
+
Vagrant::Action::Builder.new.tap do |b|
|
73
|
+
b.use ConfigValidate
|
74
|
+
b.use Call, IsCreated do |env, b2|
|
75
|
+
if !env[:result]
|
76
|
+
b2.use MessageNotCreated
|
77
|
+
next
|
78
|
+
end
|
79
|
+
b2.use SSHRun
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def self.action_provision
|
86
|
+
Vagrant::Action::Builder.new.tap do |b|
|
87
|
+
b.use ConfigValidate
|
88
|
+
b.use Call, IsCreated do |env, b2|
|
89
|
+
if !env[:result]
|
90
|
+
b2.use MessageNotCreated
|
91
|
+
next
|
92
|
+
end
|
93
|
+
b2.use Provision
|
94
|
+
b2.use SyncFolders
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
action_root=Pathname.new (File.expand_path("../action",__FILE__))
|
100
|
+
autoload :ConnectMemset, action_root.join("connect_memset")
|
101
|
+
autoload :CreateServer, action_root.join("create_server")
|
102
|
+
autoload :CancelServer, action_root.join("cancel_server")
|
103
|
+
autoload :IsCreated, action_root.join("is_created")
|
104
|
+
autoload :ReadState , action_root.join("read_state")
|
105
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
106
|
+
autoload :SyncFolders, action_root.join("sync_folders")
|
107
|
+
autoload :MessageNotCreated, action_root.join("message_not_created")
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Memset
|
3
|
+
module Action
|
4
|
+
class CancelServer
|
5
|
+
|
6
|
+
def initialize (app, env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
|
12
|
+
if env[:machine].id
|
13
|
+
server = env[:memset_compute].call("service.cancel",{ :name => "#{env[:machine].id}"})
|
14
|
+
env[:ui].info("#{env[:machine].id} has been CANCELLED")
|
15
|
+
env[:machine].id = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
module VagrantPlugins
|
3
|
+
module Memset
|
4
|
+
module Action
|
5
|
+
class ConnectMemset
|
6
|
+
|
7
|
+
def initialize (app,env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call (env)
|
12
|
+
|
13
|
+
# It connects to Memset API
|
14
|
+
config = env[:machine].provider_config
|
15
|
+
api_url = "https://:@api.memset.com/v1/xmlrpc".insert(8,config.api_key)
|
16
|
+
env[:memset_compute]=XMLRPC::Client.new2(api_url)
|
17
|
+
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Memset
|
3
|
+
module Action
|
4
|
+
class CreateServer
|
5
|
+
|
6
|
+
def initialize (app,env)
|
7
|
+
@app=app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
#get the configs
|
12
|
+
config = env[:machine].provider_config
|
13
|
+
|
14
|
+
#get the pub key
|
15
|
+
key = env[:machine].config.ssh.private_key_path
|
16
|
+
key = key[0] if key.is_a?(Array)
|
17
|
+
if !key
|
18
|
+
env[:ui].info("SSH keys not configured")
|
19
|
+
else
|
20
|
+
begin
|
21
|
+
pub_key= File.read(File.expand_path("#{key}.pub",__FILE__))
|
22
|
+
rescue Exeption => msg
|
23
|
+
env[:ui].info("#{key}.pub file not found in the path")
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#create a miniserver
|
29
|
+
server = env[:memset_compute].call("create.hourly_miniserver", {
|
30
|
+
:sku => "#{config.sku}",
|
31
|
+
:dry_run => "#{config.dry_run}",
|
32
|
+
:os => "#{config.os}",
|
33
|
+
:vlan => "#{config.vlan}",
|
34
|
+
:pub_ssh_key => "#{pub_key}"
|
35
|
+
# :discount_code => "#{config.discount_code}"
|
36
|
+
})
|
37
|
+
|
38
|
+
if not server["job"]
|
39
|
+
env[:ui].info("TEST, dry_run is set to True")
|
40
|
+
env[:ui].info("#{server}")
|
41
|
+
else
|
42
|
+
job_id = server["job"]["id"]
|
43
|
+
env[:ui].info("Server is being provisioned, please wait a few minutes")
|
44
|
+
|
45
|
+
while true
|
46
|
+
status = env[:memset_compute].call("job.status",{:id => job_id})
|
47
|
+
break if env[:interrupted]
|
48
|
+
break if status["finished"] == true
|
49
|
+
env[:ui].info("Status of the server is #{status["status"]}")
|
50
|
+
sleep 15
|
51
|
+
end
|
52
|
+
|
53
|
+
env[:machine].id = status["service"]
|
54
|
+
env[:ui].info("Your server #{env[:machine].id} is ready")
|
55
|
+
|
56
|
+
@app.call(env)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Memset
|
3
|
+
module Action
|
4
|
+
class MessageNotCreated
|
5
|
+
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
env[:ui].info("Miniserver is not created")
|
12
|
+
@app.call(env)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'pp'
|
2
|
+
module VagrantPlugins
|
3
|
+
module Memset
|
4
|
+
module Action
|
5
|
+
class ReadSSHInfo
|
6
|
+
|
7
|
+
def initialize (app,env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
|
13
|
+
return "not created" if env[:machine].id.nil?
|
14
|
+
print env[:machine].id
|
15
|
+
env[:machine_ssh_info] = {
|
16
|
+
:host => "#{env[:machine].id}.miniserver.com",
|
17
|
+
:port => 22,
|
18
|
+
:username => "root"
|
19
|
+
}
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Memset
|
3
|
+
module Action
|
4
|
+
class ReadState
|
5
|
+
|
6
|
+
def initialize (app,env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call (env)
|
11
|
+
|
12
|
+
return "not created" if env[:machine].id.nil?
|
13
|
+
status = env[:memset_compute].call("service.info", {:name => "#{env[:machine].id}"})
|
14
|
+
env[:machine_state_id] = status["status"]
|
15
|
+
if not status["status"] == "LIVE"
|
16
|
+
env[:machine].id = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'rbconfig'
|
3
|
+
require "vagrant/util/subprocess"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Memset
|
7
|
+
module Action
|
8
|
+
class SyncFolders
|
9
|
+
|
10
|
+
def initialize(app,env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
ssh_info = env[:machine].ssh_info
|
18
|
+
config = env[:machine].provider_config
|
19
|
+
env[:machine].config.vm.synced_folders.each do |id, data|
|
20
|
+
hostpath = File.expand_path(data[:hostpath], env[:root_path])
|
21
|
+
guestpath = data[:guestpath]
|
22
|
+
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
23
|
+
env[:ui].info("Syncing folders: \n Host: #{hostpath} \n Guest: #{guestpath}")
|
24
|
+
env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
|
25
|
+
env[:machine].communicate.sudo("chown -R #{ssh_info[:username]} '#{guestpath}'")
|
26
|
+
command = ["rsync", "--verbose", "--archive", "--compress", "--delete","-e","ssh -p #{ssh_info[:port]} -i '#{ssh_info[:private_key_path][0]}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",hostpath,"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
27
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
28
|
+
if r.exit_code != 0
|
29
|
+
raise Errors::RsyncError,
|
30
|
+
:guestpath => guestpath,
|
31
|
+
:hostpath => hostpath,
|
32
|
+
:stderr => r.stderr
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Memset
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
|
7
|
+
#Memset api key
|
8
|
+
attr_accessor :api_key
|
9
|
+
|
10
|
+
#Memset vps model
|
11
|
+
attr_accessor :sku
|
12
|
+
|
13
|
+
# Image
|
14
|
+
attr_accessor :os
|
15
|
+
|
16
|
+
# Discount code
|
17
|
+
attr_accessor :discount_code
|
18
|
+
|
19
|
+
# Vlan name
|
20
|
+
attr_accessor :vlan
|
21
|
+
|
22
|
+
# Test run
|
23
|
+
attr_accessor :dry_run
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@api_key = UNSET_VALUE
|
27
|
+
@sku = UNSET_VALUE
|
28
|
+
@os = UNSET_VALUE
|
29
|
+
@discount_code = UNSET_VALUE
|
30
|
+
@vlan = UNSET_VALUE
|
31
|
+
@dry_run = UNSET_VALUE
|
32
|
+
end
|
33
|
+
|
34
|
+
def finalize!
|
35
|
+
@api_key = nil if api_key == UNSET_VALUE
|
36
|
+
@sku = nil if @sku == UNSET_VALUE
|
37
|
+
@os = nil if @os == UNSET_VALUE
|
38
|
+
@discount_code = nil if @discount == UNSET_VALUE
|
39
|
+
@vlan = nil if @vlan == UNSET_VALUE
|
40
|
+
@dry_run = /True/ if @dry_run == UNSET_VALUE
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate (machine)
|
45
|
+
errors = []
|
46
|
+
{ "Memset Provider" => errors }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "Memset provider must be run within vagrant"
|
5
|
+
end
|
6
|
+
|
7
|
+
#if Vagrant::Version < "1.2.0"
|
8
|
+
# raise "Memset only runs on Vagrant 1.2.0 and above"
|
9
|
+
#end
|
10
|
+
|
11
|
+
module VagrantPlugins
|
12
|
+
module Memset
|
13
|
+
class Plugin < Vagrant.plugin("2")
|
14
|
+
|
15
|
+
name "Memset Public Cloud"
|
16
|
+
description <<-DESC
|
17
|
+
This plugin enables Vagrant to manage machines in Memset Cloud.
|
18
|
+
DESC
|
19
|
+
|
20
|
+
config(:memset, :provider) do
|
21
|
+
require_relative "config"
|
22
|
+
Config
|
23
|
+
end
|
24
|
+
|
25
|
+
provider(:memset) do
|
26
|
+
# Load the actual provider
|
27
|
+
require_relative "provider"
|
28
|
+
Provider
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "vagrant"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Memset
|
6
|
+
class Provider < Vagrant.plugin("2", :provider)
|
7
|
+
|
8
|
+
def initialize(machine)
|
9
|
+
@machine = machine
|
10
|
+
end
|
11
|
+
|
12
|
+
def action(name)
|
13
|
+
# Attempt to get the action method from the Action class if it
|
14
|
+
# # exists, otherwise return nil to show that we don't support the
|
15
|
+
# # given action.
|
16
|
+
action_method = "action_#{name}"
|
17
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssh_info
|
22
|
+
env = @machine.action("read_ssh_info")
|
23
|
+
env[:machine_ssh_info]
|
24
|
+
end
|
25
|
+
|
26
|
+
def state
|
27
|
+
env = @machine.action("read_state")
|
28
|
+
state_id = env[:machine_state_id]
|
29
|
+
short = "Machine state is #{state_id}"
|
30
|
+
long = "Machine state is #{state_id}"
|
31
|
+
Vagrant::MachineState.new(state_id,short,long)
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
id = @machine.id.nil? ? "new" : @machine.id
|
36
|
+
"MCL (#{id})"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/memset.box
ADDED
Binary file
|
data/vagrant-memset.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
#
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
4
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
5
|
+
require 'vagrant-memset/version'
|
5
6
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "vagrant-memset"
|
9
|
+
gem.version = VagrantPlugins::Memset::VERSION
|
10
|
+
gem.authors = ["Javier Caro Ruiz"]
|
11
|
+
gem.email = ["javienet@gmail.com"]
|
12
|
+
gem.summary = %q{Memset CLoud provider}
|
13
|
+
gem.description = %q{Allows to communicate Vagrant with Memset API}
|
14
|
+
gem.homepage = ""
|
15
|
+
gem.license = "MIT"
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
-
spec.add_development_dependency "rake"
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
23
21
|
|
22
|
+
gem.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
gem.add_development_dependency "rake"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-memset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Caro Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,8 +50,26 @@ files:
|
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
-
-
|
54
|
-
-
|
53
|
+
- changelog.txt
|
54
|
+
- example_box/README.md
|
55
|
+
- example_box/Vagrantfile
|
56
|
+
- example_box/memset.box
|
57
|
+
- example_box/metadata.json
|
58
|
+
- lib/vagrant-memset.rb
|
59
|
+
- lib/vagrant-memset/action.rb
|
60
|
+
- lib/vagrant-memset/action/cancel_server.rb
|
61
|
+
- lib/vagrant-memset/action/connect_memset.rb
|
62
|
+
- lib/vagrant-memset/action/create_server.rb
|
63
|
+
- lib/vagrant-memset/action/is_created.rb
|
64
|
+
- lib/vagrant-memset/action/message_not_created.rb
|
65
|
+
- lib/vagrant-memset/action/read_ssh_info.rb
|
66
|
+
- lib/vagrant-memset/action/read_state.rb
|
67
|
+
- lib/vagrant-memset/action/sync_folders.rb
|
68
|
+
- lib/vagrant-memset/config.rb
|
69
|
+
- lib/vagrant-memset/plugin.rb
|
70
|
+
- lib/vagrant-memset/provider.rb
|
71
|
+
- lib/vagrant-memset/version.rb
|
72
|
+
- memset.box
|
55
73
|
- vagrant-memset.gemspec
|
56
74
|
homepage: ''
|
57
75
|
licenses:
|