def configure_host_by_mac(mac_addr): avl_private_ip = None ip_info = db.private_ip_pool(mac_addr=mac_addr) if ip_info: avl_private_ip = ip_info.private_ip else: avl_ip = db((~db.private_ip_pool.id.belongs(db()._select(db.host.host_ip))) & (db.private_ip_pool.vlan == HOST_VLAN_ID)).select(db.private_ip_pool.private_ip) if avl_ip.first(): ip_info = avl_ip.first() avl_private_ip = ip_info['private_ip'] if avl_private_ip: logger.debug('Available IP for mac address %s is %s'%(mac_addr, avl_private_ip)) host_name = 'host'+str(avl_private_ip.split('.')[3]) create_dhcp_entry(host_name, mac_addr, avl_private_ip) db.host[0] = dict(host_ip=ip_info['id'], host_name=host_name, mac_addr=mac_addr, status=HOST_STATUS_DOWN) return 'Host configured. Proceed for PXE boot.' else: logger.error('Available Private IPs for host are exhausted.') return 'Available Private IPs for host are exhausted.'
def get_stream_data(self): response = byteify(self.__twitterreq(TWITTER_STREAM_URL, "GET", [])) try: for line in response: string_data = unicode(line.strip(), 'utf-8') json_data = byteify(json.loads(string_data)) self.handle_stream_data(string_data, json_data) except httplib.IncompleteRead as e: logger.error("IncompleteRead")
def check_host_service_status(host_ip): #Check libvirt status command = "ps -ef | grep libvirtd | grep -v grep | wc -l" ret = execute_remote_cmd(host_ip, 'root',command) if ret == 0 : logger.error("Critical: Libvirt service is not running on host " + host_ip) return False #Check OVS status command = "service openvswitch-switch status | grep -w 'running' | wc -l" ret = execute_remote_cmd(host_ip, 'root',command) if ret == 0 : logger.error("Critical: OVS switch is not running on host " + host_ip) return False return True