From f7c8d4a726f9a60a1a62f2ad7cb73b8a177f8f45 Mon Sep 17 00:00:00 2001 From: Dmitry Teselkin Date: Wed, 6 Mar 2013 19:27:15 +0400 Subject: [PATCH] Modified files from cloudbase-init added --- .../cloudbase-init/config/cloudbase-init.conf | 10 +++++ .../cloudbase-init/plugins/setagentconfig.py | 37 +++++++++++++++++++ .../cloudbase-init/plugins/sethostname.py | 20 ++++++++++ 3 files changed, 67 insertions(+) create mode 100644 Deployment/cloudbase-init/config/cloudbase-init.conf create mode 100644 Deployment/cloudbase-init/plugins/setagentconfig.py create mode 100644 Deployment/cloudbase-init/plugins/sethostname.py diff --git a/Deployment/cloudbase-init/config/cloudbase-init.conf b/Deployment/cloudbase-init/config/cloudbase-init.conf new file mode 100644 index 0000000..57d1faa --- /dev/null +++ b/Deployment/cloudbase-init/config/cloudbase-init.conf @@ -0,0 +1,10 @@ +[DEFAULT] +username=Admin +groups=Administrators +inject_user_password=false +network_adapters= +config_drive_raw_hdd=false +config_drive_cdrom=false +verbose=true +logdir=C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\log\ +logfile=cloudbase-init.log diff --git a/Deployment/cloudbase-init/plugins/setagentconfig.py b/Deployment/cloudbase-init/plugins/setagentconfig.py new file mode 100644 index 0000000..25f93ce --- /dev/null +++ b/Deployment/cloudbase-init/plugins/setagentconfig.py @@ -0,0 +1,37 @@ +import codecs + +from cloudbaseinit.osutils.factory import * +from cloudbaseinit.plugins.base import * +from cloudbaseinit.openstack.common import log as logging + +opts = [ + cfg.StrOpt('agent_config_file', default='C:\\Keero\\Agent\\WindowsAgent.exe.config', help='') +] + +CONF = cfg.CONF +CONF.register_opts(opts) + +LOG = logging.getLogger(__name__) + + +class SetHostNamePlugin(BasePlugin): + def execute(self, service): + meta_data = service.get_meta_data('openstack') + if 'meta' not in meta_data: + LOG.debug("Section 'meta' not found in metadata") + return False + + if 'agent_config_xml' not in meta_data['meta']: + LOG.debug("Config for agent not found in metadata section") + return False + + try: + configFile=codecs.open(CONF.agent_config_file, encoding='utf-8', mode='w+') + configFile.write(meta_data['meta']['agent_config_xml']) + configFile.close() + except: + LOG.error("Unable to update agent file.") + return False + + return True + diff --git a/Deployment/cloudbase-init/plugins/sethostname.py b/Deployment/cloudbase-init/plugins/sethostname.py new file mode 100644 index 0000000..9aa2e8d --- /dev/null +++ b/Deployment/cloudbase-init/plugins/sethostname.py @@ -0,0 +1,20 @@ + +from cloudbaseinit.osutils.factory import * +from cloudbaseinit.plugins.base import * +from cloudbaseinit.openstack.common import log as logging + +LOG = logging.getLogger(__name__) + + +class SetHostNamePlugin(BasePlugin): + def execute(self, service): + meta_data = service.get_meta_data('openstack') + if 'name' not in meta_data: + LOG.debug('Name not found in metadata') + return False + + osutils = OSUtilsFactory().get_os_utils() + + new_host_name = meta_data['name'].replace('.', '-') + return osutils.set_host_name(new_host_name) +