def container(): c = Config() database, websites = c.get_configuration() i = Initialize() browsers, dns_types = i.get_initialization() operation_system = platform.system() if operation_system == "Windows": system = Windows() elif operation_system == "Linux": system = Linux() resolver, recursive = system.get_dns_metadata() return database, websites, browsers, dns_types, resolver, recursive, system
def uploadFile(num): try: updateSvn(local_path) logs = ansSvnLog(local_path,svn_path,num) for server in servers: host = Linux(server['ip'],server['port'], server['username'], server['password']) host.connect() for i in logs: server_path = i.replace(local_path,server['path']).replace('\\','/') # 文件存在,则进行上传/更新 if os.path.exists(i): if os.path.isdir(i): host.exec_commands('mkdir -p '+server_path) print i +'...OK' if os.path.isfile(i): host.exec_commands('mkdir -p '+os.path.dirname(server_path)) host.upload(i,server_path) print i +'...OK' # 文件不存在,则代表svn的删除操作,直接删除服务端代码文件 else: host.exec_commands('rm -rf '+server_path) print i +'...OK' host.close() print '------------------------------------------------------------------' except Exception, e: print e
def sysdescrparser(sysdescr): """SNMP sysDescr parsing. Args: :sysdescr(str): SNMP sysDescr raw string. Returns: :SysDescr sub-class instance: SysDescr is abstract super class. Each vendor class extends Sysdescr class and following attributes. :vendor(str): Vendor name. :model(str): Product Model name. :os(str): OS name. :version(str): OS version name. Example: .. code-block:: python >>> from sysdescrparser import sysdescrparser >>> sysdescr = sysdescrparser('Juniper Networks, Inc. ...') >>> sysdescr.vendor 'JUNIPER' >>> sysdescr.model 'ex2200-48t-4g' >>> sysdescr.os 'JUNOS' >>> sysdescr.version '10.2R1.8' Support: Currently supported Vendor and OS. https://github.com/mtoshi/sysdescrparser/blob/master/samples/sample_data.json See also: https://github.com/mtoshi/sysdescrparser/blob/master/README.rst """ # # cisco nxos # obj = CiscoNXOS(sysdescr) if obj.parse(): return obj # # cisco iosxr # obj = CiscoIOSXR(sysdescr) if obj.parse(): return obj # # cisco ios # obj = CiscoIOS(sysdescr) if obj.parse(): return obj # # juniper junos # obj = JuniperJunos(sysdescr) if obj.parse(): return obj # # juniper screenos # obj = JuniperScreenOS(sysdescr) if obj.parse(): return obj # # brocade ironware # obj = BrocadeIronWare(sysdescr) if obj.parse(): return obj # # brocade serveriron # obj = BrocadeServerIron(sysdescr) if obj.parse(): return obj # # brocade networkos # obj = BrocadeNetworkOS(sysdescr) if obj.parse(): return obj # # foundry ironware # obj = FoundryIronWare(sysdescr) if obj.parse(): return obj # # arista eos # obj = AristaEOS(sysdescr) if obj.parse(): return obj # # extreme xos # obj = ExtremeXOS(sysdescr) if obj.parse(): return obj # # hp procurve # obj = HPProCurve(sysdescr) if obj.parse(): return obj # # paloalto panos # obj = PaloAltoPANOS(sysdescr) if obj.parse(): return obj # # a10 acos # obj = A10ACOS(sysdescr) if obj.parse(): return obj # # citrix netscaler # obj = CitrixNetscaler(sysdescr) if obj.parse(): return obj # # linux # obj = Linux(sysdescr) if obj.parse(): return obj # # sun sunos # obj = SunSUNOS(sysdescr) if obj.parse(): return obj # # freebsd # obj = FreeBSD(sysdescr) if obj.parse(): return obj # # iij seil # obj = IIJSeil(sysdescr) if obj.parse(): return obj # # yamaha rtx # obj = YamahaRTX(sysdescr) if obj.parse(): return obj # # Unknown # obj = Unknown(sysdescr) if obj.parse(): return obj
import traceback elf = Elf("../progs_to_test/bin/hello_cpp") mem = Memory() # Load program segments into the memory for ph in elf.program_header.entries: data = ph.data_to_load_to_memory print("writing a segment: %d bytes at pos 0x%x" % (len(data), ph.p_vaddr)) mem.write(ph.p_vaddr, data) cpu = Cpu(mem, elf.elf_header.e_entry, 0x123456789ABCDEF) linux = Linux(cpu, mem) cpu.linux = linux # set gs and fs to non-zero values # TODO: initialize to meaningful values cpu.gs = 0xeeeeeeeeeeee cpu.fs = 0xf0f0f0f0f0f0 try: while not cpu.stopped: print("=====") print("pos = 0x%x" % cpu.mem_stream.pos) cpu.exectute_next_instruction() except Exception: for i in range(16):
def __init__(self): self.__conn=libvirtHypervisor() self.__hostPtr=Linux()
class vmHost: def __init__(self): self.__conn=libvirtHypervisor() self.__hostPtr=Linux() def getHostSpecsList(self): return self.__hostPtr.getList() def getHypervisorSpecsList(self): return self.__conn.getList() def isConnected(self): return self.__conn.isConnected() def getHostVirtType(self): return self.__conn.getVirtType() def getHostVirtVersion(self): return self.__conn.getVirtVersion() def getHostVirtLibVersion(self): return self.__conn.getVirtLibVersion() def getHostVirtURI(self): return self.__conn.getVirtURI() def connisEncrypted(self): return self.__conn.connisEncrypted() def connisSecure(self): return self.__conn.connisSecure() def getNumofActiveVms(self): return self.__conn.getNumofActiveVms() def getNumofInactiveVms(self): return self.__conn.getNumofInactiveVms() def getNumofAllVms(self): return self.__conn.getNumofAllVms() def getActiveVmNames(self): return self.__conn.getActiveVmNames() def getInactiveVmNames(self): return self.__conn.getInactiveVmNames() def getAllVmNames(self): return self.__conn.getAllVmNames() def getGuest(self,guest_id=None,guest_uuid=None,guest_name=None): if (guest_id is not None) and (guest_uuid is None) and (guest_name is None): return self.__conn.lookUpGuestById(guest_id) elif (guest_uuid is not None) and (guest_id is None) and (guest_name is None): return self.__conn.lookUpGuestByUUID(guest_uuid) elif (guest_name is not None) and (guest_id is None) and (guest_uuid is None): return self.__conn.lookUpGuestByName(guest_name) def getVmDevicesList(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getDevicesList() def getVmSpecsList(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getSpecsList() def launchVm(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).launch() def shutdownVm(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).shutdown() def poweroffVm(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).poweroff() def rebootVm(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).reboot() def VmIsRunning(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).isRunning() def VmIsPersistent(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).isPersistent() def getVmVirtType(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getVirtType() def getVmId(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getId() def getVmName(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getName() def getVmUuid(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getUuid() def getVmMaxMemory(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getMaxMemory() def getVmCurrentMemory(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getCurrentMemory() def getVmMaxVcpu(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getMaxVcpu() def getVmCurrentVcpu(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getCurrentVcpu() def getVmArch(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getArch() def getGuestType(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getGuestType() def getVmBootDevice(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getBootDevice() def isVmAcpiEnabled(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).isAcpiEnabled() def isVmApicEnabled(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).isApicEnabled() def isVmPaeEnabled(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).isPaeEnabled() def getVmCpuModel(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getCpuModel() def getVmClockOffset(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getClockOffset() def getVmActions(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getActions() def getVmDeviceEmulator(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getDeviceEmulator() def getVmDisks(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getDisks() def getVmControllers(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getControllers() def getVmInterfaces(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getInterfaces() def getVmSerialConnectors(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getSerialConnectors() def getVmConsoleTypes(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getConsoleTypes() def getVmInputs(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getInputs() def getVmMonitors(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getMonitors() def getVmSoundCards(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getSoundCards() def getVmVideoCards(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getVideoCards() def getVmMemBalloons(self,guest_id=None,guest_uuid=None,guest_name=None): return self.getGuest(guest_id, guest_uuid, guest_name).getMemBalloons() def isVirtServiceRunning(self): return self.__hostPtr.isVirtServiceRunning() def startVirtService(self): return self.__hostPtr.startVirtService() def stopVirtService(self): return self.__hostPtr.stopVirtService() def restartVirtService(self): return self.__hostPtr.restartVirtService() def killVirtService(self): return self.__hostPtr.killVirtService() def getCpuUsage(self): return self.__hostPtr.getCpuUsage() def getAgentPid(self): return self.__hostPtr.getAgentPid() def getLinuxDistroCode(self): return self.__hostPtr.getLinuxDistroCode() def getLinuxDistroName(self): return self.__hostPtr.getLinuxDistroName() def getLinuxDistroVersion(self): return self.__hostPtr.getLinuxDistroVersion() def getFreePhysicalMemory(self): return self.__hostPtr.getFreePhysicalMemory() def getFreeVirtualMemory(self): return self.__hostPtr.getFreeVirtualMemory() def getLinuxKernelVersion(self): return self.__hostPtr.getLinuxKernelVersion() def getArchType(self): return self.__hostPtr.getArchType() def getNetworkName(self): return self.__hostPtr.getNetworkName() def getProcessCpuUsage(self): return self.__hostPtr.getProcessCpuUsage() def getProcessMemoryUsage(self): return self.__hostPtr.getProcessMemoryUsage() def getProcessorSpecs(self): return self.__hostPtr.getProcessorSpecs() def getAgentUptime(self): return self.__hostPtr.getAgentUptime() def getPythonVersion(self): return self.__hostPtr.getPythonVersion() def getTotalVirtualMemory(self): return self.__hostPtr.getTotalVirtualMemory() def getUsedPhysicalMemory(self): return self.__hostPtr.getUsedPhysicalMemory() def getVirtProcessCpuUsage(self): return self.__hostPtr.getVirtProcessCpuUsage() def getVirtProcessMemUsage(self): return self.__hostPtr.getVirtProcessMemUsage() def getVirtProcessName(self): return self.__hostPtr.getVirtProcessName() def getVirtProcessId(self): return self.__hostPtr.getVirtProcessId()