Escape credentials for cirros image upload

Special characters could cause cirros image
upload to fail. Shellquote.escape will ensure
the password passed is valid.
Also fixes typo in cirros image upload failure

Change-Id: I3773385d05e91c87ddf56c251203f6a2068b1c16
Closes-Bug: #1285318
This commit is contained in:
Matthew Mosesohn 2014-02-27 15:19:14 +04:00
parent 10cccc87f2
commit f15f561524
2 changed files with 5 additions and 5 deletions

View File

@ -325,9 +325,9 @@ module Astute
end
os = {
'os_tenant_name' => controller['access']['tenant'],
'os_username' => controller['access']['user'],
'os_password' => controller['access']['password'],
'os_tenant_name' => Shellwords.escape("#{controller['access']['tenant']}"),
'os_username' => Shellwords.escape("#{controller['access']['user']}"),
'os_password' => Shellwords.escape("#{controller['access']['password']}"),
'os_auth_url' => "http://#{controller['management_vip'] || '127.0.0.1'}:5000/v2.0/",
'disk_format' => 'qcow2',
'container_format' => 'bare',
@ -344,7 +344,7 @@ module Astute
when 'ubuntu_1204_x86_64'
'/usr/share/cirros-testvm/cirros-x86_64-disk.img'
else
raise CirrosError, "Unknow system #{controller['cobbler']['profile']}"
raise CirrosError, "Unknown system #{controller['cobbler']['profile']}"
end
auth_params = "-N #{os['os_auth_url']} \
-T #{os['os_tenant_name']} \

View File

@ -259,7 +259,7 @@ describe Astute::Orchestrator do
nodes_data.first['cobbler']['profile'] = 'unknown'
ctx.expects(:status).returns(1 => 'success', 2 => 'success')
Astute::DeploymentEngine::NailyFact.any_instance.stubs(:deploy).with(nodes_data)
expect {@orchestrator.send(:upload_cirros_image, nodes_data, ctx)}.to raise_error(Astute::CirrosError, /Unknow system/)
expect {@orchestrator.send(:upload_cirros_image, nodes_data, ctx)}.to raise_error(Astute::CirrosError, /Unknown system/)
end
it 'should not add new image if it already added' do