Пример #1
0
    def check_vmrun_version(self, minimum_required_version="1.13.0"):
        """
        Checks the vmrun version.

        VMware VIX library version must be at least >= 1.13 by default
        VIX 1.13 was the release for VMware Fusion 6, Workstation 10, and Player 6.
        VIX 1.14 was the release for VMware Fusion 7, Workstation 11 and Player 7.
        VIX 1.15 was the release for VMware Fusion 8, Workstation Pro 12 and Workstation Player 12.

        :param required_version: required vmrun version number
        """

        vmrun_path = self.vmrun_path
        if not vmrun_path:
            vmrun_path = self.find_vmrun()

        try:
            output = yield from subprocess_check_output(vmrun_path)
            match = re.search("vmrun version ([0-9\.]+)", output)
            version = None
            if match:
                version = match.group(1)
                log.debug("VMware vmrun version {} detected, minimum required: {}".format(version, minimum_required_version))
                if parse_version(version) < parse_version(minimum_required_version):
                    raise VMwareError("VMware vmrun executable version must be >= version {}".format(minimum_required_version))
            if version is None:
                log.warning("Could not find VMware vmrun version. Output: {}".format(output))
                raise VMwareError("Could not find VMware vmrun version. Output: {}".format(output))
        except (OSError, subprocess.SubprocessError) as e:
            log.error("Error while looking for the VMware vmrun version: {}".format(e))
            raise VMwareError("Error while looking for the VMware vmrun version: {}".format(e))
