def run(self): while True: host = self.queue.get() #with self.lock: # string = self.getName()+': '+host #print string server = UcsServer(host, USERNAME, CURRENT_PASSWORD) try: if server.login(): if server.set_password(USERNAME, NEW_PASSWORD): with self.lock: print "%s: Changed user '%s' password to '%s'" % (host, USERNAME, NEW_PASSWORD) else: with self.lock: print "%s: Error changing password" % host server.logout() #else: # with self.lock: # print "Couldn't log in to", host except Exception as err: with self.lock: print "Server Error:", host, err finally: #print 'Queue size:',queue.qsize() self.queue.task_done()
from pycimc import UcsServer import config __author__ = 'Rob Horner ([email protected])' for address in config.SERVERS: server = UcsServer(address, config.USERNAME, config.PASSWORD) if server.login(): server.get_eth_settings() interface_string = address + '\t' for interface in server.adaptor_host_eth_list: adaptor = interface['dn'].split('/')[2] interface_name = adaptor + '-' + interface['name'] mac = interface['mac'] interface_string += interface_name + '\t' + mac + '\t' print interface_string server.logout() else: continue