Fixes return values and exceptions in some plugins
This avoids misleading exceptions in the logs.
This commit is contained in:
parent
4b08f9ef93
commit
3e120de02a
@ -37,10 +37,11 @@ class NetworkConfigPlugin(base.BasePlugin):
|
|||||||
def execute(self, service):
|
def execute(self, service):
|
||||||
meta_data = service.get_meta_data('openstack')
|
meta_data = service.get_meta_data('openstack')
|
||||||
if 'network_config' not in meta_data:
|
if 'network_config' not in meta_data:
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
network_config = meta_data['network_config']
|
network_config = meta_data['network_config']
|
||||||
if 'content_path' not in network_config:
|
if 'content_path' not in network_config:
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
content_path = network_config['content_path']
|
content_path = network_config['content_path']
|
||||||
content_name = content_path.rsplit('/', 1)[-1]
|
content_name = content_path.rsplit('/', 1)[-1]
|
||||||
|
@ -26,7 +26,7 @@ class SetHostNamePlugin(base.BasePlugin):
|
|||||||
meta_data = service.get_meta_data('openstack')
|
meta_data = service.get_meta_data('openstack')
|
||||||
if 'hostname' not in meta_data:
|
if 'hostname' not in meta_data:
|
||||||
LOG.debug('Hostname not found in metadata')
|
LOG.debug('Hostname not found in metadata')
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
osutils = osutils_factory.OSUtilsFactory().get_os_utils()
|
osutils = osutils_factory.OSUtilsFactory().get_os_utils()
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class SetUserSSHPublicKeysPlugin(base.BasePlugin):
|
|||||||
def execute(self, service):
|
def execute(self, service):
|
||||||
meta_data = service.get_meta_data('openstack')
|
meta_data = service.get_meta_data('openstack')
|
||||||
if not 'public_keys' in meta_data:
|
if not 'public_keys' in meta_data:
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
username = CONF.username
|
username = CONF.username
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import re
|
|||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from cloudbaseinit.metadata.services import base as metadata_services_base
|
||||||
from cloudbaseinit.openstack.common import log as logging
|
from cloudbaseinit.openstack.common import log as logging
|
||||||
from cloudbaseinit.osutils import factory as osutils_factory
|
from cloudbaseinit.osutils import factory as osutils_factory
|
||||||
from cloudbaseinit.plugins import base
|
from cloudbaseinit.plugins import base
|
||||||
@ -28,9 +29,13 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class UserDataPlugin(base.BasePlugin):
|
class UserDataPlugin(base.BasePlugin):
|
||||||
def execute(self, service):
|
def execute(self, service):
|
||||||
user_data = service.get_user_data('openstack')
|
try:
|
||||||
|
user_data = service.get_user_data('openstack')
|
||||||
|
except metadata_services_base.NotExistingMetadataException:
|
||||||
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
if not user_data:
|
if not user_data:
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
LOG.debug('User data content:\n%s' % user_data)
|
LOG.debug('User data content:\n%s' % user_data)
|
||||||
|
|
||||||
@ -53,7 +58,7 @@ class UserDataPlugin(base.BasePlugin):
|
|||||||
else:
|
else:
|
||||||
# Unsupported
|
# Unsupported
|
||||||
LOG.warning('Unsupported user_data format')
|
LOG.warning('Unsupported user_data format')
|
||||||
return False
|
return (base.PLUGIN_EXECUTION_DONE, False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(target_path, 'wb') as f:
|
with open(target_path, 'wb') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user