Search in sources :

Example 6 with BigSwitchBcfApiException

use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testPingCommandStatusApiException.

@Test
public void testPingCommandStatusApiException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    ControlClusterStatus ccs = mock(ControlClusterStatus.class);
    when(ccs.getStatus()).thenReturn(false);
    when(_bigswitchBcfApi.getControlClusterStatus()).thenThrow(new BigSwitchBcfApiException());
    PingCommand ping = _resource.getCurrentStatus(42);
    assertTrue(ping == null);
}
Also used : ControlClusterStatus(com.cloud.network.bigswitch.ControlClusterStatus) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 7 with BigSwitchBcfApiException

use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testCreateAttachmentApiException.

@Test
public void testCreateAttachmentApiException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    AttachmentData attachmentData = mock(AttachmentData.class);
    AttachmentData.Attachment attachment = mock(AttachmentData.Attachment.class);
    when(attachmentData.getAttachment()).thenReturn(attachment);
    when(attachment.getId()).thenReturn("eeee");
    doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).createAttachment((String) any(), (String) any(), (AttachmentData) any());
    CreateBcfAttachmentCommand cmd = new CreateBcfAttachmentCommand("tenantid", "tenantname", "networkid", "portid", "nicId", 100, "1.2.3.4", "aa:bb:cc:dd:ee:ff");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertFalse(ans.getResult());
    verify(_bigswitchBcfApi, times(3)).createAttachment((String) any(), (String) any(), (AttachmentData) any());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) CreateBcfAttachmentCommand(com.cloud.agent.api.CreateBcfAttachmentCommand) AttachmentData(com.cloud.network.bigswitch.AttachmentData) Test(org.junit.Test)

Example 8 with BigSwitchBcfApiException

use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testCreateRouterRetryOnce.

@Test
public void testCreateRouterRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    when(_bigswitchBcfApi.createRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
    CreateBcfRouterCommand cmd = new CreateBcfRouterCommand("tenantid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertTrue(ans.getResult());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) CreateBcfRouterCommand(com.cloud.agent.api.CreateBcfRouterCommand) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) RouterData(com.cloud.network.bigswitch.RouterData) Test(org.junit.Test)

Example 9 with BigSwitchBcfApiException

use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testUpdateAttachmentException.

@Test
public void testUpdateAttachmentException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).modifyAttachment((String) any(), (String) any(), (AttachmentData) any());
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(new UpdateBcfAttachmentCommand("networkId", "portId", "tenantId", "portname"));
    assertFalse(ans.getResult());
    verify(_bigswitchBcfApi, times(3)).modifyAttachment((String) any(), (String) any(), (AttachmentData) any());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) UpdateBcfAttachmentCommand(com.cloud.agent.api.UpdateBcfAttachmentCommand) Test(org.junit.Test)

Example 10 with BigSwitchBcfApiException

use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testDeleteNetworkRetryOnce.

@Test
public void testDeleteNetworkRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    when(_bigswitchBcfApi.deleteNetwork((String) any(), (String) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
    DeleteBcfSegmentCommand cmd = new DeleteBcfSegmentCommand("tenantid", "networkid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertTrue(ans.getResult());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) DeleteBcfSegmentCommand(com.cloud.agent.api.DeleteBcfSegmentCommand) Test(org.junit.Test)

Aggregations

BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)30 BcfAnswer (com.cloud.agent.api.BcfAnswer)29 Test (org.junit.Test)22 AttachmentData (com.cloud.network.bigswitch.AttachmentData)5 RouterData (com.cloud.network.bigswitch.RouterData)5 UpdateBcfRouterCommand (com.cloud.agent.api.UpdateBcfRouterCommand)4 NetworkData (com.cloud.network.bigswitch.NetworkData)3 CreateBcfAttachmentCommand (com.cloud.agent.api.CreateBcfAttachmentCommand)2 CreateBcfRouterCommand (com.cloud.agent.api.CreateBcfRouterCommand)2 CreateBcfSegmentCommand (com.cloud.agent.api.CreateBcfSegmentCommand)2 CreateBcfStaticNatCommand (com.cloud.agent.api.CreateBcfStaticNatCommand)2 DeleteBcfAttachmentCommand (com.cloud.agent.api.DeleteBcfAttachmentCommand)2 DeleteBcfSegmentCommand (com.cloud.agent.api.DeleteBcfSegmentCommand)2 DeleteBcfStaticNatCommand (com.cloud.agent.api.DeleteBcfStaticNatCommand)2 UpdateBcfAttachmentCommand (com.cloud.agent.api.UpdateBcfAttachmentCommand)2 FloatingIpData (com.cloud.network.bigswitch.FloatingIpData)2 TopologyData (com.cloud.network.bigswitch.TopologyData)2 PingCommand (com.cloud.agent.api.PingCommand)1 SyncBcfTopologyCommand (com.cloud.agent.api.SyncBcfTopologyCommand)1 AclData (com.cloud.network.bigswitch.AclData)1