Search in sources :

Example 6 with UnPlugNicAnswer

use of com.cloud.agent.api.UnPlugNicAnswer in project cloudstack by apache.

the class ManagementServerMock method deleteVM.

public void deleteVM(UserVm vm, Network network) {
    Answer<?> callback = new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            Commands cmds = (Commands) args[1];
            if (cmds == null) {
                return null;
            }
            UnPlugNicAnswer reply = new UnPlugNicAnswer(null, true, "PlugNic");
            com.cloud.agent.api.Answer[] answers = { reply };
            cmds.setAnswers(answers);
            return null;
        }
    };
    try {
        Mockito.when(_agentMgr.send(Matchers.anyLong(), Matchers.any(Commands.class))).thenAnswer(callback);
    } catch (AgentUnavailableException e) {
        e.printStackTrace();
    } catch (OperationTimedoutException e) {
        e.printStackTrace();
    }
    _userVmDao.remove(vm.getId());
}
Also used : UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) Answer(org.mockito.stubbing.Answer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) Commands(com.cloud.agent.manager.Commands)

Aggregations

UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)6 NicTO (com.cloud.agent.api.to.NicTO)3 Commands (com.cloud.agent.manager.Commands)2 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)2 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 RemoteException (java.rmi.RemoteException)2 ConfigurationException (javax.naming.ConfigurationException)2 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)1 UnPlugNicCommand (com.cloud.agent.api.UnPlugNicCommand)1 DataCenter (com.cloud.dc.DataCenter)1 CloudException (com.cloud.exception.CloudException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 InterfaceDef (com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef)1 VifDriver (com.cloud.hypervisor.kvm.resource.VifDriver)1 ClusterMO (com.cloud.hypervisor.vmware.mo.ClusterMO)1 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)1 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)1