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:
parent
7c3f05d564
commit
0011414107
|
@ -75,19 +75,25 @@ class Configuration:
|
||||||
jinja2.StrictUndefined(
|
jinja2.StrictUndefined(
|
||||||
'No match found for path %s' % path))
|
'No match found for path %s' % path))
|
||||||
|
|
||||||
def get_first(self, *paths):
|
def get_first(self, *paths, default=None):
|
||||||
result = self._get_first(*paths)
|
result = self._get_first(*paths)
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
else:
|
||||||
|
if default:
|
||||||
|
return default
|
||||||
else:
|
else:
|
||||||
return jinja2.StrictUndefined(
|
return jinja2.StrictUndefined(
|
||||||
'Nothing found matching paths: %s' % ','.join(paths))
|
'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)
|
result = _get(self.documents, kind=kind, schema=schema, name=name)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
return result['data']
|
return result['data']
|
||||||
|
else:
|
||||||
|
if default:
|
||||||
|
return default
|
||||||
else:
|
else:
|
||||||
return jinja2.StrictUndefined(
|
return jinja2.StrictUndefined(
|
||||||
'No document found matching kind=%s schema=%s name=%s' %
|
'No document found matching kind=%s schema=%s name=%s' %
|
||||||
|
|
|
@ -39,6 +39,8 @@ class JoinScriptsResource(BaseResource):
|
||||||
design_ref = req.get_param('design_ref', required=True)
|
design_ref = req.get_param('design_ref', required=True)
|
||||||
ip = req.get_param('ip', required=True)
|
ip = req.get_param('ip', required=True)
|
||||||
hostname = req.get_param('hostname', 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')
|
dynamic_labels = _get_param_list(req, 'labels.dynamic')
|
||||||
static_labels = _get_param_list(req, 'labels.static')
|
static_labels = _get_param_list(req, 'labels.static')
|
||||||
|
@ -70,6 +72,7 @@ class JoinScriptsResource(BaseResource):
|
||||||
},
|
},
|
||||||
'data': {
|
'data': {
|
||||||
'hostname': hostname,
|
'hostname': hostname,
|
||||||
|
'domain': dns_domain,
|
||||||
'ip': ip,
|
'ip': ip,
|
||||||
'join_ip': join_ip,
|
'join_ip': join_ip,
|
||||||
'labels': {
|
'labels': {
|
||||||
|
|
|
@ -81,6 +81,9 @@ data:
|
||||||
hostname:
|
hostname:
|
||||||
$ref: '#/definitions/hostname'
|
$ref: '#/definitions/hostname'
|
||||||
|
|
||||||
|
domain:
|
||||||
|
type: string
|
||||||
|
|
||||||
ip:
|
ip:
|
||||||
$ref: '#/definitions/ip_address'
|
$ref: '#/definitions/ip_address'
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ data:
|
||||||
ip:
|
ip:
|
||||||
$ref: '#/definitions/ip_address'
|
$ref: '#/definitions/ip_address'
|
||||||
|
|
||||||
|
domain:
|
||||||
|
type: string
|
||||||
|
|
||||||
join_ip:
|
join_ip:
|
||||||
$ref: '#/definitions/ip_address'
|
$ref: '#/definitions/ip_address'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# This file is controlled by Promenade. Do not modify.
|
# 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
|
127.0.0.1 localhost
|
||||||
{%- for entry in config.get_path('KubernetesNetwork:hosts_entries', []) %}
|
{%- for entry in config.get_path('KubernetesNetwork:hosts_entries', []) %}
|
||||||
{{ entry['ip'] }} {{ entry['names'] | join(' ') }}
|
{{ entry['ip'] }} {{ entry['names'] | join(' ') }}
|
||||||
|
|
Loading…
Reference in New Issue