示例#1
0
 def test_stop_twice(self):
     with ServiceControlManagerContext() as scm:
         infi_service = scm.open_service("VSS")
         with infi_service:
             infi_service.safe_stop()
             time.sleep(6)
     with ServiceControlManagerContext() as scm:
         infi_service = scm.open_service("VSS")
         with infi_service:
             infi_service.safe_stop()
             time.sleep(6)
示例#2
0
    def _delete(self):
        with ServiceControlManagerContext() as scm:
            infi_service = scm.open_service(INFI_SERVICE_NAME)
            infi_service.delete()
            infi_service.close()

        # sleep to let the service db refresh or something; otherwise the open succeeds, somehow, sometimes
        time.sleep(3)

        with ServiceControlManagerContext() as scm:
            with self.assertRaisesRegexp(
                    WindowsError,
                    "The specified service does not exist as an installed service."
            ):
                infi_service = scm.open_service(INFI_SERVICE_NAME)
示例#3
0
 def uninstall(self):
     '''Stop the iscsi service on windows
     '''
     with ServiceControlManagerContext() as scm:
         with scm.open_service('MSiSCSI') as service:
             logger.debug("stopping MSiSCSI")
             service.safe_stop()
             service.wait_on_pending()
             service.disable()
示例#4
0
 def _start_stop(self):
     with ServiceControlManagerContext() as scm:
         infi_service = scm.open_service(INFI_SERVICE_NAME)
         infi_service.start()
         time.sleep(3)
         self.assertTrue(infi_service.is_running())
         infi_service.stop()
         time.sleep(6)
         self.assertFalse(infi_service.is_running())
         infi_service.close()
示例#5
0
 def _register(self):
     with ServiceControlManagerContext() as scm:
         python_exe = os.path.abspath(
             os.path.join(os.path.dirname(__file__), os.path.pardir, "bin",
                          "python.exe"))
         scm.create_service(
             INFI_SERVICE_NAME, u"Infinidat Test Service",
             ServiceType.WIN32_OWN_PROCESS, ServiceStartType.AUTO,
             "\"{}\" {}".format(python_exe,
                                __file__.replace('.pyc', '.py'))).close()
示例#6
0
 def install(self):
     '''start the iSCSI service on windows.
        in the future will also autostart the service
     '''
     logger.debug("trying to start service MSiSCSI")
     with ServiceControlManagerContext() as scm:
         with scm.open_service('MSiSCSI') as service:
             logger.debug("starting service MSiSCSI")
             service.start_automatically()
             service.safe_start()
             service.wait_on_pending()
示例#7
0
 def _stop(self):
     with ServiceControlManagerContext() as scm:
         infi_service = scm.open_service(INFI_SERVICE_NAME)
         with infi_service:
             infi_service.safe_stop()
             time.sleep(6)
示例#8
0
 def is_installed(self):
     '''in windows return True if iSCSI initiator sw is running otherwise return False
     '''
     with ServiceControlManagerContext() as scm:
         with scm.open_service('MSiSCSI') as service:
             return service.is_running() and service.is_autostart()