findbugs and PMD fixes

This closes #168

Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>
This commit is contained in:
KC Wang 2014-09-26 14:09:30 -07:00 committed by Rajani Karuturi
parent 9836ccdcf3
commit 581f3b79a3
31 changed files with 313 additions and 310 deletions

View File

@ -22,17 +22,17 @@ package com.cloud.agent.api;
public class BcfAnswer extends Answer{ public class BcfAnswer extends Answer{
private final String hash; private final String hash;
public BcfAnswer(Command command, boolean success, String details) { public BcfAnswer(final Command command, final boolean success, final String details) {
super(command, success, details); super(command, success, details);
this.hash = ""; this.hash = "";
} }
public BcfAnswer(Command command, boolean success, String details, String hash) { public BcfAnswer(final Command command, final boolean success, final String details, final String hash) {
super(command, success, details); super(command, success, details);
this.hash = hash; this.hash = hash;
} }
public BcfAnswer(Command command, Exception e) { public BcfAnswer(final Command command, final Exception e) {
super(command, e); super(command, e);
this.hash = ""; this.hash = "";
} }

View File

@ -22,8 +22,8 @@ package com.cloud.agent.api;
import com.cloud.network.bigswitch.TopologyData; import com.cloud.network.bigswitch.TopologyData;
public class BcfCommand extends Command { public class BcfCommand extends Command {
private TopologyData topology = null; private TopologyData topology;
private boolean _topologySyncRequested = false; private boolean topologySyncRequested;
@Override @Override
public boolean executeInSequence() { public boolean executeInSequence() {
@ -34,15 +34,15 @@ public class BcfCommand extends Command {
return topology; return topology;
} }
public void setTopology(TopologyData topology) { public void setTopology(final TopologyData topology) {
this.topology = topology; this.topology = topology;
} }
public boolean is_topologySyncRequested() { public boolean isTopologySyncRequested() {
return _topologySyncRequested; return topologySyncRequested;
} }
public void set_topologySyncRequested(boolean requested) { public void setTopologySyncRequested(final boolean requested) {
this._topologySyncRequested = requested; this.topologySyncRequested = requested;
} }
} }

View File

@ -22,10 +22,10 @@ package com.cloud.agent.api;
import com.cloud.network.bigswitch.TopologyData; import com.cloud.network.bigswitch.TopologyData;
public class CacheBcfTopologyCommand extends Command{ public class CacheBcfTopologyCommand extends Command{
private final TopologyData topology; private final TopologyData _topology;
public CacheBcfTopologyCommand(TopologyData topology){ public CacheBcfTopologyCommand(final TopologyData topology){
this.topology = topology; this._topology = topology;
} }
@Override @Override
@ -34,6 +34,6 @@ public class CacheBcfTopologyCommand extends Command{
} }
public TopologyData getTopology() { public TopologyData getTopology() {
return topology; return _topology;
} }
} }

View File

@ -20,18 +20,18 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class CreateBcfAttachmentCommand extends BcfCommand { public class CreateBcfAttachmentCommand extends BcfCommand {
private String _tenantId; private final String _tenantId;
private String _tenantName; private final String _tenantName;
private String _networkId; private final String _networkId;
private String _portId; private final String _portId;
private String _nicId; private final String _nicId;
private Integer _vlan; private final Integer _vlan;
private String _ipv4; private final String _ipv4;
private String _mac; private final String _mac;
public CreateBcfAttachmentCommand(String tenantId, String tenantName, public CreateBcfAttachmentCommand(final String tenantId, final String tenantName,
String networkId, String portId, String nicId, final String networkId, final String portId, final String nicId,
Integer vlan, String ipv4, String mac) { final Integer vlan, final String ipv4, final String mac) {
this._tenantId = tenantId; this._tenantId = tenantId;
this._tenantName = tenantName; this._tenantName = tenantName;
this._networkId = networkId; this._networkId = networkId;

View File

@ -22,11 +22,11 @@ package com.cloud.agent.api;
public class CreateBcfRouterCommand extends BcfCommand { public class CreateBcfRouterCommand extends BcfCommand {
private final String _tenantId; private final String _tenantId;
public CreateBcfRouterCommand(String tenantId){ public CreateBcfRouterCommand(final String tenantId){
this._tenantId = tenantId; this._tenantId = tenantId;
} }
public String get_tenantId() { public String getTenantId() {
return _tenantId; return _tenantId;
} }
} }

View File

@ -26,8 +26,8 @@ public class CreateBcfRouterInterfaceCommand extends BcfCommand{
private final String _gateway; private final String _gateway;
private final String _networkName; private final String _networkName;
public CreateBcfRouterInterfaceCommand(String tenantId, String networkId, String cidr, public CreateBcfRouterInterfaceCommand(final String tenantId, final String networkId,
String gateway, String networkName){ final String cidr, final String gateway, final String networkName){
this._tenantId = tenantId; this._tenantId = tenantId;
this._networkId = networkId; this._networkId = networkId;
this._networkName = networkName; this._networkName = networkName;
@ -35,23 +35,23 @@ public class CreateBcfRouterInterfaceCommand extends BcfCommand{
this._gateway = gateway; this._gateway = gateway;
} }
public String get_tenantId() { public String getTenantId() {
return _tenantId; return _tenantId;
} }
public String get_networkId() { public String getNetworkId() {
return _networkId; return _networkId;
} }
public String get_networkName() { public String getNetworkName() {
return _networkName; return _networkName;
} }
public String get_cidr() { public String getCidr() {
return _cidr; return _cidr;
} }
public String get_gateway() { public String getGateway() {
return _gateway; return _gateway;
} }
} }

View File

@ -20,14 +20,14 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class CreateBcfSegmentCommand extends BcfCommand { public class CreateBcfSegmentCommand extends BcfCommand {
private String _tenantId; private final String _tenantId;
private String _tenantName; private final String _tenantName;
private String _networkId; private final String _networkId;
private String _networkName; private final String _networkName;
private Integer _vlan; private final Integer _vlan;
public CreateBcfSegmentCommand(String tenantId, String tenantName, public CreateBcfSegmentCommand(final String tenantId, final String tenantName,
String networkId, String networkName, Integer vlan) { final String networkId, final String networkName, final Integer vlan) {
this._tenantId = tenantId; this._tenantId = tenantId;
this._tenantName = tenantName; this._tenantName = tenantName;
this._networkId = networkId; this._networkId = networkId;

View File

@ -26,8 +26,8 @@ public class CreateBcfStaticNatCommand extends BcfCommand {
private final String _publicIp; private final String _publicIp;
private final String _mac; private final String _mac;
public CreateBcfStaticNatCommand(String tenantId, String networkId, public CreateBcfStaticNatCommand(final String tenantId, final String networkId,
String privateIp, String publicIp, String mac){ final String privateIp, final String publicIp, final String mac){
this._tenantId = tenantId; this._tenantId = tenantId;
this._networkId = networkId; this._networkId = networkId;
this._privateIp = privateIp; this._privateIp = privateIp;
@ -35,23 +35,23 @@ public class CreateBcfStaticNatCommand extends BcfCommand {
this._mac = mac; this._mac = mac;
} }
public String get_tenantId() { public String getTenantId() {
return _tenantId; return _tenantId;
} }
public String get_networkId() { public String getNetworkId() {
return _networkId; return _networkId;
} }
public String get_privateIp() { public String getPrivateIp() {
return _privateIp; return _privateIp;
} }
public String get_publicIp() { public String getPublicIp() {
return _publicIp; return _publicIp;
} }
public String get_mac() { public String getMac() {
return _mac; return _mac;
} }
} }

View File

@ -20,12 +20,12 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class DeleteBcfAttachmentCommand extends BcfCommand { public class DeleteBcfAttachmentCommand extends BcfCommand {
private String _tenantId; private final String _tenantId;
private String _networkId; private final String _networkId;
private String _attachmentId; private final String _attachmentId;
public DeleteBcfAttachmentCommand(String tenantId, public DeleteBcfAttachmentCommand(final String tenantId,
String networkId, String attachmentId) { final String networkId, final String attachmentId) {
this._tenantId = tenantId; this._tenantId = tenantId;
this._networkId = networkId; this._networkId = networkId;
this._attachmentId = attachmentId; this._attachmentId = attachmentId;

View File

@ -21,15 +21,15 @@ package com.cloud.agent.api;
public class DeleteBcfSegmentCommand extends BcfCommand { public class DeleteBcfSegmentCommand extends BcfCommand {
private String _tenantUuid; private final String _tenantUuid;
private String _networkUuid; private final String _networkUuid;
public DeleteBcfSegmentCommand(String tenantUuid, String networkUuid) { public DeleteBcfSegmentCommand(final String tenantUuid, final String networkUuid) {
this._tenantUuid = tenantUuid; this._tenantUuid = tenantUuid;
this._networkUuid = networkUuid; this._networkUuid = networkUuid;
} }
public String get_tenantUuid() { public String getTenantUuid() {
return _tenantUuid; return _tenantUuid;
} }

View File

@ -24,21 +24,21 @@ public class DeleteBcfStaticNatCommand extends BcfCommand {
private final String _publicIp; private final String _publicIp;
private final String _floatingIpId; private final String _floatingIpId;
public DeleteBcfStaticNatCommand(String tenantId, String publicIp){ public DeleteBcfStaticNatCommand(final String tenantId, final String publicIp){
this._tenantId = tenantId; this._tenantId = tenantId;
this._publicIp = publicIp; this._publicIp = publicIp;
this._floatingIpId = publicIp.replace(".", "-"); this._floatingIpId = publicIp.replace(".", "-");
} }
public String get_tenantId() { public String getTenantId() {
return _tenantId; return _tenantId;
} }
public String get_publicIp() { public String getPublicIp() {
return _publicIp; return _publicIp;
} }
public String get_floatingIpId() { public String getFloatingIpId() {
return _floatingIpId; return _floatingIpId;
} }
} }

View File

@ -20,26 +20,27 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class GetControllerDataAnswer extends Answer { public class GetControllerDataAnswer extends Answer {
private final String ipAddress; private final String _ipAddress;
private final boolean isMaster; private final boolean _isMaster;
public GetControllerDataAnswer(GetControllerDataCommand cmd, public GetControllerDataAnswer(final GetControllerDataCommand cmd,
String ipAddress, boolean isMaster){ final String ipAddress, final boolean isMaster){
this.ipAddress = ipAddress; super(cmd);
this.isMaster = isMaster; this._ipAddress = ipAddress;
this._isMaster = isMaster;
} }
public GetControllerDataAnswer(Command command, Exception e) { public GetControllerDataAnswer(final Command command, final Exception e) {
super(command, e); super(command, e);
this.ipAddress = null; this._ipAddress = null;
this.isMaster = false; this._isMaster = false;
} }
public String getIpAddress() { public String getIpAddress() {
return ipAddress; return _ipAddress;
} }
public boolean isMaster() { public boolean isMaster() {
return isMaster; return _isMaster;
} }
} }

View File

@ -20,6 +20,4 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class GetControllerDataCommand extends BcfCommand { public class GetControllerDataCommand extends BcfCommand {
public GetControllerDataCommand() {
}
} }

View File

@ -28,13 +28,13 @@ public class GetControllerHostsAnswer {
public HostVO getMaster() { public HostVO getMaster() {
return master; return master;
} }
public void setMaster(HostVO master) { public void setMaster(final HostVO master) {
this.master = master; this.master = master;
} }
public HostVO getSlave() { public HostVO getSlave() {
return slave; return slave;
} }
public void setSlave(HostVO slave) { public void setSlave(final HostVO slave) {
this.slave = slave; this.slave = slave;
} }
} }

View File

@ -20,6 +20,4 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class GetControllerHostsCommand extends BcfCommand { public class GetControllerHostsCommand extends BcfCommand {
public GetControllerHostsCommand() {
}
} }

View File

@ -20,19 +20,19 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class SyncBcfTopologyCommand extends BcfCommand { public class SyncBcfTopologyCommand extends BcfCommand {
private final boolean networkIncluded; private final boolean _networkIncluded;
private final boolean routerIncluded; private final boolean _routerIncluded;
public SyncBcfTopologyCommand(boolean networkIncluded, boolean routerIncluded) { public SyncBcfTopologyCommand(final boolean networkIncluded, final boolean routerIncluded) {
this.networkIncluded = networkIncluded; this._networkIncluded = networkIncluded;
this.routerIncluded = routerIncluded; this._routerIncluded = routerIncluded;
} }
public boolean isNetworkIncluded() { public boolean isNetworkIncluded() {
return networkIncluded; return _networkIncluded;
} }
public boolean isRouterIncluded() { public boolean isRouterIncluded() {
return routerIncluded; return _routerIncluded;
} }
} }

View File

@ -20,12 +20,13 @@
package com.cloud.agent.api; package com.cloud.agent.api;
public class UpdateBcfAttachmentCommand extends BcfCommand { public class UpdateBcfAttachmentCommand extends BcfCommand {
private String _networkId; private final String _networkId;
private String _attachmentId; private final String _attachmentId;
private String _tenantId; private final String _tenantId;
private String _attachmentName; private final String _attachmentName;
public UpdateBcfAttachmentCommand(String networkId, String attachmentId, String tenantId, String attachmentName) { public UpdateBcfAttachmentCommand(final String networkId, final String attachmentId,
final String tenantId, final String attachmentName) {
this._networkId = networkId; this._networkId = networkId;
this._attachmentId = attachmentId; this._attachmentId = attachmentId;
this._tenantId = tenantId; this._tenantId = tenantId;

View File

@ -27,9 +27,9 @@ import com.cloud.network.bigswitch.AclData;
public class UpdateBcfRouterCommand extends BcfCommand { public class UpdateBcfRouterCommand extends BcfCommand {
private String tenantId; private String tenantId;
private String publicIp; private String publicIp;
private List<AclData> acls; private final List<AclData> acls;
public UpdateBcfRouterCommand(String tenantId){ public UpdateBcfRouterCommand(final String tenantId){
this.tenantId = tenantId; this.tenantId = tenantId;
this.publicIp = null; this.publicIp = null;
this.acls = new ArrayList<AclData>(); this.acls = new ArrayList<AclData>();
@ -39,7 +39,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return tenantId; return tenantId;
} }
public void setTenantId(String tenantId) { public void setTenantId(final String tenantId) {
this.tenantId = tenantId; this.tenantId = tenantId;
} }
@ -47,7 +47,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return publicIp; return publicIp;
} }
public void setPublicIp(String publicIp) { public void setPublicIp(final String publicIp) {
this.publicIp = publicIp; this.publicIp = publicIp;
} }
@ -55,7 +55,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return acls; return acls;
} }
public void addAcl(AclData acl){ public void addAcl(final AclData acl){
this.acls.add(acl); this.acls.add(acl);
} }
} }

View File

@ -43,9 +43,9 @@ import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "addBigSwitchBcfDevice", responseObject = BigSwitchBcfDeviceResponse.class, description = "Adds a BigSwitch BCF Controller device", since = "4.6.0", @APICommand(name = "addBigSwitchBcfDevice", responseObject = BigSwitchBcfDeviceResponse.class, description = "Adds a BigSwitch BCF Controller device", since = "4.6.0",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd { public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
private static final String s_name = "addbigswitchbcfdeviceresponse"; private static final String S_NAME = "addbigswitchbcfdeviceresponse";
@Inject @Inject
BigSwitchBcfElementService _bigswitchBcfElementService; private BigSwitchBcfElementService bcfElementService;
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
@ -105,25 +105,24 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException { ResourceAllocationException {
try { try {
BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = _bigswitchBcfElementService.addBigSwitchBcfDevice(this); final BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = bcfElementService.addBigSwitchBcfDevice(this);
if (bigswitchBcfDeviceVO != null) { if (bigswitchBcfDeviceVO == null) {
BigSwitchBcfDeviceResponse response = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller device due to internal error.");
}
final BigSwitchBcfDeviceResponse response = bcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO);
response.setObjectName("bigswitchbcfdevice"); response.setObjectName("bigswitchbcfdevice");
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller device due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) { } catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) { } catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
} }
} }
@Override @Override
public String getCommandName() { public String getCommandName() {
return s_name; return S_NAME;
} }
@Override @Override
@ -133,7 +132,7 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
@Override @Override
public String getEventType() { public String getEventType() {
return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_ADD; return BcfConstants.EVENT_BCF_CONTROLLER_ADD;
} }
@Override @Override

View File

@ -27,11 +27,11 @@ public class BcfConstants {
public static final String BIGSWITCH_BCF_DEVICE_ID = "bcfdeviceid"; public static final String BIGSWITCH_BCF_DEVICE_ID = "bcfdeviceid";
public static final String BIGSWITCH_BCF_DEVICE_NAME = "bigswitchdevicename"; public static final String BIGSWITCH_BCF_DEVICE_NAME = "bigswitchdevicename";
public static final String BIGSWITCH_BCF_DEVICE_NAT = "nat"; public static final String BIGSWITCH_BCF_DEVICE_NAT = "nat";
public static final String EVENT_EXTERNAL_BCF_CONTROLLER_ADD = "PHYSICAL.BCFCONTROLLER.ADD"; public static final String EVENT_BCF_CONTROLLER_ADD = "PHYSICAL.BCFCONTROLLER.ADD";
public static final String EVENT_EXTERNAL_BCF_CONTROLLER_DELETE = "PHYSICAL.BCFCONTROLLER.DELETE"; public static final String EVENT_BCF_CONTROLLER_DELETE = "PHYSICAL.BCFCONTROLLER.DELETE";
public static final Provider BigSwitchBcf = new Provider("BigSwitchBcf", true); public static final Provider BIG_SWITCH_BCF = new Provider("BigSwitchBcf", true);
public static final NetworkDevice BigSwitchBcfDevice = new NetworkDevice("BigSwitchBcf", BigSwitchBcf.getName()); public static final NetworkDevice BIG_SWITCH_BCF_DEVICE = new NetworkDevice("BigSwitchBcf", BIG_SWITCH_BCF.getName());
} }

View File

@ -41,9 +41,9 @@ import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "deleteBigSwitchBcfDevice", responseObject = SuccessResponse.class, description = " delete a BigSwitch BCF Controller device", since = "4.6.0", @APICommand(name = "deleteBigSwitchBcfDevice", responseObject = SuccessResponse.class, description = " delete a BigSwitch BCF Controller device", since = "4.6.0",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd { public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
private static final String s_name = "deletebigswitchbcfdeviceresponse"; private static final String S_NAME = "deletebigswitchbcfdeviceresponse";
@Inject @Inject
BigSwitchBcfElementService _bigswitchBcfElementService; private BigSwitchBcfElementService bigswitchBcfElementService;
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
@ -72,24 +72,24 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException { ResourceAllocationException {
try { try {
boolean result = _bigswitchBcfElementService.deleteBigSwitchBcfDevice(this); final boolean result = bigswitchBcfElementService.deleteBigSwitchBcfDevice(this);
if (result) { if (result) {
SuccessResponse response = new SuccessResponse(getCommandName()); final SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} else { } else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch device."); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch device.");
} }
} catch (InvalidParameterValueException invalidParamExcp) { } catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) { } catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
} }
} }
@Override @Override
public String getCommandName() { public String getCommandName() {
return s_name; return S_NAME;
} }
@Override @Override
@ -99,7 +99,7 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
@Override @Override
public String getEventType() { public String getEventType() {
return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_DELETE; return BcfConstants.EVENT_BCF_CONTROLLER_DELETE;
} }
@Override @Override

View File

@ -48,10 +48,10 @@ import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "listBigSwitchBcfDevices", responseObject = BigSwitchBcfDeviceResponse.class, description = "Lists BigSwitch BCF Controller devices", since = "4.6.0", @APICommand(name = "listBigSwitchBcfDevices", responseObject = BigSwitchBcfDeviceResponse.class, description = "Lists BigSwitch BCF Controller devices", since = "4.6.0",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListBigSwitchBcfDevicesCmd extends BaseListCmd { public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName()); public static final Logger S_LOGGER = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName());
private static final String s_name = "listbigswitchbcfdeviceresponse"; private static final String S_NAME = "listbigswitchbcfdeviceresponse";
@Inject @Inject
BigSwitchBcfElementService _bigswitchBcfElementService; private BigSwitchBcfElementService bigswitchBcfElementService;
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
@ -86,13 +86,13 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException { ResourceAllocationException {
try { try {
List<BigSwitchBcfDeviceVO> bigswitchDevices = _bigswitchBcfElementService.listBigSwitchBcfDevices(this); final List<BigSwitchBcfDeviceVO> bigswitchDevices = bigswitchBcfElementService.listBigSwitchBcfDevices(this);
ListResponse<BigSwitchBcfDeviceResponse> response = new ListResponse<BigSwitchBcfDeviceResponse>(); final ListResponse<BigSwitchBcfDeviceResponse> response = new ListResponse<BigSwitchBcfDeviceResponse>();
List<BigSwitchBcfDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchBcfDeviceResponse>(); final List<BigSwitchBcfDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchBcfDeviceResponse>();
if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) { if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
for (BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) { for (final BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) {
BigSwitchBcfDeviceResponse bigswitchDeviceResponse = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO); final BigSwitchBcfDeviceResponse bigswitchDeviceResponse = bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO);
bigswitchDevicesResponse.add(bigswitchDeviceResponse); bigswitchDevicesResponse.add(bigswitchDeviceResponse);
} }
} }
@ -101,14 +101,14 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} catch (InvalidParameterValueException invalidParamExcp) { } catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) { } catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
} }
} }
@Override @Override
public String getCommandName() { public String getCommandName() {
return s_name; return S_NAME;
} }
} }

View File

@ -65,35 +65,35 @@ public class BigSwitchBcfDeviceResponse extends BaseResponse {
return this.id; return this.id;
} }
public void setId(String bcfDeviceId) { public void setId(final String bcfDeviceId) {
this.id = bcfDeviceId; this.id = bcfDeviceId;
} }
public void setPhysicalNetworkId(String physicalNetworkId) { public void setPhysicalNetworkId(final String physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId; this.physicalNetworkId = physicalNetworkId;
} }
public void setProviderName(String providerName) { public void setProviderName(final String providerName) {
this.providerName = providerName; this.providerName = providerName;
} }
public void setDeviceName(String deviceName) { public void setDeviceName(final String deviceName) {
this.deviceName = deviceName; this.deviceName = deviceName;
} }
public void setHostName(String hostName) { public void setHostName(final String hostName) {
this.hostName = hostName; this.hostName = hostName;
} }
public void setUserName(String username) { public void setUserName(final String username) {
this.username = username; this.username = username;
} }
public void setPassword(String password) { public void setPassword(final String password) {
this.password = password; this.password = password;
} }
public void setNat(Boolean nat) { public void setNat(final Boolean nat) {
this.nat = nat; this.nat = nat;
} }
} }

