cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [4/8] git commit: updated refs/heads/master to 770297e
Date Thu, 09 Apr 2015 07:45:40 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java
new file mode 100644
index 0000000..4b6cc3a
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java
@@ -0,0 +1,37 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.api.commands;
+
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+
+import com.cloud.network.Network.Provider;
+
+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 Provider BigSwitchBcf = new Provider("BigSwitchBcf", true);
+
+    public static final NetworkDevice BigSwitchBcfDevice = new NetworkDevice("BigSwitchBcf", BigSwitchBcf.getName());
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java
new file mode 100644
index 0000000..520be8d
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java
@@ -0,0 +1,110 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.api.commands;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.api.response.BigSwitchBcfDeviceResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.element.BigSwitchBcfElementService;
+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";
+    @Inject
+    BigSwitchBcfElementService _bigswitchBcfElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = BcfConstants.BIGSWITCH_BCF_DEVICE_ID,
+               type = CommandType.UUID,
+               entityType = BigSwitchBcfDeviceResponse.class,
+               required = true,
+               description = "BigSwitch device ID")
+    private Long bigswitchBcfDeviceId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getBigSwitchBcfDeviceId() {
+        return bigswitchBcfDeviceId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+        ResourceAllocationException {
+        try {
+            boolean result = _bigswitchBcfElementService.deleteBigSwitchBcfDevice(this);
+            if (result) {
+                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());
+        } catch (CloudRuntimeException runtimeExcp) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
+        }
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccount().getId();
+    }
+
+    @Override
+    public String getEventType() {
+        return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting BigSwitch BCF Controller";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java
new file mode 100644
index 0000000..25c6752
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java
@@ -0,0 +1,114 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+
+import com.cloud.api.response.BigSwitchBcfDeviceResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.BigSwitchBcfDeviceVO;
+import com.cloud.network.element.BigSwitchBcfElementService;
+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";
+    @Inject
+    BigSwitchBcfElementService _bigswitchBcfElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
+    private Long physicalNetworkId;
+
+    @Parameter(name = BcfConstants.BIGSWITCH_BCF_DEVICE_ID,
+               type = CommandType.UUID,
+               entityType = BigSwitchBcfDeviceResponse.class,
+               description = "bigswitch BCF controller device ID")
+    private Long bigswitchBcfDeviceId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getBigSwitchBcfDeviceId() {
+        return bigswitchBcfDeviceId;
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    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>();
+
+            if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
+                for (BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) {
+                    BigSwitchBcfDeviceResponse bigswitchDeviceResponse = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO);
+                    bigswitchDevicesResponse.add(bigswitchDeviceResponse);
+                }
+            }
+
+            response.setResponses(bigswitchDevicesResponse);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } catch (InvalidParameterValueException invalidParamExcp) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
+        } catch (CloudRuntimeException runtimeExcp) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
+        }
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java b/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java
new file mode 100644
index 0000000..37906a5
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java
@@ -0,0 +1,99 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.api.response;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.api.commands.BcfConstants;
+import com.cloud.network.BigSwitchBcfDeviceVO;
+import com.cloud.serializer.Param;
+
+@EntityReference(value = BigSwitchBcfDeviceVO.class)
+public class BigSwitchBcfDeviceResponse extends BaseResponse {
+    @SerializedName(BcfConstants.BIGSWITCH_BCF_DEVICE_ID)
+    @Param(description = "device id of the BigSwitch BCF Controller")
+    private String id;
+
+    @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
+    @Param(description = "the physical network to which this BigSwitch BCF segment belongs to")
+    private String physicalNetworkId;
+
+    @SerializedName(ApiConstants.PROVIDER)
+    @Param(description = "name of the provider")
+    private String providerName;
+
+    @SerializedName(BcfConstants.BIGSWITCH_BCF_DEVICE_NAME)
+    @Param(description = "device name")
+    private String deviceName;
+
+    @SerializedName(ApiConstants.HOST_NAME)
+    @Param(description = "the controller Ip address")
+    private String hostName;
+
+    @SerializedName(ApiConstants.USERNAME) @Param(description="the controller username")
+    private String username;
+
+    @SerializedName(ApiConstants.PASSWORD) @Param(description="the controller password")
+    private String password;
+
+    @SerializedName(BcfConstants.BIGSWITCH_BCF_DEVICE_NAT)
+    @Param(description = "NAT support")
+    private Boolean nat;
+
+    public String getId() {
+        return this.id;
+    }
+
+    public void setId(String bcfDeviceId) {
+        this.id = bcfDeviceId;
+    }
+
+    public void setPhysicalNetworkId(String physicalNetworkId) {
+        this.physicalNetworkId = physicalNetworkId;
+    }
+
+    public void setProviderName(String providerName) {
+        this.providerName = providerName;
+    }
+
+    public void setDeviceName(String deviceName) {
+        this.deviceName = deviceName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public void setUserName(String username) {
+        this.username = username;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setNat(Boolean nat) {
+        this.nat = nat;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java b/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java
new file mode 100644
index 0000000..8c7269e
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java
@@ -0,0 +1,143 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network;
+
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "external_bigswitch_bcf_devices")
+public class BigSwitchBcfDeviceVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "uuid")
+    private String uuid;
+
+    @Column(name = "host_id")
+    private long hostId;
+
+    @Column(name = "physical_network_id")
+    private long physicalNetworkId;
+
+    @Column(name = "provider_name")
+    private String providerName;
+
+    @Column(name = "device_name")
+    private String deviceName;
+
+    @Column(name = "hostname")
+    private String hostName;
+
+    @Column(name = "username")
+    private String userName;
+
+    @Column(name = "password")
+    private String password;
+
+    @Column(name = "nat")
+    private Boolean nat;
+
+    @Column(name = "hash")
+    private String hash;
+
+    public BigSwitchBcfDeviceVO() {
+        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) {
+        super();
+        this.hostId = hostId;
+        this.physicalNetworkId = physicalNetworkId;
+        this.providerName = providerName;
+        this.deviceName = deviceName;
+        this.uuid = UUID.randomUUID().toString();
+        this.hostName = hostName;
+        this.userName = username;
+        this.password = password;
+        this.nat = nat;
+        this.hash = hash;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public long getHostId() {
+        return hostId;
+    }
+
+    public String getProviderName() {
+        return providerName;
+    }
+
+    public String getDeviceName() {
+        return deviceName;
+    }
+
+    public String getHash() {
+        return hash;
+    }
+
+    public void setHash(String h) {
+        hash = h;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public Boolean getNat() {
+        return nat;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java
new file mode 100644
index 0000000..72b0cc9
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java
@@ -0,0 +1,114 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import com.cloud.network.vpc.NetworkACLItem;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * AclData contains information expected by Big Switch Controller
+ * in ApplyBcfAclCommand
+ */
+
+public class AclData {
+    @SerializedName("id") private String id;
+    @SerializedName("priority") private int priority;
+    @SerializedName("action") private String action;
+    @SerializedName("ipproto") private String ipProto;
+    @SerializedName("source") private AclNetwork source;
+    @SerializedName("destination") private AclNetwork destination;
+
+    public AclData(){
+        this.id = null;
+        this.priority = 0;
+        this.action = null;
+        this.ipProto = null;
+        this.source = new AclNetwork();
+        this.destination = new AclNetwork();;
+    }
+
+    public class AclNetwork{
+        @SerializedName("cidr") private String cidr;
+        @SerializedName("port") private Integer port;
+
+        public AclNetwork(){
+            this.cidr = null;
+            this.port = null;
+        }
+
+        public AclNetwork(String cidr, Integer port){
+            this.cidr = cidr;
+            this.port = port;
+        }
+    }
+
+    public String getId() {
+        return id;
+    }
+    public void setId(String id) {
+        this.id = id;
+    }
+    public int getPriority() {
+        return priority;
+    }
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+    public String getAction() {
+        return action;
+    }
+    public void setAction(String action) {
+        if(action.equalsIgnoreCase(NetworkACLItem.Action.Allow.name())){
+            this.action = "permit";
+        } else {
+            this.action = "deny";
+        }
+    }
+    public String getIpProto() {
+        return ipProto;
+    }
+    public void setIpProto(String ipProto) {
+        if (!ipProto.equalsIgnoreCase("all")){
+            switch(ipProto.toLowerCase()){
+            case "tcp":
+                this.ipProto = "6";
+                break;
+            case "udp":
+                this.ipProto = "17";
+                break;
+            case "icmp":
+                this.ipProto = "1";
+                break;
+            }
+        }
+    }
+    public AclNetwork getSource() {
+        return source;
+    }
+    public void setSource(AclNetwork source) {
+        this.source = source;
+    }
+    public AclNetwork getDestination() {
+        return destination;
+    }
+    public void setDestination(AclNetwork destination) {
+        this.destination = destination;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java
new file mode 100644
index 0000000..649f704
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java
@@ -0,0 +1,142 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import java.util.ArrayList;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * AttachmentData contains information expected by Big Switch Controller
+ * in CreateBcfAttachmentCommand
+ */
+public class AttachmentData {
+    @SerializedName("port") private Attachment attachment;
+
+    public Attachment getAttachment() {
+        return this.attachment;
+    }
+
+    public AttachmentData() {
+        this.attachment = new Attachment();
+    }
+
+    public class Attachment {
+        @SerializedName("id") private String id;
+        @SerializedName("tenant_name") private String tenantName;
+        @SerializedName("vlan") private Integer vlan;
+        @SerializedName("fixed_ips") private ArrayList<IpAddress> fixedIps;
+        @SerializedName("mac_address") private String macAddress;
+        @SerializedName("bound_segment") private BoundSegment boundSegment;
+        @SerializedName("binding:host_id") private String hostId;
+
+        public Attachment(){
+            this.boundSegment = new BoundSegment();
+            this.fixedIps = new ArrayList<IpAddress>();
+        }
+
+        public class BoundSegment {
+            @SerializedName("segmentation_id") private Integer segmentationId;
+
+            public Integer getSegmentationId() {
+                return segmentationId;
+            }
+
+            public void setSegmentationId(Integer segmentationId) {
+                this.segmentationId = segmentationId;
+            }
+        }
+
+        public class IpAddress {
+            @SerializedName("ip_address") private String ipAddress;
+
+            public IpAddress(String ipAddr) {
+                this.ipAddress = ipAddr;
+            }
+
+            public String getIpAddress(){
+                return ipAddress;
+            }
+        }
+
+        private String state;
+
+        public String getTenantName() {
+            return tenantName;
+        }
+
+        public void setTenantName(String tenantName) {
+            this.tenantName = tenantName;
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        public String getHostId() {
+            return hostId;
+        }
+
+        public void setHostId(String hostId) {
+            this.hostId = hostId;
+        }
+
+        public Integer getVlan() {
+            return vlan;
+        }
+
+        public void setVlan(Integer vlan) {
+            this.vlan = vlan;
+            this.boundSegment.setSegmentationId(vlan);
+        }
+
+        public ArrayList<IpAddress> getIpv4List() {
+            return fixedIps;
+        }
+
+        public void addIpv4(String ipv4) {
+            this.fixedIps.add(new IpAddress(ipv4));
+        }
+
+        public String getMac() {
+            return macAddress;
+        }
+
+        public void setMac(String mac) {
+            this.macAddress = mac;
+        }
+
+        public BoundSegment getBoundSegment() {
+            return boundSegment;
+        }
+
+        public String getState() {
+            return state;
+        }
+
+        public void setState(String state) {
+            this.state = state;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java
new file mode 100644
index 0000000..5c1efb0
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java
@@ -0,0 +1,459 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.log4j.Logger;
+
+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 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 String _host;
+    private String _username;
+    private String _password;
+    private String _hash;
+    private String _zoneId;
+    private Boolean _nat;
+
+    private boolean _isMaster = false;
+
+    private int _port = 8000;
+
+    private HttpClient _client;
+    private Gson gson = new Gson();
+
+    public final static String HASH_CONFLICT = "HASH_CONFLICT";
+    public final static String HASH_IGNORE = "HASH_IGNORE";
+
+    /* This factory method is protected so we can extend this
+     * in the unittests.
+     */
+    protected HttpClient createHttpClient() {
+        return new HttpClient(s_httpClientManager);
+    }
+
+    protected HttpMethod createMethod(String type, String uri, int port) throws BigSwitchBcfApiException {
+        String url;
+        try {
+            url = new URL(s_protocol, _host, port, uri).toString();
+        } catch (MalformedURLException e) {
+            s_logger.error("Unable to build Big Switch API URL", e);
+            throw new BigSwitchBcfApiException("Unable to build Big Switch API URL", e);
+        }
+
+        if ("post".equalsIgnoreCase(type)) {
+            return new PostMethod(url);
+        } else if ("get".equalsIgnoreCase(type)) {
+            return new GetMethod(url);
+        } else if ("delete".equalsIgnoreCase(type)) {
+            return new DeleteMethod(url);
+        } else if ("put".equalsIgnoreCase(type)) {
+            return new PutMethod(url);
+        } else {
+            throw new BigSwitchBcfApiException("Requesting unknown method type");
+        }
+    }
+
+    public BigSwitchBcfApi() {
+        _client = createHttpClient();
+        _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+
+        try {
+            // 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);
+        }
+    }
+
+    /**
+     * Setter used by UI to set BSN controller address
+     * @param address
+     */
+    public void setControllerAddress(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;
+    }
+
+    /**
+     * Setter used by UI to set BSN controller password
+     * @param password
+     */
+    public void setControllerPassword(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 boolean isNatEnabled() {
+        return this._nat;
+    }
+
+    /**
+     * Setter used by UI to set BSN controller password
+     * @param password
+     */
+    public void setZoneId(String zoneId) {
+        this._zoneId = zoneId;
+    }
+
+    public String createNetwork(NetworkData network) throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/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;
+        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";
+        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";
+        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";
+        return executeDeleteObject(uri);
+    }
+
+    public String createRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers";
+        return executeCreateObject(router, uri, Collections.<String, String> emptyMap());
+    }
+
+    public String modifyRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException,
+    IllegalArgumentException{
+        String uri = s_nsBaseUri + "/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";
+        return executeCreateObject(routerInterface, uri, Collections.<String, String> emptyMap());
+    }
+
+    public String createFloatingIp(String tenantId, FloatingIpData fip) throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/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;
+        return executeDeleteObject(uri);
+    }
+
+    public ControlClusterStatus getControlClusterStatus() throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/health";
+        ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
+        }.getType(), uri, null);
+        ccs.setStatus(true);
+        return ccs;
+    }
+
+    public Capabilities getCapabilities() throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/capabilities";
+        List<String> capslist = executeRetrieveObject(new TypeToken<List<String>>() {
+        }.getType(), uri, null);
+        Capabilities caps = new Capabilities();
+        caps.setCapabilities(capslist);
+        return caps;
+    }
+
+    public String syncTopology(TopologyData topo) throws BigSwitchBcfApiException {
+        String uri = s_nsBaseUri + "/topology";
+        return executeCreateObject(topo, uri, Collections.<String, String> emptyMap());
+    }
+
+    public ControllerData getControllerData() {
+        return new ControllerData(_host, _isMaster);
+    }
+
+    private void checkInvariants() throws BigSwitchBcfApiException{
+        if (_host == null || _host.isEmpty()) {
+            throw new BigSwitchBcfApiException("Hostname is null or empty");
+        }
+        if (_username == null || _username.isEmpty()){
+            throw new BigSwitchBcfApiException("Username is null or empty");
+        }
+        if (_password == null || _password.isEmpty()){
+            throw new BigSwitchBcfApiException("Password is null or empty");
+        }
+    }
+
+    private String checkResponse(HttpMethodBase m, String errorMessageBase) throws BigSwitchBcfApiException,
+    IllegalArgumentException{
+        String customErrorMsg = null;
+        if (m.getStatusCode() == HttpStatus.SC_OK) {
+            String hash = "";
+            if (m.getResponseHeader(HASH_MATCH) != null) {
+                hash = m.getResponseHeader(HASH_MATCH).getValue();
+                set_hash(hash);
+            }
+            return hash;
+        }
+        if (m.getStatusCode() == HttpStatus.SC_CONFLICT) {
+            if(m instanceof GetMethod) {
+                return HASH_CONFLICT;
+            }
+            throw new BigSwitchBcfApiException("BCF topology sync required", true);
+        }
+        if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) {
+            _isMaster = false;
+            set_hash(HASH_IGNORE);
+            return HASH_IGNORE;
+        }
+        if (m.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
+            if (m instanceof DeleteMethod){
+                return "";
+            }
+        }
+        if (m.getStatusCode() == HttpStatus.SC_BAD_REQUEST) {
+            customErrorMsg = " Invalid data in BCF request";
+            throw new IllegalArgumentException(customErrorMsg);
+        }
+        String errorMessage = responseToErrorMessage(m);
+        m.releaseConnection();
+        s_logger.error(errorMessageBase + errorMessage);
+        throw new BigSwitchBcfApiException(errorMessageBase + errorMessage + customErrorMsg);
+    }
+
+    private void setHttpHeader(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);
+        }
+
+        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,
+    IllegalArgumentException{
+        checkInvariants();
+
+        PutMethod pm = (PutMethod)createMethod("put", uri, _port);
+
+        setHttpHeader(pm);
+
+        try {
+            pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), CONTENT_JSON, null));
+        } catch (UnsupportedEncodingException e) {
+            throw new BigSwitchBcfApiException("Failed to encode json request body", e);
+        }
+
+        executeMethod(pm);
+
+        String hash = checkResponse(pm, "BigSwitch HTTP update failed: ");
+
+        pm.releaseConnection();
+
+        return hash;
+    }
+
+    protected <T> String executeCreateObject(T newObject, String uri, Map<String, String> parameters) throws BigSwitchBcfApiException {
+        checkInvariants();
+
+        PostMethod pm = (PostMethod)createMethod("post", uri, _port);
+
+        setHttpHeader(pm);
+
+        try {
+            pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), CONTENT_JSON, null));
+        } catch (UnsupportedEncodingException e) {
+            throw new BigSwitchBcfApiException("Failed to encode json request body", e);
+        }
+
+        executeMethod(pm);
+
+        String hash = checkResponse(pm, "BigSwitch HTTP create failed: ");
+
+        pm.releaseConnection();
+
+        return hash;
+    }
+
+    protected String executeDeleteObject(String uri) throws BigSwitchBcfApiException {
+        checkInvariants();
+
+        DeleteMethod dm = (DeleteMethod)createMethod("delete", uri, _port);
+
+        setHttpHeader(dm);
+
+        executeMethod(dm);
+
+        String hash = checkResponse(dm, "BigSwitch HTTP delete failed: ");
+
+        dm.releaseConnection();
+
+        return hash;
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T executeRetrieveObject(Type returnObjectType,
+            String uri, Map<String, String> parameters) throws BigSwitchBcfApiException {
+        checkInvariants();
+
+        GetMethod gm = (GetMethod)createMethod("get", uri, _port);
+
+        setHttpHeader(gm);
+
+        if (parameters != null && !parameters.isEmpty()) {
+            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
+            for (Entry<String, String> e : parameters.entrySet()) {
+                nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
+            }
+            gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
+        }
+
+        executeMethod(gm);
+
+        String hash = checkResponse(gm, "BigSwitch HTTP get failed: ");
+
+        T returnValue;
+        try {
+            // 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);
+            throw new BigSwitchBcfApiException(e);
+        } finally {
+            gm.releaseConnection();
+        }
+        if(returnValue instanceof ControlClusterStatus) {
+            if(hash == HASH_CONFLICT) {
+                _isMaster = true;
+                ((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
+            } else if (hash != HASH_IGNORE && !_isMaster) {
+                _isMaster = true;
+                ((ControlClusterStatus) returnValue).setTopologySyncRequested(true);
+            }
+        }
+        return returnValue;
+    }
+
+    protected void executeMethod(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);
+            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);
+            method.releaseConnection();
+            throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e);
+        }
+    }
+
+    private String responseToErrorMessage(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())) {
+            // The error message is the response content
+            // Safety margin of 2048 characters, anything longer is probably useless
+            // and will clutter the logs
+            try {
+                return method.getResponseBodyAsString(2048);
+            } catch (IOException e) {
+                s_logger.debug("Error while loading response body", e);
+            }
+        }
+
+        // The default
+        return method.getStatusText();
+    }
+
+    public static String getCloudstackInstanceId() {
+        return CLOUDSTACK_INSTANCE_ID;
+    }
+
+    public String get_hash() {
+        return _hash;
+    }
+
+    public void set_hash(String hash) {
+        this._hash = hash;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApiException.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApiException.java
new file mode 100644
index 0000000..feed707
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApiException.java
@@ -0,0 +1,55 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+public class BigSwitchBcfApiException extends Exception {
+
+    private static final long serialVersionUID = -5864952230870945604L;
+    private boolean topologySyncRequested = false;
+
+    public BigSwitchBcfApiException() {
+    }
+
+    public BigSwitchBcfApiException(String message) {
+        super(message);
+    }
+
+    public BigSwitchBcfApiException(Throwable cause) {
+        super(cause);
+    }
+
+    public BigSwitchBcfApiException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public BigSwitchBcfApiException(String message, boolean syncRequest) {
+        super(message);
+        this.set_topologySyncRequested(syncRequest);
+    }
+
+    public boolean is_topologySyncRequested() {
+        return topologySyncRequested;
+    }
+
+    public void set_topologySyncRequested(boolean requested) {
+        this.topologySyncRequested = requested;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
new file mode 100644
index 0000000..b6e3359
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
@@ -0,0 +1,571 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.log4j.Logger;
+import org.bouncycastle.util.IPAddress;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.BcfAnswer;
+import com.cloud.agent.api.BcfCommand;
+import com.cloud.agent.api.CacheBcfTopologyCommand;
+import com.cloud.agent.api.GetControllerDataAnswer;
+import com.cloud.agent.api.GetControllerDataCommand;
+import com.cloud.agent.api.SyncBcfTopologyCommand;
+import com.cloud.dc.VlanVO;
+import com.cloud.dc.dao.VlanDao;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.BigSwitchBcfDeviceVO;
+import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.bigswitch.TopologyData.Port;
+import com.cloud.network.dao.BigSwitchBcfDao;
+import com.cloud.network.dao.FirewallRulesCidrsDao;
+import com.cloud.network.dao.FirewallRulesCidrsVO;
+import com.cloud.network.dao.FirewallRulesDao;
+import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.IPAddressVO;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.rules.FirewallRule.Purpose;
+import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.NetworkACLItemCidrsDao;
+import com.cloud.network.vpc.NetworkACLItemCidrsVO;
+import com.cloud.network.vpc.NetworkACLItemDao;
+import com.cloud.network.vpc.NetworkACLItemVO;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionCallback;
+import com.cloud.utils.db.TransactionStatus;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.NicVO;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.VMInstanceDao;
+
+public class BigSwitchBcfUtils {
+    private static final Logger s_logger = Logger.getLogger(BigSwitchBcfUtils.class);
+
+    private final NetworkDao _networkDao;
+    private final NicDao _nicDao;
+    private final VMInstanceDao _vmDao;
+    private final HostDao _hostDao;
+    private final VpcDao _vpcDao;
+    private final BigSwitchBcfDao _bigswitchBcfDao;
+    private final AgentManager _agentMgr;
+    private final VlanDao _vlanDao;
+    private final IPAddressDao _ipAddressDao;
+    private final FirewallRulesDao _fwRulesDao;
+    private final FirewallRulesCidrsDao _fwCidrsDao;
+    private final NetworkACLItemDao _aclItemDao;
+    private final NetworkACLItemCidrsDao _aclItemCidrsDao;
+    private final NetworkModel _networkModel;
+
+    public BigSwitchBcfUtils(NetworkDao networkDao,
+            NicDao nicDao, VMInstanceDao vmDao, HostDao hostDao,
+            VpcDao vpcDao, BigSwitchBcfDao bigswitchBcfDao,
+            AgentManager agentMgr, VlanDao vlanDao, IPAddressDao ipAddressDao,
+            FirewallRulesDao fwRulesDao, FirewallRulesCidrsDao fwCidrsDao,
+            NetworkACLItemDao aclItemDao, NetworkACLItemCidrsDao aclItemCidrsDao,
+            NetworkModel networkModel){
+        _networkDao = networkDao;
+        _nicDao = nicDao;
+        _vmDao = vmDao;
+        _hostDao = hostDao;
+        _vpcDao = vpcDao;
+        _bigswitchBcfDao = bigswitchBcfDao;
+        _agentMgr = agentMgr;
+        _vlanDao = vlanDao;
+        _ipAddressDao = ipAddressDao;
+        _fwRulesDao = fwRulesDao;
+        _fwCidrsDao = fwCidrsDao;
+        _aclItemDao = aclItemDao;
+        _aclItemCidrsDao = aclItemCidrsDao;
+        _networkModel = networkModel;
+    }
+
+    public ControlClusterData getControlClusterData(long physicalNetworkId){
+        ControlClusterData cluster = new ControlClusterData();
+
+        // reusable command to query all devices
+        GetControllerDataCommand cmd = new GetControllerDataCommand();
+
+        // retrieve all registered BCF devices
+        List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listByPhysicalNetwork(physicalNetworkId);
+        for (BigSwitchBcfDeviceVO d: devices){
+            HostVO bigswitchBcfHost = _hostDao.findById(d.getHostId());
+            if (bigswitchBcfHost == null){
+                continue;
+            }
+
+            _hostDao.loadDetails(bigswitchBcfHost);
+            GetControllerDataAnswer answer = (GetControllerDataAnswer) _agentMgr.easySend(bigswitchBcfHost.getId(), cmd);
+            if (answer != null){
+                if (answer.isMaster()) {
+                    cluster.setMaster(bigswitchBcfHost);
+                } else {
+                    cluster.setSlave(bigswitchBcfHost);
+                }
+            }
+        }
+        return cluster;
+    }
+
+    public TopologyData getTopology(){
+        long physicalNetworkId;
+        List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listAll();
+        if(!devices.isEmpty()){
+            physicalNetworkId = devices.get(0).getPhysicalNetworkId();
+            return getTopology(physicalNetworkId);
+        } else {
+            return null;
+        }
+    }
+
+    public NetworkVO getPublicNetwork(long physicalNetworkId){
+        List<NetworkVO> pubNets = _networkDao.listByPhysicalNetworkTrafficType(physicalNetworkId, TrafficType.Public);
+        return pubNets.get(0);
+    }
+
+    public TopologyData getTopology(long physicalNetworkId){
+        List<NetworkVO> networks;
+        List<NicVO> nics;
+
+        networks = _networkDao.listByPhysicalNetworkTrafficType(physicalNetworkId, TrafficType.Guest);
+
+        TopologyData topo = new TopologyData();
+
+        // networks:
+        // - all user created networks (VPC or non-VPC)
+        // - one external network
+        // routers:
+        // - per VPC (handle in network loop)
+        // - per stand-alone network (handle in network loop)
+        // - one external router
+
+        // handle external network first, only if NAT service is enabled
+        if(networks != null) {
+            if(!(networks.isEmpty()) && isNatEnabled()!=null && isNatEnabled()){
+                // get public net info - needed to set up source nat gateway
+                NetworkVO pubNet = getPublicNetwork(physicalNetworkId);
+
+                // locate subnet info
+                SearchCriteria<VlanVO> sc = _vlanDao.createSearchCriteria();
+                sc.setParameters("network_id", pubNet.getId());
+                VlanVO vlanVO = _vlanDao.findOneBy(sc);
+
+                // add tenant external network external
+                TopologyData.Network network = topo.new Network();
+                network.setId("external");
+                network.setName("external");
+                network.setTenantId("external");
+                network.setTenantName("external");
+
+                String pubVlan = null;
+                try {
+                    pubVlan = BroadcastDomainType.getValue(vlanVO.getVlanTag());
+                    if(StringUtils.isNumeric(pubVlan)){
+                        network.setVlan(Integer.valueOf(pubVlan));
+                    } else {
+                        // untagged
+                        pubVlan = "0";
+                    }
+                } catch (URISyntaxException e) {
+                    e.printStackTrace();
+                }
+
+                topo.addNetwork(network);
+            }
+        }
+
+        // routerMap used internally for multiple updates to same tenant's router
+        // add back to topo.routers after loop
+        HashMap<String, RouterData> routerMap = new HashMap<String, RouterData>();
+
+        for (NetworkVO netVO: networks){
+            TopologyData.Network network = topo.new Network();
+            network.setId(netVO.getUuid());
+            network.setName(netVO.getName());
+
+            Integer vlan = null;
+            if (netVO.getBroadcastUri() != null) {
+                String vlanStr = BroadcastDomainType.getValue(netVO.getBroadcastUri());
+                if(StringUtils.isNumeric(vlanStr)){
+                    vlan = Integer.valueOf(vlanStr);
+                } else {
+                    // untagged
+                    vlan = 0;
+                }
+            }
+            network.setVlan(vlan);
+            network.setState(netVO.getState().name());
+
+            nics = _nicDao.listByNetworkId(netVO.getId());
+            List<Port> ports = new ArrayList<Port>();
+            String tenantId = null;
+            String tenantName = null;
+
+            // if VPC network, assign BCF tenant id with vpc uuid
+            Vpc vpc = null;
+            if(netVO.getVpcId()!=null){
+                vpc = _vpcDao.acquireInLockTable(netVO.getVpcId());
+            }
+
+            if (vpc != null) {
+                tenantId = vpc.getUuid();
+                tenantName = vpc.getName();
+            } else {
+                tenantId = netVO.getUuid();
+                tenantName = netVO.getName();
+            }
+
+            for(NicVO nic: nics){
+                NetworkData netData = new NetworkData();
+                TopologyData.Port p = topo.new Port();
+
+                p.setAttachmentInfo(netData.new AttachmentInfo(nic.getUuid(),nic.getMacAddress()));
+
+                VMInstanceVO vm = _vmDao.findById(nic.getInstanceId());
+                HostVO host = _hostDao.findById(vm.getHostId());
+
+                // if host not found, ignore this nic
+                if (host == null) {
+                    continue;
+                }
+
+                String hostname = host.getName();
+                long zoneId = netVO.getDataCenterId();
+                String vmwareVswitchLabel = _networkModel.getDefaultGuestTrafficLabel(zoneId, HypervisorType.VMware);
+                String[] labelArray = null;
+                String vswitchName = null;
+                if(vmwareVswitchLabel!=null){
+                    labelArray=vmwareVswitchLabel.split(",");
+                    vswitchName = labelArray[0];
+                }
+
+                // hypervisor type:
+                //   kvm: ivs port name
+                //   vmware: specific portgroup naming convention
+                String pgName = "";
+                if (host.getHypervisorType() == HypervisorType.KVM){
+                    pgName = hostname;
+                } else if (host.getHypervisorType() == HypervisorType.VMware){
+                    pgName = hostname + "-" + vswitchName;
+                }
+
+                p.setHostId(pgName);
+
+                p.setSegmentInfo(netData.new SegmentInfo(BroadcastDomainType.Vlan.name(), vlan));
+
+                p.setOwner(BigSwitchBcfApi.getCloudstackInstanceId());
+
+                List<AttachmentData.Attachment.IpAddress> ipList = new ArrayList<AttachmentData.Attachment.IpAddress>();
+                ipList.add(new AttachmentData().getAttachment().new IpAddress(nic.getIp4Address()));
+                p.setIpAddresses(ipList);
+
+                p.setId(nic.getUuid());
+
+                p.setMac(nic.getMacAddress());
+
+                netData.getNetwork().setId(network.getId());
+                netData.getNetwork().setName(network.getName());
+                netData.getNetwork().setTenantId(tenantId);
+                netData.getNetwork().setTenantName(tenantName);
+                netData.getNetwork().setState(netVO.getState().name());
+
+                p.setNetwork(netData.getNetwork());
+                ports.add(p);
+            }
+            network.setTenantId(tenantId);
+            network.setTenantName(tenantName);
+            network.setPorts(ports);
+            topo.addNetwork(network);
+
+            // add router for network
+            RouterData routerData;
+            if(tenantId != null){
+                if(!routerMap.containsKey(tenantId)){
+                    routerData = new RouterData(tenantId);
+                    routerMap.put(tenantId, routerData);
+                } else {
+                    routerData = routerMap.get(tenantId);
+                }
+
+                routerData.getRouter().getAcls().addAll(listACLbyNetwork(netVO));
+                if(vpc != null){
+                    routerData.getRouter().addExternalGateway(getPublicIpByVpc(vpc));
+                } else {
+                    routerData.getRouter().addExternalGateway(getPublicIpByNetwork(netVO));
+                }
+
+                RouterInterfaceData intf = new RouterInterfaceData(tenantId, netVO.getGateway(), netVO.getCidr(),
+                        netVO.getUuid(), netVO.getName());
+                routerData.getRouter().addInterface(intf);
+            }
+        }
+
+        for(RouterData rd: routerMap.values()) {
+            topo.addRouter(rd.getRouter());
+        }
+
+        return topo;
+    }
+
+    public String getPublicIpByNetwork(Network network){
+        List<IPAddressVO> allocatedIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
+        for (IPAddressVO ip: allocatedIps){
+            if(ip.isSourceNat()){
+                return ip.getAddress().addr();
+            }
+        }
+        return null;
+    }
+
+    public String getPublicIpByVpc(Vpc vpc){
+        List<IPAddressVO> allocatedIps = _ipAddressDao.listByAssociatedVpc(vpc.getId(), true);
+        for (IPAddressVO ip: allocatedIps){
+            if(ip.isSourceNat()){
+                return ip.getAddress().addr();
+            }
+        }
+        return null;
+    }
+
+    public List<AclData> listACLbyNetwork(Network network){
+        List<AclData> aclList = new ArrayList<AclData>();
+
+        List<FirewallRuleVO> fwRules;
+        fwRules = _fwRulesDao.listByNetworkAndPurposeAndNotRevoked(network.getId(), Purpose.Firewall);
+        List<FirewallRulesCidrsVO> fwCidrList = null;
+        SubnetUtils utils;
+
+        for(FirewallRuleVO rule: fwRules){
+            AclData acl = new AclData();
+            acl.setId(rule.getUuid());
+            acl.setPriority((int)rule.getId()); // CloudStack Firewall interface does not have priority
+            acl.setIpProto(rule.getProtocol());
+            String cidr = null;
+            Integer port = rule.getSourcePortStart();
+            fwCidrList = _fwCidrsDao.listByFirewallRuleId(rule.getId());
+            if(fwCidrList != null){
+                if(fwCidrList.size()>1 || rule.getSourcePortEnd()!=port){
+                    continue;
+                } else {
+                    cidr = fwCidrList.get(0).getCidr();
+                }
+            }
+            if (cidr == null || cidr.equalsIgnoreCase("0.0.0.0/0")) {
+                cidr = "";
+            } else {
+                utils = new SubnetUtils(cidr);
+                if(!utils.getInfo().getNetworkAddress().equals(utils.getInfo().getAddress())){
+                    continue;
+                }
+            }
+            acl.setSource(acl.new AclNetwork(cidr, port));
+            acl.setAction("permit");
+
+            aclList.add(acl);
+        }
+
+        List<NetworkACLItemVO> aclItems;
+        List<NetworkACLItemCidrsVO> aclCidrList;
+
+        if (network.getNetworkACLId() != null){
+            aclItems = _aclItemDao.listByACL(network.getNetworkACLId());
+            for(NetworkACLItem item: aclItems){
+                AclData acl = new AclData();
+                acl.setId(item.getUuid());
+                acl.setPriority(item.getNumber());
+                acl.setIpProto(item.getProtocol());
+                String cidr = null; // currently BCF supports single cidr policy
+                Integer port = item.getSourcePortStart(); // currently BCF supports single port policy
+                aclCidrList = _aclItemCidrsDao.listByNetworkACLItemId(item.getId());
+                if(aclCidrList != null){
+                    if(aclCidrList.size()>1 || item.getSourcePortEnd()!=port){
+                        continue;
+                    } else {
+                        cidr = aclCidrList.get(0).getCidr();
+                    }
+                }
+                if (cidr == null || cidr.equalsIgnoreCase("0.0.0.0/0")) {
+                    cidr = "";
+                } else {
+                    utils = new SubnetUtils(cidr);
+                    if(!utils.getInfo().getNetworkAddress().equals(utils.getInfo().getAddress())){
+                        continue;
+                    }
+                }
+                acl.setSource(acl.new AclNetwork(cidr, port));
+                acl.setAction(item.getAction().name());
+
+                aclList.add(acl);
+            }
+        }
+
+        return aclList;
+    }
+
+    public String syncTopologyToBcfHost(HostVO bigswitchBcfHost){
+        SyncBcfTopologyCommand syncCmd;
+        if(isNatEnabled()!=null && isNatEnabled()){
+            syncCmd = new SyncBcfTopologyCommand(true, true);
+        } else {
+            syncCmd = new SyncBcfTopologyCommand(true, false);
+        }
+        BcfAnswer syncAnswer = (BcfAnswer) _agentMgr.easySend(bigswitchBcfHost.getId(), syncCmd);
+        if (syncAnswer == null || !syncAnswer.getResult()) {
+            s_logger.error("SyncBcfTopologyCommand failed");
+            return null;
+        }
+        return syncAnswer.getHash();
+    }
+
+    public String syncTopologyToBcfHost(HostVO bigswitchBcfHost, boolean natEnabled){
+        SyncBcfTopologyCommand syncCmd;
+        if(natEnabled){
+            syncCmd = new SyncBcfTopologyCommand(true, true);
+        } else {
+            syncCmd = new SyncBcfTopologyCommand(true, false);
+        }
+        BcfAnswer syncAnswer = (BcfAnswer) _agentMgr.easySend(bigswitchBcfHost.getId(), syncCmd);
+        if (syncAnswer == null || !syncAnswer.getResult()) {
+            s_logger.error("SyncBcfTopologyCommand failed");
+            return null;
+        }
+        return syncAnswer.getHash();
+    }
+
+    public BcfAnswer sendBcfCommandWithNetworkSyncCheck(BcfCommand cmd, Network network)throws IllegalArgumentException{
+        // get registered Big Switch controller
+        ControlClusterData cluster = getControlClusterData(network.getPhysicalNetworkId());
+        if(cluster.getMaster()==null){
+            return new BcfAnswer(cmd, new CloudRuntimeException("Big Switch Network controller temporarily unavailable"));
+        }
+
+        TopologyData topo = getTopology(network.getPhysicalNetworkId());
+
+        cmd.setTopology(topo);
+        BcfAnswer answer =  (BcfAnswer) _agentMgr.easySend(cluster.getMaster().getId(), cmd);
+
+        if (answer == null || !answer.getResult()) {
+            s_logger.error ("BCF API Command failed");
+            throw new IllegalArgumentException("Failed API call to Big Switch Network plugin");
+        }
+
+        String newHash = answer.getHash();
+        if (cmd.is_topologySyncRequested()) {
+            newHash = syncTopologyToBcfHost(cluster.getMaster());
+        }
+        if(newHash != null){
+            commitTopologyHash(network.getPhysicalNetworkId(), newHash);
+        }
+
+        HostVO slave = cluster.getSlave();
+        if(slave != null){
+            TopologyData newTopo = getTopology(network.getPhysicalNetworkId());
+            CacheBcfTopologyCommand cacheCmd = new CacheBcfTopologyCommand(newTopo);
+            _agentMgr.easySend(cluster.getSlave().getId(), cacheCmd);
+        }
+
+        return answer;
+    }
+
+    @DB
+    public Boolean commitTopologyHash(long physicalNetworkId, final String hash) {
+        final List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listByPhysicalNetwork(physicalNetworkId);
+
+        return Transaction.execute(new TransactionCallback<Boolean>() {
+            @Override
+            public Boolean doInTransaction(TransactionStatus status) {
+                for (BigSwitchBcfDeviceVO d: devices){
+                    d.setHash(hash);
+                    _bigswitchBcfDao.update(d.getId(), d);
+                }
+                return true;
+            }
+        });
+    }
+
+    public Boolean isNatEnabled(){
+        List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listAll();
+        if(devices != null && !devices.isEmpty()){
+            return devices.get(0).getNat();
+        } else {
+            return null;
+        }
+    }
+
+    public Integer getSubnetMaskLength(String maskString){
+        if(!IPAddress.isValidIPv4(maskString)){
+            return null;
+        }
+        String[] octets = maskString.split(".");
+        Integer bits = 0;
+        for (String o: octets){
+            switch(o){
+            case "255":
+                bits += 8;
+                continue;
+            case "254":
+                bits += 7;
+                return bits;
+            case "252":
+                bits += 6;
+                return bits;
+            case "248":
+                bits += 5;
+                return bits;
+            case "240":
+                bits += 4;
+                return bits;
+            case "224":
+                bits += 3;
+                return bits;
+            case "192":
+                bits += 2;
+                return bits;
+            case "128":
+                bits += 1;
+                return bits;
+            case "0":
+                return bits;
+            default:
+                throw new NumberFormatException("non-contiguous subnet mask not supported");
+            }
+        }
+        return bits;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchStatus.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchStatus.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchStatus.java
new file mode 100644
index 0000000..0b3a895
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchStatus.java
@@ -0,0 +1,32 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+public class BigSwitchStatus {
+    private boolean topologySyncRequested = false;
+
+    public boolean isTopologySyncRequested() {
+        return topologySyncRequested;
+    }
+
+    public void setTopologySyncRequested(boolean topologySyncRequested) {
+        this.topologySyncRequested = topologySyncRequested;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/Capabilities.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/Capabilities.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/Capabilities.java
new file mode 100644
index 0000000..b033a84
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/Capabilities.java
@@ -0,0 +1,34 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import java.util.List;
+
+public class Capabilities extends BigSwitchStatus {
+    private List<String> capabilities;
+
+    public List<String> getCapabilities() {
+        return capabilities;
+    }
+
+    public void setCapabilities(List<String> caps) {
+        capabilities = caps;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterData.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterData.java
new file mode 100644
index 0000000..7d62899
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterData.java
@@ -0,0 +1,43 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import com.cloud.host.HostVO;
+
+public class ControlClusterData {
+    private HostVO master;
+    private HostVO slave;
+
+    public HostVO getMaster() {
+        return master;
+    }
+
+    public void setMaster(HostVO master) {
+        this.master = master;
+    }
+
+    public HostVO getSlave() {
+        return slave;
+    }
+
+    public void setSlave(HostVO slave) {
+        this.slave = slave;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterStatus.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterStatus.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterStatus.java
new file mode 100644
index 0000000..8a17bea
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControlClusterStatus.java
@@ -0,0 +1,32 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+public class ControlClusterStatus extends BigSwitchStatus {
+    private boolean healthy;
+
+    public boolean getStatus() {
+        return healthy;
+    }
+
+    public void setStatus(boolean status) {
+        this.healthy = status;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControllerData.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControllerData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControllerData.java
new file mode 100644
index 0000000..224a7ab
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/ControllerData.java
@@ -0,0 +1,39 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+public class ControllerData {
+    private final String ipAddress;
+    private final boolean isMaster;
+
+    public ControllerData(String ipAddress, boolean isMaster) {
+        this.ipAddress = ipAddress;
+        this.isMaster = isMaster;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public boolean isMaster() {
+        return isMaster;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/FloatingIpData.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/FloatingIpData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/FloatingIpData.java
new file mode 100644
index 0000000..6e2c422
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/FloatingIpData.java
@@ -0,0 +1,93 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.network.bigswitch;
+
+import com.google.gson.annotations.SerializedName;
+
+public class FloatingIpData {
+    @SerializedName("router_id") private String routerId;
+    @SerializedName("tenant_id") private String tenantId;
+    @SerializedName("floating_network_id") private String networkId;
+    @SerializedName("fixed_ip_address") private String fixedIp;
+    @SerializedName("floating_ip_address") private String floatingIp;
+    @SerializedName("floating_mac_address") private String mac;
+    @SerializedName("id") private String id;
+
+    public FloatingIpData(){
+        this.mac = null;
+    }
+
+    public String getRouterId() {
+        return routerId;
+    }
+
+    public void setRouterId(String routerId) {
+        this.routerId = routerId;
+    }
+
+    public String getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(String tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getNetworkId() {
+        return networkId;
+    }
+
+    public void setNetworkId(String networkId) {
+        this.networkId = networkId;
+    }
+
+    public String getFixedIp() {
+        return fixedIp;
+    }
+
+    public void setFixedIp(String fixedIp) {
+        this.fixedIp = fixedIp;
+    }
+
+    public String getFloatingIp() {
+        return floatingIp;
+    }
+
+    /***
+     * current implementation auto-generates id using public ip
+     * replacing "." with "-"
+     ***/
+    public void setFloatingIpAndId(String floatingIp) {
+        this.floatingIp = floatingIp;
+        this.id = floatingIp.replace(".", "-");
+    }
+
+    public String getMac() {
+        return mac;
+    }
+
+    public void setMac(String mac) {
+        this.mac = mac;
+    }
+
+    public String getId() {
+        return id;
+    }
+}


Mime
View raw message