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{
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);
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);
this.hash = hash;
}
public BcfAnswer(Command command, Exception e) {
public BcfAnswer(final Command command, final Exception e) {
super(command, e);
this.hash = "";
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,12 +20,13 @@
package com.cloud.agent.api;
public class UpdateBcfAttachmentCommand extends BcfCommand {
private String _networkId;
private String _attachmentId;
private String _tenantId;
private String _attachmentName;
private final String _networkId;
private final String _attachmentId;
private final String _tenantId;
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._attachmentId = attachmentId;
this._tenantId = tenantId;

View File

@ -27,9 +27,9 @@ import com.cloud.network.bigswitch.AclData;
public class UpdateBcfRouterCommand extends BcfCommand {
private String tenantId;
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.publicIp = null;
this.acls = new ArrayList<AclData>();
@ -39,7 +39,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return tenantId;
}
public void setTenantId(String tenantId) {
public void setTenantId(final String tenantId) {
this.tenantId = tenantId;
}
@ -47,7 +47,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return publicIp;
}
public void setPublicIp(String publicIp) {
public void setPublicIp(final String publicIp) {
this.publicIp = publicIp;
}
@ -55,7 +55,7 @@ public class UpdateBcfRouterCommand extends BcfCommand {
return acls;
}
public void addAcl(AclData acl){
public void addAcl(final AclData 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",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
private static final String s_name = "addbigswitchbcfdeviceresponse";
private static final String S_NAME = "addbigswitchbcfdeviceresponse";
@Inject
BigSwitchBcfElementService _bigswitchBcfElementService;
private BigSwitchBcfElementService bcfElementService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
@ -105,25 +105,24 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException {
try {
BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = _bigswitchBcfElementService.addBigSwitchBcfDevice(this);
if (bigswitchBcfDeviceVO != null) {
BigSwitchBcfDeviceResponse response = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO);
final BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = bcfElementService.addBigSwitchBcfDevice(this);
if (bigswitchBcfDeviceVO == null) {
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.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller device due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
}
}
@Override
public String getCommandName() {
return s_name;
return S_NAME;
}
@Override
@ -133,7 +132,7 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
@Override
public String getEventType() {
return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_ADD;
return BcfConstants.EVENT_BCF_CONTROLLER_ADD;
}
@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_NAME = "bigswitchdevicename";
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_EXTERNAL_BCF_CONTROLLER_DELETE = "PHYSICAL.BCFCONTROLLER.DELETE";
public static final String EVENT_BCF_CONTROLLER_ADD = "PHYSICAL.BCFCONTROLLER.ADD";
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",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
private static final String s_name = "deletebigswitchbcfdeviceresponse";
private static final String S_NAME = "deletebigswitchbcfdeviceresponse";
@Inject
BigSwitchBcfElementService _bigswitchBcfElementService;
private BigSwitchBcfElementService bigswitchBcfElementService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
@ -72,24 +72,24 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException {
try {
boolean result = _bigswitchBcfElementService.deleteBigSwitchBcfDevice(this);
final boolean result = bigswitchBcfElementService.deleteBigSwitchBcfDevice(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
final SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch device.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
}
}
@Override
public String getCommandName() {
return s_name;
return S_NAME;
}
@Override
@ -99,7 +99,7 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
@Override
public String getEventType() {
return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_DELETE;
return BcfConstants.EVENT_BCF_CONTROLLER_DELETE;
}
@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",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName());
private static final String s_name = "listbigswitchbcfdeviceresponse";
public static final Logger S_LOGGER = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName());
private static final String S_NAME = "listbigswitchbcfdeviceresponse";
@Inject
BigSwitchBcfElementService _bigswitchBcfElementService;
private BigSwitchBcfElementService bigswitchBcfElementService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
@ -86,13 +86,13 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException {
try {
List<BigSwitchBcfDeviceVO> bigswitchDevices = _bigswitchBcfElementService.listBigSwitchBcfDevices(this);
ListResponse<BigSwitchBcfDeviceResponse> response = new ListResponse<BigSwitchBcfDeviceResponse>();
List<BigSwitchBcfDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchBcfDeviceResponse>();
final List<BigSwitchBcfDeviceVO> bigswitchDevices = bigswitchBcfElementService.listBigSwitchBcfDevices(this);
final ListResponse<BigSwitchBcfDeviceResponse> response = new ListResponse<BigSwitchBcfDeviceResponse>();
final List<BigSwitchBcfDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchBcfDeviceResponse>();
if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
for (BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) {
BigSwitchBcfDeviceResponse bigswitchDeviceResponse = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO);
for (final BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) {
final BigSwitchBcfDeviceResponse bigswitchDeviceResponse = bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO);
bigswitchDevicesResponse.add(bigswitchDeviceResponse);
}
}
@ -101,14 +101,14 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp);
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp);
}
}
@Override
public String getCommandName() {
return s_name;
return S_NAME;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -53,25 +53,25 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class BigSwitchBcfApi {
private static final Logger s_logger = Logger.getLogger(BigSwitchBcfApi.class);
private final static String s_protocol = "https";
private final static String s_nsBaseUri = "/networkService/v1.1";
private static final Logger S_LOGGER = Logger.getLogger(BigSwitchBcfApi.class);
private final static String S_PROTOCOL = "https";
private final static String S_NS_BASE_URL = "/networkService/v1.1";
private final static String CONTENT_TYPE = "Content-type";
private final static String ACCEPT = "Accept";
private final static String CONTENT_JSON = "application/json";
private final static String HTTP_HEADER_INSTANCE_ID = "Instance-ID";
private final static String CLOUDSTACK_INSTANCE_ID = "cloudstack";
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 _username;
private String _password;
private String _hash;
private String _zoneId;
private Boolean _nat;
private String host;
private String username;
private String password;
private String hash;
private String zoneId;
private Boolean nat;
private boolean _isMaster = false;
private boolean isMaster;
private int _port = 8000;
@ -85,15 +85,15 @@ public class BigSwitchBcfApi {
* in the unittests.
*/
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;
try {
url = new URL(s_protocol, _host, port, uri).toString();
url = new URL(S_PROTOCOL, host, port, uri).toString();
} 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);
}
@ -118,7 +118,7 @@ public class BigSwitchBcfApi {
// Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), _port));
} 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
* @param address
*/
public void setControllerAddress(String address) {
this._host = address;
public void setControllerAddress(final String address) {
this.host = address;
}
/**
* Setter used by UI to set BSN controller user name
* @param username
*/
public void setControllerUsername(String username) {
this._username = username;
public void setControllerUsername(final String username) {
this.username = username;
}
/**
* Setter used by UI to set BSN controller password
* @param password
*/
public void setControllerPassword(String password) {
this._password = password;
public void setControllerPassword(final String password) {
this.password = password;
}
/**
* Setter used by UI to set BSN controller NAT mode
* @param nat
*/
public void setControllerNat(Boolean nat) {
this._nat = nat;
public void setControllerNat(final Boolean nat) {
this.nat = nat;
}
public boolean isNatEnabled() {
return this._nat;
return this.nat;
}
/**
* Setter used by UI to set BSN controller password
* @param password
*/
public void setZoneId(String zoneId) {
this._zoneId = zoneId;
public void setZoneId(final String zoneId) {
this.zoneId = zoneId;
}
public String createNetwork(NetworkData network) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + network.getNetwork().getTenantId() + "/networks";
public String createNetwork(final NetworkData network) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + network.getNetwork().getTenantId() + "/networks";
return executeCreateObject(network, uri, Collections.<String, String> emptyMap());
}
public String deleteNetwork(String tenantId, String networkId) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId;
public String deleteNetwork(final String tenantId, final String networkId) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId;
return executeDeleteObject(uri);
}
public String createAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment";
public String createAttachment(final String tenantId, final String networkId,
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());
}
public String modifyAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment";
public String modifyAttachment(final String tenantId, final String networkId,
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());
}
public String deleteAttachment(String tenantId, String networkId, String attachmentId) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment";
public String deleteAttachment(final String tenantId, final String networkId,
final String attachmentId) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment";
return executeDeleteObject(uri);
}
public String createRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers";
public String createRouter(final String tenantId, final RouterData router) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers";
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{
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers";
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers";
return executeCreateObject(router, uri, Collections.<String, String> emptyMap());
}
public String createRouterInterface(String tenantId, String routerId, RouterInterfaceData routerInterface) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces";
public String createRouterInterface(final String tenantId, final String routerId,
final RouterInterfaceData routerInterface) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces";
return executeCreateObject(routerInterface, uri, Collections.<String, String> emptyMap());
}
public String createFloatingIp(String tenantId, FloatingIpData fip) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips";
public String createFloatingIp(final String tenantId, final FloatingIpData fip) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips";
return executeCreateObject(fip, uri, Collections.<String, String> emptyMap());
}
public String deleteFloatingIp(String tenantId, String fipId) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips/" + fipId;
public String deleteFloatingIp(final String tenantId, final String fipId) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips/" + fipId;
return executeDeleteObject(uri);
}
public ControlClusterStatus getControlClusterStatus() throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/health";
String uri = S_NS_BASE_URL + "/health";
ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
}.getType(), uri, null);
ccs.setStatus(true);
@ -226,7 +226,7 @@ public class BigSwitchBcfApi {
}
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>>() {
}.getType(), uri, null);
Capabilities caps = new Capabilities();
@ -234,28 +234,28 @@ public class BigSwitchBcfApi {
return caps;
}
public String syncTopology(TopologyData topo) throws BigSwitchBcfApiException {
String uri = s_nsBaseUri + "/topology";
public String syncTopology(final TopologyData topo) throws BigSwitchBcfApiException {
String uri = S_NS_BASE_URL + "/topology";
return executeCreateObject(topo, uri, Collections.<String, String> emptyMap());
}
public ControllerData getControllerData() {
return new ControllerData(_host, _isMaster);
return new ControllerData(host, isMaster);
}
private void checkInvariants() throws BigSwitchBcfApiException{
if (_host == null || _host.isEmpty()) {
if (host == null || host.isEmpty()) {
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");
}
if (_password == null || _password.isEmpty()){
if (password == null || password.isEmpty()){
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{
String customErrorMsg = null;
if (m.getStatusCode() == HttpStatus.SC_OK) {
@ -273,7 +273,7 @@ public class BigSwitchBcfApi {
throw new BigSwitchBcfApiException("BCF topology sync required", true);
}
if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) {
_isMaster = false;
isMaster = false;
set_hash(HASH_IGNORE);
return HASH_IGNORE;
}
@ -288,24 +288,25 @@ public class BigSwitchBcfApi {
}
String errorMessage = responseToErrorMessage(m);
m.releaseConnection();
s_logger.error(errorMessageBase + errorMessage);
S_LOGGER.error(errorMessageBase + errorMessage);
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(ACCEPT, CONTENT_JSON);
m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + _zoneId);
if (_hash != "" ) {
m.setRequestHeader(HASH_MATCH, _hash);
m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + zoneId);
if (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")));
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{
checkInvariants();
@ -328,7 +329,8 @@ public class BigSwitchBcfApi {
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();
PostMethod pm = (PostMethod)createMethod("post", uri, _port);
@ -350,7 +352,7 @@ public class BigSwitchBcfApi {
return hash;
}
protected String executeDeleteObject(String uri) throws BigSwitchBcfApiException {
protected String executeDeleteObject(final String uri) throws BigSwitchBcfApiException {
checkInvariants();
DeleteMethod dm = (DeleteMethod)createMethod("delete", uri, _port);
@ -367,8 +369,8 @@ public class BigSwitchBcfApi {
}
@SuppressWarnings("unchecked")
protected <T> T executeRetrieveObject(Type returnObjectType,
String uri, Map<String, String> parameters) throws BigSwitchBcfApiException {
protected <T> T executeRetrieveObject(final Type returnObjectType,
final String uri, final Map<String, String> parameters) throws BigSwitchBcfApiException {
checkInvariants();
GetMethod gm = (GetMethod)createMethod("get", uri, _port);
@ -392,41 +394,41 @@ public class BigSwitchBcfApi {
// CAUTIOUS: Safety margin of 2048 characters - extend if needed.
returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(2048), returnObjectType);
} 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);
} finally {
gm.releaseConnection();
}
if(returnValue instanceof ControlClusterStatus) {
if(hash == HASH_CONFLICT) {
_isMaster = true;
isMaster = true;
((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
} else if (hash != HASH_IGNORE && !_isMaster) {
_isMaster = true;
} else if (hash != HASH_IGNORE && !isMaster) {
isMaster = true;
((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
}
}
return returnValue;
}
protected void executeMethod(HttpMethodBase method) throws BigSwitchBcfApiException {
protected void executeMethod(final HttpMethodBase method) throws BigSwitchBcfApiException {
try {
_client.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
method.releaseConnection();
}
} 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();
throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", 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();
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";
if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
@ -436,7 +438,7 @@ public class BigSwitchBcfApi {
try {
return method.getResponseBodyAsString(2048);
} 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() {
return _hash;
return hash;
}
public void set_hash(String hash) {
this._hash = hash;
public void set_hash(final String hash) {
this.hash = hash;
}
}

View File

@ -486,7 +486,7 @@ public class BigSwitchBcfUtils {
}
String newHash = answer.getHash();
if (cmd.is_topologySyncRequested()) {
if (cmd.isTopologySyncRequested()) {
newHash = syncTopologyToBcfHost(cluster.getMaster());
}
if(newHash != null){
@ -519,7 +519,7 @@ public class BigSwitchBcfUtils {
});
}
public boolean isNatEnabled() {
public Boolean isNatEnabled(){
List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listAll();
if(devices != null && !devices.isEmpty()){
return devices.get(0).getNat();
@ -528,8 +528,6 @@ public class BigSwitchBcfUtils {
}
}
// returns null: should throw something^%*%#&
// Integer -> int
public Integer getSubnetMaskLength(String maskString){
if(!IPAddress.isValidIPv4(maskString)){
return null;

View File

@ -30,26 +30,25 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.commons.net.util.SubnetUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import org.apache.commons.net.util.SubnetUtils;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.BcfAnswer;
import com.cloud.agent.api.UpdateBcfRouterCommand;
import com.cloud.agent.api.CreateBcfAttachmentCommand;
import com.cloud.agent.api.CreateBcfStaticNatCommand;
import com.cloud.agent.api.DeleteBcfAttachmentCommand;
import com.cloud.agent.api.DeleteBcfStaticNatCommand;
import com.cloud.agent.api.StartupBigSwitchBcfCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.UpdateBcfRouterCommand;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.commands.AddBigSwitchBcfDeviceCmd;
import com.cloud.api.commands.BcfConstants;
import com.cloud.api.commands.DeleteBigSwitchBcfDeviceCmd;
import com.cloud.api.commands.ListBigSwitchBcfDevicesCmd;
import com.cloud.api.commands.BcfConstants;
import com.cloud.api.response.BigSwitchBcfDeviceResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenterVO;
@ -209,7 +208,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
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());
return false;
}
@ -411,7 +410,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
ServerResource resource = new BigSwitchBcfResource();
final String deviceName = BcfConstants.BigSwitchBcf.getName();
final String deviceName = BcfConstants.BIG_SWITCH_BCF.getName();
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
final String hostname = cmd.getHost();
@ -452,7 +451,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter {
zoneName = String.valueOf(zoneId);
}
boolean natNow = _bcfUtils.isNatEnabled();
Boolean natNow = _bcfUtils.isNatEnabled();
if (!nat && natNow){
throw new CloudRuntimeException("NAT is enabled in existing controller. Enable NAT for new controller or remove existing controller first.");
} else if (nat && !natNow){

View File

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