Search in sources :

Example 6 with BcfAnswer

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

the class BigSwitchBcfResourceTest method testCreateAttachmentRetryOnce.

@Test
public void testCreateAttachmentRetryOnce() 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");
    when(_bigswitchBcfApi.createAttachment((String) any(), (String) any(), (AttachmentData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
    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);
    assertTrue(ans.getResult());
}
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 7 with BcfAnswer

use of com.cloud.agent.api.BcfAnswer 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 BcfAnswer

use of com.cloud.agent.api.BcfAnswer 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 BcfAnswer

use of com.cloud.agent.api.BcfAnswer 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 BcfAnswer

use of com.cloud.agent.api.BcfAnswer 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

BcfAnswer (com.cloud.agent.api.BcfAnswer)33 BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)29 Test (org.junit.Test)21 UpdateBcfRouterCommand (com.cloud.agent.api.UpdateBcfRouterCommand)5 AttachmentData (com.cloud.network.bigswitch.AttachmentData)5 RouterData (com.cloud.network.bigswitch.RouterData)5 SyncBcfTopologyCommand (com.cloud.agent.api.SyncBcfTopologyCommand)3 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 AclData (com.cloud.network.bigswitch.AclData)2 FloatingIpData (com.cloud.network.bigswitch.FloatingIpData)2 TopologyData (com.cloud.network.bigswitch.TopologyData)2 CacheBcfTopologyCommand (com.cloud.agent.api.CacheBcfTopologyCommand)1