vagrant-subutai 1.0.3 → 1.1.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 +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +7 -0
- data/README.md +3 -2
- data/lib/vagrant-subutai.rb +33 -7
- data/lib/vagrant-subutai/blueprint/ansible_controller.rb +93 -0
- data/lib/vagrant-subutai/blueprint/environment_controller.rb +324 -0
- data/lib/vagrant-subutai/blueprint/variables_controller.rb +547 -0
- data/lib/vagrant-subutai/command.rb +84 -90
- data/lib/vagrant-subutai/config.rb +8 -43
- data/lib/vagrant-subutai/configs/configs.rb +179 -0
- data/lib/vagrant-subutai/models/ansible.rb +18 -0
- data/lib/vagrant-subutai/models/console/container.rb +27 -0
- data/lib/vagrant-subutai/models/console/environment.rb +16 -0
- data/lib/vagrant-subutai/models/container.rb +34 -0
- data/lib/vagrant-subutai/models/domain.rb +11 -0
- data/lib/vagrant-subutai/models/environment.rb +13 -0
- data/lib/vagrant-subutai/packer/subutai_config.rb +17 -1
- data/lib/vagrant-subutai/plugin.rb +10 -3
- data/lib/vagrant-subutai/provisioner.rb +63 -0
- data/lib/vagrant-subutai/put.rb +21 -0
- data/lib/vagrant-subutai/rest/bazaar.rb +141 -0
- data/lib/vagrant-subutai/rest/gorjun.rb +40 -0
- data/lib/vagrant-subutai/rest/subutai_console.rb +189 -0
- data/lib/vagrant-subutai/subutai_commands.rb +250 -122
- data/lib/vagrant-subutai/version.rb +1 -1
- metadata +18 -6
- data/Vagrantfile +0 -7
- data/lib/vagrant-subutai/models/resource_host.rb +0 -7
- data/lib/vagrant-subutai/rest.rb +0 -77
- data/lib/vagrant-subutai/rh_controller.rb +0 -32
@@ -2,116 +2,110 @@ require_relative '../vagrant-subutai'
|
|
2
2
|
require 'optparse'
|
3
3
|
require 'io/console'
|
4
4
|
require 'net/https'
|
5
|
-
require_relative 'subutai_commands'
|
6
5
|
require 'fileutils'
|
7
6
|
|
8
7
|
module VagrantSubutai
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
class Command < Vagrant.plugin('2', :command)
|
9
|
+
attr_accessor :box
|
10
|
+
# shows description when `vagrant list-commands` is triggered
|
11
|
+
def self.synopsis
|
12
|
+
'Vagrant Subutai Plugin - executes Subutai scripts in target hosts'
|
13
|
+
end
|
15
14
|
|
16
|
-
def execute
|
17
|
-
cli_info
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
$SUBUTAI_BOX_NAME = machine.config.vm.box
|
22
|
-
end
|
16
|
+
def execute
|
17
|
+
cli_info
|
23
18
|
|
24
|
-
|
19
|
+
# Gets Subutai console url and box name from Vagrantfile
|
20
|
+
with_target_vms(nil, single_target: true) do |machine|
|
21
|
+
@box = machine.config.vm.box
|
22
|
+
end
|
25
23
|
|
26
|
-
|
27
|
-
when 'register'
|
28
|
-
check_subutai_console_url(subutai_cli)
|
29
|
-
subutai_cli.register(nil, nil)
|
30
|
-
when 'fingerprint'
|
31
|
-
check_subutai_console_url(subutai_cli)
|
32
|
-
subutai_cli.fingerprint($SUBUTAI_CONSOLE_URL)
|
33
|
-
when 'disk'
|
34
|
-
disk = SubutaiConfig.get(:DISK_SIZE)
|
24
|
+
subutai_cli = Commands.new(ARGV, @env)
|
35
25
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
case ARGV[1]
|
27
|
+
when 'register'
|
28
|
+
subutai_cli.register(nil, nil, check_subutai_console_url(subutai_cli))
|
29
|
+
when 'fingerprint'
|
30
|
+
subutai_cli.fingerprint(check_subutai_console_url(subutai_cli))
|
31
|
+
when 'open'
|
32
|
+
subutai_cli.open(check_subutai_console_url(subutai_cli))
|
33
|
+
when 'blueprint'
|
34
|
+
subutai_cli.blueprint(check_subutai_console_url(subutai_cli))
|
35
|
+
when '-h'
|
36
|
+
STDOUT.puts cli_info
|
37
|
+
when '--help'
|
38
|
+
STDOUT.puts cli_info
|
39
|
+
else
|
40
|
+
# All Agent CLI commands implemented here
|
47
41
|
|
48
|
-
|
49
|
-
|
42
|
+
command = ARGV
|
43
|
+
command.shift
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
45
|
+
if command.empty?
|
46
|
+
STDOUT.puts cli_info
|
47
|
+
else
|
48
|
+
subutai_cli.ssh("#{subutai_cli.base} #{command.join(' ')}")
|
49
|
+
end
|
57
50
|
end
|
51
|
+
end
|
58
52
|
|
59
|
-
|
60
|
-
|
53
|
+
def check_subutai_console_url(subutai_cli)
|
54
|
+
ip = subutai_cli.info(Configs::VagrantCommand::ARG_IP_ADDR)
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
$SUBUTAI_CONSOLE_URL = "https://#{ip}:#{SubutaiConsoleAPI::PORT}"
|
56
|
+
if ip.nil?
|
57
|
+
STDOUT.puts 'We can\'t detect your Subutai Console ip address!'
|
58
|
+
exit
|
67
59
|
end
|
60
|
+
"https://#{ip}:#{Configs::SubutaiConsoleAPI::PORT}"
|
61
|
+
end
|
68
62
|
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
def cli_info
|
64
|
+
commands = <<-EOF
|
65
|
+
|
72
66
|
Usage: vagrant subutai command [command options] [arguments...]
|
73
67
|
|
74
68
|
COMMANDS:
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
69
|
+
attach - attach to Subutai container
|
70
|
+
backup - backup Subutai container
|
71
|
+
batch - batch commands execution
|
72
|
+
checkpoint - checkpoint/restore in user space
|
73
|
+
clone - clone Subutai container
|
74
|
+
cleanup - clean Subutai environment
|
75
|
+
config - edit container config
|
76
|
+
daemon - start Subutai agent
|
77
|
+
demote - demote Subutai container
|
78
|
+
destroy - destroy Subutai container
|
79
|
+
export - export Subutai container
|
80
|
+
import - import Subutai template
|
81
|
+
info - information about host system
|
82
|
+
hostname - Set hostname of container or host
|
83
|
+
list - list Subutai container
|
84
|
+
log - print application logs
|
85
|
+
map - Subutai port mapping
|
86
|
+
metrics - list Subutai container
|
87
|
+
migrate - migrate Subutai container
|
88
|
+
p2p - P2P network operations
|
89
|
+
promote - promote Subutai container
|
90
|
+
proxy - Subutai reverse proxy
|
91
|
+
quota - set quotas for Subutai container
|
92
|
+
rename - rename Subutai container
|
93
|
+
restore - restore Subutai container
|
94
|
+
stats - statistics from host
|
95
|
+
start - start Subutai container
|
96
|
+
stop - stop Subutai container
|
97
|
+
tunnel - SSH tunnel management
|
98
|
+
update - update Subutai management, container or Resource host
|
99
|
+
vxlan - VXLAN tunnels operation
|
100
|
+
register - register Subutai PeerOS to Bazaar
|
101
|
+
fingerprint - shows fingerprint Subutai Console
|
102
|
+
open - open the Subutai PeerOS in browser
|
103
|
+
blueprint - run blueprint provisioning
|
109
104
|
|
110
105
|
GLOBAL OPTIONS:
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
106
|
+
-h, --help - show help
|
107
|
+
EOF
|
108
|
+
commands
|
115
109
|
end
|
116
110
|
end
|
117
111
|
end
|
@@ -1,52 +1,17 @@
|
|
1
1
|
require_relative '../vagrant-subutai'
|
2
2
|
|
3
|
-
module SubutaiAgentCommand
|
4
|
-
BASE = "sudo /snap/bin/subutai"
|
5
|
-
UPDATE = " update" # arg required
|
6
|
-
LOG = " log"
|
7
|
-
INFO = " info" # arg required
|
8
|
-
TEMPLATE_IMPORT = " import ubuntu16"
|
9
|
-
TEMPLATE_CLONE = " clone ubuntu16" # arg required
|
10
|
-
TEMPLATE_ATTACH = " attach" # arg required
|
11
|
-
TEMPLATE_EXPORT = " export" # arg required
|
12
|
-
LIST = " list"
|
13
|
-
end
|
14
|
-
|
15
|
-
module SubutaiConsoleAPI
|
16
|
-
PORT = "8443"
|
17
|
-
module V1
|
18
|
-
TOKEN = "/rest/v1/identity/gettoken"
|
19
|
-
REGISTER_HUB = "/rest/v1/hub/register?sptoken="
|
20
|
-
APPROVE = "/rest/v1/registration/requests"
|
21
|
-
FINGERPRINT = "/rest/v1/security/keyman/getpublickeyfingerprint"
|
22
|
-
REQUESTS = "/rest/v1/registration/requests?sptoken="
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
3
|
module VagrantSubutai
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
class Config < Vagrant.plugin('2', :config)
|
31
|
-
attr_accessor :url
|
4
|
+
class Config < Vagrant.plugin('2', :config)
|
5
|
+
attr_accessor :url
|
32
6
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@url = UNSET_VALUE
|
10
|
+
end
|
37
11
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
12
|
+
def finalize!
|
13
|
+
@url = '' if @url == UNSET_VALUE
|
41
14
|
end
|
42
15
|
end
|
43
16
|
end
|
44
17
|
|
45
|
-
module VagrantCommand
|
46
|
-
INIT = "vagrant init"
|
47
|
-
UP = "vagrant up"
|
48
|
-
RH_UP = "SUBUTAI_PEER=false vagrant up"
|
49
|
-
PROVISION = "vagrant provision"
|
50
|
-
SUBUTAI_ID = "vagrant subutai --info id"
|
51
|
-
ARG_IP_ADDR = "ipaddr"
|
52
|
-
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
module VagrantSubutai
|
2
|
+
module Configs
|
3
|
+
module VagrantCommand
|
4
|
+
INIT = 'vagrant init'.freeze
|
5
|
+
UP = 'vagrant up'.freeze
|
6
|
+
RH_UP = 'SUBUTAI_PEER=false vagrant up'.freeze
|
7
|
+
PROVISION = 'vagrant provision'.freeze
|
8
|
+
SUBUTAI_ID = 'vagrant subutai --info id'.freeze
|
9
|
+
ARG_IP_ADDR = 'ipaddr'.freeze
|
10
|
+
end
|
11
|
+
|
12
|
+
module Ansible
|
13
|
+
TEMPLATE_NAME = 'generic-ansible'.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
module Quota
|
17
|
+
# CPU percentage %
|
18
|
+
# RAM, DISK unit Gigabytes
|
19
|
+
RESOURCE = {
|
20
|
+
TINY: { CPU: 10, RAM: 0.25, DISK: 4 },
|
21
|
+
SMALL: { CPU: 25, RAM: 0.5, DISK: 10 },
|
22
|
+
MEDIUM: { CPU: 50, RAM: 1, DISK: 20 },
|
23
|
+
LARGE: { CPU: 75, RAM: 2, DISK: 40 },
|
24
|
+
HUGE: { CPU: 100, RAM: 4, DISK: 100 }
|
25
|
+
}.freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
module Blueprint
|
29
|
+
SCHEME = {
|
30
|
+
name: 'name',
|
31
|
+
description: 'My static website',
|
32
|
+
version: 'Blueprint version',
|
33
|
+
'author': 'Author',
|
34
|
+
'ssh-key': 'ssh-key-name',
|
35
|
+
containers: [
|
36
|
+
{
|
37
|
+
hostname: 'www',
|
38
|
+
template: 'apache',
|
39
|
+
size: 'TINY',
|
40
|
+
'peer-criteria': 'HTTP-GROUP',
|
41
|
+
'port-mapping': [
|
42
|
+
{
|
43
|
+
protocol: 'http',
|
44
|
+
domain: '${domain}',
|
45
|
+
'internal-port': '80',
|
46
|
+
'external-port': '80'
|
47
|
+
},
|
48
|
+
{
|
49
|
+
protocol: 'tcp',
|
50
|
+
domain: '${domain}',
|
51
|
+
'internal-port': '22',
|
52
|
+
'external-port': '4040'
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
],
|
57
|
+
'peer-criteria': [
|
58
|
+
{
|
59
|
+
name: 'HTTP-GROUP',
|
60
|
+
'max-price': '5',
|
61
|
+
'avg-cpu-load': '50',
|
62
|
+
'min-free-ram': '128',
|
63
|
+
'min-free-disk-space': '10'
|
64
|
+
}
|
65
|
+
],
|
66
|
+
'ansible-configuration': {
|
67
|
+
'source-url': 'zip_file_url',
|
68
|
+
'ansible-playbook': 'any_name',
|
69
|
+
'extra-vars': [
|
70
|
+
{
|
71
|
+
'key': 'any_name',
|
72
|
+
'value': 'any_name_value'
|
73
|
+
}
|
74
|
+
],
|
75
|
+
'groups': [
|
76
|
+
{
|
77
|
+
'name': 'any_name',
|
78
|
+
'python-interpreter': '/usr/bin/python3',
|
79
|
+
'hostnames': [
|
80
|
+
'hostname_of_container'
|
81
|
+
]
|
82
|
+
}
|
83
|
+
]
|
84
|
+
},
|
85
|
+
'user-variables': {
|
86
|
+
any_name: {
|
87
|
+
description: 'Select your domain or create new one',
|
88
|
+
type: 'domain',
|
89
|
+
default: 'site.env.subutai.cloud',
|
90
|
+
validation: '[a-zA-Z0-9.-]+'
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}.freeze
|
94
|
+
CONTAINER_SIZES = %w(TINY SMALL MEDIUM LARGE HUGE).freeze
|
95
|
+
|
96
|
+
module MODE
|
97
|
+
PEER = 'peer'.freeze
|
98
|
+
BAZAAR = 'bazaar'.freeze
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
module Environment
|
103
|
+
PROD = 'prod'.freeze
|
104
|
+
DEV = 'dev'.freeze
|
105
|
+
SYSNET = 'sysnet'.freeze
|
106
|
+
MASTER = 'master'.freeze
|
107
|
+
end
|
108
|
+
|
109
|
+
module SubutaiConsoleAPI
|
110
|
+
PORT = '8443'.freeze
|
111
|
+
COMMAND = '/rest/ui/commands?sptoken='.freeze
|
112
|
+
|
113
|
+
module V1
|
114
|
+
TOKEN = '/rest/v1/identity/gettoken'.freeze
|
115
|
+
REGISTER_HUB = '/rest/v1/hub/register?sptoken='.freeze
|
116
|
+
APPROVE = '/rest/v1/registration/requests'.freeze
|
117
|
+
FINGERPRINT = '/rest/v1/security/keyman/getpublickeyfingerprint'.freeze
|
118
|
+
REQUESTS = '/rest/v1/registration/requests?sptoken='.freeze
|
119
|
+
ENVIRONMENT = '/rest/v1/environments?sptoken='.freeze
|
120
|
+
HOSTS = '/rest/v1/hosts?sptoken='.freeze
|
121
|
+
ENVIRONMENTS = '/rest/v1/environments?sptoken='.freeze
|
122
|
+
LOG = '/rest/v1/tracker/operations/ENVIRONMENT%20MANAGER/'.freeze
|
123
|
+
RESOURCES = '/rest/v1/peer/resources?sptoken='.freeze
|
124
|
+
DOMAIN = '/rest/ui/environments/'.freeze
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
module Gorjun
|
129
|
+
INFO_DEV = 'https://devcdn.subutai.io:8338/kurjun/rest/template/info'.freeze
|
130
|
+
INFO_MASTER = 'https://mastercdn.subutai.io:8338/kurjun/rest/template/info'.freeze
|
131
|
+
INFO_PROD = 'https://cdn.subutai.io:8338/kurjun/rest/template/info'.freeze
|
132
|
+
end
|
133
|
+
|
134
|
+
module Bazaar
|
135
|
+
BASE_DEV = 'https://devbazaar.subutai.io'.freeze
|
136
|
+
BASE_MASTER = 'https://masterbazaar.subutai.io'.freeze
|
137
|
+
BASE_PROD = 'https://bazaar.subutai.io'.freeze
|
138
|
+
|
139
|
+
module V1
|
140
|
+
PEER = '/rest/v1/tray/peers/{FINGERPRINT}'.freeze
|
141
|
+
LOGIN = '/rest/v1/client/login'.freeze
|
142
|
+
ENVIRONMENTS = '/rest/v1/client/environments'.freeze
|
143
|
+
LOG = '/rest/v1/client/environments/{SUBUTAI_ID}'.freeze
|
144
|
+
DOMAIN_RESERVE = '/rest/v1/client/domains/{DOMAIN}'
|
145
|
+
VARIABLES = '/rest/v1/client/blueprint/variables'.freeze
|
146
|
+
BLUEPRINT = '/rest/v1/client/blueprint/build'.freeze
|
147
|
+
DOMAIN_LIST = '/rest/v1/client/domains'.freeze
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
module Blueprint
|
152
|
+
FILE_NAME = 'Subutai.json'.freeze
|
153
|
+
end
|
154
|
+
|
155
|
+
module EnvironmentState
|
156
|
+
FAILED = 'FAILED'.freeze
|
157
|
+
SUCCEEDED = 'SUCCEEDED'.freeze
|
158
|
+
HEALTHY = 'HEALTHY'.freeze
|
159
|
+
UNHEALTHY = 'UNHEALTHY'.freeze
|
160
|
+
end
|
161
|
+
|
162
|
+
module ApplicationState
|
163
|
+
INSTALLING = 'INSTALLING'.freeze
|
164
|
+
INSTALLED = 'INSTALLED'.freeze
|
165
|
+
end
|
166
|
+
|
167
|
+
module SubutaiAgentCommand
|
168
|
+
BASE = 'sudo /snap/bin/subutai'.freeze
|
169
|
+
UPDATE = ' update'.freeze # arg required
|
170
|
+
LOG = ' log'.freeze
|
171
|
+
INFO = ' info'.freeze # arg required
|
172
|
+
LIST = ' list'.freeze
|
173
|
+
TEMPLATE_IMPORT = ' import ubuntu16'.freeze
|
174
|
+
TEMPLATE_CLONE = ' clone ubuntu16'.freeze # arg required
|
175
|
+
TEMPLATE_ATTACH = ' attach'.freeze # arg required
|
176
|
+
TEMPLATE_EXPORT = ' export'.freeze # arg required
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Blueprint ansible model
|
2
|
+
|
3
|
+
module VagrantSubutai
|
4
|
+
module Models
|
5
|
+
class Ansible
|
6
|
+
attr_accessor :extra_vars, # Array of JSON objects { "key": string, "value": string }
|
7
|
+
:source_url,
|
8
|
+
:ansible_playbook,
|
9
|
+
:groups # Array of JSON objects { "name": string, "hostnames": [ string ] }
|
10
|
+
|
11
|
+
def context
|
12
|
+
self.instance_variables.map do |attribute|
|
13
|
+
{ attribute => self.instance_variable_get(attribute) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|