2
# Copyright (C) 2015 Canonical
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Constants for this service."""
24
SOLUTION_NAME = "core-image-testing"
26
SERVICE_NAME = "core-image-builder"
30
"""Return sanitized contents of /etc/hostname.
32
It is necessary because current juju hostnames (juju-<env-name>-machine-#)
33
are too big due to our long environment names ('<spec_name>-<MD5>').
34
Linux (DNS for RFC1035, really) only supports labels up to 64 chars and
35
the fallback varies from tool to tool, `cloud-init` chokes on longer
36
names and sets 'ubuntu' (which is the value considered by socket.get*),
37
`hostnamectl` (systemd) would truncate the given data.
39
None of this is ideal to our applications, that's why we will operate
40
on the pristine /etc/hostname and remove the 'juju-' and '-machine' terms
43
with open('/etc/hostname') as fd:
45
return hostname.replace('juju-', '').replace('-machine', '').strip()
48
HOSTNAME = _get_hostname()
51
'solution': SOLUTION_NAME,
52
'service': SERVICE_NAME,