def initdomain(self): print red(''' INIT CONFIG FILES. ''') domain_name = self.bind_deployschema.schema_name cmdbobserver = XMLCMDBObserver() domain_dict = {} host_ip_dict = {} for host in cmdbobserver.getHostlist(): ipaddrs = {'bindPrivateIP' : []} ethernets = host.findall('./Hardware/EthernetIF') for ethernet in ethernets: if ethernet.attrib['bindPrivateIP']: ipaddrs['bindPrivateIP'].append(ethernet.attrib['bindPrivateIP']) if ethernet.attrib['bindPublicIP']: ipaddrs['bindPublicIP'] = ethernet.attrib['bindPublicIP'] host_ip_dict[host.attrib['name']] = ipaddrs domain_dict[host.attrib['name']] = host.attrib['name'] + '.' + domain_name + '.com' print "init domain name and hostname config... \n" jsondata = json.dumps(domain_dict) with open(DOMAIN_FILE, 'w+') as f: f.write(jsondata) time.sleep(1) print "init ip node..." j = json.dumps(host_ip_dict) with open(HOST_IP_FILE, 'w+') as f: f.write(j) time.sleep(1)
def initdomain(self): print red(''' INIT CONFIG FILES. ''') domain_name = self.bind_deployschema.schema_name cmdbobserver = XMLCMDBObserver() domain_dict = {} host_ip_dict = {} for host in cmdbobserver.getHostlist(): ipaddrs = {'bindPrivateIP': []} ethernets = host.findall('./Hardware/EthernetIF') for ethernet in ethernets: if ethernet.attrib['bindPrivateIP']: ipaddrs['bindPrivateIP'].append( ethernet.attrib['bindPrivateIP']) if ethernet.attrib['bindPublicIP']: ipaddrs['bindPublicIP'] = ethernet.attrib['bindPublicIP'] host_ip_dict[host.attrib['name']] = ipaddrs domain_dict[host.attrib[ 'name']] = host.attrib['name'] + '.' + domain_name + '.com' print "init domain name and hostname config... \n" jsondata = json.dumps(domain_dict) with open(DOMAIN_FILE, 'w+') as f: f.write(jsondata) time.sleep(1) print "init ip node..." j = json.dumps(host_ip_dict) with open(HOST_IP_FILE, 'w+') as f: f.write(j) time.sleep(1)
def __init__(self): xcbo = XMLCMDBObserver() self._manageResource(xcbo.getDataCenter()) self._manageResource(xcbo.getNetwork()) self._manageResource(xcbo.getHostlist()) self._manageResource(xcbo.getContainerlist())