Remove some useless method
These methods are deprecated. They are for old nova cli auth. Change-Id: I3065864458827d4c1c3c81688502d1057124322a
This commit is contained in:
parent
775b7aa5f6
commit
6911474b19
|
@ -60,21 +60,6 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
|||
'/etc/nova/nova.conf'
|
||||
end
|
||||
|
||||
# deprecated: method for old nova cli auth
|
||||
def self.withenv(hash, &block)
|
||||
saved = ENV.to_hash
|
||||
hash.each do |name, val|
|
||||
ENV[name.to_s] = val
|
||||
end
|
||||
|
||||
yield
|
||||
ensure
|
||||
ENV.clear
|
||||
saved.each do |name, val|
|
||||
ENV[name] = val
|
||||
end
|
||||
end
|
||||
|
||||
def self.nova_conf
|
||||
return @nova_conf if @nova_conf
|
||||
@nova_conf = Puppet::Util::IniConfig::File.new
|
||||
|
@ -128,40 +113,6 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
|||
@auth_endpoint ||= get_auth_endpoint
|
||||
end
|
||||
|
||||
# deprecated: method for old nova cli auth
|
||||
def self.auth_nova(*args)
|
||||
q = nova_credentials
|
||||
authenv = {
|
||||
:OS_AUTH_URL => self.auth_endpoint,
|
||||
:OS_USERNAME => q['username'],
|
||||
:OS_PROJECT_NAME => q['project_name'],
|
||||
:OS_PASSWORD => q['password']
|
||||
}
|
||||
if q.key?('region_name')
|
||||
authenv[:OS_REGION_NAME] = q['region_name']
|
||||
end
|
||||
begin
|
||||
withenv authenv do
|
||||
nova(args)
|
||||
end
|
||||
rescue Exception => e
|
||||
if (e.message =~ /\[Errno 111\] Connection refused/) or
|
||||
(e.message =~ /\(HTTP 400\)/)
|
||||
sleep 10
|
||||
withenv authenv do
|
||||
nova(args)
|
||||
end
|
||||
else
|
||||
raise(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# deprecated: method for old nova cli auth
|
||||
def auth_nova(*args)
|
||||
self.class.auth_nova(args)
|
||||
end
|
||||
|
||||
def self.reset
|
||||
@nova_conf = nil
|
||||
@nova_credentials = nil
|
||||
|
|
|
@ -65,34 +65,6 @@ describe Puppet::Provider::Nova do
|
|||
|
||||
end
|
||||
|
||||
describe 'when invoking the nova cli' do
|
||||
|
||||
it 'should set auth credentials in the environment' do
|
||||
authenv = {
|
||||
:OS_AUTH_URL => auth_endpoint,
|
||||
:OS_USERNAME => credential_hash['username'],
|
||||
:OS_PROJECT_NAME => credential_hash['project_name'],
|
||||
:OS_PASSWORD => credential_hash['password'],
|
||||
:OS_REGION_NAME => credential_hash['region_name'],
|
||||
}
|
||||
klass.expects(:get_nova_credentials).with().returns(credential_hash)
|
||||
klass.expects(:withenv).with(authenv)
|
||||
klass.auth_nova('test_retries')
|
||||
end
|
||||
|
||||
['[Errno 111] Connection refused',
|
||||
'(HTTP 400)'].reverse.each do |valid_message|
|
||||
it "should retry when nova cli returns with error #{valid_message}" do
|
||||
klass.expects(:get_nova_credentials).with().returns({})
|
||||
klass.expects(:sleep).with(10).returns(nil)
|
||||
klass.expects(:nova).twice.with(['test_retries']).raises(
|
||||
Exception, valid_message).then.returns('')
|
||||
klass.auth_nova('test_retries')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'when parse a string line' do
|
||||
it 'should return the same string' do
|
||||
res = klass.str2hash("zone1")
|
||||
|
|
Loading…
Reference in New Issue