use of com.cloud.network.bigswitch.RouterData in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(UpdateBcfRouterCommand cmd, int numRetries) {
RouterData routerData = new RouterData(cmd.getTenantId());
List<AclData> acls = new ArrayList<AclData>();
acls.addAll(cmd.getAcls());
routerData.getRouter().getAcls().addAll(acls);
routerData.getRouter().addExternalGateway(cmd.getPublicIp());
try {
String hash = _bigswitchBcfApi.modifyRouter(cmd.getTenantId(), routerData);
return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated but topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
} catch (IllegalArgumentException e1) {
return new BcfAnswer(cmd, false, "Illegal argument in BCF router update");
}
}
use of com.cloud.network.bigswitch.RouterData 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());
}
use of com.cloud.network.bigswitch.RouterData in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testDeleteSourceNatRetryOnce.
@Test
public void testDeleteSourceNatRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
when(_bigswitchBcfApi.modifyRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
assertTrue(ans.getResult());
}
use of com.cloud.network.bigswitch.RouterData in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testCreateSourceNatRetryOnce.
@Test
public void testCreateSourceNatRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
when(_bigswitchBcfApi.modifyRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
assertTrue(ans.getResult());
}
use of com.cloud.network.bigswitch.RouterData in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(CreateBcfRouterCommand cmd, int numRetries) {
RouterData router = new RouterData(cmd.getTenantId());
try {
String hash;
hash = _bigswitchBcfApi.createRouter(cmd.getTenantId(), router);
return new BcfAnswer(cmd, true, "router " + cmd.getTenantId() + " created.", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, " created; topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
}
}
Aggregations