use of com.cloud.network.bigswitch.BigSwitchBcfApiException 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.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(CreateBcfStaticNatCommand cmd, int numRetries) {
FloatingIpData fip = new FloatingIpData();
fip.setTenantId(cmd.getTenantId());
fip.setNetworkId(cmd.getNetworkId());
fip.setFixedIp(cmd.getPrivateIp());
fip.setFloatingIpAndId(cmd.getPublicIp());
fip.setMac(cmd.getMac());
try {
String hash = _bigswitchBcfApi.createFloatingIp(cmd.getTenantId(), fip);
return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" + cmd.getPrivateIp() + " created", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" + cmd.getPrivateIp() + " created; topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
}
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(UpdateBcfAttachmentCommand cmd, int numRetries) {
AttachmentData attachment = new AttachmentData();
attachment.getAttachment().setId(cmd.getAttachmentId());
attachment.getAttachment().setTenantName(cmd.getTenantId());
try {
String hash = _bigswitchBcfApi.modifyAttachment(cmd.getTenantId(), cmd.getNetworkId(), attachment);
return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated; topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
}
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(CreateBcfSegmentCommand cmd, int numRetries) {
NetworkData network = new NetworkData();
network.getNetwork().setTenantId(cmd.getTenantId());
network.getNetwork().setTenantName(cmd.getTenantName());
network.getNetwork().setId(cmd.getNetworkId());
network.getNetwork().setName(truncate("segment-cloudstack-" + cmd.getNetworkName(), 64));
network.getNetwork().setVlan(cmd.getVlan());
try {
String hash = _bigswitchBcfApi.createNetwork(network);
return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created; topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
}
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResource method executeRequest.
private Answer executeRequest(CreateBcfAttachmentCommand cmd, int numRetries) {
AttachmentData attachment = new AttachmentData();
attachment.getAttachment().setId(cmd.getNicId());
attachment.getAttachment().setHostId(cmd.getPortId());
attachment.getAttachment().setTenantName(cmd.getTenantName());
attachment.getAttachment().setVlan(cmd.getVlan());
attachment.getAttachment().addIpv4(cmd.getIpv4());
attachment.getAttachment().setMac(cmd.getMac());
try {
String hash = _bigswitchBcfApi.createAttachment(cmd.getTenantId(), cmd.getNetworkId(), attachment);
return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created", hash);
} catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) {
cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created; topology sync required.");
} else {
if (numRetries > 0) {
return retry(cmd, --numRetries);
} else {
return new BcfAnswer(cmd, e);
}
}
}
}
Aggregations