View File

@ -73,8 +73,10 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity {
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
} }
public BigSwitchBcfDeviceVO(long hostId, long physicalNetworkId, String providerName, String deviceName, public BigSwitchBcfDeviceVO(final long hostId, final long physicalNetworkId,
String hostName, String username, String password, Boolean nat, String hash) { final String providerName, final String deviceName,final String hostName,
final String username, final String password, final Boolean nat,
final String hash) {
super(); super();
this.hostId = hostId; this.hostId = hostId;
this.physicalNetworkId = physicalNetworkId; this.physicalNetworkId = physicalNetworkId;
@ -97,7 +99,7 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity {
return uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(final String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
@ -121,7 +123,7 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity {
return hash; return hash;
} }
public void setHash(String h) { public void setHash(final String h) {
hash = h; hash = h;
} }

View File

@ -19,6 +19,8 @@
package com.cloud.network.bigswitch; package com.cloud.network.bigswitch;
import java.util.Locale;
import com.cloud.network.vpc.NetworkACLItem; import com.cloud.network.vpc.NetworkACLItem;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -41,19 +43,19 @@ public class AclData {
this.action = null; this.action = null;
this.ipProto = null; this.ipProto = null;
this.source = new AclNetwork(); this.source = new AclNetwork();
this.destination = new AclNetwork();; this.destination = new AclNetwork();
} }
public class AclNetwork{ public class AclNetwork{
@SerializedName("cidr") private String cidr; @SerializedName("cidr") final private String cidr;
@SerializedName("port") private Integer port; @SerializedName("port") final private Integer port;
public AclNetwork(){ public AclNetwork(){
this.cidr = null; this.cidr = null;
this.port = null; this.port = null;
} }
public AclNetwork(String cidr, Integer port){ public AclNetwork(final String cidr, final Integer port){
this.cidr = cidr; this.cidr = cidr;
this.port = port; this.port = port;
} }
@ -62,19 +64,19 @@ public class AclData {
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(final String id) {
this.id = id; this.id = id;
} }
public int getPriority() { public int getPriority() {
return priority; return priority;
} }
public void setPriority(int priority) { public void setPriority(final int priority) {
this.priority = priority; this.priority = priority;
} }
public String getAction() { public String getAction() {
return action; return action;
} }
public void setAction(String action) { public void setAction(final String action) {
if(action.equalsIgnoreCase(NetworkACLItem.Action.Allow.name())){ if(action.equalsIgnoreCase(NetworkACLItem.Action.Allow.name())){
this.action = "permit"; this.action = "permit";
} else { } else {
@ -84,9 +86,9 @@ public class AclData {
public String getIpProto() { public String getIpProto() {
return ipProto; return ipProto;
} }
public void setIpProto(String ipProto) { public void setIpProto(final String ipProto) {
if (!ipProto.equalsIgnoreCase("all")){ if (ipProto != null && !ipProto.equalsIgnoreCase("all")){
switch(ipProto.toLowerCase()){ switch(ipProto.toLowerCase(Locale.ENGLISH)){
case "tcp": case "tcp":
this.ipProto = "6"; this.ipProto = "6";
break; break;
@ -96,19 +98,21 @@ public class AclData {
case "icmp": case "icmp":
this.ipProto = "1"; this.ipProto = "1";
break; break;
default:
throw new IllegalArgumentException("Protocol in ACL rule not supported");
} }
} }
} }
public AclNetwork getSource() { public AclNetwork getSource() {
return source; return source;
} }
public void setSource(AclNetwork source) { public void setSource(final AclNetwork source) {
this.source = source; this.source = source;
} }
public AclNetwork getDestination() { public AclNetwork getDestination() {
return destination; return destination;
} }
public void setDestination(AclNetwork destination) { public void setDestination(final AclNetwork destination) {
this.destination = destination; this.destination = destination;
} }
} }

View File

@ -20,6 +20,7 @@
package com.cloud.network.bigswitch; package com.cloud.network.bigswitch;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -28,7 +29,7 @@ import com.google.gson.annotations.SerializedName;
* in CreateBcfAttachmentCommand * in CreateBcfAttachmentCommand
*/ */
public class AttachmentData { public class AttachmentData {
@SerializedName("port") private Attachment attachment; @SerializedName("port") final private Attachment attachment;
public Attachment getAttachment() { public Attachment getAttachment() {
return this.attachment; return this.attachment;
@ -42,9 +43,9 @@ public class AttachmentData {
@SerializedName("id") private String id; @SerializedName("id") private String id;
@SerializedName("tenant_name") private String tenantName; @SerializedName("tenant_name") private String tenantName;
@SerializedName("vlan") private Integer vlan; @SerializedName("vlan") private Integer vlan;
@SerializedName("fixed_ips") private ArrayList<IpAddress> fixedIps; @SerializedName("fixed_ips") final private List<IpAddress> fixedIps;
@SerializedName("mac_address") private String macAddress; @SerializedName("mac_address") private String macAddress;
@SerializedName("bound_segment") private BoundSegment boundSegment; @SerializedName("bound_segment") final private BoundSegment boundSegment;
@SerializedName("binding:host_id") private String hostId; @SerializedName("binding:host_id") private String hostId;
public Attachment(){ public Attachment(){
@ -65,14 +66,14 @@ public class AttachmentData {
} }
public class IpAddress { public class IpAddress {
@SerializedName("ip_address") private String ipAddress; @SerializedName("ip_address") private String address;
public IpAddress(String ipAddr) { public IpAddress(final String ipAddr) {
this.ipAddress = ipAddr; this.address = ipAddr;
} }
public String getIpAddress(){ public String getIpAddress(){
return ipAddress; return address;
} }
} }
@ -82,7 +83,7 @@ public class AttachmentData {
return tenantName; return tenantName;
} }
public void setTenantName(String tenantName) { public void setTenantName(final String tenantName) {
this.tenantName = tenantName; this.tenantName = tenantName;
} }
@ -90,7 +91,7 @@ public class AttachmentData {
return id; return id;
} }
public void setId(String id) { public void setId(final String id) {
this.id = id; this.id = id;
} }
@ -98,7 +99,7 @@ public class AttachmentData {
return hostId; return hostId;
} }
public void setHostId(String hostId) { public void setHostId(final String hostId) {
this.hostId = hostId; this.hostId = hostId;
} }
@ -106,16 +107,16 @@ public class AttachmentData {
return vlan; return vlan;
} }
public void setVlan(Integer vlan) { public void setVlan(final Integer vlan) {
this.vlan = vlan; this.vlan = vlan;
this.boundSegment.setSegmentationId(vlan); this.boundSegment.setSegmentationId(vlan);
} }
public ArrayList<IpAddress> getIpv4List() { public List<IpAddress> getIpv4List() {
return fixedIps; return fixedIps;
} }
public void addIpv4(String ipv4) { public void addIpv4(final String ipv4) {
this.fixedIps.add(new IpAddress(ipv4)); this.fixedIps.add(new IpAddress(ipv4));
} }
@ -123,7 +124,7 @@ public class AttachmentData {
return macAddress; return macAddress;
} }
public void setMac(String mac) { public void setMac(final String mac) {
this.macAddress = mac; this.macAddress = mac;
} }
@ -135,7 +136,7 @@ public class AttachmentData {
return state; return state;
} }
public void setState(String state) { public void setState(final String state) {
this.state = state; this.state = state;
} }
} }

View File

@ -53,25 +53,25 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
public class BigSwitchBcfApi { public class BigSwitchBcfApi {
private static final Logger s_logger = Logger.getLogger(BigSwitchBcfApi.class); private static final Logger S_LOGGER = Logger.getLogger(BigSwitchBcfApi.class);
private final static String s_protocol = "https"; private final static String S_PROTOCOL = "https";
private final static String s_nsBaseUri = "/networkService/v1.1"; private final static String S_NS_BASE_URL = "/networkService/v1.1";
private final static String CONTENT_TYPE = "Content-type"; private final static String CONTENT_TYPE = "Content-type";
private final static String ACCEPT = "Accept"; private final static String ACCEPT = "Accept";
private final static String CONTENT_JSON = "application/json"; private final static String CONTENT_JSON = "application/json";
private final static String HTTP_HEADER_INSTANCE_ID = "Instance-ID"; private final static String HTTP_HEADER_INSTANCE_ID = "Instance-ID";
private final static String CLOUDSTACK_INSTANCE_ID = "cloudstack"; private final static String CLOUDSTACK_INSTANCE_ID = "cloudstack";
private final static String HASH_MATCH = "X-BSN-BVS-HASH-MATCH"; private final static String HASH_MATCH = "X-BSN-BVS-HASH-MATCH";
private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); private final static MultiThreadedHttpConnectionManager S_HTTP_CLIENT_MANAGER = new MultiThreadedHttpConnectionManager();
private String _host; private String host;
private String _username; private String username;
private String _password; private String password;
private String _hash; private String hash;
private String _zoneId; private String zoneId;
private Boolean _nat; private Boolean nat;
private boolean _isMaster = false; private boolean isMaster;
private int _port = 8000; private int _port = 8000;
@ -85,15 +85,15 @@ public class BigSwitchBcfApi {
* in the unittests. * in the unittests.
*/ */
protected HttpClient createHttpClient() { protected HttpClient createHttpClient() {
return new HttpClient(s_httpClientManager); return new HttpClient(S_HTTP_CLIENT_MANAGER);
} }
protected HttpMethod createMethod(String type, String uri, int port) throws BigSwitchBcfApiException { protected HttpMethod createMethod(final String type, final String uri, final int port) throws BigSwitchBcfApiException {
String url; String url;
try { try {
url = new URL(s_protocol, _host, port, uri).toString(); url = new URL(S_PROTOCOL, host, port, uri).toString();
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
s_logger.error("Unable to build Big Switch API URL", e); S_LOGGER.error("Unable to build Big Switch API URL", e);
throw new BigSwitchBcfApiException("Unable to build Big Switch API URL", e); throw new BigSwitchBcfApiException("Unable to build Big Switch API URL", e);
} }
@ -118,7 +118,7 @@ public class BigSwitchBcfApi {
// Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), _port)); Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), _port));
} catch (IOException e) { } catch (IOException e) {
s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e); S_LOGGER.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
} }
} }
@ -126,99 +126,99 @@ public class BigSwitchBcfApi {
* Setter used by UI to set BSN controller address * Setter used by UI to set BSN controller address
* @param address * @param address
*/ */
public void setControllerAddress(String address) { public void setControllerAddress(final String address) {
this._host = address; this.host = address;
} }
/** /**
* Setter used by UI to set BSN controller user name * Setter used by UI to set BSN controller user name
* @param username * @param username
*/ */
public void setControllerUsername(String username) { public void setControllerUsername(final String username) {
this._username = username; this.username = username;
} }
/** /**
* Setter used by UI to set BSN controller password * Setter used by UI to set BSN controller password
* @param password * @param password
*/ */
public void setControllerPassword(String password) { public void setControllerPassword(final String password) {
this._password = password; this.password = password;
} }
/** /**
* Setter used by UI to set BSN controller NAT mode * Setter used by UI to set BSN controller NAT mode
* @param nat * @param nat
*/ */
public void setControllerNat(Boolean nat) { public void setControllerNat(final Boolean nat) {
this._nat = nat; this.nat = nat;
} }
public boolean isNatEnabled() { public boolean isNatEnabled() {
return this._nat; return this.nat;
} }
/** public void setZoneId(final String zoneId) {
* Setter used by UI to set BSN controller password this.zoneId = zoneId;
* @param password
*/
public void setZoneId(String zoneId) {
this._zoneId = zoneId;
} }
public String createNetwork(NetworkData network) throws BigSwitchBcfApiException { public String createNetwork(final NetworkData network) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + network.getNetwork().getTenantId() + "/networks"; String uri = S_NS_BASE_URL + "/tenants/" + network.getNetwork().getTenantId() + "/networks";
return executeCreateObject(network, uri, Collections.<String, String> emptyMap()); return executeCreateObject(network, uri, Collections.<String, String> emptyMap());
} }
public String deleteNetwork(String tenantId, String networkId) throws BigSwitchBcfApiException { public String deleteNetwork(final String tenantId, final String networkId) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId; String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId;
return executeDeleteObject(uri); return executeDeleteObject(uri);
} }
public String createAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException { public String createAttachment(final String tenantId, final String networkId,
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; final AttachmentData attachment) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment";
return executeCreateObject(attachment, uri, Collections.<String, String> emptyMap()); return executeCreateObject(attachment, uri, Collections.<String, String> emptyMap());
} }
public String modifyAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException { public String modifyAttachment(final String tenantId, final String networkId,
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; final AttachmentData attachment) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment";
return executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap()); return executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap());
} }
public String deleteAttachment(String tenantId, String networkId, String attachmentId) throws BigSwitchBcfApiException { public String deleteAttachment(final String tenantId, final String networkId,
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment"; final String attachmentId) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment";
return executeDeleteObject(uri); return executeDeleteObject(uri);
} }
public String createRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException { public String createRouter(final String tenantId, final RouterData router) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers"; String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers";
return executeCreateObject(router, uri, Collections.<String, String> emptyMap()); return executeCreateObject(router, uri, Collections.<String, String> emptyMap());
} }
public String modifyRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException, public String modifyRouter(final String tenantId, final RouterData router) throws BigSwitchBcfApiException,
IllegalArgumentException{ IllegalArgumentException{
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers"; String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers";
return executeCreateObject(router, uri, Collections.<String, String> emptyMap()); return executeCreateObject(router, uri, Collections.<String, String> emptyMap());
} }
public String createRouterInterface(String tenantId, String routerId, RouterInterfaceData routerInterface) throws BigSwitchBcfApiException { public String createRouterInterface(final String tenantId, final String routerId,
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces"; final RouterInterfaceData routerInterface) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces";
return executeCreateObject(routerInterface, uri, Collections.<String, String> emptyMap()); return executeCreateObject(routerInterface, uri, Collections.<String, String> emptyMap());
} }
public String createFloatingIp(String tenantId, FloatingIpData fip) throws BigSwitchBcfApiException { public String createFloatingIp(final String tenantId, final FloatingIpData fip) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips"; String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips";
return executeCreateObject(fip, uri, Collections.<String, String> emptyMap()); return executeCreateObject(fip, uri, Collections.<String, String> emptyMap());
} }
public String deleteFloatingIp(String tenantId, String fipId) throws BigSwitchBcfApiException { public String deleteFloatingIp(final String tenantId, final String fipId) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips/" + fipId; String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips/" + fipId;
return executeDeleteObject(uri); return executeDeleteObject(uri);
} }
public ControlClusterStatus getControlClusterStatus() throws BigSwitchBcfApiException { public ControlClusterStatus getControlClusterStatus() throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/health"; String uri = S_NS_BASE_URL + "/health";
ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() { ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
}.getType(), uri, null); }.getType(), uri, null);
ccs.setStatus(true); ccs.setStatus(true);
@ -226,7 +226,7 @@ public class BigSwitchBcfApi {
} }
public Capabilities getCapabilities() throws BigSwitchBcfApiException { public Capabilities getCapabilities() throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/capabilities"; String uri = S_NS_BASE_URL + "/capabilities";
List<String> capslist = executeRetrieveObject(new TypeToken<List<String>>() { List<String> capslist = executeRetrieveObject(new TypeToken<List<String>>() {
}.getType(), uri, null); }.getType(), uri, null);
Capabilities caps = new Capabilities(); Capabilities caps = new Capabilities();
@ -234,28 +234,28 @@ public class BigSwitchBcfApi {
return caps; return caps;
} }
public String syncTopology(TopologyData topo) throws BigSwitchBcfApiException { public String syncTopology(final TopologyData topo) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/topology"; String uri = S_NS_BASE_URL + "/topology";
return executeCreateObject(topo, uri, Collections.<String, String> emptyMap()); return executeCreateObject(topo, uri, Collections.<String, String> emptyMap());
} }
public ControllerData getControllerData() { public ControllerData getControllerData() {
return new ControllerData(_host, _isMaster); return new ControllerData(host, isMaster);
} }
private void checkInvariants() throws BigSwitchBcfApiException{ private void checkInvariants() throws BigSwitchBcfApiException{
if (_host == null || _host.isEmpty()) { if (host == null || host.isEmpty()) {
throw new BigSwitchBcfApiException("Hostname is null or empty"); throw new BigSwitchBcfApiException("Hostname is null or empty");
} }
if (_username == null || _username.isEmpty()){ if (username == null || username.isEmpty()){
throw new BigSwitchBcfApiException("Username is null or empty"); throw new BigSwitchBcfApiException("Username is null or empty");
} }
if (_password == null || _password.isEmpty()){ if (password == null || password.isEmpty()){
throw new BigSwitchBcfApiException("Password is null or empty"); throw new BigSwitchBcfApiException("Password is null or empty");
} }
} }
private String checkResponse(HttpMethodBase m, String errorMessageBase) throws BigSwitchBcfApiException, private String checkResponse(final HttpMethodBase m, final String errorMessageBase) throws BigSwitchBcfApiException,
IllegalArgumentException{ IllegalArgumentException{
String customErrorMsg = null; String customErrorMsg = null;
if (m.getStatusCode() == HttpStatus.SC_OK) { if (m.getStatusCode() == HttpStatus.SC_OK) {
@ -273,7 +273,7 @@ public class BigSwitchBcfApi {
throw new BigSwitchBcfApiException("BCF topology sync required", true); throw new BigSwitchBcfApiException("BCF topology sync required", true);
} }
if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) { if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) {
_isMaster = false; isMaster = false;
set_hash(HASH_IGNORE); set_hash(HASH_IGNORE);
return HASH_IGNORE; return HASH_IGNORE;
} }
@ -288,24 +288,25 @@ public class BigSwitchBcfApi {
} }
String errorMessage = responseToErrorMessage(m); String errorMessage = responseToErrorMessage(m);
m.releaseConnection(); m.releaseConnection();
s_logger.error(errorMessageBase + errorMessage); S_LOGGER.error(errorMessageBase + errorMessage);
throw new BigSwitchBcfApiException(errorMessageBase + errorMessage + customErrorMsg); throw new BigSwitchBcfApiException(errorMessageBase + errorMessage + customErrorMsg);
} }
private void setHttpHeader(HttpMethodBase m) { private void setHttpHeader(final HttpMethodBase m) {
m.setRequestHeader(CONTENT_TYPE, CONTENT_JSON); m.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
m.setRequestHeader(ACCEPT, CONTENT_JSON); m.setRequestHeader(ACCEPT, CONTENT_JSON);
m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + _zoneId); m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + zoneId);
if (_hash != "" ) { if (hash != "" ) {
m.setRequestHeader(HASH_MATCH, _hash); m.setRequestHeader(HASH_MATCH, hash);
} }
String authString = _username + ":" + _password; String authString = username + ":" + password;
String encodedAuthString = "Basic " + Base64.encodeBase64String(authString.getBytes(Charset.forName("UTF-8"))); String encodedAuthString = "Basic " + Base64.encodeBase64String(authString.getBytes(Charset.forName("UTF-8")));
m.setRequestHeader("Authorization", encodedAuthString); m.setRequestHeader("Authorization", encodedAuthString);
} }
protected <T> String executeUpdateObject(T newObject, String uri, Map<String, String> parameters) throws BigSwitchBcfApiException, protected <T> String executeUpdateObject(final T newObject, final String uri,
final Map<String, String> parameters) throws BigSwitchBcfApiException,
IllegalArgumentException{ IllegalArgumentException{
checkInvariants(); checkInvariants();
@ -328,7 +329,8 @@ public class BigSwitchBcfApi {
return hash; return hash;
} }
protected <T> String executeCreateObject(T newObject, String uri, Map<String, String> parameters) throws BigSwitchBcfApiException { protected <T> String executeCreateObject(final T newObject, final String uri,
final Map<String, String> parameters) throws BigSwitchBcfApiException {
checkInvariants(); checkInvariants();
PostMethod pm = (PostMethod)createMethod("post", uri, _port); PostMethod pm = (PostMethod)createMethod("post", uri, _port);
@ -350,7 +352,7 @@ public class BigSwitchBcfApi {
return hash; return hash;
} }
protected String executeDeleteObject(String uri) throws BigSwitchBcfApiException { protected String executeDeleteObject(final String uri) throws BigSwitchBcfApiException {
checkInvariants(); checkInvariants();
DeleteMethod dm = (DeleteMethod)createMethod("delete", uri, _port); DeleteMethod dm = (DeleteMethod)createMethod("delete", uri, _port);
@ -367,8 +369,8 @@ public class BigSwitchBcfApi {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <T> T executeRetrieveObject(Type returnObjectType, protected <T> T executeRetrieveObject(final Type returnObjectType,
String uri, Map<String, String> parameters) throws BigSwitchBcfApiException { final String uri, final Map<String, String> parameters) throws BigSwitchBcfApiException {
checkInvariants(); checkInvariants();
GetMethod gm = (GetMethod)createMethod("get", uri, _port); GetMethod gm = (GetMethod)createMethod("get", uri, _port);
@ -392,41 +394,41 @@ public class BigSwitchBcfApi {
// CAUTIOUS: Safety margin of 2048 characters - extend if needed. // CAUTIOUS: Safety margin of 2048 characters - extend if needed.
returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(2048), returnObjectType); returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(2048), returnObjectType);
} catch (IOException e) { } catch (IOException e) {
s_logger.error("IOException while retrieving response body", e); S_LOGGER.error("IOException while retrieving response body", e);
throw new BigSwitchBcfApiException(e); throw new BigSwitchBcfApiException(e);
} finally { } finally {
gm.releaseConnection(); gm.releaseConnection();
} }
if(returnValue instanceof ControlClusterStatus) { if(returnValue instanceof ControlClusterStatus) {
if(hash == HASH_CONFLICT) { if(hash == HASH_CONFLICT) {
_isMaster = true; isMaster = true;
((ControlClusterStatus) returnValue).setTopologySyncRequested(true); ((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
} else if (hash != HASH_IGNORE && !_isMaster) { } else if (hash != HASH_IGNORE && !isMaster) {
_isMaster = true; isMaster = true;
((ControlClusterStatus) returnValue).setTopologySyncRequested(true); ((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
} }
} }
return returnValue; return returnValue;
} }
protected void executeMethod(HttpMethodBase method) throws BigSwitchBcfApiException { protected void executeMethod(final HttpMethodBase method) throws BigSwitchBcfApiException {
try { try {
_client.executeMethod(method); _client.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
method.releaseConnection(); method.releaseConnection();
} }
} catch (HttpException e) { } catch (HttpException e) {
s_logger.error("HttpException caught while trying to connect to the BigSwitch Controller", e); S_LOGGER.error("HttpException caught while trying to connect to the BigSwitch Controller", e);
method.releaseConnection(); method.releaseConnection();
throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e);
} catch (IOException e) { } catch (IOException e) {
s_logger.error("IOException caught while trying to connect to the BigSwitch Controller", e); S_LOGGER.error("IOException caught while trying to connect to the BigSwitch Controller", e);
method.releaseConnection(); method.releaseConnection();
throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e);
} }
} }
private String responseToErrorMessage(HttpMethodBase method) { private String responseToErrorMessage(final HttpMethodBase method) {
assert method.isRequestSent() : "no use getting an error message unless the request is sent"; assert method.isRequestSent() : "no use getting an error message unless the request is sent";
if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
@ -436,7 +438,7 @@ public class BigSwitchBcfApi {
try { try {
return method.getResponseBodyAsString(2048); return method.getResponseBodyAsString(2048);
} catch (IOException e) { } catch (IOException e) {
s_logger.debug("Error while loading response body", e); S_LOGGER.debug("Error while loading response body", e);
} }
} }
@ -449,11 +451,11 @@ public class BigSwitchBcfApi {
} }
public String get_hash() { public String get_hash() {
return _hash; return hash;
} }
public void set_hash(String hash) { public void set_hash(final String hash) {
this._hash = hash; this.hash = hash;
} }
} }

