foreman_azure_rm 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -2
- data/app/models/concerns/foreman_azure_rm/vm_extensions/managed_vm.rb +28 -31
- data/app/models/foreman_azure_rm/azure_rm.rb +2 -3
- data/app/models/foreman_azure_rm/azure_rm_compute.rb +4 -0
- data/app/views/compute_resources_vms/form/azurerm/_base.html.erb +3 -3
- data/lib/foreman_azure_rm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e741ec81cb86b9264c85d90144d72b977041fa7862719a2ffefb3ee0a08e091
|
4
|
+
data.tar.gz: 1f650dc025e09281b48651d5b51a67a90fa406dd94adaddc8fe0cff66a1aa30d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87b2e1e4f809356ad3366b13b61e317f038b292e138431746f6d3360b45075326b3e220e2c53aa8f718985b18d9c414cd18a42ecdea4670ded22d41c741a6fd6
|
7
|
+
data.tar.gz: 560fd23c83eeef07f8669edd5380d5ee51312000640e3c31c7779e546d00288527bb6d38cc4c83e4693dae0edec268b01192047fc630d725d44a87225a5599b1
|
data/README.md
CHANGED
@@ -6,6 +6,49 @@
|
|
6
6
|
* Website: [TheForeman.org](http://theforeman.org)
|
7
7
|
* Support: [Foreman support](http://theforeman.org/support.html)
|
8
8
|
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
### Bundle (Gem)
|
12
|
+
|
13
|
+
Add the following to bundler.d/Gemfile.local.rb in your Foreman installation directory (/usr/share/foreman by default)
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ gem 'foreman_azure_rm'
|
17
|
+
```
|
18
|
+
|
19
|
+
Or simply:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ echo "gem 'foreman_azure_rm'" > /usr/share/foreman/bundler.d/Gemfile.local.rb
|
23
|
+
```
|
24
|
+
|
25
|
+
Then run `bundle install` from the same directory
|
26
|
+
|
27
|
+
### Package
|
28
|
+
```
|
29
|
+
# yum install tfm-rubygem-foreman_azure_rm
|
30
|
+
```
|
31
|
+
|
32
|
+
### Foreman Installer
|
33
|
+
```
|
34
|
+
# foreman-installer --enable-foreman-plugin-azure
|
35
|
+
```
|
36
|
+
|
37
|
+
### Development Setup
|
38
|
+
|
39
|
+
Clone the repo from github:
|
40
|
+
```bash
|
41
|
+
git clone https://github.com/theforeman/foreman_azure_rm.git
|
42
|
+
```
|
43
|
+
|
44
|
+
Add the following to bundler.d/Gemfile.local.rb in your Foreman development directory
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
$ gem 'foreman_azure_rm', :path => 'path to foreman_azure_rm directory'
|
48
|
+
```
|
49
|
+
|
50
|
+
Then run `bundle install` from the same directory
|
51
|
+
|
9
52
|
## Features
|
10
53
|
* Support for most typical IaaS operations
|
11
54
|
* VM creation
|
@@ -28,13 +71,13 @@ Choose the **Azure Resource Manager provider**, and fill in all the fields. You
|
|
28
71
|
That's it. You're now ready to create and manage Azure resources in your new Azure Resource Manager compute resource. You should see something like this in the Compute Resource page:
|
29
72
|
|
30
73
|
|
31
|
-
![](https://i.imgur.com/
|
74
|
+
![](https://i.imgur.com/4ClZhTP.png)
|
32
75
|
|
33
76
|
|
34
77
|
![](https://i.imgur.com/eFHucdb.png)
|
35
78
|
|
36
79
|
|
37
|
-
![](https://i.imgur.com/
|
80
|
+
![](https://i.imgur.com/YjlRQIE.png)
|
38
81
|
|
39
82
|
|
40
83
|
## Planned Features
|
@@ -45,6 +88,7 @@ That's it. You're now ready to create and manage Azure resources in your new Azu
|
|
45
88
|
* Improved extension support
|
46
89
|
|
47
90
|
## Known Limitations
|
91
|
+
* Please note that currently username is expected to be the same on both Virtual Machine tab for Host creation and during Image creation for Compute Resource. The password field for Image creation is optional.
|
48
92
|
* Unable to provision using Windows Images
|
49
93
|
|
50
94
|
## Links
|
@@ -4,8 +4,7 @@ module ForemanAzureRm
|
|
4
4
|
module ManagedVM
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
def define_managed_storage_profile(vm_name,
|
8
|
-
os_disk_caching, platform, premium_os_disk)
|
7
|
+
def define_managed_storage_profile(vm_name, os_disk_caching, platform, premium_os_disk)
|
9
8
|
storage_profile = ComputeModels::StorageProfile.new
|
10
9
|
os_disk = ComputeModels::OSDisk.new
|
11
10
|
managed_disk_params = ComputeModels::ManagedDiskParameters.new
|
@@ -35,22 +34,10 @@ module ForemanAzureRm
|
|
35
34
|
os_disk.managed_disk = managed_disk_params
|
36
35
|
storage_profile.os_disk = os_disk
|
37
36
|
|
38
|
-
# TODO - disk creation for volume capability
|
39
|
-
|
40
|
-
if vhd_path.nil?
|
41
|
-
# We are using a marketplace image
|
42
|
-
storage_profile.image_reference = image_reference(publisher, offer,
|
43
|
-
sku, version)
|
44
|
-
else
|
45
|
-
# We are using a custom managed image
|
46
|
-
image_ref = ComputeModels::ImageReference.new
|
47
|
-
image_ref.id = vhd_path
|
48
|
-
storage_profile.image_reference = image_ref
|
49
|
-
end
|
50
37
|
storage_profile
|
51
38
|
end
|
52
39
|
|
53
|
-
def
|
40
|
+
def marketplace_image_reference(publisher, offer, sku, version)
|
54
41
|
image_reference = ComputeModels::ImageReference.new
|
55
42
|
image_reference.publisher = publisher
|
56
43
|
image_reference.offer = offer
|
@@ -59,6 +46,30 @@ module ForemanAzureRm
|
|
59
46
|
image_reference
|
60
47
|
end
|
61
48
|
|
49
|
+
def define_image(vhd_path)
|
50
|
+
# If image UUID begins with / it is a custom managed image
|
51
|
+
# Otherwise it is a marketplace URN
|
52
|
+
unless vhd_path.start_with?('/')
|
53
|
+
urn = vhd_path.split(':')
|
54
|
+
publisher = urn[0]
|
55
|
+
offer = urn[1]
|
56
|
+
sku = urn[2]
|
57
|
+
version = urn[3]
|
58
|
+
vhd_path = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
if vhd_path.nil?
|
62
|
+
# For marketplace image
|
63
|
+
image_reference = marketplace_image_reference(publisher, offer, sku, version)
|
64
|
+
else
|
65
|
+
# For custom managed image
|
66
|
+
image_ref = ComputeModels::ImageReference.new
|
67
|
+
image_ref.id = vhd_path
|
68
|
+
image_reference = image_ref
|
69
|
+
end
|
70
|
+
image_reference
|
71
|
+
end
|
72
|
+
|
62
73
|
def define_network_profile(network_interface_card_ids)
|
63
74
|
network_interface_cards = []
|
64
75
|
network_interface_card_ids.each_with_index do |id, index|
|
@@ -133,16 +144,6 @@ module ForemanAzureRm
|
|
133
144
|
sub_resource.id = vm_hash[:availability_set_id]
|
134
145
|
vm.availability_set = sub_resource
|
135
146
|
end
|
136
|
-
# If image UUID begins with / it is a custom managed image
|
137
|
-
# Otherwise it is a marketplace URN
|
138
|
-
unless vm_hash[:vhd_path].start_with?('/')
|
139
|
-
urn = vm_hash[:vhd_path].split(':')
|
140
|
-
vm_hash[:publisher] = urn[0]
|
141
|
-
vm_hash[:offer] = urn[1]
|
142
|
-
vm_hash[:sku] = urn[2]
|
143
|
-
vm_hash[:version] = urn[3]
|
144
|
-
vm_hash[:vhd_path] = nil
|
145
|
-
end
|
146
147
|
|
147
148
|
vm.os_profile = ComputeModels::OSProfile.new.tap do |os_profile|
|
148
149
|
os_profile.computer_name = vm_hash[:name]
|
@@ -173,14 +174,9 @@ module ForemanAzureRm
|
|
173
174
|
end
|
174
175
|
vm.storage_profile = define_managed_storage_profile(
|
175
176
|
vm_hash[:name],
|
176
|
-
vm_hash[:vhd_path],
|
177
|
-
vm_hash[:publisher],
|
178
|
-
vm_hash[:offer],
|
179
|
-
vm_hash[:sku],
|
180
|
-
vm_hash[:version],
|
181
177
|
vm_hash[:os_disk_caching],
|
182
178
|
vm_hash[:platform],
|
183
|
-
vm_hash[:premium_os_disk]
|
179
|
+
vm_hash[:premium_os_disk]
|
184
180
|
)
|
185
181
|
vm.hardware_profile = ComputeModels::HardwareProfile.new.tap do |hw_profile|
|
186
182
|
hw_profile.vm_size = vm_hash[:vm_size]
|
@@ -193,6 +189,7 @@ module ForemanAzureRm
|
|
193
189
|
def create_managed_virtual_machine(vm_hash)
|
194
190
|
vm_params = initialize_vm(vm_hash)
|
195
191
|
vm_params.network_profile = define_network_profile(vm_hash[:network_interface_card_ids])
|
192
|
+
vm_params.storage_profile.image_reference = define_image(vm_hash[:vhd_path])
|
196
193
|
sdk.create_or_update_vm(vm_hash[:resource_group], vm_hash[:name], vm_params)
|
197
194
|
end
|
198
195
|
|
@@ -74,7 +74,7 @@ module ForemanAzureRm
|
|
74
74
|
end
|
75
75
|
|
76
76
|
validates :region, inclusion: { in: regions.collect(&:second),
|
77
|
-
message: "%{value} must be lowercase." }
|
77
|
+
message: "%{value} must be lowercase eg. 'eastus'. No special characters allowed." }
|
78
78
|
|
79
79
|
def resource_groups
|
80
80
|
sdk.rgs
|
@@ -88,7 +88,7 @@ module ForemanAzureRm
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def new_vm(args = {})
|
91
|
-
return AzureRmCompute.new(sdk: sdk) if args.empty?
|
91
|
+
return AzureRmCompute.new(sdk: sdk) if args.empty?
|
92
92
|
opts = vm_instance_defaults.merge(args.to_h).deep_symbolize_keys
|
93
93
|
# convert rails nested_attributes into a plain hash
|
94
94
|
nested_args = opts.delete(:interfaces_attributes)
|
@@ -104,7 +104,6 @@ module ForemanAzureRm
|
|
104
104
|
platform: opts[:platform],
|
105
105
|
ssh_key_data: opts[:ssh_key_data],
|
106
106
|
os_disk_caching: opts[:os_disk_caching],
|
107
|
-
vhd_path: opts[:image_id],
|
108
107
|
premium_os_disk: opts[:premium_os_disk]
|
109
108
|
)
|
110
109
|
if opts[:interfaces].present?
|
@@ -88,7 +88,7 @@
|
|
88
88
|
<% # This view has been modified and refers to the properties wrapper class %>
|
89
89
|
|
90
90
|
<%= selectable_f f, :resource_group, resource_groups,
|
91
|
-
{ :include_blank =>
|
91
|
+
{ :include_blank => _('Please select a Resource Group') },
|
92
92
|
{
|
93
93
|
:disabled => resource_groups.empty?,
|
94
94
|
:label => _('Resource Group'),
|
@@ -106,7 +106,7 @@
|
|
106
106
|
%>
|
107
107
|
|
108
108
|
<%= selectable_f f, :vm_size, compute_resource.vm_sizes.map { |size| size.name },
|
109
|
-
{},
|
109
|
+
{ :include_blank => _('Please select a VM Size') },
|
110
110
|
{
|
111
111
|
:label => _('VM Size'),
|
112
112
|
:required => true,
|
@@ -185,6 +185,6 @@
|
|
185
185
|
:required => true,
|
186
186
|
:label_size => "col-md-2",
|
187
187
|
:id => 'azure_rm_image_id'
|
188
|
-
}
|
188
|
+
} if controller_name != "compute_attributes"
|
189
189
|
%>
|
190
190
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_azure_rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: deface
|