Skip to content

Commit

Permalink
update host: use looser matching
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jan 2, 2024
1 parent f145528 commit 3f07e6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions ailib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def update_host(self, hostname, overrides):
infra_env_id = self.get_infra_env_id(infra_env)
hosts = self.client.v2_list_hosts(infra_env_id=infra_env_id)
matchingids = [host['id'] for host in hosts
if host['requested_hostname'] == hostname or host['id'] == hostname or
if host['requested_hostname'].startswith(hostname) or host['id'].startswith(hostname) or
match_mac(host, hostname)]
if matchingids:
infra_envs[infra_env_id] = matchingids
Expand Down Expand Up @@ -1515,8 +1515,8 @@ def create_deployment(self, cluster, overrides, force=False, debug=False):
self.create_infra_env(infraenv, overrides)
del overrides['cluster']
if not self.saas:
info("Waiting 120s for iso to be available")
sleep(120)
info("Waiting 240s for iso to be available")
sleep(240)
if 'iso_url' in overrides:
download_iso_path = overrides.get('download_iso_path')
if download_iso_path is None:
Expand Down
25 changes: 15 additions & 10 deletions ailib/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ def create_onprem(overrides={}, debug=False):
ip = overrides.get('ip') or get_ip() or '192.168.122.1'
ipv6 = ':' in ip
info(f"Using ip {ip}")
with open(f"{tmpdir}/pod.yml", 'w') as p:
pod_url = "https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/pod.yml"
response = urllib.request.urlopen(pod_url).read().decode('utf-8')
response = response.replace('latest', onprem_version).replace(f'centos7:{onprem_version}', 'centos7:latest')
if ipv6:
response = response.replace('127.0.0.1', f"[{ip}")
p.write(response)
if os.path.exists('pod.yml'):
info("Using existing pod.yml")
copy2("pod.yml", tmpdir)
else:
with open(f"{tmpdir}/pod.yml", 'w') as p:
pod_url = "https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/pod.yml"
response = urllib.request.urlopen(pod_url).read().decode('utf-8')
response = response.replace('latest', onprem_version).replace(f'centos7:{onprem_version}',
'centos7:latest')
p.write(response)
if os.path.exists('configmap.yml'):
info("Using existing configmap.yml")
copy2("configmap.yml", tmpdir)
Expand All @@ -173,8 +176,10 @@ def create_onprem(overrides={}, debug=False):
cm_name = 'okd-configmap' if overrides.get('okd', False) else 'configmap'
cm_url = "https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/"
cm_url += f"{cm_name}.yml"
response = urllib.request.urlopen(cm_url)
c.write(response.read().decode('utf-8'))
response = urllib.request.urlopen(cm_url).read().decode('utf-8')
if ipv6:
response = response.replace('127.0.0.1:8090', f'"[{ip}]:8090"')
c.write(response)
if ipv6 and '[' not in ip:
ip = f"[{ip}]"
IMAGE_SERVICE_BASE_URL = f'http://{ip}:8888'
Expand All @@ -198,7 +203,7 @@ def create_onprem(overrides={}, debug=False):
call(cmd, shell=True)
storage = '--storage-driver vfs' if 'KUBERNETES_SERVICE_PORT' in os.environ else ''
network = '--network assistedv6' if ipv6 else ''
cmd = f"podman {storage} {network} play kube --replace --configmap {tmpdir}/configmap.yml {tmpdir}/pod.yml"
cmd = f"podman {storage} play kube {network} --replace --configmap {tmpdir}/configmap.yml {tmpdir}/pod.yml"
info(f"Running: {cmd}")
call(cmd, shell=True)

Expand Down

0 comments on commit 3f07e6a

Please sign in to comment.