Esempio n. 1
0
 def test_002_is_vm_provider_by_cpuid_retruns(self):
     """Test vm_provider_by_cpuid ."""
     with patch.object(VMDetect, 'vm_provider_by_cpuid',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.vm_provider_by_cpuid()
     mock_method.assert_called()
Esempio n. 2
0
def main(test_type=None):
    """Console script for py_vmdetect."""
    vmd = VMDetect()

    if not test_type:
        click.echo("Is Virtual: {}".format("yes" if vmd.is_vm() else "no"))
        return 0

    if re.match('is_vm', test_type):
        click.echo("Is Virtual: {}".format("yes" if vmd.is_vm() else "no"))
    elif re.match('vm_provider_by_cpuid', test_type):
        click.echo("VM Provider by CPUID: {}".format(
            vmd.vm_provider_by_cpuid()))
    elif re.match('isVMware', test_type):
        click.echo("Is VMware: {}".format("yes" if vmd.isVMware() else "no"))
    elif re.match('isHyperV', test_type):
        click.echo("Is HyperV: {}".format("yes" if vmd.isHyperV() else "no"))
    elif re.match('isOpenVZ', test_type):
        click.echo("Is OpenVZ: {}".format("yes" if vmd.isOpenVZ() else "no"))
    elif re.match('isUserModeLinux', test_type):
        click.echo("Is UserModeLinux: {}".format(
            "yes" if vmd.isUserModeLinux() else "no"))
    elif re.match('isKvm', test_type):
        click.echo("Is Kvm: {}".format("yes" if vmd.isKvm() else "no"))
    elif re.match('isXENDomU', test_type):
        click.echo("Is XEN: {}".format("yes" if vmd.isXENDomU() else "no"))
    elif re.match('isFreeBSDJAIL', test_type):
        click.echo("Is FreeBSD JAIL: {}".format(
            "yes" if vmd.isFreeBSDJAIL() else "no"))
    return 0