View File

@ -177,7 +177,7 @@ public class BigSwitchBcfUtils {
// handle external network first, only if NAT service is enabled // handle external network first, only if NAT service is enabled
if(networks != null) { if(networks != null) {
if (!(networks.isEmpty()) && isNatEnabled()) { if(!(networks.isEmpty()) && isNatEnabled()){
// get public net info - needed to set up source nat gateway // get public net info - needed to set up source nat gateway
NetworkVO pubNet = getPublicNetwork(physicalNetworkId); NetworkVO pubNet = getPublicNetwork(physicalNetworkId);
@ -380,7 +380,7 @@ public class BigSwitchBcfUtils {
Integer port = rule.getSourcePortStart(); Integer port = rule.getSourcePortStart();
fwCidrList = _fwCidrsDao.listByFirewallRuleId(rule.getId()); fwCidrList = _fwCidrsDao.listByFirewallRuleId(rule.getId());
if(fwCidrList != null){ if(fwCidrList != null){
if (fwCidrList.size() > 1 || !rule.getSourcePortEnd().equals(port)) { if(fwCidrList.size()>1 || !rule.getSourcePortEnd().equals(port)){
continue; continue;
} else { } else {
cidr = fwCidrList.get(0).getCidr(); cidr = fwCidrList.get(0).getCidr();
@ -414,7 +414,7 @@ public class BigSwitchBcfUtils {
Integer port = item.getSourcePortStart(); // currently BCF supports single port policy Integer port = item.getSourcePortStart(); // currently BCF supports single port policy
aclCidrList = _aclItemCidrsDao.listByNetworkACLItemId(item.getId()); aclCidrList = _aclItemCidrsDao.listByNetworkACLItemId(item.getId());
if(aclCidrList != null){ if(aclCidrList != null){
if (aclCidrList.size() > 1 || !item.getSourcePortEnd().equals(port)) { if(aclCidrList.size()>1 || !item.getSourcePortEnd().equals(port)){
continue; continue;
} else { } else {
cidr = aclCidrList.get(0).getCidr(); cidr = aclCidrList.get(0).getCidr();
@ -440,7 +440,7 @@ public class BigSwitchBcfUtils {
public String syncTopologyToBcfHost(HostVO bigswitchBcfHost){ public String syncTopologyToBcfHost(HostVO bigswitchBcfHost){
SyncBcfTopologyCommand syncCmd; SyncBcfTopologyCommand syncCmd;
if (isNatEnabled()) { if(isNatEnabled()){
syncCmd = new SyncBcfTopologyCommand(true, true); syncCmd = new SyncBcfTopologyCommand(true, true);
} else { } else {
syncCmd = new SyncBcfTopologyCommand(true, false); syncCmd = new SyncBcfTopologyCommand(true, false);
@ -486,7 +486,7 @@ public class BigSwitchBcfUtils {
} }
String newHash = answer.getHash(); String newHash = answer.getHash();
if (cmd.is_topologySyncRequested()) { if (cmd.isTopologySyncRequested()) {
newHash = syncTopologyToBcfHost(cluster.getMaster()); newHash = syncTopologyToBcfHost(cluster.getMaster());
} }
if(newHash != null){ if(newHash != null){
@ -519,7 +519,7 @@ public class BigSwitchBcfUtils {
}); });
} }
public boolean isNatEnabled() { public Boolean isNatEnabled(){
List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listAll(); List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listAll();
if(devices != null && !devices.isEmpty()){ if(devices != null && !devices.isEmpty()){
return devices.get(0).getNat(); return devices.get(0).getNat();
@ -528,8 +528,6 @@ public class BigSwitchBcfUtils {
} }
} }
// returns null: should throw something^%*%#&
// Integer -> int
public Integer getSubnetMaskLength(String maskString){ public Integer getSubnetMaskLength(String maskString){
if(!IPAddress.isValidIPv4(maskString)){ if(!IPAddress.isValidIPv4(maskString)){
return null; return null;

View File

@ -30,26 +30,25 @@ import javax.ejb.Local;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.commons.net.util.SubnetUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import org.apache.commons.net.util.SubnetUtils;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.BcfAnswer; import com.cloud.agent.api.BcfAnswer;
import com.cloud.agent.api.UpdateBcfRouterCommand;
import com.cloud.agent.api.CreateBcfAttachmentCommand; import com.cloud.agent.api.CreateBcfAttachmentCommand;
import com.cloud.agent.api.CreateBcfStaticNatCommand; import com.cloud.agent.api.CreateBcfStaticNatCommand;
import com.cloud.agent.api.DeleteBcfAttachmentCommand; import com.cloud.agent.api.DeleteBcfAttachmentCommand;
import com.cloud.agent.api.DeleteBcfStaticNatCommand; import com.cloud.agent.api.DeleteBcfStaticNatCommand;
import com.cloud.agent.api.StartupBigSwitchBcfCommand; import com.cloud.agent.api.StartupBigSwitchBcfCommand;
import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.UpdateBcfRouterCommand;
import com.cloud.api.ApiDBUtils; import com.cloud.api.ApiDBUtils;
import com.cloud.api.commands.AddBigSwitchBcfDeviceCmd; import com.cloud.api.commands.AddBigSwitchBcfDeviceCmd;
import com.cloud.api.commands.BcfConstants;
import com.cloud.api.commands.DeleteBigSwitchBcfDeviceCmd; import com.cloud.api.commands.DeleteBigSwitchBcfDeviceCmd;
import com.cloud.api.commands.ListBigSwitchBcfDevicesCmd; import com.cloud.api.commands.ListBigSwitchBcfDevicesCmd;
import com.cloud.api.commands.BcfConstants;
import com.cloud.api.response.BigSwitchBcfDeviceResponse; import com.cloud.api.response.BigSwitchBcfDeviceResponse;
import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenterVO; import com.cloud.dc.DataCenterVO;
@ -209,7 +208,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
return false; return false;
} }
if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, BcfConstants.BigSwitchBcf)) { if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, BcfConstants.BIG_SWITCH_BCF)) {
s_logger.debug("BigSwitchBcfElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); s_logger.debug("BigSwitchBcfElement can't provide the " + service.getName() + " service on network " + network.getDisplayText());
return false; return false;
} }
@ -411,7 +410,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
ServerResource resource = new BigSwitchBcfResource(); ServerResource resource = new BigSwitchBcfResource();
final String deviceName = BcfConstants.BigSwitchBcf.getName(); final String deviceName = BcfConstants.BIG_SWITCH_BCF.getName();
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName); NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
final Long physicalNetworkId = cmd.getPhysicalNetworkId(); final Long physicalNetworkId = cmd.getPhysicalNetworkId();
final String hostname = cmd.getHost(); final String hostname = cmd.getHost();
@ -452,7 +451,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
zoneName = String.valueOf(zoneId); zoneName = String.valueOf(zoneId);
} }
boolean natNow = _bcfUtils.isNatEnabled(); Boolean natNow = _bcfUtils.isNatEnabled();
if (!nat && natNow){ if (!nat && natNow){
throw new CloudRuntimeException("NAT is enabled in existing controller. Enable NAT for new controller or remove existing controller first."); throw new CloudRuntimeException("NAT is enabled in existing controller. Enable NAT for new controller or remove existing controller first.");
} else if (nat && !natNow){ } else if (nat && !natNow){
@ -684,7 +683,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
} }
cidrList = r.getSourceCidrList(); cidrList = r.getSourceCidrList();
if(cidrList != null){ if(cidrList != null){
if (cidrList.size() > 1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())) { if(cidrList.size()>1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())){
throw new ResourceUnavailableException("One CIDR and one port only please.", throw new ResourceUnavailableException("One CIDR and one port only please.",
Network.class, network.getId()); Network.class, network.getId());
} else { } else {
@ -718,7 +717,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
} }
cidrList = r.getSourceCidrList(); cidrList = r.getSourceCidrList();
if(cidrList != null){ if(cidrList != null){
if (cidrList.size() > 1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())) { if(cidrList.size()>1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())){
throw new ResourceUnavailableException("One CIDR and one port only please.", throw new ResourceUnavailableException("One CIDR and one port only please.",
Network.class, network.getId()); Network.class, network.getId());
} else { } else {

View File

@ -312,7 +312,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created", hash); return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created; topology sync required."); return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -327,11 +327,11 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
private Answer executeRequest(DeleteBcfSegmentCommand cmd, int numRetries) { private Answer executeRequest(DeleteBcfSegmentCommand cmd, int numRetries) {
try { try {
String hash = _bigswitchBcfApi.deleteNetwork(cmd.get_tenantUuid(), cmd.getNetworkUuid()); String hash = _bigswitchBcfApi.deleteNetwork(cmd.getTenantUuid(), cmd.getNetworkUuid());
return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted", hash); return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted; topology sync required."); return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -357,7 +357,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created", hash); return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created; topology sync required."); return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -376,7 +376,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted", hash); return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted; topology sync required."); return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -398,7 +398,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated", hash); return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated; topology sync required."); return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -412,21 +412,21 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
private Answer executeRequest(CreateBcfStaticNatCommand cmd, int numRetries) { private Answer executeRequest(CreateBcfStaticNatCommand cmd, int numRetries) {
FloatingIpData fip = new FloatingIpData(); FloatingIpData fip = new FloatingIpData();
fip.setTenantId(cmd.get_tenantId()); fip.setTenantId(cmd.getTenantId());
fip.setNetworkId(cmd.get_networkId()); fip.setNetworkId(cmd.getNetworkId());
fip.setFixedIp(cmd.get_privateIp()); fip.setFixedIp(cmd.getPrivateIp());
fip.setFloatingIpAndId(cmd.get_publicIp()); fip.setFloatingIpAndId(cmd.getPublicIp());
fip.setMac(cmd.get_mac()); fip.setMac(cmd.getMac());
try { try {
String hash = _bigswitchBcfApi.createFloatingIp(cmd.get_tenantId(), fip); String hash = _bigswitchBcfApi.createFloatingIp(cmd.getTenantId(), fip);
return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + ":" + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" +
cmd.get_privateIp() + " created", hash); cmd.getPrivateIp() + " created", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + ":" + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" +
cmd.get_privateIp() + " created; topology sync required."); cmd.getPrivateIp() + " created; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
return retry(cmd, --numRetries); return retry(cmd, --numRetries);
@ -439,12 +439,12 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
private Answer executeRequest(DeleteBcfStaticNatCommand cmd, int numRetries) { private Answer executeRequest(DeleteBcfStaticNatCommand cmd, int numRetries) {
try { try {
String hash = _bigswitchBcfApi.deleteFloatingIp(cmd.get_tenantId(), cmd.get_floatingIpId()); String hash = _bigswitchBcfApi.deleteFloatingIp(cmd.getTenantId(), cmd.getFloatingIpId());
return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + " deleted", hash); return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + " deleted", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + " deleted; topology sync required."); return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + " deleted; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
return retry(cmd, --numRetries); return retry(cmd, --numRetries);
@ -456,16 +456,16 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
} }
private Answer executeRequest(CreateBcfRouterCommand cmd, int numRetries) { private Answer executeRequest(CreateBcfRouterCommand cmd, int numRetries) {
RouterData router = new RouterData(cmd.get_tenantId()); RouterData router = new RouterData(cmd.getTenantId());
try { try {
String hash; String hash;
hash = _bigswitchBcfApi.createRouter(cmd.get_tenantId(), router); hash = _bigswitchBcfApi.createRouter(cmd.getTenantId(), router);
return new BcfAnswer(cmd, true, "router " + cmd.get_tenantId() + return new BcfAnswer(cmd, true, "router " + cmd.getTenantId() +
" created.", hash); " created.", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, " created; topology sync required."); return new BcfAnswer(cmd, true, " created; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -478,18 +478,18 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
} }
private Answer executeRequest(CreateBcfRouterInterfaceCommand cmd, int numRetries) { private Answer executeRequest(CreateBcfRouterInterfaceCommand cmd, int numRetries) {
RouterInterfaceData routerInterface = new RouterInterfaceData(cmd.get_tenantId(), RouterInterfaceData routerInterface = new RouterInterfaceData(cmd.getTenantId(),
cmd.get_gateway(), cmd.get_cidr(), cmd.get_networkId(), cmd.get_networkName()); cmd.getGateway(), cmd.getCidr(), cmd.getNetworkId(), cmd.getNetworkName());
try { try {
String hash; String hash;
hash = _bigswitchBcfApi.createRouterInterface(cmd.get_tenantId(), hash = _bigswitchBcfApi.createRouterInterface(cmd.getTenantId(),
cmd.get_tenantId(), routerInterface); cmd.getTenantId(), routerInterface);
return new BcfAnswer(cmd, true, "router " + cmd.get_tenantId() + return new BcfAnswer(cmd, true, "router " + cmd.getTenantId() +
" created.", hash); " created.", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, " created; topology sync required."); return new BcfAnswer(cmd, true, " created; topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {
@ -515,7 +515,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource
return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated", hash); return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated", hash);
} catch (BigSwitchBcfApiException e) { } catch (BigSwitchBcfApiException e) {
if (e.is_topologySyncRequested()) { if (e.is_topologySyncRequested()) {
cmd.set_topologySyncRequested(true); cmd.setTopologySyncRequested(true);
return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated but topology sync required."); return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated but topology sync required.");
} else { } else {
if (numRetries > 0) { if (numRetries > 0) {