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()
def run(self): while True: host = self.queue.get() with UcsServer(host, config.USERNAME, config.PASSWORD) as server: server.get_interface_inventory() out_string = server.ipaddress for int in server.inventory['adaptor']: out_string += ',SLOT-'+int['pciSlot'] for port in int['port']: out_string += ',port-'+str(port['portId'])+','+port['adminSpeed']+','+port['linkState'] for vnic in port['vnic']: out_string += ','+str(vnic['name'])+','+str(vnic['mac']) with self.lock: print out_string self.queue.task_done()
def run(self): while True: host = self.queue.get() with UcsServer(host, config.USERNAME, config.PASSWORD) as server: if server is None: # The login failed, skip this server and go on to the next logging.info('Login failed for %r user %r' % (host, config.USERNAME)) return if server.get_chassis_info(): with self.screenlock: print 'Server', server.ipaddress, 'is', server.inventory[ 'chassis']['operPower'] # server.set_power_state('bmc-reset-immediate', force=True) else: with self.screenlock: print host, 'get_chassis_info() returned False' 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
from pycimc import UcsServer import config for address in config.SERVERS: with UcsServer(address, config.USERNAME, config.PASSWORD) as server: server.get_fw_versions() out_string = server.ipaddress + ',' for key, value in server.inventory['fw'].items(): path_list = key.split('/')[2:] path = '/'.join(path_list) out_string += path + ',' + value + ',' print out_string