foreman_azure_rm 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 +7 -0
- data/LICENSE +619 -0
- data/README.md +23 -0
- data/Rakefile +47 -0
- data/app/assets/javascripts/foreman_azure_rm/azure_rm_location_callbacks.js +72 -0
- data/app/assets/javascripts/foreman_azure_rm/azure_rm_size_from_location.js +39 -0
- data/app/assets/javascripts/foreman_azure_rm/azure_rm_subnet_from_vnet.js +39 -0
- data/app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb +33 -0
- data/app/models/concerns/fog_extensions/azurerm/compute.rb +246 -0
- data/app/models/concerns/fog_extensions/azurerm/data_disk.rb +24 -0
- data/app/models/concerns/fog_extensions/azurerm/managed_disk.rb +10 -0
- data/app/models/concerns/fog_extensions/azurerm/managed_disks.rb +15 -0
- data/app/models/concerns/fog_extensions/azurerm/network_interface.rb +19 -0
- data/app/models/concerns/fog_extensions/azurerm/network_interfaces.rb +16 -0
- data/app/models/concerns/fog_extensions/azurerm/server.rb +123 -0
- data/app/models/concerns/fog_extensions/azurerm/servers.rb +23 -0
- data/app/models/foreman_azure_rm/azure_rm.rb +310 -0
- data/app/overrides/add_location_size_js.rb +20 -0
- data/app/views/compute_resources/form/_azurerm.html.erb +9 -0
- data/app/views/compute_resources/show/_azurerm.html.erb +0 -0
- data/app/views/compute_resources_vms/form/azurerm/_base.html.erb +207 -0
- data/app/views/compute_resources_vms/form/azurerm/_network.html.erb +23 -0
- data/app/views/compute_resources_vms/form/azurerm/_volume.html.erb +22 -0
- data/app/views/compute_resources_vms/index/_azurerm.html.erb +29 -0
- data/app/views/compute_resources_vms/show/_azurerm.html.erb +14 -0
- data/app/views/images/form/_azurerm.html.erb +6 -0
- data/config/routes.rb +8 -0
- data/lib/foreman_azure_rm.rb +5 -0
- data/lib/foreman_azure_rm/engine.rb +92 -0
- data/lib/foreman_azure_rm/version.rb +3 -0
- data/locale/gemspec.rb +2 -0
- metadata +103 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
Deface::Override.new(
|
2
|
+
:virtual_path => 'hosts/_form',
|
3
|
+
:name => 'add_location_size_js',
|
4
|
+
:insert_after => 'erb[loud]:contains("javascript")',
|
5
|
+
:text => "<% javascript 'foreman_azure_rm/azure_rm_size_from_location' %>"
|
6
|
+
)
|
7
|
+
|
8
|
+
Deface::Override.new(
|
9
|
+
:virtual_path => 'hosts/_form',
|
10
|
+
:name => 'add_vnet_subnets_js',
|
11
|
+
:insert_after => 'erb[loud]:contains("javascript")',
|
12
|
+
:text => "<% javascript 'foreman_azure_rm/azure_rm_subnet_from_vnet' %>"
|
13
|
+
)
|
14
|
+
|
15
|
+
Deface::Override.new(
|
16
|
+
:virtual_path => 'hosts/_form',
|
17
|
+
:name => 'add_location_callbacks_js',
|
18
|
+
:insert_after => 'erb[loud]:contains("javascript")',
|
19
|
+
:text => "<% javascript 'foreman_azure_rm/azure_rm_location_callbacks' %>"
|
20
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= text_f f, :url, :label => _('Client ID'), :required => true %>
|
2
|
+
<%= password_f f, :password, :label => _('Client Secret'), :required => true %>
|
3
|
+
<%= text_f f, :user, :label => _('Subscription ID'), :required => true %>
|
4
|
+
<%= text_f f, :uuid, :label => _('Tenant ID'), :required => true,
|
5
|
+
:help_inline => link_to_function(
|
6
|
+
_("Test Connection"), "testConnection(this)",
|
7
|
+
:class => "btn btn-default",
|
8
|
+
:'data-url' => test_connection_compute_resources_path) +
|
9
|
+
hidden_spinner('', :id => 'test_connection_indicator').html_safe %>
|
File without changes
|
@@ -0,0 +1,207 @@
|
|
1
|
+
<% arch ||= nil
|
2
|
+
os ||= nil
|
3
|
+
images = possible_images(compute_resource, arch, os)
|
4
|
+
resource_groups = compute_resource.resource_groups
|
5
|
+
%>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
function azure_rm_location_callback() {
|
9
|
+
azure_rm_get_size_from_location();
|
10
|
+
azure_rm_subnets_from_location();
|
11
|
+
}
|
12
|
+
|
13
|
+
function azure_rm_get_size_from_location() {
|
14
|
+
var location = $('#azure_rm_location').val();
|
15
|
+
var size_spinner = $('#azure_rm_size_spinner');
|
16
|
+
var sizes = $('#azure_rm_size');
|
17
|
+
var imageId = $('#azure_rm_image_id').val();
|
18
|
+
if (typeof tfm == 'undefined') { // earlier than 1.13
|
19
|
+
foreman.tools.showSpinner();
|
20
|
+
} else {
|
21
|
+
tfm.tools.showSpinner();
|
22
|
+
}
|
23
|
+
size_spinner.removeClass('hide');
|
24
|
+
$.ajax({
|
25
|
+
data: {"location_string": location, "image_id": imageId},
|
26
|
+
type: 'get',
|
27
|
+
url: '/azure_rm/sizes',
|
28
|
+
complete: function () {
|
29
|
+
reloadOnAjaxComplete('#azure_rm_size');
|
30
|
+
size_spinner.addClass('hide');
|
31
|
+
if (typeof tfm == 'undefined') { // earlier than 1.13
|
32
|
+
foreman.tools.hideSpinner();
|
33
|
+
} else {
|
34
|
+
tfm.tools.hideSpinner();
|
35
|
+
}
|
36
|
+
},
|
37
|
+
error: function (request, status, error) {
|
38
|
+
console.log(request);
|
39
|
+
console.log(error);
|
40
|
+
},
|
41
|
+
success: function (request_sizes) {
|
42
|
+
sizes.empty();
|
43
|
+
$.each(request_sizes, function () {
|
44
|
+
sizes.append($("<option />").val(this).text(this));
|
45
|
+
});
|
46
|
+
}
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
function azure_rm_subnets_from_location() {
|
51
|
+
var imageId = $('#azure_rm_image_id').val();
|
52
|
+
var subnets = $('#azure_rm_subnet');
|
53
|
+
var location = $('#azure_rm_location').val();
|
54
|
+
if (typeof tfm == 'undefined') { // earlier than 1.13
|
55
|
+
foreman.tools.showSpinner();
|
56
|
+
} else {
|
57
|
+
tfm.tools.showSpinner();
|
58
|
+
}
|
59
|
+
$.ajax({
|
60
|
+
data: {"image_id": imageId, "location": location},
|
61
|
+
type: "get",
|
62
|
+
url: "/azure_rm/subnets",
|
63
|
+
complete: function () {
|
64
|
+
reloadOnAjaxComplete('#azure_rm_subnet');
|
65
|
+
if (typeof tfm == 'undefined') { // earlier than 1.13
|
66
|
+
foreman.tools.hideSpinner();
|
67
|
+
} else {
|
68
|
+
tfm.tools.hideSpinner();
|
69
|
+
}
|
70
|
+
},
|
71
|
+
error: function (request, status, error) {
|
72
|
+
console.log(status);
|
73
|
+
console.log(request);
|
74
|
+
console.log(error);
|
75
|
+
},
|
76
|
+
success: function (request_subnets) {
|
77
|
+
subnets.empty();
|
78
|
+
$.each(request_subnets, function () {
|
79
|
+
//noinspection JSAnnotator
|
80
|
+
subnets.append($("<option />").val(this.id).text(`${this.virtual_network_name} - ${this.name} (${this.address_prefix})`));
|
81
|
+
});
|
82
|
+
}
|
83
|
+
});
|
84
|
+
}
|
85
|
+
</script>
|
86
|
+
|
87
|
+
<%= selectable_f f, :location, compute_resource.locations,
|
88
|
+
{ :include_blank => _('Please select an Azure region') },
|
89
|
+
{
|
90
|
+
:label => _('Azure Region'),
|
91
|
+
:required => true,
|
92
|
+
:id => 'azure_rm_location',
|
93
|
+
:label_size => "col-md-2",
|
94
|
+
:onchange => 'azure_rm_location_callback();',
|
95
|
+
:help_inline => spinner_button_f(f, _('Reload Images, Sizes, vNets'),
|
96
|
+
'azure_rm_location_callback();',
|
97
|
+
{
|
98
|
+
:id => 'load_subnets_btn',
|
99
|
+
:spinner_id => 'load_subnets_indicator',
|
100
|
+
:class => 'btn-success',
|
101
|
+
:spinner_class => 'spinner-inverse'
|
102
|
+
})
|
103
|
+
}
|
104
|
+
%>
|
105
|
+
|
106
|
+
<%= selectable_f f, :resource_group, resource_groups,
|
107
|
+
{ :include_blank => true },
|
108
|
+
{
|
109
|
+
:disabled => resource_groups.empty?,
|
110
|
+
:label => _('Resource Group'),
|
111
|
+
:required => true,
|
112
|
+
:id => 'azure_rm_rg'
|
113
|
+
}
|
114
|
+
%>
|
115
|
+
|
116
|
+
<%= selectable_f f, :vm_size, [],
|
117
|
+
{ :include_blank => _('Please first select an Azure region') },
|
118
|
+
{
|
119
|
+
:label => _('VM Size'),
|
120
|
+
:required => true,
|
121
|
+
:id => 'azure_rm_size'
|
122
|
+
}
|
123
|
+
%>
|
124
|
+
|
125
|
+
<%= selectable_f f, :platform, %w(Linux Windows),
|
126
|
+
{},
|
127
|
+
{
|
128
|
+
:label => _('Platform'),
|
129
|
+
:required => true
|
130
|
+
}
|
131
|
+
%>
|
132
|
+
|
133
|
+
<%= text_f f, :username,
|
134
|
+
{
|
135
|
+
:label => _('Username'),
|
136
|
+
:required => true
|
137
|
+
}
|
138
|
+
%>
|
139
|
+
<%= text_f f, :password,
|
140
|
+
{
|
141
|
+
:label => _('Password'),
|
142
|
+
:required => true
|
143
|
+
}
|
144
|
+
%>
|
145
|
+
|
146
|
+
<%= textarea_f f, :ssh_key_data,
|
147
|
+
{
|
148
|
+
:label => _('SSH Key')
|
149
|
+
}
|
150
|
+
%>
|
151
|
+
|
152
|
+
<%= number_f f, :os_disk_size,
|
153
|
+
{
|
154
|
+
:class => "col-md-2",
|
155
|
+
:label => _('OS Disk Size (GB)'), :label_size => "col-md-2",
|
156
|
+
:required => true
|
157
|
+
}
|
158
|
+
%>
|
159
|
+
|
160
|
+
<%= checkbox_f f, :premium_os_disk,
|
161
|
+
{
|
162
|
+
:label => _('Premium OS Disk'), :label_size => "col-md-2"
|
163
|
+
},
|
164
|
+
'true',
|
165
|
+
'false'
|
166
|
+
%>
|
167
|
+
|
168
|
+
<%= selectable_f f, :os_disk_caching, %w(None ReadOnly ReadWrite),
|
169
|
+
{},
|
170
|
+
{
|
171
|
+
:label => _('OS Disk Caching'),
|
172
|
+
:required => true,
|
173
|
+
:class => "col-md-2"
|
174
|
+
}
|
175
|
+
%>
|
176
|
+
|
177
|
+
<%= text_f f, :puppet_master,
|
178
|
+
{
|
179
|
+
:label => _('Puppet Master'),
|
180
|
+
:help_inline => _('For the Azure Puppet extension for Windows')
|
181
|
+
}
|
182
|
+
%>
|
183
|
+
|
184
|
+
<%= text_f f, :script_command,
|
185
|
+
{
|
186
|
+
:label => _('Custom Script Command')
|
187
|
+
}
|
188
|
+
%>
|
189
|
+
|
190
|
+
<%= text_f f, :script_uris,
|
191
|
+
{
|
192
|
+
:label => _('Comma seperated file URIs')
|
193
|
+
}
|
194
|
+
%>
|
195
|
+
|
196
|
+
<div id="image_selection">
|
197
|
+
<%= select_f f, :image_id, images, :uuid, :name,
|
198
|
+
{ :include_blank => (images.empty? or images.size == 1) ? false : _('Please select an image') },
|
199
|
+
{
|
200
|
+
:disabled => images.empty?,
|
201
|
+
:label => _('Image'),
|
202
|
+
:required => true,
|
203
|
+
:label_size => "col-md-2",
|
204
|
+
:id => 'azure_rm_image_id'
|
205
|
+
}
|
206
|
+
%>
|
207
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= selectable_f f, :network, [],
|
2
|
+
{ :include_blank => _('Please first select an image and an Azure region')},
|
3
|
+
{
|
4
|
+
:label => _('Azure Subnet'),
|
5
|
+
:required => true,
|
6
|
+
:id => 'azure_rm_subnet',
|
7
|
+
:class => "col-lg-8"
|
8
|
+
}
|
9
|
+
%>
|
10
|
+
|
11
|
+
<%= selectable_f f, :bridge, ['None', 'Dynamic', 'Static'],
|
12
|
+
{},
|
13
|
+
{
|
14
|
+
:label => _("Public IP"),
|
15
|
+
:label_size => "col-md-2"
|
16
|
+
}
|
17
|
+
%>
|
18
|
+
|
19
|
+
<%= checkbox_f f, :name,
|
20
|
+
{ :label => _("Static Private IP"), :label_size => "col-md-2" },
|
21
|
+
'true',
|
22
|
+
'false'
|
23
|
+
%>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= number_f f, :disk_size_gb,
|
2
|
+
{
|
3
|
+
:class => "col-md-2",
|
4
|
+
:label => _("Size (GB)"), :label_size => "col-md-2",
|
5
|
+
:required => true
|
6
|
+
}
|
7
|
+
%>
|
8
|
+
|
9
|
+
<%= checkbox_f f, :account_type, {
|
10
|
+
:label => _("Premium Disk"), :label_size => "col-md-2"},
|
11
|
+
'true',
|
12
|
+
'false'
|
13
|
+
%>
|
14
|
+
|
15
|
+
<%= selectable_f f, :data_disk_caching, %w(None ReadOnly ReadWrite),
|
16
|
+
{ },
|
17
|
+
{
|
18
|
+
:label => _('Data Caching'),
|
19
|
+
:required => true,
|
20
|
+
:class => "col-md-2"
|
21
|
+
}
|
22
|
+
%>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<table class="table table-bordered" data-table="inline">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th><%= _('Name') %></th>
|
5
|
+
<th><%= _('Size') %></th>
|
6
|
+
<th><%= _('Resource Group') %></th>
|
7
|
+
<th><%= _('Region') %></th>
|
8
|
+
<th><%= _('State') %></th>
|
9
|
+
<th></th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<% @vms.each do |vm| %>
|
13
|
+
<tr>
|
14
|
+
<td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity).merge(:auth_object => @compute_resource, :authorizer => :authorizer) %></td>
|
15
|
+
<td><%= vm.vm_size %></td>
|
16
|
+
<td><%= vm.resource_group %></td>
|
17
|
+
<td><%= vm.location %></td>
|
18
|
+
<td> <span <%= vm_power_class(vm.ready?) %>> <%= vm_state(vm) %> </span> </td>
|
19
|
+
<td>
|
20
|
+
<%= action_buttons(
|
21
|
+
vm_power_action(vm, authorizer),
|
22
|
+
display_delete_if_authorized(hash_for_compute_resource_vm_path(
|
23
|
+
:compute_resource_id => @compute_resource,
|
24
|
+
:id => vm.identity).merge(:auth_object => @compute_resource, :authorizer => authorizer))
|
25
|
+
) %>
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
<% end %>
|
29
|
+
</table>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% title @vm.name %>
|
2
|
+
<div class='col-md-12'>
|
3
|
+
<table class="<%= table_css_classes %>">
|
4
|
+
<thead>
|
5
|
+
<tr><th colspan="2"><%=_('Properties') %></th></tr>
|
6
|
+
</thead>
|
7
|
+
<tbody>
|
8
|
+
<%= prop :id %>
|
9
|
+
<%= prop :location %>
|
10
|
+
<%= prop :vm_size %>
|
11
|
+
<%= prop :platform %>
|
12
|
+
</tbody>
|
13
|
+
</table>
|
14
|
+
</div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= text_f f, :username, :value => @image.username || "root",
|
2
|
+
:help_inline => _("The user that will be used to SSH into the VM for completion")
|
3
|
+
%>
|
4
|
+
<%= password_f f, :password, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
|
5
|
+
<%= image_field(f, :label => _("Managed Image ID or Marketplace URN")) %>
|
6
|
+
<%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input?") %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module ForemanAzureRM
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
engine_name 'foreman_azure_rm'
|
4
|
+
|
5
|
+
initializer 'foreman_azure_rm.register_plugin', :before => :finisher_hook do
|
6
|
+
Foreman::Plugin.register :foreman_azure_rm do
|
7
|
+
requires_foreman '>= 1.14'
|
8
|
+
compute_resource ForemanAzureRM::AzureRM
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer 'foreman_azure_rm.register_gettext', after: :load_config_initializers do
|
13
|
+
locale_dir = File.join(File.expand_path('../../../', __FILE__), 'locale')
|
14
|
+
locale_domain = 'foreman_azure_rm'
|
15
|
+
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'foreman_azure_rm.assets.precompile' do |app|
|
19
|
+
app.config.assets.precompile += %w(foreman_azure_rm/azure_rm_size_from_location.js
|
20
|
+
foreman_azure_rm/azure_rm_subnet_from_vnet.js
|
21
|
+
foreman_azure_rm/azure_rm_location_callbacks.js)
|
22
|
+
end
|
23
|
+
|
24
|
+
initializer 'foreman_azure_rm.configure_assets', :group => :assets do
|
25
|
+
SETTINGS[:foreman_azure_rm] = { :assets => { :precompile => %w(foreman_azure_rm/azure_rm_size_from_location.js
|
26
|
+
foreman_azure_rm/azure_rm_subnet_from_vnet.js
|
27
|
+
foreman_azure_rm/azure_rm_location_callbacks.js) } }
|
28
|
+
end
|
29
|
+
|
30
|
+
config.to_prepare do
|
31
|
+
require 'fog/azurerm'
|
32
|
+
|
33
|
+
require 'fog/azurerm/models/compute/server'
|
34
|
+
require File.expand_path(
|
35
|
+
'../../../app/models/concerns/fog_extensions/azurerm/server',
|
36
|
+
__FILE__
|
37
|
+
)
|
38
|
+
Fog::Compute::AzureRM::Server.send(:prepend, FogExtensions::AzureRM::Server)
|
39
|
+
|
40
|
+
require 'fog/azurerm/models/compute/servers'
|
41
|
+
require File.expand_path(
|
42
|
+
'../../../app/models/concerns/fog_extensions/azurerm/servers',
|
43
|
+
__FILE__
|
44
|
+
)
|
45
|
+
Fog::Compute::AzureRM::Servers.send(:include, FogExtensions::AzureRM::Servers)
|
46
|
+
|
47
|
+
require 'fog/azurerm/models/storage/data_disk'
|
48
|
+
require File.expand_path(
|
49
|
+
'../../../app/models/concerns/fog_extensions/azurerm/data_disk',
|
50
|
+
__FILE__
|
51
|
+
)
|
52
|
+
Fog::Storage::AzureRM::DataDisk.send(:prepend, FogExtensions::AzureRM::DataDisk)
|
53
|
+
|
54
|
+
require 'fog/azurerm/compute'
|
55
|
+
require File.expand_path(
|
56
|
+
'../../../app/models/concerns/fog_extensions/azurerm/compute',
|
57
|
+
__FILE__
|
58
|
+
)
|
59
|
+
Fog::Compute::AzureRM::Real.send(:prepend, FogExtensions::AzureRM::Compute)
|
60
|
+
|
61
|
+
::HostsController.send(:include, ForemanAzureRM::Concerns::HostsControllerExtensions)
|
62
|
+
|
63
|
+
require 'fog/azurerm/models/network/network_interface'
|
64
|
+
require File.expand_path(
|
65
|
+
'../../../app/models/concerns/fog_extensions/azurerm/network_interface',
|
66
|
+
__FILE__
|
67
|
+
)
|
68
|
+
Fog::Network::AzureRM::NetworkInterface.send(:include, FogExtensions::AzureRM::NetworkInterface)
|
69
|
+
|
70
|
+
require 'fog/azurerm/models/network/network_interfaces'
|
71
|
+
require File.expand_path(
|
72
|
+
'../../../app/models/concerns/fog_extensions/azurerm/network_interfaces',
|
73
|
+
__FILE__
|
74
|
+
)
|
75
|
+
Fog::Network::AzureRM::NetworkInterfaces.send(:include, FogExtensions::AzureRM::NetworkInterfaces)
|
76
|
+
|
77
|
+
require 'fog/azurerm/models/compute/managed_disk'
|
78
|
+
require File.expand_path(
|
79
|
+
'../../../app/models/concerns/fog_extensions/azurerm/managed_disk',
|
80
|
+
__FILE__
|
81
|
+
)
|
82
|
+
Fog::Compute::AzureRM::ManagedDisk.send(:include, FogExtensions::AzureRM::ManagedDisk)
|
83
|
+
|
84
|
+
require 'fog/azurerm/models/compute/managed_disks'
|
85
|
+
require File.expand_path(
|
86
|
+
'../../../app/models/concerns/fog_extensions/azurerm/managed_disks',
|
87
|
+
__FILE__
|
88
|
+
)
|
89
|
+
Fog::Compute::AzureRM::ManagedDisks.send(:include, FogExtensions::AzureRM::ManagedDisks)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|