umbreo_cli 1.0.141
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 +7 -0
- data/.env +2 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +106 -0
- data/README.md +1625 -0
- data/Rakefile +44 -0
- data/bin/manifests/init.pp +20 -0
- data/bin/umbreo +1684 -0
- data/bin/umbreo.json +34 -0
- data/lib/umbreo.rb +49 -0
- data/lib/umbreo/helpers/alert_message.rb +58 -0
- data/lib/umbreo/helpers/error_exception.rb +15 -0
- data/lib/umbreo/helpers/file_generator.rb +13 -0
- data/lib/umbreo/helpers/json_base_convert.rb +30 -0
- data/lib/umbreo/helpers/table.rb +45 -0
- data/lib/umbreo/models/amazon_web_service_provider.rb +260 -0
- data/lib/umbreo/models/authentication.rb +99 -0
- data/lib/umbreo/models/blueprint.rb +241 -0
- data/lib/umbreo/models/cloud_provider.rb +143 -0
- data/lib/umbreo/models/configuration.rb +98 -0
- data/lib/umbreo/models/digital_ocean_provider.rb +204 -0
- data/lib/umbreo/models/google_compute_engine_provider.rb +232 -0
- data/lib/umbreo/models/instance.rb +170 -0
- data/lib/umbreo/models/module.rb +61 -0
- data/lib/umbreo/models/openstack_provider.rb +260 -0
- data/lib/umbreo/models/profile.rb +61 -0
- data/lib/umbreo/models/provider.rb +164 -0
- data/lib/umbreo/models/service.rb +244 -0
- data/lib/umbreo/models/service_provider.rb +185 -0
- data/lib/umbreo/models/stack.rb +181 -0
- data/lib/umbreo/models/system.rb +43 -0
- data/lib/umbreo/models/umbreo_stack_template.rb +163 -0
- data/lib/umbreo/models/xenserver_provider.rb +200 -0
- data/lib/umbreo/version.rb +3 -0
- data/manifests/init.pp +20 -0
- data/manifests1/init.pp +9 -0
- data/umbreo.gemspec +28 -0
- metadata +241 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
module Umbreo
|
2
|
+
module Models
|
3
|
+
class Configuration
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
create_configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# Create file configuration
|
11
|
+
#
|
12
|
+
def create_configuration
|
13
|
+
File.open(FILE_CONFIG, "w+") if !File.exists?(FILE_CONFIG)
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Write authentication to File Configuration
|
18
|
+
#
|
19
|
+
def write_file_authentication(data, endpoint_url = nil)
|
20
|
+
name = data['name'] || data[:name]
|
21
|
+
email = data['email'] || data[:email]
|
22
|
+
token = data['authentication_token'] || data[:authentication_token]
|
23
|
+
|
24
|
+
File.open("#{FILE_CONFIG}", 'w+') do |file|
|
25
|
+
file.puts("# Umbreo's user configuration file.")
|
26
|
+
file.puts("")
|
27
|
+
file.puts("[user]")
|
28
|
+
file.puts("Name=#{name}")
|
29
|
+
file.puts("Email=#{email}")
|
30
|
+
file.puts("APIKey=#{token}")
|
31
|
+
|
32
|
+
if endpoint_url.present?
|
33
|
+
file.puts("Endpoint=#{endpoint_url}")
|
34
|
+
else
|
35
|
+
file.puts("Endpoint=#{SERVER_END_POINT}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Umbreo::Helpers::AlertMessage.show_success_message(read_file_authentication)
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Read file configuration
|
44
|
+
#
|
45
|
+
def read_file_authentication
|
46
|
+
@parse_file = ParseConfig.new(FILE_CONFIG) rescue nil
|
47
|
+
if @parse_file.present?
|
48
|
+
email = @parse_file.params["user"]["Email"] rescue nil
|
49
|
+
apikey = @parse_file.params['user']['APIKey'] rescue nil
|
50
|
+
name = @parse_file.params['user']['Name'] rescue nil
|
51
|
+
endpoint = @parse_file.params["user"]["Endpoint"] rescue nil
|
52
|
+
|
53
|
+
return { email: email, api_key: apikey, name: name, end_point: endpoint }
|
54
|
+
else
|
55
|
+
return ""
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# remove file configuration
|
61
|
+
#
|
62
|
+
def delete
|
63
|
+
File.delete(FILE_CONFIG) if File.exists? FILE_CONFIG
|
64
|
+
|
65
|
+
return true
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# check valid user
|
70
|
+
#
|
71
|
+
def is_valid_user?
|
72
|
+
@parse_file = ParseConfig.new(FILE_CONFIG) rescue nil
|
73
|
+
@user_auth = @parse_file.params["user"] rescue nil
|
74
|
+
|
75
|
+
if @user_auth.present?
|
76
|
+
email = @user_auth["Email"]
|
77
|
+
apikey = @user_auth["APIKey"]
|
78
|
+
name = @user_auth["Name"]
|
79
|
+
endpoint = @user_auth["Endpoint"]
|
80
|
+
|
81
|
+
request = Typhoeus.get(
|
82
|
+
"#{endpoint}/api/v1/users/is_valid_user",
|
83
|
+
body: {
|
84
|
+
email: email,
|
85
|
+
apikey: apikey,
|
86
|
+
}
|
87
|
+
)
|
88
|
+
data = JSON.parse request.response_body
|
89
|
+
|
90
|
+
return data['success']
|
91
|
+
else
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
module Umbreo
|
2
|
+
module Models
|
3
|
+
class DigitalOceanProvider
|
4
|
+
|
5
|
+
#
|
6
|
+
# init params which required for create cloud provider
|
7
|
+
#
|
8
|
+
def initialize(credentials = {}, name_or_id = nil)
|
9
|
+
if credentials.present?
|
10
|
+
@email = credentials[:email]
|
11
|
+
@api_key = credentials[:api_key]
|
12
|
+
@endpoint = credentials[:end_point] || SERVER_END_POINT
|
13
|
+
end
|
14
|
+
|
15
|
+
@errors = []
|
16
|
+
@name_or_id = name_or_id
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# get list image of digital ocean
|
21
|
+
#
|
22
|
+
def digital_ocean_image_list
|
23
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
24
|
+
|
25
|
+
if valid?
|
26
|
+
Helpers::ErrorException.rescue do
|
27
|
+
data = Typhoeus.get(
|
28
|
+
"#{@endpoint}/api/v1/digital_ocean_services/image_list",
|
29
|
+
body: {
|
30
|
+
authenticate_token: @api_key,
|
31
|
+
email: @email,
|
32
|
+
id: @name_or_id
|
33
|
+
}
|
34
|
+
)
|
35
|
+
|
36
|
+
data = JSON.parse data.response_body
|
37
|
+
|
38
|
+
if data['success']
|
39
|
+
Helpers::Table.show_table(data['images'], "List Digital Ocean Image", ['Image Name', 'Image ID'])
|
40
|
+
else
|
41
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
else
|
45
|
+
Helpers::AlertMessage.show_error_message(error)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# get list flavors of digital ocean
|
51
|
+
#
|
52
|
+
def digital_ocean_flavor_list(image)
|
53
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
54
|
+
@errors << "Image digital ocean provider is required." if image.blank?
|
55
|
+
|
56
|
+
if valid?
|
57
|
+
Helpers::ErrorException.rescue do
|
58
|
+
data = Typhoeus.get(
|
59
|
+
"#{@endpoint}/api/v1/digital_ocean_services/flavor_list",
|
60
|
+
body: {
|
61
|
+
authenticate_token: @api_key,
|
62
|
+
email: @email,
|
63
|
+
id: @name_or_id,
|
64
|
+
image_id: image
|
65
|
+
}
|
66
|
+
)
|
67
|
+
|
68
|
+
data = JSON.parse data.response_body
|
69
|
+
|
70
|
+
if data['success']
|
71
|
+
Helpers::Table.show_table(data['flavors'], "List Digital Ocean Flavor", ['Flavor Detail', 'Slug'])
|
72
|
+
else
|
73
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
else
|
77
|
+
Helpers::AlertMessage.show_error_message(error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# get list flavors of digital ocean
|
83
|
+
#
|
84
|
+
def digital_ocean_region_list(image)
|
85
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
86
|
+
@errors << "Image digital ocean provider is required." if image.blank?
|
87
|
+
|
88
|
+
if valid?
|
89
|
+
Helpers::ErrorException.rescue do
|
90
|
+
data = Typhoeus.get(
|
91
|
+
"#{@endpoint}/api/v1/digital_ocean_services/region_list",
|
92
|
+
body: {
|
93
|
+
authenticate_token: @api_key,
|
94
|
+
email: @email,
|
95
|
+
id: @name_or_id,
|
96
|
+
image_id: image
|
97
|
+
}
|
98
|
+
)
|
99
|
+
|
100
|
+
data = JSON.parse data.response_body
|
101
|
+
|
102
|
+
if data['success']
|
103
|
+
Helpers::Table.show_table(data['regions'], "List Digital Ocean Region", ['Region Name', 'Slug'])
|
104
|
+
else
|
105
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
Helpers::AlertMessage.show_error_message(error)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# get json credential file
|
115
|
+
#
|
116
|
+
def export
|
117
|
+
@errors << "ID or Slug is required." if @name_or_id.blank?
|
118
|
+
|
119
|
+
if valid?
|
120
|
+
Helpers::ErrorException.rescue do
|
121
|
+
data = Typhoeus.get(
|
122
|
+
"#{@endpoint}/api/v1/digital_ocean_services/export",
|
123
|
+
body: {
|
124
|
+
authenticate_token: @api_key,
|
125
|
+
email: @email,
|
126
|
+
id: @name_or_id
|
127
|
+
}
|
128
|
+
)
|
129
|
+
|
130
|
+
data = JSON.parse data.response_body rescue nil
|
131
|
+
user_provider = data["user_provider"]
|
132
|
+
|
133
|
+
if user_provider.present?
|
134
|
+
name_file = "digital_ocean_provider"
|
135
|
+
Helpers::FileGenerator.create(name_file, user_provider)
|
136
|
+
Helpers::AlertMessage.show_success_message("Success export digital ocean provider. Your file is saved on json file with name #{name_file}.json")
|
137
|
+
else
|
138
|
+
Helpers::AlertMessage.show_error_message(data["message"])
|
139
|
+
end
|
140
|
+
end
|
141
|
+
else
|
142
|
+
Helpers::AlertMessage.show_error_message(error)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# check valid json params
|
148
|
+
#
|
149
|
+
def validate(file_path)
|
150
|
+
@errors << "File directory is required." if file_path.blank?
|
151
|
+
|
152
|
+
begin
|
153
|
+
file = File.open(file_path, "r")
|
154
|
+
content = file.read
|
155
|
+
json = JSON.parse(content)
|
156
|
+
encode = Helpers::JsonBaseConvert.encode(json)
|
157
|
+
rescue
|
158
|
+
@errors << "Error on file. Please check again."
|
159
|
+
end
|
160
|
+
|
161
|
+
@errors << "Content of file is required." if content.blank?
|
162
|
+
|
163
|
+
if valid?
|
164
|
+
Helpers::ErrorException.rescue do
|
165
|
+
|
166
|
+
response = Typhoeus.get(
|
167
|
+
"#{@endpoint}/api/v1/digital_ocean_services/validate",
|
168
|
+
body: {
|
169
|
+
authenticate_token: @api_key,
|
170
|
+
email: @email,
|
171
|
+
content: encode
|
172
|
+
}
|
173
|
+
)
|
174
|
+
|
175
|
+
@response = JSON.parse response.response_body
|
176
|
+
|
177
|
+
if @response["success"]
|
178
|
+
Helpers::AlertMessage.show_success_message(@response["message"])
|
179
|
+
else
|
180
|
+
Helpers::AlertMessage.show_error_message(@response["message"])
|
181
|
+
end
|
182
|
+
end
|
183
|
+
else
|
184
|
+
Helpers::AlertMessage.show_error_message(error)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
#
|
189
|
+
# check no errors
|
190
|
+
#
|
191
|
+
def valid?
|
192
|
+
@errors.blank?
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# call errors
|
197
|
+
#
|
198
|
+
def error
|
199
|
+
@errors.first
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
module Umbreo
|
2
|
+
module Models
|
3
|
+
class GoogleComputeEngineProvider
|
4
|
+
|
5
|
+
#
|
6
|
+
# init params which required for create cloud provider
|
7
|
+
#
|
8
|
+
def initialize(credentials = {}, name_or_id = nil)
|
9
|
+
if credentials.present?
|
10
|
+
@email = credentials[:email]
|
11
|
+
@api_key = credentials[:api_key]
|
12
|
+
@endpoint = credentials[:end_point] || SERVER_END_POINT
|
13
|
+
end
|
14
|
+
|
15
|
+
@errors = []
|
16
|
+
@name_or_id = name_or_id
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
#
|
21
|
+
# get list size of amazon web service
|
22
|
+
#
|
23
|
+
def region_list
|
24
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
25
|
+
|
26
|
+
if valid?
|
27
|
+
Helpers::ErrorException.rescue do
|
28
|
+
data = Typhoeus.get(
|
29
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/region_list",
|
30
|
+
body: {
|
31
|
+
authenticate_token: @api_key,
|
32
|
+
email: @email,
|
33
|
+
id: @name_or_id
|
34
|
+
}
|
35
|
+
)
|
36
|
+
|
37
|
+
data = JSON.parse data.response_body
|
38
|
+
|
39
|
+
if data['success']
|
40
|
+
Helpers::Table.table_callback_retrieve_data(data['regions'], "List GCE Region")
|
41
|
+
else
|
42
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
Helpers::AlertMessage.show_error_message(error)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
#
|
52
|
+
# get list machine of google
|
53
|
+
#
|
54
|
+
def machine_list
|
55
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
56
|
+
|
57
|
+
if valid?
|
58
|
+
Helpers::ErrorException.rescue do
|
59
|
+
data = Typhoeus.get(
|
60
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/machine_list",
|
61
|
+
body: {
|
62
|
+
authenticate_token: @api_key,
|
63
|
+
email: @email,
|
64
|
+
id: @name_or_id
|
65
|
+
}
|
66
|
+
)
|
67
|
+
|
68
|
+
data = JSON.parse data.response_body
|
69
|
+
|
70
|
+
if data['success']
|
71
|
+
Helpers::Table.show_table(data['machines'], "List GCE Machine", ['Machine Description', 'Machine Name'])
|
72
|
+
else
|
73
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
else
|
77
|
+
Helpers::AlertMessage.show_error_message(error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# get list machine of google
|
83
|
+
#
|
84
|
+
def image_list
|
85
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
86
|
+
|
87
|
+
if valid?
|
88
|
+
Helpers::ErrorException.rescue do
|
89
|
+
data = Typhoeus.get(
|
90
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/image_list",
|
91
|
+
body: {
|
92
|
+
authenticate_token: @api_key,
|
93
|
+
email: @email,
|
94
|
+
id: @name_or_id
|
95
|
+
}
|
96
|
+
)
|
97
|
+
|
98
|
+
data = JSON.parse data.response_body
|
99
|
+
|
100
|
+
if data['success']
|
101
|
+
Helpers::Table.show_table(data['images'], "List GCE Image", ['Image ID', 'Image Name'])
|
102
|
+
else
|
103
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
104
|
+
end
|
105
|
+
end
|
106
|
+
else
|
107
|
+
Helpers::AlertMessage.show_error_message(error)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# get list network of google
|
113
|
+
#
|
114
|
+
def network_list
|
115
|
+
@errors << "ID or Name provider is required." if @name_or_id.blank?
|
116
|
+
|
117
|
+
if valid?
|
118
|
+
Helpers::ErrorException.rescue do
|
119
|
+
data = Typhoeus.get(
|
120
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/network_list",
|
121
|
+
body: {
|
122
|
+
authenticate_token: @api_key,
|
123
|
+
email: @email,
|
124
|
+
id: @name_or_id
|
125
|
+
}
|
126
|
+
)
|
127
|
+
|
128
|
+
data = JSON.parse data.response_body
|
129
|
+
|
130
|
+
if data['success']
|
131
|
+
Helpers::Table.table_callback_retrieve_data(data['networks'], "List GCE Network")
|
132
|
+
else
|
133
|
+
Helpers::AlertMessage.show_error_message(data['message'])
|
134
|
+
end
|
135
|
+
end
|
136
|
+
else
|
137
|
+
Helpers::AlertMessage.show_error_message(error)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# get json credential file
|
143
|
+
#
|
144
|
+
def export
|
145
|
+
@errors << "ID or Slug is required." if @name_or_id.blank?
|
146
|
+
|
147
|
+
if valid?
|
148
|
+
Helpers::ErrorException.rescue do
|
149
|
+
data = Typhoeus.get(
|
150
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/export",
|
151
|
+
body: {
|
152
|
+
authenticate_token: @api_key,
|
153
|
+
email: @email,
|
154
|
+
id: @name_or_id
|
155
|
+
}
|
156
|
+
)
|
157
|
+
|
158
|
+
data = JSON.parse data.response_body rescue nil
|
159
|
+
user_provider = data["user_provider"]
|
160
|
+
|
161
|
+
if user_provider.present?
|
162
|
+
name_file = "google_compute_engine_service_provider"
|
163
|
+
Helpers::FileGenerator.create(name_file, user_provider)
|
164
|
+
Helpers::AlertMessage.show_success_message("Success export google compute engine provider. Your file is saved on json file with name #{name_file}.json")
|
165
|
+
else
|
166
|
+
Helpers::AlertMessage.show_error_message(data["message"])
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else
|
170
|
+
Helpers::AlertMessage.show_error_message(error)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
#
|
175
|
+
# check valid json params
|
176
|
+
#
|
177
|
+
def validate(file_path)
|
178
|
+
@errors << "File directory is required." if file_path.blank?
|
179
|
+
|
180
|
+
begin
|
181
|
+
file = File.open(file_path, "r")
|
182
|
+
content = file.read
|
183
|
+
json = JSON.parse(content)
|
184
|
+
encode = Helpers::JsonBaseConvert.encode(json)
|
185
|
+
rescue
|
186
|
+
@errors << "Error on file. Please check again."
|
187
|
+
end
|
188
|
+
|
189
|
+
@errors << "Content of file is required." if content.blank?
|
190
|
+
|
191
|
+
if valid?
|
192
|
+
Helpers::ErrorException.rescue do
|
193
|
+
|
194
|
+
response = Typhoeus.get(
|
195
|
+
"#{@endpoint}/api/v1/google_compute_engine_services/validate",
|
196
|
+
body: {
|
197
|
+
authenticate_token: @api_key,
|
198
|
+
email: @email,
|
199
|
+
content: encode
|
200
|
+
}
|
201
|
+
)
|
202
|
+
|
203
|
+
@response = JSON.parse response.response_body
|
204
|
+
|
205
|
+
if @response["success"]
|
206
|
+
Helpers::AlertMessage.show_success_message(@response["message"])
|
207
|
+
else
|
208
|
+
Helpers::AlertMessage.show_error_message(@response["message"])
|
209
|
+
end
|
210
|
+
end
|
211
|
+
else
|
212
|
+
Helpers::AlertMessage.show_error_message(error)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# check no errors
|
218
|
+
#
|
219
|
+
def valid?
|
220
|
+
@errors.blank?
|
221
|
+
end
|
222
|
+
|
223
|
+
#
|
224
|
+
# call errors
|
225
|
+
#
|
226
|
+
def error
|
227
|
+
@errors.first
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|