Supporting setting domain on nodes

- During the genesis or join operation when /etc/hosts and
  /etc/resolv.conf are controlled by Promeande, we need to
  support including a domain name. This can be configured
  by YAML definition or by the join-script API. To support
  backward compatability use a default of 'local' when no
  domain is specified.

Testing: `./tools/gate.sh resiliency` has passed locally

Change-Id: Ia0d300912d3ec25eb7f1cb9c580eaa40b5b4addb
This commit is contained in:
Scott Hussey 2018-08-06 20:53:35 -05:00
parent 7c3f05d564
commit 0011414107
5 changed files with 23 additions and 8 deletions

View File

@ -75,23 +75,29 @@ class Configuration:
jinja2.StrictUndefined(
'No match found for path %s' % path))
def get_first(self, *paths):
def get_first(self, *paths, default=None):
result = self._get_first(*paths)
if result:
return result
else:
return jinja2.StrictUndefined(
'Nothing found matching paths: %s' % ','.join(paths))
if default:
return default
else:
return jinja2.StrictUndefined(
'Nothing found matching paths: %s' % ','.join(paths))
def get(self, *, kind=None, name=None, schema=None):
def get(self, *, kind=None, name=None, schema=None, default=None):
result = _get(self.documents, kind=kind, schema=schema, name=name)
if result:
return result['data']
else:
return jinja2.StrictUndefined(
'No document found matching kind=%s schema=%s name=%s' %
(kind, schema, name))
if default:
return default
else:
return jinja2.StrictUndefined(
'No document found matching kind=%s schema=%s name=%s' %
(kind, schema, name))
def iterate(self, *, kind=None, schema=None, labels=None, name=None):
if kind is not None:

View File

@ -39,6 +39,8 @@ class JoinScriptsResource(BaseResource):
design_ref = req.get_param('design_ref', required=True)
ip = req.get_param('ip', required=True)
hostname = req.get_param('hostname', required=True)
# NOTE(sh8121att): Set a default here for backward compatability
dns_domain = req.get_param('domain', default='local')
dynamic_labels = _get_param_list(req, 'labels.dynamic')
static_labels = _get_param_list(req, 'labels.static')
@ -70,6 +72,7 @@ class JoinScriptsResource(BaseResource):
},
'data': {
'hostname': hostname,
'domain': dns_domain,
'ip': ip,
'join_ip': join_ip,
'labels': {

View File

@ -81,6 +81,9 @@ data:
hostname:
$ref: '#/definitions/hostname'
domain:
type: string
ip:
$ref: '#/definitions/ip_address'

View File

@ -26,6 +26,9 @@ data:
ip:
$ref: '#/definitions/ip_address'
domain:
type: string
join_ip:
$ref: '#/definitions/ip_address'

View File

@ -1,6 +1,6 @@
# This file is controlled by Promenade. Do not modify.
#
127.0.0.1 {{ config.get_first('Genesis:hostname', 'KubernetesNode:hostname') }}
127.0.0.1 {{ config.get_first('Genesis:hostname', 'KubernetesNode:hostname') }}.{{ config.get_first('Genesis:domain', 'KubernetesNode:domain', default='local') }} {{ config.get_first('Genesis:hostname', 'KubernetesNode:hostname') }}
127.0.0.1 localhost
{%- for entry in config.get_path('KubernetesNetwork:hosts_entries', []) %}
{{ entry['ip'] }} {{ entry['names'] | join(' ') }}