summaryrefslogtreecommitdiffstats
path: root/utils/src/ooinstall/utils.py
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@afrolegs.com>2016-10-21 13:07:30 -0400
committerGitHub <noreply@github.com>2016-10-21 13:07:30 -0400
commit65a478443e4c86576f99936dac3f2989c685552e (patch)
tree5215d83878a96ea82c608d9740a322af17eed21b /utils/src/ooinstall/utils.py
parent88347f4866ed41132abb7f78fe37ac264236a395 (diff)
parent1c7dd6d5cd94c92ebec0a0fda789f4bfffa23472 (diff)
downloadopenshift-65a478443e4c86576f99936dac3f2989c685552e.tar.gz
openshift-65a478443e4c86576f99936dac3f2989c685552e.tar.bz2
openshift-65a478443e4c86576f99936dac3f2989c685552e.tar.xz
openshift-65a478443e4c86576f99936dac3f2989c685552e.zip
Merge pull request #2563 from smunilla/BZ1339621
a-o-i: Separate install and scaleup workflows
Diffstat (limited to 'utils/src/ooinstall/utils.py')
-rw-r--r--utils/src/ooinstall/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/src/ooinstall/utils.py b/utils/src/ooinstall/utils.py
index eb27a57e4..85a77c75e 100644
--- a/utils/src/ooinstall/utils.py
+++ b/utils/src/ooinstall/utils.py
@@ -1,4 +1,6 @@
import logging
+import re
+
installer_log = logging.getLogger('installer')
@@ -8,3 +10,12 @@ def debug_env(env):
if k.startswith("OPENSHIFT") or k.startswith("ANSIBLE") or k.startswith("OO"):
installer_log.debug("{key}: {value}".format(
key=k, value=env[k]))
+
+
+def is_valid_hostname(hostname):
+ if not hostname or len(hostname) > 255:
+ return False
+ if hostname[-1] == ".":
+ hostname = hostname[:-1] # strip exactly one dot from the right, if present
+ allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
+ return all(allowed.match(x) for x in hostname.split("."))