Add support for min ram and min disk
Add min_ram and min_disk properties to the glance_image resource. Change-Id: I27202559bc73283a318575669c957238f5aee988
This commit is contained in:
parent
28bcf83e14
commit
7e2e1162d0
@ -45,6 +45,8 @@ Puppet::Type.type(:glance_image).provide(
|
||||
end
|
||||
properties << "--container-format=#{resource[:container_format]}"
|
||||
properties << "--disk-format=#{resource[:disk_format]}"
|
||||
properties << "--min-disk=#{resource[:min_disk]}" if resource[:min_disk]
|
||||
properties << "--min-ram=#{resource[:min_ram]}" if resource[:min_ram]
|
||||
properties << location
|
||||
@property_hash = self.class.request('image', 'create', properties)
|
||||
@property_hash[:ensure] = :present
|
||||
@ -83,6 +85,14 @@ Puppet::Type.type(:glance_image).provide(
|
||||
@property_hash[:container_format]
|
||||
end
|
||||
|
||||
def min_ram=(value)
|
||||
@property_flush[:min_ram] = value
|
||||
end
|
||||
|
||||
def min_disk=(value)
|
||||
@property_flush[:min_disk] = value
|
||||
end
|
||||
|
||||
def id=(id)
|
||||
fail('id is read only')
|
||||
end
|
||||
@ -101,7 +111,9 @@ Puppet::Type.type(:glance_image).provide(
|
||||
:is_public => attrs[:is_public].downcase.chomp == 'true'? true : false,
|
||||
:container_format => attrs[:container_format],
|
||||
:id => attrs[:id],
|
||||
:disk_format => attrs[:disk_format]
|
||||
:disk_format => attrs[:disk_format],
|
||||
:min_disk => attrs['min_disk'],
|
||||
:min_ram => attrs['min_ram']
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -122,6 +134,8 @@ Puppet::Type.type(:glance_image).provide(
|
||||
(properties << '--private') if @property_flush[:is_public] == :false
|
||||
(properties << "--container-format=#{@property_flush[:container_format]}") if @property_flush[:container_format]
|
||||
(properties << "--disk-format=#{@property_flush[:disk_format]}") if @property_flush[:disk_format]
|
||||
(properties << "--min-ram=#{@property_flush[:min_ram]}") if @property_flush[:min_ram]
|
||||
(properties << "--min-disk=#{@property_flush[:min_disk]}") if @property_flush[:min_disk]
|
||||
self.class.request('image', 'set', properties)
|
||||
@property_flush.clear
|
||||
end
|
||||
|
@ -11,6 +11,8 @@ Puppet::Type.newtype(:glance_image) do
|
||||
container_format => ovf,
|
||||
disk_format => 'qcow2',
|
||||
source => 'http://uec-images.ubuntu.com/releases/precise/release/ubuntu-12.04-server-cloudimg-amd64-disk1.img'
|
||||
min_ram => 1234,
|
||||
min_disk => 1234,
|
||||
}
|
||||
|
||||
Known problems / limitations:
|
||||
@ -72,6 +74,16 @@ Puppet::Type.newtype(:glance_image) do
|
||||
newvalues(/\S+/)
|
||||
end
|
||||
|
||||
newparam(:min_ram) do
|
||||
desc "The minimal ram size"
|
||||
newvalues(/\d+/)
|
||||
end
|
||||
|
||||
newparam(:min_disk) do
|
||||
desc "The minimal disk size"
|
||||
newvalues(/\d+/)
|
||||
end
|
||||
|
||||
# Require the Glance service to be running
|
||||
autorequire(:service) do
|
||||
['glance']
|
||||
|
@ -23,6 +23,8 @@ describe provider_class do
|
||||
:container_format => 'bare',
|
||||
:disk_format => 'qcow2',
|
||||
:source => 'http://example.com/image1.img',
|
||||
:min_ram => 1024,
|
||||
:min_disk => 1024,
|
||||
}
|
||||
end
|
||||
|
||||
@ -43,7 +45,7 @@ describe provider_class do
|
||||
"534 5b502-efe4-4852-a45d-edaba3a3acc6","image1","raw","bare",1270,"active"
|
||||
')
|
||||
provider.class.stubs(:openstack)
|
||||
.with('image', 'create', '--format', 'shell', ['image1', '--public', '--container-format=bare', '--disk-format=qcow2', '--copy-from=http://example.com/image1.img' ])
|
||||
.with('image', 'create', '--format', 'shell', ['image1', '--public', '--container-format=bare', '--disk-format=qcow2', '--min-disk=1024', '--min-ram=1024', '--copy-from=http://example.com/image1.img' ])
|
||||
.returns('checksum="09b9c392dc1f6e914cea287cb6be34b0"
|
||||
container_format="bare"
|
||||
created_at="2015-04-08T18:28:01"
|
||||
@ -52,8 +54,8 @@ deleted_at="None"
|
||||
disk_format="qcow2"
|
||||
id="5345b502-efe4-4852-a45d-edaba3a3acc6"
|
||||
is_public="True"
|
||||
min_disk="0"
|
||||
min_ram="0"
|
||||
min_disk="1024"
|
||||
min_ram="1024"
|
||||
name="image1"
|
||||
owner="None"
|
||||
properties="{}"
|
||||
@ -99,8 +101,8 @@ deleted_at="None"
|
||||
disk_format="qcow2"
|
||||
id="5345b502-efe4-4852-a45d-edaba3a3acc6"
|
||||
is_public="True"
|
||||
min_disk="0"
|
||||
min_ram="0"
|
||||
min_disk="1024"
|
||||
min_ram="1024"
|
||||
name="image1"
|
||||
owner="None"
|
||||
properties="{}"
|
||||
|
Loading…
Reference in New Issue
Block a user