|
|
|
@ -39,31 +39,26 @@ describe provider_class do
|
|
|
|
|
it_behaves_like 'authenticated with environment variables' do
|
|
|
|
|
describe '#create' do
|
|
|
|
|
it 'creates an image' do
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'list', '--quiet', '--format', 'csv', '--long')
|
|
|
|
|
.returns('"ID","Name","Disk Format","Container Format","Size","Status"
|
|
|
|
|
"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', '--min-disk=1024', '--min-ram=1024', '--copy-from=http://example.com/image1.img' ])
|
|
|
|
|
.returns('checksum="09b9c392dc1f6e914cea287cb6be34b0"
|
|
|
|
|
.returns('checksum="ee1eca47dc88f4879d8a229cc70a07c6"
|
|
|
|
|
container_format="bare"
|
|
|
|
|
created_at="2015-04-08T18:28:01"
|
|
|
|
|
deleted="False"
|
|
|
|
|
deleted_at="None"
|
|
|
|
|
created_at="2016-03-29T20:52:24Z"
|
|
|
|
|
disk_format="qcow2"
|
|
|
|
|
id="5345b502-efe4-4852-a45d-edaba3a3acc6"
|
|
|
|
|
is_public="True"
|
|
|
|
|
file="/v2/images/8801c5b0-c505-4a15-8ca3-1d2383f8c015/file"
|
|
|
|
|
id="8801c5b0-c505-4a15-8ca3-1d2383f8c015"
|
|
|
|
|
min_disk="1024"
|
|
|
|
|
min_ram="1024"
|
|
|
|
|
name="image1"
|
|
|
|
|
owner="None"
|
|
|
|
|
properties="{}"
|
|
|
|
|
owner="5a9e521e17014804ab8b4e8b3de488a4"
|
|
|
|
|
protected="False"
|
|
|
|
|
size="1270"
|
|
|
|
|
schema="/v2/schemas/image"
|
|
|
|
|
size="13287936"
|
|
|
|
|
status="active"
|
|
|
|
|
updated_at="2015-04-10T18:18:18"
|
|
|
|
|
tags=""
|
|
|
|
|
updated_at="2016-03-29T20:52:40Z"
|
|
|
|
|
virtual_size="None"
|
|
|
|
|
visibility="public"
|
|
|
|
|
')
|
|
|
|
|
provider.create
|
|
|
|
|
expect(provider.exists?).to be_truthy
|
|
|
|
@ -73,9 +68,6 @@ virtual_size="None"
|
|
|
|
|
|
|
|
|
|
describe '#destroy' do
|
|
|
|
|
it 'destroys an image' do
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'list', '--quiet', '--format', 'csv')
|
|
|
|
|
.returns('"ID","Name","Disk Format","Container Format","Size","Status"')
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'delete', 'image1')
|
|
|
|
|
provider.destroy
|
|
|
|
@ -87,9 +79,9 @@ virtual_size="None"
|
|
|
|
|
describe '.instances' do
|
|
|
|
|
it 'finds every image' do
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'list', '--quiet', '--format', 'csv', '--long')
|
|
|
|
|
.returns('"ID","Name","Disk Format","Container Format","Size","Status"
|
|
|
|
|
"5345b502-efe4-4852-a45d-edaba3a3acc6","image1","raw","bare",1270,"active"
|
|
|
|
|
.with('image', 'list', '--quiet', '--format', 'csv', [])
|
|
|
|
|
.returns('"ID","Name","Status"
|
|
|
|
|
"5345b502-efe4-4852-a45d-edaba3a3acc6","image1","active"
|
|
|
|
|
')
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'show', '--format', 'shell', '5345b502-efe4-4852-a45d-edaba3a3acc6')
|
|
|
|
@ -118,4 +110,95 @@ virtual_size="None"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'when managing an image with properties' do
|
|
|
|
|
|
|
|
|
|
let(:tenant_attrs) do
|
|
|
|
|
{
|
|
|
|
|
:ensure => 'present',
|
|
|
|
|
:name => 'image1',
|
|
|
|
|
:is_public => 'yes',
|
|
|
|
|
:container_format => 'bare',
|
|
|
|
|
:disk_format => 'qcow2',
|
|
|
|
|
:source => '/var/tmp/image1.img',
|
|
|
|
|
:min_ram => 1024,
|
|
|
|
|
:min_disk => 1024,
|
|
|
|
|
:properties => { 'something' => 'what', 'vmware_disktype' => 'sparse' }
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:resource) do
|
|
|
|
|
Puppet::Type::Glance_image.new(tenant_attrs)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:provider) do
|
|
|
|
|
provider_class.new(resource)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'authenticated with environment variables' do
|
|
|
|
|
describe '#create' do
|
|
|
|
|
it 'creates an image' do
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'create', '--format', 'shell', ['image1', '--public', '--container-format=bare', '--disk-format=qcow2', '--min-disk=1024', '--min-ram=1024', ['--property', 'something=what', '--property', 'vmware_disktype=sparse'], '--file=/var/tmp/image1.img' ])
|
|
|
|
|
.returns('checksum="ee1eca47dc88f4879d8a229cc70a07c6"
|
|
|
|
|
container_format="bare"
|
|
|
|
|
created_at="2016-03-29T20:52:24Z"
|
|
|
|
|
disk_format="qcow2"
|
|
|
|
|
file="/v2/images/8801c5b0-c505-4a15-8ca3-1d2383f8c015/file"
|
|
|
|
|
id="8801c5b0-c505-4a15-8ca3-1d2383f8c015"
|
|
|
|
|
min_disk="1024"
|
|
|
|
|
min_ram="1024"
|
|
|
|
|
name="image1"
|
|
|
|
|
owner="5a9e521e17014804ab8b4e8b3de488a4"
|
|
|
|
|
properties="something=\'what\', vmware_disktype=\'sparse\'"
|
|
|
|
|
protected="False"
|
|
|
|
|
schema="/v2/schemas/image"
|
|
|
|
|
size="13287936"
|
|
|
|
|
status="active"
|
|
|
|
|
tags=""
|
|
|
|
|
updated_at="2016-03-29T20:52:40Z"
|
|
|
|
|
virtual_size="None"
|
|
|
|
|
visibility="public"
|
|
|
|
|
')
|
|
|
|
|
provider.create
|
|
|
|
|
expect(provider.exists?).to be_truthy
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '.instances' do
|
|
|
|
|
it 'finds every image' do
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'list', '--quiet', '--format', 'csv', [])
|
|
|
|
|
.returns('"ID","Name","Status"
|
|
|
|
|
"5345b502-efe4-4852-a45d-edaba3a3acc6","image1","active"
|
|
|
|
|
')
|
|
|
|
|
provider.class.stubs(:openstack)
|
|
|
|
|
.with('image', 'show', '--format', 'shell', '5345b502-efe4-4852-a45d-edaba3a3acc6')
|
|
|
|
|
.returns('checksum="09b9c392dc1f6e914cea287cb6be34b0"
|
|
|
|
|
container_format="bare"
|
|
|
|
|
created_at="2015-04-08T18:28:01"
|
|
|
|
|
deleted="False"
|
|
|
|
|
deleted_at="None"
|
|
|
|
|
disk_format="qcow2"
|
|
|
|
|
id="5345b502-efe4-4852-a45d-edaba3a3acc6"
|
|
|
|
|
is_public="True"
|
|
|
|
|
min_disk="1024"
|
|
|
|
|
min_ram="1024"
|
|
|
|
|
name="image1"
|
|
|
|
|
owner="None"
|
|
|
|
|
properties="something=\'what\', vmware_disktype=\'sparse\'"
|
|
|
|
|
protected="False"
|
|
|
|
|
size="1270"
|
|
|
|
|
status="active"
|
|
|
|
|
updated_at="2015-04-10T18:18:18"
|
|
|
|
|
virtual_size="None"
|
|
|
|
|
')
|
|
|
|
|
instances = provider_class.instances
|
|
|
|
|
expect(instances.count).to eq(1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|