~gz/juju-ci-tools/always_finish_reports

« back to all changes in this revision

Viewing changes to substrate.py

  • Committer: John George
  • Date: 2015-02-25 21:38:23 UTC
  • mfrom: (836.2.6 fetch_maas_logs)
  • Revision ID: john.george@canonical.com-20150225213823-ipln6duzhle1u7wv
Resolve MaaS DNS names against the server defined in the environment and use the IP to fetch logs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
)
6
6
import logging
7
7
import os
 
8
import re
8
9
import subprocess
9
10
import sys
10
11
from time import sleep
492
493
    except subprocess.CalledProcessError:
493
494
        raise Exception('%s failed' % command)
494
495
    return sub_output
 
496
 
 
497
 
 
498
def get_maas_ip_from_name(server_url, host):
 
499
    match = re.match('http://(\d+\.\d+\.\d+\.\d+)/MAAS/',
 
500
                     server_url)
 
501
    if match is not None:
 
502
        maas_ip = match.groups()[0]
 
503
        command = ['dig', '@' + maas_ip, host, '+short']
 
504
        host = subprocess.check_output(command)
 
505
        return host.splitlines().pop()