Example #1
0
 def test_found_when_guestinfo_present(self, m_subp, m_which):
     """When there is a ovf info, transport should return it."""
     m_which.return_value = self.rpctool_path
     content = fill_properties({})
     m_subp.return_value = (content, "")
     self.assertEqual(content, dsovf.transport_vmware_guestinfo())
     self.assertEqual(1, m_subp.call_count)
Example #2
0
 def test_found_when_guestinfo_present(self, m_subp, m_which):
     """When there is a ovf info, transport should return it."""
     m_which.return_value = self.rpctool_path
     content = fill_properties({})
     m_subp.return_value = (content, '')
     self.assertEqual(content, dsovf.transport_vmware_guestinfo())
     self.assertEqual(1, m_subp.call_count)
Example #3
0
 def test_without_vmware_rpctool_returns_notfound(self, m_subp, m_which):
     m_which.return_value = None
     self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
     self.assertEqual(
         0,
         m_subp.call_count,
         "subp should not be called if no rpctool in path.",
     )
Example #4
0
 def test_notfound_and_warns_on_unexpected_exit_code(self, m_subp, m_which):
     """If vmware-rpctool exits non zero or 1, warnings should be logged."""
     m_which.return_value = self.rpctool_path
     m_subp.side_effect = subp.ProcessExecutionError(
         stdout=None, stderr="No value found", exit_code=2, cmd=["unused"])
     self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
     self.assertEqual(1, m_subp.call_count)
     self.assertIn("WARNING", self.logs.getvalue(),
                   "exit code of 2 by rpctool should log WARNING.")
Example #5
0
 def test_notfound_and_warns_on_unexpected_exit_code(self, m_subp, m_which):
     """If vmware-rpctool exits non zero or 1, warnings should be logged."""
     m_which.return_value = self.rpctool_path
     m_subp.side_effect = util.ProcessExecutionError(
         stdout=None, stderr="No value found", exit_code=2, cmd=["unused"])
     self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
     self.assertEqual(1, m_subp.call_count)
     self.assertIn("WARNING", self.logs.getvalue(),
                   "exit code of 2 by rpctool should log WARNING.")
Example #6
0
 def test_notfound_on_exit_code_1(self, m_subp, m_which):
     """If vmware-rpctool exits 1, then must return not found."""
     m_which.return_value = self.rpctool_path
     m_subp.side_effect = util.ProcessExecutionError(
         stdout="", stderr="No value found", exit_code=1, cmd=["unused"])
     self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
     self.assertEqual(1, m_subp.call_count)
     self.assertNotIn("WARNING", self.logs.getvalue(),
                      "exit code of 1 by rpctool should not cause warning.")
Example #7
0
    def test_notfound_if_no_content_but_exit_zero(self, m_subp, m_which):
        """If vmware-rpctool exited 0 with no stdout is normal not-found.

        This isn't actually a case I've seen. normally on "not found",
        rpctool would exit 1 with 'No value found' on stderr.  But cover
        the case where it exited 0 and just wrote nothing to stdout.
        """
        m_which.return_value = self.rpctool_path
        m_subp.return_value = ("", "")
        self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
        self.assertEqual(1, m_subp.call_count)
Example #8
0
    def test_notfound_if_no_content_but_exit_zero(self, m_subp, m_which):
        """If vmware-rpctool exited 0 with no stdout is normal not-found.

        This isn't actually a case I've seen. normally on "not found",
        rpctool would exit 1 with 'No value found' on stderr.  But cover
        the case where it exited 0 and just wrote nothing to stdout.
        """
        m_which.return_value = self.rpctool_path
        m_subp.return_value = ('', '')
        self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
        self.assertEqual(1, m_subp.call_count)
Example #9
0
 def test_without_vmware_rpctool_returns_notfound(self, m_subp, m_which):
     m_which.return_value = None
     self.assertEqual(NOT_FOUND, dsovf.transport_vmware_guestinfo())
     self.assertEqual(0, m_subp.call_count,
                      "subp should not be called if no rpctool in path.")