test_class.declarator: hostDao
test_class.modifier: @Mock
test_class.original_string: @Mock
      HostDao hostDao;
test_class.type: HostDao
test_class.var_name: hostDao
test_class.declarator: agentManager
test_class.modifier: @Mock
test_class.original_string: @Mock
      AgentManager agentManager;
test_class.type: AgentManager
test_class.var_name: agentManager
test_class.declarator: alertMgr
test_class.modifier: @Mock
test_class.original_string: @Mock
      AlertManager alertMgr;
test_class.type: AlertManager
test_class.var_name: alertMgr
test_class.declarator: resourceManager
test_class.modifier: @Mock
test_class.original_string: @Mock
      ResourceManager resourceManager;
test_class.type: ResourceManager
test_class.var_name: resourceManager
test_class.declarator: fencer
test_class.original_string: KVMFencer fencer;
test_class.type: KVMFencer
test_class.var_name: fencer
test_class.file: server/src/test/java/com/cloud/ha/KVMFencerTest.java
test_class.identifier: KVMFencerTest
test_case.body: @Test
      public void testWithSingleNotKVM() {
          HostVO host = Mockito.mock(HostVO.class);
          Mockito.when(host.getClusterId()).thenReturn(1l);
          Mockito.when(host.getHypervisorType()).thenReturn(HypervisorType.Any);
          Mockito.when(host.getStatus()).thenReturn(Status.Down);
          Mockito.when(host.getId()).thenReturn(1l);
          Mockito.when(host.getDataCenterId()).thenReturn(1l);
          Mockito.when(host.getPodId()).thenReturn(1l);
          VirtualMachine virtualMachine = Mockito.mock(VirtualMachine.class);
  
          Mockito.when(resourceManager.listAllHostsInCluster(1l)).thenReturn(Collections.singletonList(host));
          Assert.assertNull(fencer.fenceOff(virtualMachine, host));
      }
test_case.class_method_signature: KVMFencerTest.testWithSingleNotKVM()
test_case.full_signature: @Test public void testWithSingleNotKVM()
test_case.identifier: testWithSingleNotKVM
test_case.invocations: mock thenReturn when getClusterId thenReturn when getHypervisorType thenReturn when getStatus thenReturn when getId thenReturn when getDataCenterId thenReturn when getPodId mock thenReturn when listAllHostsInCluster singletonList assertNull fenceOff
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWithSingleNotKVM()
focal_class.declarator: s_logger = LoggerFactory.getLogger(KVMFencer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(KVMFencer.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: _hostDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      HostDao _hostDao;
focal_class.type: HostDao
focal_class.var_name: _hostDao
focal_class.declarator: _agentMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      AgentManager _agentMgr;
focal_class.type: AgentManager
focal_class.var_name: _agentMgr
focal_class.declarator: _alertMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      AlertManager _alertMgr;
focal_class.type: AlertManager
focal_class.var_name: _alertMgr
focal_class.declarator: _resourceMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      ResourceManager _resourceMgr;
focal_class.type: ResourceManager
focal_class.var_name: _resourceMgr
focal_class.file: server/src/main/java/com/cloud/ha/KVMFencer.java
focal_class.identifier: KVMFencer
focal_class.interfaces: implements FenceBuilder
focal_class.class_method_signature: KVMFencer.configure(String name, Map<String, Object> params)
focal_class.full_signature: @Override public boolean configure(String name, Map<String, Object> params)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (String name, Map<String, Object> params)
focal_class.return: boolean
focal_class.signature: boolean configure(String name, Map<String, Object> params)
focal_class.class_method_signature: KVMFencer.start()
focal_class.full_signature: @Override public boolean start()
focal_class.identifier: start
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean start()
focal_class.class_method_signature: KVMFencer.stop()
focal_class.full_signature: @Override public boolean stop()
focal_class.identifier: stop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean stop()
focal_class.class_method_signature: KVMFencer.KVMFencer()
focal_class.full_signature: public  KVMFencer()
focal_class.identifier: KVMFencer
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  KVMFencer()
focal_class.class_method_signature: KVMFencer.fenceOff(VirtualMachine vm, Host host)
focal_class.full_signature: @Override public Boolean fenceOff(VirtualMachine vm, Host host)
focal_class.identifier: fenceOff
focal_class.modifiers: @Override public
focal_class.parameters: (VirtualMachine vm, Host host)
focal_class.return: Boolean
focal_class.signature: Boolean fenceOff(VirtualMachine vm, Host host)
focal_class.superclass: extends AdapterBase
focal_method.body: @Override
      public Boolean fenceOff(VirtualMachine vm, Host host) {
          if (host.getHypervisorType() != HypervisorType.KVM) {
              s_logger.warn("Don't know how to fence non kvm hosts " + host.getHypervisorType());
              return null;
          }
  
          List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
          FenceCommand fence = new FenceCommand(vm, host);
  
          int i = 0;
          for (HostVO h : hosts) {
              if (h.getHypervisorType() == HypervisorType.KVM) {
                  if (h.getStatus() != Status.Up) {
                      continue;
                  }
  
                  i++;
  
                  if (h.getId() == host.getId()) {
                      continue;
                  }
                  FenceAnswer answer;
                  try {
                      answer = (FenceAnswer)_agentMgr.send(h.getId(), fence);
                  } catch (AgentUnavailableException e) {
                      s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                      continue;
                  } catch (OperationTimedoutException e) {
                      s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                      continue;
                  }
                  if (answer != null && answer.getResult()) {
                      return true;
                  }
              }
          }
  
          _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(),
                              "Unable to fence off host: " + host.getId(),
                              "Fencing off host " + host.getId() + " did not succeed after asking " + i + " hosts. " +
                              "Check Agent logs for more information.");
  
          s_logger.error("Unable to fence off " + vm.toString() + " on " + host.toString());
  
          return false;
      }
focal_method.class_method_signature: KVMFencer.fenceOff(VirtualMachine vm, Host host)
focal_method.full_signature: @Override public Boolean fenceOff(VirtualMachine vm, Host host)
focal_method.identifier: fenceOff
focal_method.invocations: getHypervisorType warn getHypervisorType listAllHostsInCluster getClusterId getHypervisorType getStatus getId getId send getId info toString info toString getResult sendAlert getDataCenterId getPodId getId getId error toString toString
focal_method.modifiers: @Override public
focal_method.parameters: (VirtualMachine vm, Host host)
focal_method.return: Boolean
focal_method.signature: Boolean fenceOff(VirtualMachine vm, Host host)