Пример #2
0
    def check_vmrun_version(self, minimum_required_version="1.13.0"):
        """
        Checks the vmrun version.

        VMware VIX library version must be at least >= 1.13 by default
        VIX 1.13 was the release for VMware Fusion 6, Workstation 10, and Player 6.
        VIX 1.14 was the release for VMware Fusion 7, Workstation 11 and Player 7.
        VIX 1.15 was the release for VMware Fusion 8, Workstation Pro 12 and Workstation Player 12.

        :param required_version: required vmrun version number
        """

        with (yield from self._execute_lock):
            vmrun_path = self.vmrun_path
            if not vmrun_path:
                vmrun_path = self.find_vmrun()

            try:
                output = yield from subprocess_check_output(vmrun_path)
                match = re.search("vmrun version ([0-9\.]+)", output)
                version = None
                if match:
                    version = match.group(1)
                    log.debug("VMware vmrun version {} detected, minimum required: {}".format(version, minimum_required_version))
                    if parse_version(version) < parse_version(minimum_required_version):
                        raise VMwareError("VMware vmrun executable version must be >= version {}".format(minimum_required_version))
                if version is None:
                    log.warning("Could not find VMware vmrun version. Output: {}".format(output))
                    raise VMwareError("Could not find VMware vmrun version. Output: {}".format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error("Error while looking for the VMware vmrun version: {}".format(e))
                raise VMwareError("Error while looking for the VMware vmrun version: {}".format(e))
Пример #3
0
    def check_vmrun_version(self):

        with (yield from self._execute_lock):
            vmrun_path = self.vmrun_path
            if not vmrun_path:
                vmrun_path = self.find_vmrun()

            try:
                output = yield from subprocess_check_output(vmrun_path)
                match = re.search("vmrun version ([0-9\.]+)", output)
                version = None
                if match:
                    version = match.group(1)
                    log.debug(
                        "VMware vmrun version {} detected".format(version))
                    if parse_version(version) < parse_version("1.13"):
                        # VMware VIX library version must be at least >= 1.13
                        raise VMwareError(
                            "VMware vmrun executable version must be >= version 1.13"
                        )
                if version is None:
                    log.warning(
                        "Could not find VMware vmrun version. Output: {}".
                        format(output))
                    raise VMwareError(
                        "Could not find VMware vmrun version. Output: {}".
                        format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error(
                    "Error while looking for the VMware vmrun version: {}".
                    format(e))
                raise VMwareError(
                    "Error while looking for the VMware vmrun version: {}".
                    format(e))
Пример #4
0
 def _check_ubridge_version(self, env=None):
     """
     Checks if the ubridge executable version
     """
     try:
         output = yield from subprocess_check_output(self._path,
                                                     "-v",
                                                     cwd=self._working_dir,
                                                     env=env)
         match = re.search("ubridge version ([0-9a-z\.]+)", output)
         if match:
             self._version = match.group(1)
             if sys.platform.startswith("win") or sys.platform.startswith(
                     "darwin"):
                 minimum_required_version = "0.9.12"
             else:
                 # uBridge version 0.9.14 is required for packet filters
                 # to work for IOU nodes.
                 minimum_required_version = "0.9.14"
             if parse_version(self._version) < parse_version(
                     minimum_required_version):
                 raise UbridgeError(
                     "uBridge executable version must be >= {}".format(
                         minimum_required_version))
         else:
             raise UbridgeError(
                 "Could not determine uBridge version for {}".format(
                     self._path))
     except (OSError, subprocess.SubprocessError) as e:
         raise UbridgeError(
             "Error while looking for uBridge version: {}".format(e))
Пример #5
0
 def _check_vpcs_version(self):
     """
     Checks if the VPCS executable version is >= 0.8b or == 0.6.1.
     """
     try:
         output = yield from subprocess_check_output(self._vpcs_path(),
                                                     "-v",
                                                     cwd=self.working_dir)
         match = re.search(
             "Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)",
             output)
         if match:
             version = match.group(1)
             self._vpcs_version = parse_version(version)
             if self._vpcs_version < parse_version("0.6.1"):
                 raise VPCSError(
                     "VPCS executable version must be >= 0.6.1 but not a 0.8"
                 )
         else:
             raise VPCSError(
                 "Could not determine the VPCS version for {}".format(
                     self._vpcs_path()))
     except (OSError, subprocess.SubprocessError) as e:
         raise VPCSError(
             "Error while looking for the VPCS version: {}".format(e))
Пример #6
0
def test_subprocess_check_output(loop, tmpdir, restore_original_path):

    path = str(tmpdir / "test")
    with open(path, "w+") as f:
        f.write("TEST")
    exec = subprocess_check_output("cat", path)
    result = loop.run_until_complete(asyncio.async(exec))
    assert result == "TEST"
Пример #7
0
def test_subprocess_check_output(loop, tmpdir, restore_original_path):

    path = str(tmpdir / "test")
    with open(path, "w+") as f:
        f.write("TEST")
    exec = subprocess_check_output("cat", path)
    result = loop.run_until_complete(asyncio. async (exec))
    assert result == "TEST"
Пример #8
0
    def check_vmware_version(self):
        """
        Check VMware version
        """

        if sys.platform.startswith("win"):
            # look for vmrun.exe using the directory listed in the registry
            ws_version = self._find_vmware_version_registry(r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation")
            if ws_version is None:
                player_version = self._find_vmware_version_registry(r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player")
                if player_version:
                    log.debug("VMware Player version {} detected".format(player_version))
                    if int(player_version) < 6:
                        raise VMwareError("Using VMware Player requires version 6 or above")
                else:
                    log.warning("Could not find VMware version")
            else:
                log.debug("VMware Workstation version {} detected".format(ws_version))
                if int(ws_version) < 10:
                    raise VMwareError("Using VMware Workstation requires version 10 or above")
            return
        else:
            if sys.platform.startswith("darwin"):
                if not os.path.isdir("/Applications/VMware Fusion.app"):
                    raise VMwareError("VMware Fusion is not installed in the standard location /Applications/VMware Fusion.app")
                return  # FIXME: no version checking on Mac OS X but we support all versions of fusion

            vmware_path = VMware._get_linux_vmware_binary()
            if vmware_path is None:
                raise VMwareError("VMware is not installed (vmware or vmplayer executable could not be found in $PATH)")

            try:
                output = yield from subprocess_check_output(vmware_path, "-v")
                match = re.search("VMware Workstation ([0-9]+)\.", output)
                version = None
                if match:
                    version = match.group(1)
                    log.debug("VMware Workstation version {} detected".format(version))
                    if int(version) < 10:
                        raise VMwareError("Using VMware Workstation requires version 10 or above")
                match = re.search("VMware Player ([0-9]+)\.", output)
                if match:
                    version = match.group(1)
                    log.debug("VMware Player version {} detected".format(version))
                    if int(version) < 6:
                        raise VMwareError("Using VMware Player requires version 6 or above")
                if version is None:
                    log.warning("Could not find VMware version. Output of VMware: {}".format(output))
                    raise VMwareError("Could not find VMware version. Output of VMware: {}".format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error("Error while looking for the VMware version: {}".format(e))
                raise VMwareError("Error while looking for the VMware version: {}".format(e))
Пример #9
0
    def check_vmware_version(self):
        """
        Check VMware version
        """

        if sys.platform.startswith("win"):
            # look for vmrun.exe using the directory listed in the registry
            ws_version = self._find_vmware_version_registry(r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation")
            if ws_version is None:
                player_version = self._find_vmware_version_registry(r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player")
                if player_version:
                    log.debug("VMware Player version {} detected".format(player_version))
                    yield from self._check_vmware_player_requirements(player_version)
                else:
                    log.warning("Could not find VMware version")
                    self._host_type = "ws"
            else:
                log.debug("VMware Workstation version {} detected".format(ws_version))
                yield from self._check_vmware_workstation_requirements(ws_version)
        else:
            if sys.platform.startswith("darwin"):
                if not os.path.isdir("/Applications/VMware Fusion.app"):
                    raise VMwareError("VMware Fusion is not installed in the standard location /Applications/VMware Fusion.app")
                self._host_type = "fusion"
                return  # FIXME: no version checking on Mac OS X but we support all versions of fusion

            vmware_path = VMware._get_linux_vmware_binary()
            if vmware_path is None:
                raise VMwareError("VMware is not installed (vmware or vmplayer executable could not be found in $PATH)")

            try:
                output = yield from subprocess_check_output(vmware_path, "-v")
                match = re.search("VMware Workstation ([0-9]+)\.", output)
                version = None
                if match:
                    # VMware Workstation has been detected
                    version = match.group(1)
                    log.debug("VMware Workstation version {} detected".format(version))
                    yield from self._check_vmware_workstation_requirements(version)
                match = re.search("VMware Player ([0-9]+)\.", output)
                if match:
                    # VMware Player has been detected
                    version = match.group(1)
                    log.debug("VMware Player version {} detected".format(version))
                    yield from self._check_vmware_player_requirements(version)
                if version is None:
                    log.warning("Could not find VMware version. Output of VMware: {}".format(output))
                    raise VMwareError("Could not find VMware version. Output of VMware: {}".format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error("Error while looking for the VMware version: {}".format(e))
                raise VMwareError("Error while looking for the VMware version: {}".format(e))
Пример #10
0
 def _check_vpcs_version(self):
     """
     Checks if the VPCS executable version is >= 0.5b1.
     """
     try:
         output = yield from subprocess_check_output(self.vpcs_path, "-v", cwd=self.working_dir)
         match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output)
         if match:
             version = match.group(1)
             if parse_version(version) < parse_version("0.5b1"):
                 raise VPCSError("VPCS executable version must be >= 0.5b1")
         else:
             raise VPCSError("Could not determine the VPCS version for {}".format(self.vpcs_path))
     except (OSError, subprocess.SubprocessError) as e:
         raise VPCSError("Error while looking for the VPCS version: {}".format(e))
Пример #11
0
 def _check_ubridge_version(self):
     """
     Checks if the ubridge executable version is >= 0.9.4
     """
     try:
         output = yield from subprocess_check_output(self._path, "-v", cwd=self._working_dir)
         match = re.search("ubridge version ([0-9a-z\.]+)", output)
         if match:
             version = match.group(1)
             if parse_version(version) < parse_version("0.9.4"):
                 raise UbridgeError("uBridge executable version must be >= 0.9.4")
         else:
             raise UbridgeError("Could not determine uBridge version for {}".format(self._path))
     except (OSError, subprocess.SubprocessError) as e:
         raise UbridgeError("Error while looking for uBridge version: {}".format(e))
Пример #12
0
 def _check_ubridge_version(self):
     """
     Checks if the ubridge executable version is >= 0.9.4
     """
     try:
         output = yield from subprocess_check_output(self._path,
                                                     "-v",
                                                     cwd=self._working_dir)
         match = re.search("ubridge version ([0-9a-z\.]+)", output)
         if match:
             version = match.group(1)
             if parse_version(version) < parse_version("0.9.4"):
                 raise UbridgeError(
                     "uBridge executable version must be >= 0.9.4")
         else:
             raise UbridgeError(
                 "Could not determine uBridge version for {}".format(
                     self._path))
     except (OSError, subprocess.SubprocessError) as e:
         raise UbridgeError(
             "Error while looking for uBridge version: {}".format(e))
Пример #13
0
 def _check_ubridge_version(self, env=None):
     """
     Checks if the ubridge executable version
     """
     try:
         output = yield from subprocess_check_output(self._path, "-v", cwd=self._working_dir, env=env)
         match = re.search("ubridge version ([0-9a-z\.]+)", output)
         if match:
             self._version = match.group(1)
             if sys.platform.startswith("win") or sys.platform.startswith("darwin"):
                 minimum_required_version = "0.9.12"
             else:
                 # uBridge version 0.9.14 is required for packet filters 
                 # to work for IOU nodes.
                 minimum_required_version = "0.9.14"
             if parse_version(self._version) < parse_version(minimum_required_version):
                 raise UbridgeError("uBridge executable version must be >= {}".format(minimum_required_version))
         else:
             raise UbridgeError("Could not determine uBridge version for {}".format(self._path))
     except (OSError, subprocess.SubprocessError) as e:
         raise UbridgeError("Error while looking for uBridge version: {}".format(e))
Пример #14
0
    def check_vmrun_version(self):

        with (yield from self._execute_lock):
            vmrun_path = self.vmrun_path
            if not vmrun_path:
                vmrun_path = self.find_vmrun()

            try:
                output = yield from subprocess_check_output(vmrun_path)
                match = re.search("vmrun version ([0-9\.]+)", output)
                version = None
                if match:
                    version = match.group(1)
                    log.debug("VMware vmrun version {} detected".format(version))
                    if parse_version(version) < parse_version("1.13"):
                        # VMware VIX library version must be at least >= 1.13
                        raise VMwareError("VMware vmrun executable version must be >= version 1.13")
                if version is None:
                    log.warning("Could not find VMware vmrun version. Output: {}".format(output))
                    raise VMwareError("Could not find VMware vmrun version. Output: {}".format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error("Error while looking for the VMware vmrun version: {}".format(e))
                raise VMwareError("Error while looking for the VMware vmrun version: {}".format(e))
Пример #15
0
    def check_vmware_version(self):
        """
        Check VMware version
        """

        if sys.platform.startswith("win"):
            # look for vmrun.exe using the directory listed in the registry
            ws_version = self._find_vmware_version_registry(
                r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation")
            if ws_version is None:
                player_version = self._find_vmware_version_registry(
                    r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player")
                if player_version:
                    log.debug("VMware Player version {} detected".format(
                        player_version))
                    if int(player_version) < 6:
                        raise VMwareError(
                            "Using VMware Player requires version 6 or above")
                else:
                    log.warning("Could not find VMware version")
            else:
                log.debug("VMware Workstation version {} detected".format(
                    ws_version))
                if int(ws_version) < 10:
                    raise VMwareError(
                        "Using VMware Workstation requires version 10 or above"
                    )
            return
        else:
            if sys.platform.startswith("darwin"):
                return  # FIXME: no version checking on Mac OS X

            vmware_path = VMware._get_linux_vmware_binary()
            if vmware_path is None:
                raise VMwareError(
                    "VMware is not installed (vmware or vmplayer executable could not be found in $PATH)"
                )

            try:
                output = yield from subprocess_check_output(vmware_path, "-v")
                match = re.search("VMware Workstation ([0-9]+)\.", output)
                version = None
                if match:
                    version = match.group(1)
                    log.debug("VMware Workstation version {} detected".format(
                        version))
                    if int(version) < 10:
                        raise VMwareError(
                            "Using VMware Workstation requires version 10 or above"
                        )
                match = re.search("VMware Player ([0-9]+)\.", output)
                if match:
                    version = match.group(1)
                    log.debug(
                        "VMware Player version {} detected".format(version))
                    if int(version) < 6:
                        raise VMwareError(
                            "Using VMware Player requires version 6 or above")
                if version is None:
                    log.warning(
                        "Could not find VMware version. Output of VMware: {}".
                        format(output))
                    raise VMwareError(
                        "Could not find VMware version. Output of VMware: {}".
                        format(output))
            except (OSError, subprocess.SubprocessError) as e:
                log.error(
                    "Error while looking for the VMware version: {}".format(e))
                raise VMwareError(
                    "Error while looking for the VMware version: {}".format(e))
Пример #16
0
def test_subprocess_check_output(loop, tmpdir, restore_original_path):

    path = str(tmpdir / "test")
    exec = subprocess_check_output("echo", "-n", path)
    result = loop.run_until_complete(asyncio.ensure_future(exec))
    assert result == path