Modified files from cloudbase-init added

This commit is contained in:
Dmitry Teselkin 2013-03-06 19:27:15 +04:00
parent 485ec41d1e
commit f7c8d4a726
3 changed files with 67 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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)