7730a743bb
Fuel agent is a bunch of tools which are supposed to be placed on bootstrap image and used for node discovering and image based provisioning. Implements: blueprint image-based-provisioning Change-Id: I946decd50c51e6db767401682d9effbe3cf42bed
88 lines
2.9 KiB
Python
88 lines
2.9 KiB
Python
# Copyright 2014 Mirantis, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from fuel_agent import errors
|
|
|
|
|
|
class ConfigDriveCommon(object):
|
|
def __init__(self, ssh_auth_key, hostname, fqdn, name_servers,
|
|
search_domain, master_ip, master_url, timezone):
|
|
self.ssh_auth_key = ssh_auth_key
|
|
self.hostname = hostname
|
|
self.fqdn = fqdn
|
|
self.name_servers = name_servers
|
|
self.search_domain = search_domain
|
|
self.master_ip = master_ip
|
|
self.master_url = master_url
|
|
self.timezone = timezone
|
|
|
|
|
|
class ConfigDrivePuppet(object):
|
|
def __init__(self, master):
|
|
self.master = master
|
|
|
|
|
|
class ConfigDriveMcollective(object):
|
|
def __init__(self, pskey, vhost, host, user, password, connector):
|
|
self.pskey = pskey
|
|
self.vhost = vhost
|
|
self.host = host
|
|
self.user = user
|
|
self.password = password
|
|
self.connector = connector
|
|
|
|
|
|
class ConfigDriveScheme(object):
|
|
def __init__(self, common=None, puppet=None,
|
|
mcollective=None, profile=None):
|
|
self.common = common
|
|
self.puppet = puppet
|
|
self.mcollective = mcollective
|
|
self._profile = profile or 'ubuntu'
|
|
|
|
# TODO(kozhukalov) make it possible to validate scheme according to
|
|
# chosen profile which means chosen set of cloud-init templates.
|
|
# In other words make this templating scheme easily extendable.
|
|
|
|
def set_common(self, **kwargs):
|
|
self.common = ConfigDriveCommon(**kwargs)
|
|
|
|
def set_puppet(self, **kwargs):
|
|
self.puppet = ConfigDrivePuppet(**kwargs)
|
|
|
|
def set_mcollective(self, **kwargs):
|
|
self.mcollective = ConfigDriveMcollective(**kwargs)
|
|
|
|
def template_data(self):
|
|
if self.common is None:
|
|
raise errors.WrongConfigDriveDataError(
|
|
'Common attribute should be defined, but it is not')
|
|
template_data = {'common': self.common}
|
|
if self.puppet is not None:
|
|
template_data.update(puppet=self.puppet)
|
|
if self.mcollective is not None:
|
|
template_data.update(mcollective=self.mcollective)
|
|
return template_data
|
|
|
|
def set_profile(self, profile):
|
|
# TODO(kozhukalov) validate profile
|
|
self._profile = profile
|
|
|
|
@property
|
|
def profile(self):
|
|
return self._profile
|
|
|
|
def template_name(self, what):
|
|
return '%s_%s.jinja2' % (what, self._profile)
|