Fixes issue with setting admin_pass password

The password was not properly set with metadata services
beside HTTP
This commit is contained in:
Alessandro Pilotti 2013-11-15 23:50:24 +02:00
parent 3a95179007
commit 766cdac675

View File

@ -101,17 +101,17 @@ class SetUserPasswordPlugin(base.BasePlugin):
def execute(self, service): def execute(self, service):
user_name = CONF.username user_name = CONF.username
if not service.can_post_password: if (service.can_post_password and
LOG.info('Cannot set the password in the metadata as it is ' service.is_password_set(self._post_password_md_ver)):
'not supported by this service')
return (base.PLUGIN_EXECUTION_DONE, False)
if service.is_password_set(self._post_password_md_ver):
LOG.debug('User\'s password already set in the instance metadata') LOG.debug('User\'s password already set in the instance metadata')
else: else:
osutils = osutils_factory.OSUtilsFactory().get_os_utils() osutils = osutils_factory.OSUtilsFactory().get_os_utils()
if osutils.user_exists(user_name): if osutils.user_exists(user_name):
password = self._set_password(service, osutils, user_name) password = self._set_password(service, osutils, user_name)
if not service.can_post_password:
LOG.info('Cannot set the password in the metadata as it '
'is not supported by this service')
return (base.PLUGIN_EXECUTION_DONE, False)
else:
self._set_metadata_password(password, service) self._set_metadata_password(password, service)
return (base.PLUGIN_EXECUTE_ON_NEXT_BOOT, False) return (base.PLUGIN_EXECUTE_ON_NEXT_BOOT, False)