You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/23 11:11:28 UTC

[1/4] git commit: updated refs/heads/master to 930e4a2

Repository: cloudstack
Updated Branches:
  refs/heads/master 0ac2eb4f6 -> 930e4a2a6


Add empty findbugs exclusion files for the new modules


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/930e4a2a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/930e4a2a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/930e4a2a

Branch: refs/heads/master
Commit: 930e4a2a6f604df3560c76bd2b38faf75b6a3709
Parents: 628d8e6
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Wed Jul 23 11:09:04 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Wed Jul 23 11:11:18 2014 +0200

----------------------------------------------------------------------
 .../brocade-vcs/findbugsExcludeFilter.xml       | 25 ++++++++++++++++++++
 .../nuage-vsp/findbugsExcludeFilter.xml         | 25 ++++++++++++++++++++
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/930e4a2a/plugins/network-elements/brocade-vcs/findbugsExcludeFilter.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/findbugsExcludeFilter.xml b/plugins/network-elements/brocade-vcs/findbugsExcludeFilter.xml
new file mode 100644
index 0000000..d372850
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/findbugsExcludeFilter.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<FindBugsFilter>
+
+
+</FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/930e4a2a/plugins/network-elements/nuage-vsp/findbugsExcludeFilter.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/findbugsExcludeFilter.xml b/plugins/network-elements/nuage-vsp/findbugsExcludeFilter.xml
new file mode 100644
index 0000000..d372850
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/findbugsExcludeFilter.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<FindBugsFilter>
+
+
+</FindBugsFilter>


[2/4] CLOUDSTACK-6823 : First code drop for Brocade Network plugin to orchestrate Brocade VDX switches for L2 connectivity

Posted by hu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/test/com/cloud/network/guru/BrocadeVcsGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/test/com/cloud/network/guru/BrocadeVcsGuestNetworkGuruTest.java b/plugins/network-elements/brocade-vcs/test/com/cloud/network/guru/BrocadeVcsGuestNetworkGuruTest.java
new file mode 100644
index 0000000..bf30bd0
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/test/com/cloud/network/guru/BrocadeVcsGuestNetworkGuruTest.java
@@ -0,0 +1,590 @@
+//
+// 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.guru;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.AssociateMacToNetworkAnswer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.CreateNetworkAnswer;
+import com.cloud.agent.api.DeleteNetworkAnswer;
+import com.cloud.agent.api.DisassociateMacFromNetworkAnswer;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.domain.Domain;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.network.BrocadeVcsNetworkVlanMappingVO;
+import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
+import com.cloud.network.Network.Service;
+import com.cloud.network.Network.State;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.dao.BrocadeVcsDao;
+import com.cloud.network.dao.BrocadeVcsNetworkVlanMappingDao;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
+import com.cloud.user.Account;
+import com.cloud.vm.Nic.ReservationStrategy;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachineProfile;
+
+public class BrocadeVcsGuestNetworkGuruTest {
+    private static final long NETWORK_ID = 42L;
+    PhysicalNetworkDao physnetdao = mock(PhysicalNetworkDao.class);
+    BrocadeVcsDao vcsdao = mock(BrocadeVcsDao.class);
+    BrocadeVcsNetworkVlanMappingDao vcsmapdao = mock(BrocadeVcsNetworkVlanMappingDao.class);
+    DataCenterDao dcdao = mock(DataCenterDao.class);
+    NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
+    AgentManager agentmgr = mock(AgentManager.class);
+    NetworkOrchestrationService netmgr = mock(NetworkOrchestrationService.class);
+    NetworkModel netmodel = mock(NetworkModel.class);
+
+    HostDao hostdao = mock(HostDao.class);
+    NetworkDao netdao = mock(NetworkDao.class);
+    GuestNetworkGuru guestGuru = mock(GuestNetworkGuru.class);
+    BrocadeVcsGuestNetworkGuru guru;
+
+    @Before
+    public void setUp() {
+
+        guru = new BrocadeVcsGuestNetworkGuru();
+        ((GuestNetworkGuru)guru)._physicalNetworkDao = physnetdao;
+        guru._brocadeVcsDao = vcsdao;
+        guru._brocadeVcsNetworkVlanDao = vcsmapdao;
+        guru._hostDao = hostdao;
+        guru._ntwkOfferingSrvcDao = nosd;
+        guru._dcDao = dcdao;
+        guru._agentMgr = agentmgr;
+
+        final DataCenterVO dc = mock(DataCenterVO.class);
+        when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
+        when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
+
+        when(dcdao.findById((Long)any())).thenReturn(dc);
+    }
+
+    @Test
+    public void testCanHandle() {
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VCS"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
+
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported TrafficType != Guest
+        when(offering.getTrafficType()).thenReturn(TrafficType.Management);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: GuestType Shared
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Shared);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: Basic networking
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+        assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
+
+        // Not supported: IsolationMethod != VCS
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+    }
+
+    @Test
+    public void testDesign() {
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long)any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VCS"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
+
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
+
+        final Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork != null);
+        assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vcs);
+    }
+
+    @Test
+    public void testDesignNoIsolationMethodVCS() {
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long)any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
+
+        final Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testDesignNoConnectivityInOffering() {
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long)any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VCS"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
+
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
+
+        final Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testImplement() throws InsufficientVirtualNetworkCapacityException, URISyntaxException {
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long)any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VCS"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
+
+        mock(DeploymentPlan.class);
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getBroadcastUri()).thenReturn(new URI("vlan://14"));
+
+        final DeployDestination dest = mock(DeployDestination.class);
+
+        final DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        List<BrocadeVcsDeviceVO> devices = new ArrayList();
+        devices.add(brocadeDevice);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        final Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        final ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        when(guestGuru.implement(network, offering, dest, res)).thenReturn(network);
+
+        final CreateNetworkAnswer answer = mock(CreateNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        final Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork != null);
+        verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testImplementFail() throws InsufficientVirtualNetworkCapacityException, URISyntaxException {
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long)any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VCS"}));
+        when(physnet.getId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getBroadcastUri()).thenReturn(new URI("vlan://14"));
+
+        final DeployDestination dest = mock(DeployDestination.class);
+
+        final DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = mock(List.class);
+        when(devices.isEmpty()).thenReturn(true);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        final Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        final ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        when(guestGuru.implement(network, offering, dest, res)).thenReturn(network);
+
+        final CreateNetworkAnswer answer = mock(CreateNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        final Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork == null);
+        verify(agentmgr, times(0)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testReserve() throws InsufficientVirtualNetworkCapacityException, URISyntaxException, InsufficientAddressCapacityException {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getBroadcastUri()).thenReturn(new URI("vlan://14"));
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NicProfile nic = mock(NicProfile.class);
+        when(nic.getMacAddress()).thenReturn("macaddress");
+        when(nic.getReservationStrategy()).thenReturn(ReservationStrategy.Start);
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+
+        final DeployDestination dest = mock(DeployDestination.class);
+
+        final DataCenterVO dc = mock(DataCenterVO.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+        when(dcdao.findById((long)anyInt())).thenReturn(dc);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        List<BrocadeVcsDeviceVO> devices = new ArrayList();
+        devices.add(brocadeDevice);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        final Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        final ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        final AssociateMacToNetworkAnswer answer = mock(AssociateMacToNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        guru.reserve(nic, network, vmProfile, dest, res);
+        verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testReserveFail() throws InsufficientVirtualNetworkCapacityException, URISyntaxException, InsufficientAddressCapacityException {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getBroadcastUri()).thenReturn(new URI("vlan://14"));
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NicProfile nic = mock(NicProfile.class);
+        when(nic.getMacAddress()).thenReturn("macaddress");
+        when(nic.getReservationStrategy()).thenReturn(ReservationStrategy.Start);
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+
+        final DeployDestination dest = mock(DeployDestination.class);
+
+        final DataCenterVO dc = mock(DataCenterVO.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+        when(dcdao.findById((long)anyInt())).thenReturn(dc);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = mock(List.class);
+        when(devices.isEmpty()).thenReturn(true);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        final Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        final ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        final AssociateMacToNetworkAnswer answer = mock(AssociateMacToNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        guru.reserve(nic, network, vmProfile, dest, res);
+        verify(agentmgr, times(0)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testDeallocate() {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NicProfile nic = mock(NicProfile.class);
+        when(nic.getMacAddress()).thenReturn("macaddress");
+        when(nic.getReservationStrategy()).thenReturn(ReservationStrategy.Start);
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = new ArrayList();
+        devices.add(brocadeDevice);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final DisassociateMacFromNetworkAnswer answer = mock(DisassociateMacFromNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        guru.deallocate(network, nic, vmProfile);
+        verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testDeallocateFail() {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NicProfile nic = mock(NicProfile.class);
+        when(nic.getMacAddress()).thenReturn("macaddress");
+        when(nic.getReservationStrategy()).thenReturn(ReservationStrategy.Start);
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = mock(List.class);
+        when(devices.isEmpty()).thenReturn(true);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final DisassociateMacFromNetworkAnswer answer = mock(DisassociateMacFromNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        guru.deallocate(network, nic, vmProfile);
+        verify(agentmgr, times(0)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testTrash() {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsNetworkVlanMappingVO mapping = mock(BrocadeVcsNetworkVlanMappingVO.class);
+        when(mapping.getVlanId()).thenReturn(14);
+        when(vcsmapdao.findByNetworkId(anyLong())).thenReturn(mapping);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = new ArrayList();
+        devices.add(brocadeDevice);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final DeleteNetworkAnswer answer = mock(DeleteNetworkAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        when(vcsdao.remove((long)anyInt())).thenReturn(true);
+
+        final boolean result = guru.trash(network, offering);
+        assertTrue(result == true);
+        verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+
+    @Test
+    public void testTrashFail() {
+
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getDataCenterId()).thenReturn(NETWORK_ID);
+
+        final NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        final HostVO brocadeHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
+        when(brocadeHost.getId()).thenReturn(NETWORK_ID);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
+
+        final BrocadeVcsNetworkVlanMappingVO mapping = mock(BrocadeVcsNetworkVlanMappingVO.class);
+        when(mapping.getVlanId()).thenReturn(14);
+        when(vcsmapdao.findByNetworkId(anyLong())).thenReturn(mapping);
+        when(vcsmapdao.remove(anyLong())).thenReturn(true);
+
+        final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
+        when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
+
+        final List<BrocadeVcsDeviceVO> devices = mock(List.class);
+        when(devices.isEmpty()).thenReturn(true);
+        when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
+
+        final boolean result = guru.trash(network, offering);
+        assertTrue(result == false);
+        verify(agentmgr, times(0)).easySend(eq(NETWORK_ID), (Command)any());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/test/com/cloud/network/resource/BrocadeVcsResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/test/com/cloud/network/resource/BrocadeVcsResourceTest.java b/plugins/network-elements/brocade-vcs/test/com/cloud/network/resource/BrocadeVcsResourceTest.java
new file mode 100644
index 0000000..f903d0e
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/test/com/cloud/network/resource/BrocadeVcsResourceTest.java
@@ -0,0 +1,261 @@
+//
+// 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.resource;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.cloud.agent.api.AssociateMacToNetworkAnswer;
+import com.cloud.agent.api.AssociateMacToNetworkCommand;
+import com.cloud.agent.api.CreateNetworkAnswer;
+import com.cloud.agent.api.CreateNetworkCommand;
+import com.cloud.agent.api.DeleteNetworkAnswer;
+import com.cloud.agent.api.DeleteNetworkCommand;
+import com.cloud.agent.api.DisassociateMacFromNetworkAnswer;
+import com.cloud.agent.api.DisassociateMacFromNetworkCommand;
+import com.cloud.agent.api.PingCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.host.Host;
+import com.cloud.network.brocade.BrocadeVcsApi;
+import com.cloud.network.brocade.BrocadeVcsApiException;
+import com.cloud.network.schema.showvcs.Output;
+import com.cloud.network.schema.showvcs.VcsNodeInfo;
+import com.cloud.network.schema.showvcs.VcsNodes;
+
+public class BrocadeVcsResourceTest {
+
+    private static final long NETWORK_ID = 42L;
+    private static final int VLAN_ID = 14;
+    private static final String MAC_ADDRESS_32 = "0050.56bf.0002";
+    private static final String MAC_ADDRESS_64 = "00:50:56:bf:00:02";
+    BrocadeVcsApi api = mock(BrocadeVcsApi.class);
+    BrocadeVcsResource resource;
+    Map<String, Object> parameters;
+
+    @Before
+    public void setUp() throws ConfigurationException {
+        resource = new BrocadeVcsResource() {
+            @Override
+            protected BrocadeVcsApi createBrocadeVcsApi(String ip, String username, String password) {
+                return api;
+            }
+        };
+
+        parameters = new HashMap<String, Object>();
+        parameters.put("name", "vcstestdevice");
+        parameters.put("ip", "127.0.0.1");
+        parameters.put("adminuser", "adminuser");
+        parameters.put("guid", "aaaaa-bbbbb-ccccc");
+        parameters.put("zoneId", "blublub");
+        parameters.put("adminpass", "adminpass");
+    }
+
+    @Test(expected = ConfigurationException.class)
+    public void resourceConfigureFailure() throws ConfigurationException {
+        resource.configure("BrocadeVcsResource", Collections.<String, Object> emptyMap());
+    }
+
+    @Test
+    public void resourceConfigure() throws ConfigurationException {
+        resource.configure("BrocadeVcsResource", parameters);
+        assertTrue("Incorrect resource name", "vcstestdevice".equals(resource.getName()));
+
+        assertTrue("Incorrect resource type", resource.getType() == Host.Type.L2Networking);
+    }
+
+    @Test
+    public void testInitialization() throws ConfigurationException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        final StartupCommand[] sc = resource.initialize();
+        assertTrue(sc.length == 1);
+        assertTrue("Incorrect startup command GUID", "aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
+        assertTrue("Incorrect Brocade device name", "vcstestdevice".equals(sc[0].getName()));
+        assertTrue("Incorrect Data Center", "blublub".equals(sc[0].getDataCenter()));
+    }
+
+    @Test
+    public void testPingCommandStatusOk() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
+        when(nodeInfo.getNodeState()).thenReturn("Online");
+
+        List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
+        nodes.add(nodeInfo);
+
+        final VcsNodes vcsNodes = mock(VcsNodes.class);
+        final Output output = mock(Output.class);
+        when(output.getVcsNodes()).thenReturn(vcsNodes);
+        when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
+        when(api.getSwitchStatus()).thenReturn(output);
+
+        final PingCommand ping = resource.getCurrentStatus(42);
+        assertTrue(ping != null);
+        assertTrue(ping.getHostId() == 42);
+        assertTrue(ping.getHostType() == Host.Type.L2Networking);
+
+    }
+
+    @Test
+    public void testPingCommandStatusFail() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
+        when(nodeInfo.getNodeState()).thenReturn("Offline");
+
+        List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
+        nodes.add(nodeInfo);
+
+        final VcsNodes vcsNodes = mock(VcsNodes.class);
+        final Output output = mock(Output.class);
+        when(output.getVcsNodes()).thenReturn(vcsNodes);
+        when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
+        when(api.getSwitchStatus()).thenReturn(output);
+
+        final PingCommand ping = resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testPingCommandStatusApiException() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+        when(api.getSwitchStatus()).thenThrow(new BrocadeVcsApiException());
+
+        final PingCommand ping = resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testRetries() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.createNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException()).thenThrow(new BrocadeVcsApiException()).thenReturn(true);
+
+        final CreateNetworkCommand cmd = new CreateNetworkCommand(VLAN_ID, NETWORK_ID, "owner");
+        final CreateNetworkAnswer answer = (CreateNetworkAnswer)resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+
+    }
+
+    @Test
+    public void testCreateNetworkApi() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.createNetwork(VLAN_ID, NETWORK_ID)).thenReturn(true);
+
+        final CreateNetworkCommand cmd = new CreateNetworkCommand(VLAN_ID, NETWORK_ID, "owner");
+        final CreateNetworkAnswer answer = (CreateNetworkAnswer)resource.executeRequest(cmd);
+        //verify(api).createNetwork(VLAN_ID, NETWORK_ID);
+        assertTrue(answer.getResult());
+
+    }
+
+    @Test
+    public void testCreateNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.createNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException());
+
+        final CreateNetworkCommand cmd = new CreateNetworkCommand(VLAN_ID, NETWORK_ID, "owner");
+        final CreateNetworkAnswer answer = (CreateNetworkAnswer)resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+
+    }
+
+    @Test
+    public void testDeleteNetworkApi() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.deleteNetwork(VLAN_ID, NETWORK_ID)).thenReturn(true);
+
+        final DeleteNetworkCommand cmd = new DeleteNetworkCommand(VLAN_ID, NETWORK_ID);
+        final DeleteNetworkAnswer answer = (DeleteNetworkAnswer)resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    @Test
+    public void testDeleteNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.deleteNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException());
+
+        final DeleteNetworkCommand cmd = new DeleteNetworkCommand(VLAN_ID, NETWORK_ID);
+        final DeleteNetworkAnswer answer = (DeleteNetworkAnswer)resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+    }
+
+    @Test
+    public void testAssociateMacToNetworkApi() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.associateMacToNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenReturn(true);
+
+        final AssociateMacToNetworkCommand cmd = new AssociateMacToNetworkCommand(NETWORK_ID, MAC_ADDRESS_64, "owner");
+        final AssociateMacToNetworkAnswer answer = (AssociateMacToNetworkAnswer)resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    @Test
+    public void testAssociateMacToNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.associateMacToNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenThrow(new BrocadeVcsApiException());
+
+        final AssociateMacToNetworkCommand cmd = new AssociateMacToNetworkCommand(NETWORK_ID, MAC_ADDRESS_64, "owner");
+        final AssociateMacToNetworkAnswer answer = (AssociateMacToNetworkAnswer)resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+    }
+
+    @Test
+    public void testDisassociateMacFromNetworkApi() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.disassociateMacFromNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenReturn(true);
+
+        final DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(NETWORK_ID, MAC_ADDRESS_64);
+        final DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer)resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    @Test
+    public void testDisassociateMacFromNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
+        resource.configure("BrocadeVcsResource", parameters);
+
+        when(api.disassociateMacFromNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenThrow(new BrocadeVcsApiException());
+
+        final DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(NETWORK_ID, MAC_ADDRESS_64);
+        final DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer)resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index eff5a01..b3890c0 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -64,6 +64,7 @@
     <module>network-elements/netscaler</module>
     <module>network-elements/nicira-nvp</module>
     <module>network-elements/bigswitch-vns</module>
+    <module>network-elements/brocade-vcs</module>
     <module>network-elements/midonet</module>
     <module>network-elements/stratosphere-ssp</module>
     <module>network-elements/opendaylight</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/setup/db/db/schema-440to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-440to450.sql b/setup/db/db/schema-440to450.sql
index 6cb81c6..d727f21 100644
--- a/setup/db/db/schema-440to450.sql
+++ b/setup/db/db/schema-440to450.sql
@@ -244,6 +244,26 @@ CREATE VIEW `cloud`.`volume_view` AS
             and async_job.instance_type = 'Volume'
             and async_job.job_status = 0;
 
+CREATE TABLE `cloud`.`external_brocade_vcs_devices` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(255) UNIQUE,
+  `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which brocade vcs switch is added',
+  `provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this brocade vcs switch',
+  `device_name` varchar(255) NOT NULL COMMENT 'name of the brocade vcs switch',
+  `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external brocade vcs switch',
+  PRIMARY KEY  (`id`),
+  CONSTRAINT `fk_external_brocade_vcs_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_external_brocade_vcs_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`brocade_network_vlan_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `network_id` bigint unsigned NOT NULL COMMENT 'id of the network',
+  `vlan_id` int(10) COMMENT 'vlan id of the network',
+  PRIMARY KEY  (`id`),
+   CONSTRAINT `fk_brocade_network_vlan_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 /* As part of the separation of Xen and XenServer, update the column for the network labels */
 ALTER TABLE `cloud`.`physical_network_traffic_types` CHANGE `xen_network_label` `xenserver_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host';
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/test/integration/component/test_brocade_vcs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_brocade_vcs.py b/test/integration/component/test_brocade_vcs.py
new file mode 100644
index 0000000..556de28
--- /dev/null
+++ b/test/integration/component/test_brocade_vcs.py
@@ -0,0 +1,333 @@
+# 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.
+
+""" P1 tests for brocade
+"""
+#Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import (cleanup_resources,
+                              random_gen, validateList)
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             PublicIPAddress,
+                             LoadBalancerRule,
+                             ServiceOffering,
+                             NetworkOffering,
+                             Host,
+                             Network,
+                             NATRule,
+                             Configurations)
+from marvin.lib.common import (get_domain,
+                               get_zone,
+                               get_template)
+from marvin.sshClient import SshClient
+from marvin.codes import PASS
+import time
+
+
+class Services:
+    """Test brocade plugin
+    """
+
+    def __init__(self):
+        self.services = {
+                         "account": {
+                                    "email": "test@test.com",
+                                    "firstname": "Test",
+                                    "lastname": "User",
+                                    "username": "test",
+                                    # Random characters are appended for unique
+                                    # username
+                                    "password": "password",
+                         },
+                         "service_offering": {
+                                    "name": "Tiny Instance",
+                                    "displaytext": "Tiny Instance",
+                                    "cpunumber": 1,
+                                    "cpuspeed": 100,    # in MHz
+                                    "memory": 128,       # In MBs
+                         },
+                         "virtual_machine": {
+                                    "displayname": "TestVM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                                },
+                         "brocade": {
+                                "ipaddress": '10.24.51.45',
+                                "username": 'admin',
+                                "password": 'password123'
+                         },
+                         "network_offering": {
+                                    "name": 'Brocade',
+                                    "displaytext": 'Brocade',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'SourceNat,Connectivity',
+                                    "traffictype": 'GUEST',
+                                    "availability": 'Optional',
+                                    "serviceProviderList": {
+                                            "SourceNat": 'VirtualRouter',
+                                            "Connectivity" : 'BrocadeVcs'
+                                    },
+                         },
+                         "network": {
+                                  "name": "Brocade",
+                                  "displaytext": "Brocade",
+                         },
+                         "ostype": 'CentOS 5.3 (64-bit)',
+                         # Cent OS 5.3 (64 bit)
+                         "sleep": 60,
+                         "timeout": 10
+                    }
+
+class TestBrocadeVcs(cloudstackTestCase):
+
+
+    @classmethod
+    def setUpClass(cls):
+        cls._cleanup = []
+        cls.testClient = super(TestBrocadeVcs, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        cls.services = Services().services
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+        cls.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                           )
+        cls.brocade_services = cls.services["brocade"]
+        try:
+
+           """ Adds Brocade device and enables NS provider"""
+           cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
+           cmd.zoneid = cls.zone.id
+           physical_networks = cls.api_client.listPhysicalNetworks(cmd)
+           if isinstance(physical_networks, list):
+               physical_network = physical_networks[0]
+           cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
+           cmd.name = 'BrocadeVcs'
+           cmd.physicalnetworkid = physical_network.id
+           nw_service_providers = cls.api_client.listNetworkServiceProviders(cmd)
+
+           if isinstance(nw_service_providers, list):
+               brocade_provider = nw_service_providers[0]
+           else:
+               cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
+               cmd1.name = 'BrocadeVcs'
+               cmd1.physicalnetworkid = physical_network.id
+               brocade_provider = cls.api_client.addNetworkServiceProvider(cmd1)
+
+           cmd2 = addBrocadeVcsDevice.addBrocadeVcsDeviceCmd()
+           cmd2.physicalnetworkid = physical_network.id
+           cmd2.username = cls.brocade_services["username"]
+           cmd2.password = cls.brocade_services["password"]
+           cmd2.hostname = cls.brocade_services["ipaddress"]
+           cls.brocade = cls.api_client.addBrocadeVcsDevice(cmd2)
+
+           if brocade_provider.state != 'Enabled':
+               cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
+               cmd.id = brocade_provider.id
+               cmd.state = 'Enabled'
+               cls.api_client.updateNetworkServiceProvider(cmd)
+
+
+           cls.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+           cls._cleanup.append(cls.network_offering)
+
+           # Enable Network offering
+           cls.network_offering.update(cls.api_client, state='Enabled')
+           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+           cls.services["virtual_machine"]["template"] = cls.template.id
+           cls.service_offering = ServiceOffering.create(
+                                            cls.api_client,
+                                            cls.services["service_offering"]
+                                            )
+           cls._cleanup.append(cls.service_offering)
+        except Exception as e:
+           cls.tearDownClass()
+           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            #Cleanup resources used
+            cmd = deleteBrocadeVcsDevice.deleteBrocadeVcsDeviceCmd()
+            cmd.vcsdeviceid = cls.brocade.vcsdeviceid
+            cls.brocade = cls.api_client.deleteBrocadeVcsDevice(cmd)
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self.cleanup = [self.account]
+        return
+
+    def tearDown(self):
+        try:
+            self.debug("Cleaning up the resources")
+            #Clean up, terminate the created network offerings
+            #cleanup_resources(self.apiclient, self.cleanup)
+            interval = Configurations.list(
+                                    self.apiclient,
+                                    name='network.gc.interval'
+                                    )
+            wait = Configurations.list(
+                                    self.apiclient,
+                                    name='network.gc.wait'
+                                    )
+            # Sleep to ensure that all resources are deleted
+            time.sleep(int(interval[0].value) + int(wait[0].value))
+            self.debug("Cleanup complete!")
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+
+    @attr(tags = ["advancedns"])
+    def test_network_vcs(self):
+        """Test Brocade Network and VM Creation
+        """
+
+
+        # Validate the following
+        # 1. Deploy the first VM using a network from the above created
+        #    Network offering.
+        # 2. Deploy another VM.
+        # 3. Delete The VMs and the Network
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        self.network = Network.create(
+                                    self.apiclient,
+                                    self.services["network"],
+                                    accountid=self.account.name,
+                                    domainid=self.account.domainid,
+                                    networkofferingid=self.network_offering.id,
+                                    zoneid=self.zone.id
+                                    )
+        self.debug("Created network with ID: %s" % self.network.id)
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine_1 = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(self.network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % self.network.id)
+        list_vm_response = VirtualMachine.list(
+                                        self.apiclient,
+                                        id=virtual_machine_1.id
+                                        )
+
+        self.debug(
+                "Verify listVirtualMachines response for virtual machine: %s" \
+                % virtual_machine_1.id
+            )
+
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        vm_response = list_vm_response[0]
+
+        self.assertEqual(
+                            vm_response.state,
+                            "Running",
+                            "VM state should be running after deployment"
+                        )
+
+        self.debug("Deploying another VM in account: %s" %
+                                            self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine_2 = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(self.network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % self.network.id)
+        list_vm_response = VirtualMachine.list(
+                                        self.apiclient,
+                                        id=virtual_machine_2.id
+                                        )
+
+        self.debug(
+                "Verify listVirtualMachines response for virtual machine: %s" \
+                % virtual_machine_2.id
+            )
+
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        vm_response = list_vm_response[0]
+
+        self.assertEqual(
+                            vm_response.state,
+                            "Running",
+                            "VM state should be running after deployment"
+                        )
+
+        # Deleting a single VM
+        VirtualMachine.delete(virtual_machine_1, self.apiclient)
+        VirtualMachine.expung(virtual_machine_1, self.apiclient)
+
+
+        # Deleting a single VM
+        VirtualMachine.delete(virtual_machine_2, self.apiclient)
+        VirtualMachine.expung(virtual_machine_2, self.apiclient)
+
+
+        # Delete Network
+        Network.delete(self.network, self.apiclient)
+
+        return
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index bcc8417..1ad493d 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -132,6 +132,7 @@ known_categories = {
     'StaticRoute': 'VPC',
     'Tags': 'Resource tags',
     'NiciraNvpDevice': 'Nicira NVP',
+    'BrocadeVcsDevice': 'Brocade VCS',
     'BigSwitchVnsDevice': 'BigSwitch VNS',
 	'NuageVsp': 'Nuage VSP',
     'AutoScale': 'AutoScale',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index c84d0dd..beb082b 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -352,6 +352,7 @@ dictionary = {
 'label.add.new.tier': '<fmt:message key="label.add.new.tier" />',
 'label.add.NiciraNvp.device': '<fmt:message key="label.add.NiciraNvp.device" />',
 'label.add.NuageVsp.device': '<fmt:message key="label.add.NuageVsp.device" />',
+'label.add.BrocadeVcs.device': '<fmt:message key="label.add.BrocadeVcs.device" />',
 'label.add.pod': '<fmt:message key="label.add.pod" />',
 'label.add.port.forwarding.rule': '<fmt:message key="label.add.port.forwarding.rule" />',
 'label.add.primary.storage': '<fmt:message key="label.add.primary.storage" />',
@@ -509,6 +510,7 @@ dictionary = {
 'label.delete.NetScaler': '<fmt:message key="label.delete.NetScaler" />',
 'label.delete.NiciraNvp': '<fmt:message key="label.delete.NiciraNvp" />',
 'label.delete.NuageVsp': '<fmt:message key="label.delete.NuageVsp" />',
+'label.delete.BrocadeVcs': '<fmt:message key="label.delete.BrocadeVcs" />',
 'label.delete.project': '<fmt:message key="label.delete.project" />',
 'label.delete.SRX': '<fmt:message key="label.delete.SRX" />',
 'label.delete.PA': '<fmt:message key="label.delete.PA" />',
@@ -868,6 +870,7 @@ dictionary = {
 'label.nicira.controller.address': '<fmt:message key="label.nicira.controller.address" />',
 'label.nicira.l3gatewayserviceuuid': '<fmt:message key="label.nicira.l3gatewayserviceuuid" />',
 'label.nicira.transportzoneuuid': '<fmt:message key="label.nicira.transportzoneuuid" />',
+'label.brocade.vcs.address': '<fmt:message key="label.brocade.vcs.address" />',
 'label.nics': '<fmt:message key="label.nics" />',
 'label.no.actions': '<fmt:message key="label.no.actions" />',
 'label.no.alerts': '<fmt:message key="label.no.alerts" />',
@@ -1433,6 +1436,7 @@ dictionary = {
 'message.configuring.storage.traffic': '<fmt:message key="message.configuring.storage.traffic" />',
 'message.confirm.action.force.reconnect': '<fmt:message key="message.confirm.action.force.reconnect" />',
 'message.confirm.delete.F5': '<fmt:message key="message.confirm.delete.F5" />',
+'message.confirm.delete.BrocadeVcs': '<fmt:message key="message.confirm.delete.BrocadeVcs" />',
 'message.confirm.delete.NetScaler': '<fmt:message key="message.confirm.delete.NetScaler" />',
 'message.confirm.delete.NuageVsp': '<fmt:message key="message.confirm.delete.NuageVsp" />',
 'message.confirm.delete.SRX': '<fmt:message key="message.confirm.delete.SRX" />',
@@ -1738,6 +1742,8 @@ dictionary = {
 'label.palo.alto.details': '<fmt:message key="label.palo.alto.details" />',
 'label.added.nicira.nvp.controller': '<fmt:message key="label.added.nicira.nvp.controller" />',
 'label.nicira.nvp.details': '<fmt:message key="label.nicira.nvp.details" />',
+'label.added.brocade.vcs.switch': '<fmt:message key="label.added.brocade.vcs.switch" />',
+'label.brocade.vcs.details': '<fmt:message key="label.brocade.vcs.details" />',
 'label.added.new.bigswitch.vns.controller': '<fmt:message key="label.added.new.bigswitch.vns.controller" />',
 'label.bigswitch.vns.details': '<fmt:message key="label.bigswitch.vns.details" />',
 'label.dedicate': '<fmt:message key="label.dedicate" />',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 502007f..4e0d78a 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -5808,6 +5808,206 @@
                             }
                         }
                     },
+					// Brocade Vcs provider detail view
+                    brocadeVcs: {
+                        type: 'detailView',
+                        id: 'brocadeVcsProvider',
+                        label: 'label.brocadeVcs',
+                        viewAll: {
+                            label: 'label.devices',
+                            path: '_zone.brocadeVcsDevices'
+                        },
+                        tabs: {
+                            details: {
+                                title: 'label.details',
+                                fields:[ {
+                                    name: {
+                                        label: 'label.name'
+                                    }
+                                },
+                                {
+                                    state: {
+                                        label: 'label.state'
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    refreshNspData("BrocadeVcs");
+                                    var providerObj;
+                                    $(nspHardcodingArray).each(function () {
+                                        if (this.id == "brocadeVcs") {
+                                            providerObj = this;
+                                            return false; //break each loop
+                                        }
+                                    });
+                                    args.response.success({
+                                        data: providerObj,
+                                        actionFilter: networkProviderActionFilter('brocadeVcs')
+                                    });
+                                }
+                            }
+                        },
+                        actions: {
+                            add: {
+                                label: 'label.add.BrocadeVcs.device',
+                                createForm: {
+                                    title: 'label.add.BrocadeVcs.device',
+                                    preFilter: function (args) {
+                                    },
+                                    // TODO What is this?
+                                    fields: {
+                                        host: {
+                                            label: 'label.ip.address'
+                                        },
+                                        username: {
+                                            label: 'label.username'
+                                        },
+                                        password: {
+                                            label: 'label.password',
+                                            isPassword: true
+                                        }
+                                    }
+                                },
+                                action: function (args) {
+                                    if (nspMap[ "brocadeVcs"] == null) {
+                                        $.ajax({
+                                            url: createURL("addNetworkServiceProvider&name=BrocadeVcs&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
+                                            dataType: "json",
+                                            async: true,
+                                            success: function (json) {
+                                                var jobId = json.addnetworkserviceproviderresponse.jobid;
+                                                var addBrocadeVcsProviderIntervalID = setInterval(function () {
+                                                    $.ajax({
+                                                        url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                        dataType: "json",
+                                                        success: function (json) {
+                                                            var result = json.queryasyncjobresultresponse;
+                                                            if (result.jobstatus == 0) {
+                                                                return; //Job has not completed
+                                                            } else {
+                                                                clearInterval(addBrocadeVcsProviderIntervalID);
+                                                                if (result.jobstatus == 1) {
+                                                                    nspMap[ "brocadeVcs"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
+                                                                    addBrocadeVcsDevice(args, selectedPhysicalNetworkObj, "addBrocadeVcsDevice", "addbrocadevcsdeviceresponse", "brocadevcsdevice")
+                                                                } else if (result.jobstatus == 2) {
+                                                                    alert("addNetworkServiceProvider&name=BrocadeVcs failed. Error: " + _s(result.jobresult.errortext));
+                                                                }
+                                                            }
+                                                        },
+                                                        error: function (XMLHttpResponse) {
+                                                            var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                            alert("addNetworkServiceProvider&name=BrocadeVcs failed. Error: " + errorMsg);
+                                                        }
+                                                    });
+                                                },
+                                                g_queryAsyncJobResultInterval);
+                                            }
+                                        });
+                                    } else {
+                                        addBrocadeVcsDevice(args, selectedPhysicalNetworkObj, "addBrocadeVcsDevice", "addbrocadevcsdeviceresponse", "brocadevcsdevice")
+                                    }
+                                },
+                                messages: {
+                                    notification: function (args) {
+                                        return 'label.add.BrocadeVcs.device';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            },
+                            enable: {
+                                label: 'label.enable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "brocadeVcs"].id + "&state=Enabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.enable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.enable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            },
+                            disable: {
+                                label: 'label.disable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "brocadeVcs"].id + "&state=Disabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.disable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.disable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            },
+                            destroy: {
+                                label: 'label.shutdown.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("deleteNetworkServiceProvider&id=" + nspMap[ "brocadeVcs"].id),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.deletenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid
+                                                }
+                                            });
+                                            $(window).trigger('cloudStack.fullRefresh');
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.shutdown.provider';
+                                    },
+                                    notification: function (args) {
+                                        return 'label.shutdown.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            }
+                        }
+                    },
                     // BigSwitch Vns provider detail view
                     bigswitchVns: {
                         type: 'detailView',
@@ -12040,6 +12240,166 @@
                     }
                 }
             },
+			// BrocadeVcs devices listView
+            brocadeVcsDevices: {
+                id: 'brocadeVcsDevices',
+                title: 'label.devices',
+                listView: {
+                    id: 'brocadeVcsDevices',
+                    fields: {
+                        hostname: {
+                            label: 'label.brocade.vcs.address'
+                        }
+                    },
+                    actions: {
+                        add: {
+                            label: 'label.add.BrocadeVcs.device',
+                            createForm: {
+                                title: 'label.add.BrocadeVcs.device',
+                                preFilter: function (args) {
+                                },
+                                // TODO What is this?
+                                fields: {
+                                    host: {
+                                        label: 'label.ip.address'
+                                    },
+                                    username: {
+                                        label: 'label.username'
+                                    },
+                                    password: {
+                                        label: 'label.password',
+                                        isPassword: true
+                                    }
+                                }
+                            },
+                            action: function (args) {
+                                if (nspMap[ "brocadeVcs"] == null) {
+                                    $.ajax({
+                                        url: createURL("addNetworkServiceProvider&name=BrocadeVcs&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
+                                        dataType: "json",
+                                        async: true,
+                                        success: function (json) {
+                                            var jobId = json.addnetworkserviceproviderresponse.jobid;
+                                            var addBrocadeVcsProviderIntervalID = setInterval(function () {
+                                                $.ajax({
+                                                    url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                    dataType: "json",
+                                                    success: function (json) {
+                                                        var result = json.queryasyncjobresultresponse;
+                                                        if (result.jobstatus == 0) {
+                                                            return; // Job has not completed
+                                                        } else {
+                                                            clearInterval(addBrocadeVcsProviderIntervalID);
+                                                            if (result.jobstatus == 1) {
+                                                                nspMap[ "brocadeVcs"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
+                                                                addBrocadeVcsDevice(args, selectedPhysicalNetworkObj, "addBrocadeVcsDevice", "addbrocadevcsdeviceresponse", "brocadevcsdevice")
+                                                            } else if (result.jobstatus == 2) {
+                                                                alert("addNetworkServiceProvider&name=BrocadeVcs failed. Error: " + _s(result.jobresult.errortext));
+                                                            }
+                                                        }
+                                                    },
+                                                    error: function (XMLHttpResponse) {
+                                                        var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                        alert("addNetworkServiceProvider&name=BrocadeVcs failed. Error: " + errorMsg);
+                                                    }
+                                                });
+                                            },
+                                            g_queryAsyncJobResultInterval);
+                                        }
+                                    });
+                                } else {
+                                    addBrocadeVcsDevice(args, selectedPhysicalNetworkObj, "addBrocadeVcsDevice", "addbrocadevcsdeviceresponse", "brocadevcsdevice")
+                                }
+                            },
+                            messages: {
+                                notification: function (args) {
+                                    return 'label.added.brocade.vcs.switch';
+                                }
+                            },
+                            notification: {
+                                poll: pollAsyncJobResult
+                            }
+                        }
+                    },
+                    dataProvider: function (args) {
+                        $.ajax({
+                            url: createURL("listBrocadeVcsDevices&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
+                            data: {
+                                page: args.page,
+                                pageSize: pageSize
+                            },
+                            dataType: "json",
+                            async: false,
+                            success: function (json) {
+                                var items = json.listbrocadevcsdeviceresponse.brocadevcsdevice;
+                                args.response.success({
+                                    data: items
+                                });
+                            }
+                        });
+                    },
+                    detailView: {
+                        name: 'label.brocade.vcs.details',
+                        actions: {
+                            'remove': {
+                                label: 'label.delete.BrocadeVcs',
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.delete.BrocadeVcs';
+                                    },
+                                    notification: function (args) {
+                                        return 'label.delete.BrocadeVcs';
+                                    }
+                                },
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("deleteBrocadeVcsDevice&vcsdeviceid=" + args.context.brocadeVcsDevices[0].vcsdeviceid),
+                                        dataType: "json",
+                                        async: true,
+                                        success: function (json) {
+                                            var jid = json.deletebrocadevcsdeviceresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            }
+                        },
+                        tabs: {
+                            details: {
+                                title: 'label.details',
+                                fields:[ {
+                                    vcsdeviceid: {
+                                        label: 'label.id'
+                                    },
+                                    hostname: {
+                                        label: 'label.ip.address'
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    $.ajax({
+                                        url: createURL("listBrocadeVcsDevices&vcsdeviceid=" + args.context.brocadeVcsDevices[0].vcsdeviceid),
+                                        dataType: "json",
+                                        async: true,
+                                        success: function (json) {
+                                            var item = json.listbrocadevcsdeviceresponse.brocadevcsdevice[0];
+                                            args.response.success({
+                                                data: item
+                                            });
+                                        }
+                                    });
+                                }
+                            }
+                        }
+                    }
+                }
+            },
             bigswitchVnsDevices: {
                 id: 'bigswitchVnsDevices',
                 title: 'label.devices',
@@ -19204,7 +19564,34 @@
             }
         });
     }
-    
+
+	function addBrocadeVcsDevice(args, physicalNetworkObj, apiCmd, apiCmdRes, apiCmdObj) {
+        var array1 =[];
+        array1.push("&physicalnetworkid=" + physicalNetworkObj.id);
+        array1.push("&username=" + todb(args.data.username));
+        array1.push("&password=" + todb(args.data.password));
+        array1.push("&hostname=" + todb(args.data.host));
+
+        $.ajax({
+            url: createURL(apiCmd + array1.join("")),
+            dataType: "json",
+            type: "POST",
+            success: function (json) {
+                var jid = json[apiCmdRes].jobid;
+                args.response.success({
+                    _custom: {
+                        jobId: jid,
+                        getUpdatedItem: function (json) {
+                            var item = json.queryasyncjobresultresponse.jobresult[apiCmdObj];
+
+                            return item;
+                        }
+                    }
+                });
+            }
+        });
+    }
+
     function addOpenDaylightController(args, physicalNetworkObj, apiCmd, apiCmdRes, apiCmdObj) {
         var array1 =[];
         array1.push("&physicalnetworkid=" + physicalNetworkObj.id);
@@ -19956,6 +20343,9 @@
                             case "NiciraNvp":
                             nspMap[ "niciraNvp"] = items[i];
                             break;
+							case "BrocadeVcs":
+                            nspMap[ "brocadeVcs"] = items[i];
+                            break;
                             case "BigSwitchVns":
                             nspMap[ "bigswitchVns"] = items[i];
                             break;
@@ -19989,6 +20379,11 @@
             name: 'Nicira Nvp',
             state: nspMap.niciraNvp ? nspMap.niciraNvp.state: 'Disabled'
         },
+		{
+            id: 'brocadeVcs',
+            name: 'Brocade',
+            state: nspMap.brocadeVcs ? nspMap.brocadeVcs.state: 'Disabled'
+        },
         {
             id: 'bigswitchVns',
             name: 'BigSwitch Vns',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/ui/scripts/ui-custom/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/zoneWizard.js b/ui/scripts/ui-custom/zoneWizard.js
index 645c2b1..f3a1aae 100644
--- a/ui/scripts/ui-custom/zoneWizard.js
+++ b/ui/scripts/ui-custom/zoneWizard.js
@@ -729,7 +729,10 @@
                             }).html('L3VPN'),
 		                    $('<option>').attr({
                                 value: 'VSP'
-                            }).html('VSP')
+                            }).html('VSP'),
+                            $('<option>').attr({
+                                value: 'VCS'
+                            }).html('VCS')
                         )
                     )
                 );


[4/4] git commit: updated refs/heads/master to 930e4a2

Posted by hu...@apache.org.
CLOUDSTACK-6823 : First code drop for Brocade Network plugin to orchestrate Brocade VDX switches for L2 connectivity

Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/628d8e66
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/628d8e66
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/628d8e66

Branch: refs/heads/master
Commit: 628d8e66f77053de9819436739325720710175ed
Parents: 0ac2eb4
Author: Ritu Sabharwal <rs...@brocade.com>
Authored: Wed Jul 23 08:51:20 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Wed Jul 23 11:11:18 2014 +0200

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |   3 +-
 api/src/com/cloud/network/Networks.java         |  16 +-
 api/src/com/cloud/network/PhysicalNetwork.java  |   2 +-
 .../network/ExternalNetworkDeviceManager.java   |   1 +
 .../classes/resources/messages.properties       |   6 +
 .../classes/resources/messages_zh_CN.properties |   3 +
 client/pom.xml                                  |   5 +
 client/tomcatconf/commands.properties.in        |   7 +
 plugins/network-elements/brocade-vcs/pom.xml    |  78 +++
 .../resources/BrocadeInterfaceSchema.xsd        |  51 ++
 .../resources/BrocadePortProfileSchema.xsd      | 118 ++++
 .../resources/BrocadeShowVcsSchema.xsd          | 108 ++++
 .../META-INF/cloudstack/vcs/module.properties   |  18 +
 .../cloudstack/vcs/spring-vcs-context.xml       |  29 +
 .../agent/api/AssociateMacToNetworkAnswer.java  |  30 +
 .../agent/api/AssociateMacToNetworkCommand.java |  48 ++
 .../cloud/agent/api/CreateNetworkAnswer.java    |  30 +
 .../cloud/agent/api/CreateNetworkCommand.java   |  48 ++
 .../cloud/agent/api/DeleteNetworkAnswer.java    |  30 +
 .../cloud/agent/api/DeleteNetworkCommand.java   |  43 ++
 .../api/DisassociateMacFromNetworkAnswer.java   |  30 +
 .../api/DisassociateMacFromNetworkCommand.java  |  42 ++
 .../agent/api/StartupBrocadeVcsCommand.java     |  27 +
 .../api/commands/AddBrocadeVcsDeviceCmd.java    | 128 ++++
 .../api/commands/DeleteBrocadeVcsDeviceCmd.java | 105 ++++
 .../ListBrocadeVcsDeviceNetworksCmd.java        | 104 ++++
 .../api/commands/ListBrocadeVcsDevicesCmd.java  | 108 ++++
 .../api/response/BrocadeVcsDeviceResponse.java  |  74 +++
 .../com/cloud/network/BrocadeVcsDeviceVO.java   |  99 ++++
 .../network/BrocadeVcsNetworkVlanMappingVO.java |  72 +++
 .../cloud/network/brocade/BrocadeVcsApi.java    | 521 ++++++++++++++++
 .../network/brocade/BrocadeVcsApiException.java |  36 ++
 .../com/cloud/network/brocade/Constants.java    |  37 ++
 .../com/cloud/network/dao/BrocadeVcsDao.java    |  35 ++
 .../cloud/network/dao/BrocadeVcsDaoImpl.java    |  53 ++
 .../dao/BrocadeVcsNetworkVlanMappingDao.java    |  32 +
 .../BrocadeVcsNetworkVlanMappingDaoImpl.java    |  49 ++
 .../network/element/BrocadeVcsElement.java      | 467 +++++++++++++++
 .../element/BrocadeVcsElementService.java       |  45 ++
 .../guru/BrocadeVcsGuestNetworkGuru.java        | 267 +++++++++
 .../network/resource/BrocadeVcsResource.java    | 310 ++++++++++
 .../network/brocade/BrocadeVcsApiTest.java      | 185 ++++++
 .../guru/BrocadeVcsGuestNetworkGuruTest.java    | 590 +++++++++++++++++++
 .../resource/BrocadeVcsResourceTest.java        | 261 ++++++++
 plugins/pom.xml                                 |   1 +
 setup/db/db/schema-440to450.sql                 |  20 +
 test/integration/component/test_brocade_vcs.py  | 333 +++++++++++
 tools/apidoc/gen_toc.py                         |   1 +
 ui/dictionary.jsp                               |   6 +
 ui/scripts/system.js                            | 397 ++++++++++++-
 ui/scripts/ui-custom/zoneWizard.js              |   5 +-
 51 files changed, 5108 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index 0a08f28..341c6c4 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -135,6 +135,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
         // add Nuage Vsp Providers
         public static final Provider NuageVsp = new Provider("NuageVsp", false);
         public static final Provider NuageVspVpc = new Provider("NuageVspVpc", false);
+        public static final Provider BrocadeVcs = new Provider("BrocadeVcs", false);
 
         private final String name;
         private final boolean isExternal;
@@ -223,7 +224,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
 
         Allocated("Indicates the network configuration is in allocated but not setup"), Setup("Indicates the network configuration is setup"), Implementing(
                 "Indicates the network configuration is being implemented"), Implemented("Indicates the network configuration is in use"), Shutdown(
-                        "Indicates the network configuration is being destroyed"), Destroy("Indicates that the network is destroyed");
+                "Indicates the network configuration is being destroyed"), Destroy("Indicates that the network is destroyed");
 
         protected static final StateMachine2<State, Network.Event, Network> s_fsm = new StateMachine2<State, Network.Event, Network>();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/api/src/com/cloud/network/Networks.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java
index 1ad3350..f027cf9 100755
--- a/api/src/com/cloud/network/Networks.java
+++ b/api/src/com/cloud/network/Networks.java
@@ -104,8 +104,20 @@ public class Networks {
                     else
                         return new URI("vxlan://" + value.toString());
                 } catch (URISyntaxException e) {
-                    throw new CloudRuntimeException(
-                            "Unable to convert to broadcast URI: " + value);
+                    throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
+                }
+            }
+        },
+        Vcs("vcs", Integer.class) {
+            @Override
+            public <T> URI toUri(T value) {
+                try {
+                    if (value.toString().contains("://"))
+                        return new URI(value.toString());
+                    else
+                        return new URI("vcs://" + value.toString());
+                } catch (URISyntaxException e) {
+                    throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
                 }
             }
         },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/api/src/com/cloud/network/PhysicalNetwork.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/PhysicalNetwork.java b/api/src/com/cloud/network/PhysicalNetwork.java
index 024b3ce..7c9349d 100644
--- a/api/src/com/cloud/network/PhysicalNetwork.java
+++ b/api/src/com/cloud/network/PhysicalNetwork.java
@@ -33,7 +33,7 @@ public interface PhysicalNetwork extends Identity, InternalIdentity {
     }
 
     public enum IsolationMethod {
-        VLAN, L3, GRE, STT, VNS, MIDO, SSP, VXLAN, ODL, L3VPN, VSP;
+        VLAN, L3, GRE, STT, VNS, MIDO, SSP, VXLAN, ODL, L3VPN, VSP, VCS;
     }
 
     public enum BroadcastDomainRange {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java b/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java
index e73f526..f38e9e6 100644
--- a/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java
+++ b/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java
@@ -46,6 +46,7 @@ public interface ExternalNetworkDeviceManager extends Manager {
         public static final NetworkDevice NiciraNvp = new NetworkDevice("NiciraNvp", Network.Provider.NiciraNvp.getName());
         public static final NetworkDevice CiscoVnmc = new NetworkDevice("CiscoVnmc", Network.Provider.CiscoVnmc.getName());
         public static final NetworkDevice OpenDaylightController = new NetworkDevice("OpenDaylightController", Network.Provider.Opendaylight.getName());
+        public static final NetworkDevice BrocadeVcs = new NetworkDevice("BrocadeVcs", Network.Provider.BrocadeVcs.getName());
 
         public NetworkDevice(String deviceName, String ntwkServiceprovider) {
             _name = deviceName;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index bb75b08..271ffec 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -328,6 +328,7 @@ label.add.new.PA=Add new Palo Alto
 label.add.new.tier=Add new tier
 label.add.NiciraNvp.device=Add Nvp Controller
 label.add.NuageVsp.device=Add Nuage Virtualized Services Directory (VSD)
+label.add.BrocadeVcs.device=Add Brocade Vcs Switch
 label.add.physical.network=Add physical network
 label.add.pod=Add Pod
 label.add.port.forwarding.rule=Add port forwarding rule
@@ -504,6 +505,7 @@ label.delete.gateway=delete gateway
 label.delete.NetScaler=Delete NetScaler
 label.delete.NiciraNvp=Remove Nvp Controller
 label.delete.NuageVsp=Remove Nuage VSD
+label.delete.BrocadeVcs=Remove Brocade Vcs Switch
 label.delete.project=Delete project
 label.delete.SRX=Delete SRX
 label.delete.PA=Delete Palo Alto
@@ -878,6 +880,7 @@ label.nic.adapter.type=NIC adapter type
 label.nicira.controller.address=Controller Address
 label.nicira.l3gatewayserviceuuid=L3 Gateway Service Uuid
 label.nicira.transportzoneuuid=Transport Zone Uuid
+label.brocade.vcs.address=Vcs Switch Address
 label.nics=NICs
 label.no.actions=No Available Actions
 label.no.alerts=No Recent Alerts
@@ -1423,6 +1426,8 @@ label.srx.details=SRX details
 label.palo.alto.details=Palo Alto details
 label.added.nicira.nvp.controller=Added new Nicira NVP Controller
 label.nicira.nvp.details=Nicira NVP details
+label.added.brocade.vcs.switch=Added new Brocade Vcs Switch
+label.brocade.vcs.details=Brocade Vcs Switch details
 label.added.new.bigswitch.vns.controller=Added new BigSwitch VNS Controller
 label.bigswitch.vns.details=BigSwitch VNS details
 label.dedicate=Dedicate
@@ -1634,6 +1639,7 @@ message.configuring.public.traffic=Configuring public traffic
 message.configuring.storage.traffic=Configuring storage traffic
 message.confirm.action.force.reconnect=Please confirm that you want to force reconnect this host.
 message.confirm.delete.F5=Please confirm that you would like to delete F5
+message.confirm.delete.BrocadeVcs=Please confirm that you would like to delete Brocade Vcs Switch
 message.confirm.delete.NetScaler=Please confirm that you would like to delete NetScaler
 message.confirm.delete.NuageVsp=Please confirm that you would like to delete Nuage Virtualized Services Directory
 message.confirm.delete.SRX=Please confirm that you would like to delete SRX

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/client/WEB-INF/classes/resources/messages_zh_CN.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages_zh_CN.properties b/client/WEB-INF/classes/resources/messages_zh_CN.properties
index d7a0ca9..2c497bc 100644
--- a/client/WEB-INF/classes/resources/messages_zh_CN.properties
+++ b/client/WEB-INF/classes/resources/messages_zh_CN.properties
@@ -298,6 +298,7 @@ label.add.new.tier=\u6dfb\u52a0\u65b0\u5c42
 label.add.nfs.secondary.staging.store=\u6dfb\u52a0 NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
 label.add.NiciraNvp.device=\u6dfb\u52a0 Nvp \u63a7\u5236\u5668
 label.add.NuageVsp.device=\u6DFB\u52A0 Nuage \u865A\u62DF\u670D\u52A1\u76EE\u5F55 (VSD)
+label.add.BrocadeVcs.device=\u6dfb\u52a0 Vcs \u63a7\u5236\u5668
 label.add.OpenDaylight.device=\u6dfb\u52a0 OpenDaylight \u63a7\u5236\u5668
 label.add.PA.device=\u6dfb\u52a0 Palo Alto \u8bbe\u5907
 label.add.physical.network=\u6dfb\u52a0\u7269\u7406\u7f51\u7edc
@@ -511,6 +512,7 @@ label.delete.gateway=\u5220\u9664\u7f51\u5173
 label.delete.NetScaler=\u5220\u9664 NetScaler
 label.delete.NiciraNvp=\u79fb\u9664 Nvp \u63a7\u5236\u5668
 label.delete.NuageVsp=\u5220\u9664 Nuage VSD
+label.delete.BrocadeVcs=\u79fb\u9664 Vcs \u63a7\u5236\u5668
 label.delete.OpenDaylight.device=\u5220\u9664 OpenDaylight \u63a7\u5236\u5668
 label.delete.PA=\u5220\u9664 Palo Alto
 label.delete.portable.ip.range=\u5220\u9664\u53ef\u79fb\u690d IP \u8303\u56f4
@@ -1610,6 +1612,7 @@ message.confirm.dedicate.pod.domain.account=\u662f\u5426\u786e\u5b9e\u8981\u5c06
 message.confirm.dedicate.zone=\u662f\u5426\u8981\u5c06\u6b64\u8d44\u6e90\u57df\u4e13\u7528\u4e8e\u57df/\u5e10\u6237?
 message.confirm.delete.ciscovnmc.resource=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 CiscoVNMC \u8d44\u6e90
 message.confirm.delete.F5=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 F5
+message.confirm.delete.BrocadeVcs=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 Brocade Vcs Switch
 message.confirm.delete.NetScaler=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 NetScaler
 message.confirm.delete.NuageVsp=\u8BF7\u786E\u8BA4\u5220\u9664 Nuage \u865A\u62DF\u670D\u52A1\u76EE\u5F55
 message.confirm.delete.PA=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 Palo Alto

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 410cb19..fcd8317 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -147,6 +147,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-network-vcs</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-hypervisor-xenserver</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index aa03949..c1d21b9 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -607,6 +607,13 @@ listNiciraNvpDeviceNetworks=1
 # Not implemented (yet)
 #configureNiciraNvpDevice=1
 
+#### brocade vcs commands
+
+addBrocadeVcsDevice=1
+deleteBrocadeVcsDevice=1
+listBrocadeVcsDevices=1
+listBrocadeVcsDeviceNetworks=1
+
 #### bigswitch vns commands
 
 addBigSwitchVnsDevice=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/pom.xml b/plugins/network-elements/brocade-vcs/pom.xml
new file mode 100644
index 0000000..50dc9a4
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/pom.xml
@@ -0,0 +1,78 @@
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>cloud-plugin-network-vcs</artifactId>
+	<name>Apache CloudStack Plugin - Network Brocade VCS</name>
+	<parent>
+		<groupId>org.apache.cloudstack</groupId>
+		<artifactId>cloudstack-plugins</artifactId>
+		<version>4.5.0-SNAPSHOT</version>
+		<relativePath>../../pom.xml</relativePath>
+	</parent>
+
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.jvnet.jaxb2.maven2</groupId>
+				<artifactId>maven-jaxb2-plugin</artifactId>
+				<version>0.7.1</version>
+				<executions>
+					<execution>
+						<id>interface</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<generateDirectory>${project.basedir}/target/generated-sources/xjc1</generateDirectory>
+							<schemaDirectory>${project.basedir}/resources</schemaDirectory>
+							<schemaIncludes>
+								<include>BrocadeInterfaceSchema.xsd</include>
+							</schemaIncludes>
+							<generatePackage>com.cloud.network.schema.interfacevlan</generatePackage>
+						</configuration>
+					</execution>
+					<execution>
+						<id>portprofile</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<generateDirectory>${project.basedir}/target/generated-sources/xjc2</generateDirectory>
+							<schemaDirectory>${project.basedir}/resources</schemaDirectory>
+							<schemaIncludes>
+								<include>BrocadePortProfileSchema.xsd</include>
+							</schemaIncludes>
+							<generatePackage>com.cloud.network.schema.portprofile</generatePackage>
+						</configuration>
+					</execution>
+					<execution>
+						<id>show-vcs</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<generateDirectory>${project.basedir}/target/generated-sources/xjc3</generateDirectory>
+							<schemaDirectory>${project.basedir}/resources</schemaDirectory>
+							<schemaIncludes>
+								<include>BrocadeShowVcsSchema.xsd</include>
+							</schemaIncludes>
+							<generatePackage>com.cloud.network.schema.showvcs</generatePackage>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/resources/BrocadeInterfaceSchema.xsd
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/resources/BrocadeInterfaceSchema.xsd b/plugins/network-elements/brocade-vcs/resources/BrocadeInterfaceSchema.xsd
new file mode 100644
index 0000000..d24e845
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/resources/BrocadeInterfaceSchema.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:brocade.com:mgmt:brocade-interface"
+	xmlns:tns="urn:brocade.com:mgmt:brocade-interface" elementFormDefault="qualified">
+
+	<annotation>
+		<documentation>
+
+			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.
+		</documentation>
+	</annotation>
+	<element name="interface-vlan">
+		<complexType>
+			<sequence>
+				<element ref="tns:interface"></element>
+			</sequence>
+		</complexType>
+	</element>
+
+	<element name="interface">
+		<complexType>
+			<sequence>
+				<element ref="tns:vlan"></element>
+
+			</sequence>
+		</complexType>
+	</element>
+
+	<element name="vlan">
+		<complexType>
+			<sequence>
+				<element name="name" type="int" />
+			</sequence>
+			<attribute name="operation" type="string" default="delete"></attribute>
+		</complexType>
+	</element>
+</schema>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/resources/BrocadePortProfileSchema.xsd
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/resources/BrocadePortProfileSchema.xsd b/plugins/network-elements/brocade-vcs/resources/BrocadePortProfileSchema.xsd
new file mode 100644
index 0000000..9f21ef0
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/resources/BrocadePortProfileSchema.xsd
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:brocade.com:mgmt:brocade-port-profile"
+	xmlns:tns="urn:brocade.com:mgmt:brocade-port-profile"
+	elementFormDefault="qualified">
+	<annotation>
+		<documentation>
+
+			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.
+		</documentation>
+	</annotation>
+
+	<element name="port-profile">
+		<complexType>
+			<sequence>
+				<element name="name" type="string"></element>
+				<element name="activate">
+					<complexType>
+						<attribute name="operation" type="string"></attribute>
+					</complexType>
+				</element>
+				<element name="static">
+					<complexType>
+						<sequence>
+							<element name="mac-address" type="string"></element>
+						</sequence>
+						<attribute name="operation" type="string"></attribute>
+					</complexType>
+				</element>
+				<element ref="tns:vlan-profile"></element>
+			</sequence>
+			<attribute name="operation" type="string"></attribute>
+		</complexType>
+	</element>
+
+	<element name="port-profile-global">
+		<complexType>
+			<sequence>
+				<element ref="tns:port-profile"></element>
+			</sequence>
+		</complexType>
+	</element>
+
+
+	<element name="vlan-profile">
+		<complexType>
+			<sequence>
+				<element name="switchport-basic">
+					<complexType>
+						<sequence>
+							<element name="basic">
+								<complexType>
+								</complexType>
+							</element>
+						</sequence>
+					</complexType>
+				</element>
+				<element name="switchport">
+					<complexType>
+						<sequence>
+							<element name="mode">
+								<complexType>
+									<sequence>
+										<element name="vlan-mode" type="string"></element>
+									</sequence>
+								</complexType>
+							</element>
+
+							<element name="trunk">
+								<complexType>
+									<sequence>
+										<element name="allowed">
+											<complexType>
+												<sequence>
+													<element name="vlan">
+														<complexType>
+															<sequence>
+																<element name="add" type="int"></element>
+															</sequence>
+														</complexType>
+													</element>
+												</sequence>
+											</complexType>
+										</element>
+									</sequence>
+								</complexType>
+							</element>
+						</sequence>
+					</complexType>
+				</element>
+			</sequence>
+		</complexType>
+	</element>
+</schema>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/resources/BrocadeShowVcsSchema.xsd
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/resources/BrocadeShowVcsSchema.xsd b/plugins/network-elements/brocade-vcs/resources/BrocadeShowVcsSchema.xsd
new file mode 100644
index 0000000..aca9125
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/resources/BrocadeShowVcsSchema.xsd
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:brocade.com:mgmt:brocade-vcs"
+	xmlns:tns="urn:brocade.com:mgmt:brocade-vcs" elementFormDefault="qualified">
+
+	<annotation>
+		<documentation>
+
+			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.
+		</documentation>
+	</annotation>
+	<element name="output">
+		<complexType>
+			<sequence>
+				<element name="vcs-cluster-type-info" type="string"></element>
+				<element name="virtual-ip-address" type="string"></element>
+				<element name="principal-switch-wwn" type="string"></element>
+				<element name="co-ordinator-wwn" type="string"></element>
+				<element name="total-nodes-in-cluster" type="int"></element>
+				<element name="nodes-disconnected-from-cluster" type="int">
+				</element>
+				<element ref="tns:vcs-nodes" />
+				<element name="cluster-generic-status" type="string"></element>
+				<element name="cluster-specific-status" type="string"></element>
+
+			</sequence>
+		</complexType>
+	</element>
+
+
+	<element name="vcs-nodes">
+		<complexType>
+			<sequence>
+				<element ref="tns:vcs-node-info" minOccurs="1" maxOccurs="unbounded"></element>
+			</sequence>
+
+		</complexType>
+	</element>
+
+	<element name="vcs-node-info">
+		<complexType>
+			<sequence>
+				<element name="node-num" type="int" />
+				<element name="node-serial-num" type="string"></element>
+				<element name="node-condition" type="string"></element>
+				<element name="node-status" type="string"></element>
+				<element name="node-vcs-mode" type="string"></element>
+				<element name="node-vcs-id" type="int"></element>
+				<element name="node-rbridge-id" type="int"></element>
+				<element name="node-is-principal" type="boolean"></element>
+				<element name="co-ordinator" type="boolean"></element>
+				<element name="node-switch-mac" type="string"></element>
+				<element name="node-switch-wwn" type="string"></element>
+				<element name="switch-fcf-mac" type="string"></element>
+				<element name="node-internal-ip-address" type="string">
+				</element>
+				<element name="node-swbd-number" type="int"></element>
+				<element name="firmware-version" type="string"></element>
+				<element name="node-switchname" type="string"></element>
+				<element name="node-switchtype" type="string"></element>
+				<element name="node-state" type="string"></element>
+				<element name="node-fabric-state" type="string"></element>
+				<element ref="tns:node-public-ip-addresses" />
+				<element ref="tns:node-public-ipv6-addresses" />
+			</sequence>
+		</complexType>
+	</element>
+
+	<element name="node-public-ip-addresses">
+		<complexType>
+			<sequence minOccurs="1" maxOccurs="unbounded">
+				<element name="node-public-ip-address" type="string"></element>
+			</sequence>
+		</complexType>
+	</element>
+
+	<element name="node-public-ipv6-addresses">
+		<complexType>
+			<sequence minOccurs="1" maxOccurs="unbounded">
+				<element name="node-public-ipv6-address" type="string"></element>
+			</sequence>
+		</complexType>
+	</element>
+</schema>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/module.properties
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/module.properties b/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/module.properties
new file mode 100644
index 0000000..db2c80d
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/module.properties
@@ -0,0 +1,18 @@
+# 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.
+name=vcs
+parent=network
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/spring-vcs-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/spring-vcs-context.xml b/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/spring-vcs-context.xml
new file mode 100644
index 0000000..4c2b419
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/resources/META-INF/cloudstack/vcs/spring-vcs-context.xml
@@ -0,0 +1,29 @@
+<!-- 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+	<bean id="brocadeVcsDaoImpl" class="com.cloud.network.dao.BrocadeVcsDaoImpl" />
+	<bean id="brocadeVcsNetworkVlanMappingDaoImpl" class="com.cloud.network.dao.BrocadeVcsNetworkVlanMappingDaoImpl" />
+	<bean id="BrocadeVcsGuestNetworkGuru" class="com.cloud.network.guru.BrocadeVcsGuestNetworkGuru">
+		<property name="name" value="BrocadeVcsGuestNetworkGuru" />
+	</bean>
+	<bean id="BrocadeVcs" class="com.cloud.network.element.BrocadeVcsElement">
+		<property name="name" value="BrocadeVcs" />
+	</bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkAnswer.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkAnswer.java
new file mode 100644
index 0000000..f8541b5
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkAnswer.java
@@ -0,0 +1,30 @@
+// 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.agent.api;
+
+public class AssociateMacToNetworkAnswer extends Answer {
+
+    public AssociateMacToNetworkAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+
+    }
+
+    public AssociateMacToNetworkAnswer(Command command, Exception e) {
+        super(command, e);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkCommand.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkCommand.java
new file mode 100644
index 0000000..91b714a
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/AssociateMacToNetworkCommand.java
@@ -0,0 +1,48 @@
+// 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.agent.api;
+
+public class AssociateMacToNetworkCommand extends Command {
+
+    private String _interfaceMac;
+    private long _networkId;
+    private String _ownerName;
+
+    public AssociateMacToNetworkCommand(long networkId, String interfaceMac, String ownerName) {
+        _networkId = networkId;
+        _interfaceMac = interfaceMac;
+        _ownerName = ownerName;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public String getInterfaceMac() {
+        return _interfaceMac;
+    }
+
+    public long getNetworkId() {
+        return _networkId;
+    }
+
+    public String getOwnerName() {
+        return _ownerName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkAnswer.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkAnswer.java
new file mode 100644
index 0000000..7d02c63
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkAnswer.java
@@ -0,0 +1,30 @@
+// 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.agent.api;
+
+public class CreateNetworkAnswer extends Answer {
+
+    public CreateNetworkAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+
+    }
+
+    public CreateNetworkAnswer(Command command, Exception e) {
+        super(command, e);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkCommand.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkCommand.java
new file mode 100644
index 0000000..3516dc3
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/CreateNetworkCommand.java
@@ -0,0 +1,48 @@
+// 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.agent.api;
+
+public class CreateNetworkCommand extends Command {
+
+    private int _vlanId;
+    private long _networkId;
+    private String _ownerName;
+
+    public CreateNetworkCommand(int vlanId, long networkId, String ownerName) {
+        _vlanId = vlanId;
+        _networkId = networkId;
+        _ownerName = ownerName;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public int getVlanId() {
+        return _vlanId;
+    }
+
+    public long getNetworkId() {
+        return _networkId;
+    }
+
+    public String getOwnerName() {
+        return _ownerName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkAnswer.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkAnswer.java
new file mode 100644
index 0000000..c12bd99
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkAnswer.java
@@ -0,0 +1,30 @@
+// 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.agent.api;
+
+public class DeleteNetworkAnswer extends Answer {
+
+    public DeleteNetworkAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+
+    }
+
+    public DeleteNetworkAnswer(Command command, Exception e) {
+        super(command, e);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkCommand.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkCommand.java
new file mode 100644
index 0000000..93e3f96
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DeleteNetworkCommand.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.agent.api;
+
+public class DeleteNetworkCommand extends Command {
+
+    private int _vlanId;
+    private long _networkId;
+
+    public DeleteNetworkCommand(int vlanId, long networkId) {
+        _vlanId = vlanId;
+        _networkId = networkId;
+
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public int getVlanId() {
+        return _vlanId;
+    }
+
+    public long getNetworkId() {
+        return _networkId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkAnswer.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkAnswer.java
new file mode 100644
index 0000000..0146fe2
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkAnswer.java
@@ -0,0 +1,30 @@
+// 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.agent.api;
+
+public class DisassociateMacFromNetworkAnswer extends Answer {
+
+    public DisassociateMacFromNetworkAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+
+    }
+
+    public DisassociateMacFromNetworkAnswer(Command command, Exception e) {
+        super(command, e);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkCommand.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkCommand.java
new file mode 100644
index 0000000..86777ae
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/DisassociateMacFromNetworkCommand.java
@@ -0,0 +1,42 @@
+// 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.agent.api;
+
+public class DisassociateMacFromNetworkCommand extends Command {
+
+    private String _interfaceMac;
+    private long _networkId;
+
+    public DisassociateMacFromNetworkCommand(long networkId, String interfaceMac) {
+        _networkId = networkId;
+        _interfaceMac = interfaceMac;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public String getInterfaceMac() {
+        return _interfaceMac;
+    }
+
+    public long getNetworkId() {
+        return _networkId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/StartupBrocadeVcsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/StartupBrocadeVcsCommand.java b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/StartupBrocadeVcsCommand.java
new file mode 100644
index 0000000..43d3222
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/agent/api/StartupBrocadeVcsCommand.java
@@ -0,0 +1,27 @@
+// 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.agent.api;
+
+import com.cloud.host.Host;
+
+public class StartupBrocadeVcsCommand extends StartupCommand {
+
+    public StartupBrocadeVcsCommand() {
+        super(Host.Type.L2Networking);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/AddBrocadeVcsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/AddBrocadeVcsDeviceCmd.java b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/AddBrocadeVcsDeviceCmd.java
new file mode 100644
index 0000000..5ade815
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/AddBrocadeVcsDeviceCmd.java
@@ -0,0 +1,128 @@
+//
+// 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.ApiConstants;
+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.PhysicalNetworkResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.api.response.BrocadeVcsDeviceResponse;
+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.BrocadeVcsDeviceVO;
+import com.cloud.network.brocade.Constants;
+import com.cloud.network.element.BrocadeVcsElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "addBrocadeVcsDevice", responseObject = BrocadeVcsDeviceResponse.class, description = "Adds a Brocade VCS Switch", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class AddBrocadeVcsDeviceCmd extends BaseAsyncCmd {
+    private static final String s_name = "addbrocadevcsdeviceresponse";
+    @Inject
+    protected BrocadeVcsElementService brocadeVcsElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, required = true, description = "the Physical Network ID")
+    private Long physicalNetworkId;
+
+    @Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "Hostname of ip address of the Brocade VCS Switch.")
+    private String host;
+
+    @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Credentials to access the Brocade VCS Switch API")
+    private String username;
+
+    @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Credentials to access the Brocade VCS Switch API")
+    private String password;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+        try {
+            BrocadeVcsDeviceVO brocadeVcsDeviceVO = brocadeVcsElementService.addBrocadeVcsDevice(this);
+            if (brocadeVcsDeviceVO != null) {
+                BrocadeVcsDeviceResponse response = brocadeVcsElementService.createBrocadeVcsDeviceResponse(brocadeVcsDeviceVO);
+                response.setObjectName("brocadevcsdevice");
+                response.setResponseName(getCommandName());
+                setResponseObject(response);
+            } else {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Brocade VCS Switch due to internal error.");
+            }
+        } 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 Constants.EVENT_EXTERNAL_VCS_CONTROLLER_ADD;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Adding a Brocade VCS Switch";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/DeleteBrocadeVcsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/DeleteBrocadeVcsDeviceCmd.java b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/DeleteBrocadeVcsDeviceCmd.java
new file mode 100644
index 0000000..6b7ccf8
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/DeleteBrocadeVcsDeviceCmd.java
@@ -0,0 +1,105 @@
+//
+// 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.BrocadeVcsDeviceResponse;
+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.brocade.Constants;
+import com.cloud.network.element.BrocadeVcsElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "deleteBrocadeVcsDevice", responseObject = SuccessResponse.class, description = " delete a Brocade VCS Switch", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class DeleteBrocadeVcsDeviceCmd extends BaseAsyncCmd {
+    private static final String s_name = "deletebrocadevcsdeviceresponse";
+    @Inject
+    protected BrocadeVcsElementService brocadeVcsElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = Constants.BROCADE_VCS_DEVICE_ID, type = CommandType.UUID, entityType = BrocadeVcsDeviceResponse.class, required = true, description = "Brocade Switch ID")
+    private Long brocadeVcsDeviceId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getBrocadeVcsDeviceId() {
+        return brocadeVcsDeviceId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+        try {
+            boolean result = brocadeVcsElementService.deleteBrocadeVcsDevice(this);
+            if (result) {
+                SuccessResponse response = new SuccessResponse(getCommandName());
+                response.setResponseName(getCommandName());
+                setResponseObject(response);
+            } else {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Brocade VCS Switch.");
+            }
+        } 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 Constants.EVENT_EXTERNAL_VCS_CONTROLLER_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting Brocade VCS Switch";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDeviceNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDeviceNetworksCmd.java b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDeviceNetworksCmd.java
new file mode 100644
index 0000000..584a6e6
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDeviceNetworksCmd.java
@@ -0,0 +1,104 @@
+//
+// 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.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+
+import com.cloud.api.response.BrocadeVcsDeviceResponse;
+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.Network;
+import com.cloud.network.brocade.Constants;
+import com.cloud.network.element.BrocadeVcsElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "listBrocadeVcsDeviceNetworks", responseObject = NetworkResponse.class, description = "lists network that are using a brocade vcs switch", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class ListBrocadeVcsDeviceNetworksCmd extends BaseListCmd {
+
+    public static final Logger s_logger = Logger.getLogger(ListBrocadeVcsDeviceNetworksCmd.class.getName());
+    private static final String s_name = "listbrocadevcsdevicenetworks";
+    @Inject
+    protected BrocadeVcsElementService brocadeVcsElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = Constants.BROCADE_VCS_DEVICE_ID, type = CommandType.UUID, entityType = BrocadeVcsDeviceResponse.class, required = true, description = "brocade vcs switch ID")
+    private Long brocadeVcsDeviceId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getBrocadeVcsDeviceId() {
+        return brocadeVcsDeviceId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+        try {
+            List<? extends Network> networks = brocadeVcsElementService.listBrocadeVcsDeviceNetworks(this);
+            ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
+            List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
+
+            if (networks != null && !networks.isEmpty()) {
+                for (Network network : networks) {
+                    NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
+                    networkResponses.add(networkResponse);
+                }
+            }
+
+            response.setResponses(networkResponses);
+            response.setResponseName(getCommandName());
+            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/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDevicesCmd.java b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDevicesCmd.java
new file mode 100644
index 0000000..3fc2be0
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/commands/ListBrocadeVcsDevicesCmd.java
@@ -0,0 +1,108 @@
+//
+// 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.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.BrocadeVcsDeviceResponse;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.network.brocade.Constants;
+import com.cloud.network.element.BrocadeVcsElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "listBrocadeVcsDevices", responseObject = BrocadeVcsDeviceResponse.class, description = "Lists Brocade VCS Switches", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class ListBrocadeVcsDevicesCmd extends BaseListCmd {
+    private static final String s_name = "listbrocadevcsdeviceresponse";
+
+    @Inject
+    protected BrocadeVcsElementService brocadeVcsElementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
+    private Long physicalNetworkId;
+
+    @Parameter(name = Constants.BROCADE_VCS_DEVICE_ID, type = CommandType.UUID, entityType = BrocadeVcsDeviceResponse.class, description = "Brocade VCS switch ID")
+    private Long brocadeVcsDeviceId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getBrocadeVcsDeviceId() {
+        return brocadeVcsDeviceId;
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
+        try {
+            List<BrocadeVcsDeviceVO> brocadeDevices = brocadeVcsElementService.listBrocadeVcsDevices(this);
+            ListResponse<BrocadeVcsDeviceResponse> response = new ListResponse<BrocadeVcsDeviceResponse>();
+            List<BrocadeVcsDeviceResponse> brocadeDevicesResponse = new ArrayList<BrocadeVcsDeviceResponse>();
+
+            if (brocadeDevices != null && !brocadeDevices.isEmpty()) {
+                for (BrocadeVcsDeviceVO brocadeDeviceVO : brocadeDevices) {
+                    BrocadeVcsDeviceResponse brocadeDeviceResponse = brocadeVcsElementService.createBrocadeVcsDeviceResponse(brocadeDeviceVO);
+                    brocadeDevicesResponse.add(brocadeDeviceResponse);
+                }
+            }
+
+            response.setResponses(brocadeDevicesResponse);
+            response.setResponseName(getCommandName());
+            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/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java b/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
new file mode 100644
index 0000000..60edbcf
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
@@ -0,0 +1,74 @@
+//
+// 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.network.BrocadeVcsDeviceVO;
+import com.cloud.network.brocade.Constants;
+import com.cloud.serializer.Param;
+
+@EntityReference(value = BrocadeVcsDeviceVO.class)
+public class BrocadeVcsDeviceResponse extends BaseResponse {
+    @SerializedName(Constants.BROCADE_VCS_DEVICE_ID)
+    @Param(description = "device id of the Brocade Vcs")
+    private String id;
+
+    @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
+    @Param(description = "the physical Network to which this Brocade VCS belongs to")
+    private String physicalNetworkId;
+
+    @SerializedName(ApiConstants.PROVIDER)
+    @Param(description = "name of the provider")
+    private String providerName;
+
+    @SerializedName(Constants.BROCADE_VCS_DEVICE_NAME)
+    @Param(description = "device name")
+    private String deviceName;
+
+    @SerializedName(ApiConstants.HOST_NAME)
+    @Param(description = "the principal switch Ip address")
+    private String hostName;
+
+    public void setId(String vcsDeviceId) {
+        this.id = vcsDeviceId;
+    }
+
+    public void setPhysicalNetworkId(final String physicalNetworkId) {
+        this.physicalNetworkId = physicalNetworkId;
+    }
+
+    public void setProviderName(final String providerName) {
+        this.providerName = providerName;
+    }
+
+    public void setDeviceName(final String deviceName) {
+        this.deviceName = deviceName;
+    }
+
+    public void setHostName(final String hostName) {
+        this.hostName = hostName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsDeviceVO.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsDeviceVO.java
new file mode 100644
index 0000000..e229e3c
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsDeviceVO.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.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_brocade_vcs_devices")
+public class BrocadeVcsDeviceVO 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;
+
+    public BrocadeVcsDeviceVO() {
+        uuid = UUID.randomUUID().toString();
+    }
+
+    public BrocadeVcsDeviceVO(final long hostId, long physicalNetworkId, final String providerName, final String deviceName) {
+        super();
+        this.hostId = hostId;
+        this.physicalNetworkId = physicalNetworkId;
+        this.providerName = providerName;
+        this.deviceName = deviceName;
+        uuid = UUID.randomUUID().toString();
+    }
+
+    @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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsNetworkVlanMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsNetworkVlanMappingVO.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsNetworkVlanMappingVO.java
new file mode 100644
index 0000000..fd3bc97
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/BrocadeVcsNetworkVlanMappingVO.java
@@ -0,0 +1,72 @@
+// 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 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 = "brocade_network_vlan_map")
+public class BrocadeVcsNetworkVlanMappingVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "network_id")
+    private long networkId;
+
+    @Column(name = "vlan_id")
+    private int vlanId;
+
+    public BrocadeVcsNetworkVlanMappingVO() {
+    }
+
+    public BrocadeVcsNetworkVlanMappingVO(long networkId, int vlanId) {
+        this.networkId = networkId;
+        this.vlanId = vlanId;
+    }
+
+    public long getNetworkId() {
+        return networkId;
+    }
+
+    public void setNetworkId(long networkId) {
+        this.networkId = networkId;
+    }
+
+    public int getVlanId() {
+        return vlanId;
+    }
+
+    public void setVlanId(int vlanId) {
+        this.vlanId = vlanId;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+}


[3/4] CLOUDSTACK-6823 : First code drop for Brocade Network plugin to orchestrate Brocade VDX switches for L2 connectivity

Posted by hu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
new file mode 100644
index 0000000..d5f06f8
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
@@ -0,0 +1,521 @@
+// 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.brocade;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPatch;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.log4j.Logger;
+
+import com.cloud.network.schema.interfacevlan.InterfaceVlan;
+import com.cloud.network.schema.interfacevlan.Interface;
+import com.cloud.network.schema.interfacevlan.Vlan;
+import com.cloud.network.schema.portprofile.PortProfile;
+import com.cloud.network.schema.portprofile.PortProfile.Activate;
+import com.cloud.network.schema.portprofile.PortProfile.Static;
+import com.cloud.network.schema.portprofile.PortProfileGlobal;
+import com.cloud.network.schema.portprofile.VlanProfile;
+import com.cloud.network.schema.portprofile.VlanProfile.Switchport;
+import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Mode;
+import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Trunk;
+import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Trunk.Allowed;
+import com.cloud.network.schema.portprofile.VlanProfile.SwitchportBasic;
+import com.cloud.network.schema.portprofile.VlanProfile.SwitchportBasic.Basic;
+import com.cloud.network.schema.showvcs.Output;
+
+public class BrocadeVcsApi {
+    private static final Logger s_logger = Logger.getLogger(BrocadeVcsApi.class);
+
+    private String _host;
+    private String _adminuser;
+    private String _adminpass;
+
+    protected DefaultHttpClient _client;
+
+    protected HttpRequestBase createMethod(String type, String uri) throws BrocadeVcsApiException {
+        String url;
+        try {
+            url = new URL(Constants.PROTOCOL, _host, Constants.PORT, uri).toString();
+        } catch (MalformedURLException e) {
+            s_logger.error("Unable to build Brocade Switch API URL", e);
+            throw new BrocadeVcsApiException("Unable to build Brocade Switch API URL", e);
+        }
+
+        if ("post".equalsIgnoreCase(type)) {
+            return new HttpPost(url);
+        } else if ("get".equalsIgnoreCase(type)) {
+            return new HttpGet(url);
+        } else if ("delete".equalsIgnoreCase(type)) {
+            return new HttpDelete(url);
+        } else if ("patch".equalsIgnoreCase(type)) {
+            return new HttpPatch(url);
+        } else {
+            throw new BrocadeVcsApiException("Requesting unknown method type");
+        }
+    }
+
+    public BrocadeVcsApi(String address, String username, String password) {
+        _host = address;
+        _adminuser = username;
+        _adminpass = password;
+        _client = new DefaultHttpClient();
+        _client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(_adminuser, _adminpass));
+
+    }
+
+    /*
+     * Get Operational Status
+     */
+    public Output getSwitchStatus() throws BrocadeVcsApiException {
+        return executeRetreiveStatus(Constants.STATUS_URI);
+
+    }
+
+    /*
+     * Creates a new virtual network.
+     */
+    public boolean createNetwork(int vlanId, long networkId) throws BrocadeVcsApiException {
+
+        if (createInterfaceVlan(vlanId)) {
+
+            PortProfile portProfile = createPortProfile(vlanId, networkId);
+
+            if (portProfile != null) {
+                return activatePortProfile(portProfile);
+            }
+        }
+        return false;
+    }
+
+    /*
+     * Activates a port-profile.
+     */
+    private boolean activatePortProfile(PortProfile portProfile) throws BrocadeVcsApiException {
+        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        portProfile.setVlanProfile(null);
+        Activate activate = new Activate();
+        portProfile.setActivate(activate);
+        portProfileGlobal.setPortProfile(portProfile);
+
+        //activate port-profile
+        return executeUpdateObject(portProfileGlobal, Constants.URI);
+    }
+
+    /*
+     *  Creates AMPP port-profile.
+     */
+    private PortProfile createPortProfile(int vlanId, long networkId) throws BrocadeVcsApiException {
+
+        PortProfile portProfile = new PortProfile();
+        portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
+        if (executeCreateObject(portProfile, Constants.URI)) {
+            if (createVlanSubProfile(vlanId, portProfile)) {
+                return portProfile;
+            }
+        }
+        return null;
+    }
+
+    /*
+     * Create vlan sub-profile for port-profile
+     */
+    private boolean createVlanSubProfile(int vlanId, PortProfile portProfile) throws BrocadeVcsApiException {
+        VlanProfile vlanProfile = new VlanProfile();
+        portProfile.setVlanProfile(vlanProfile);
+        if (executeUpdateObject(portProfile, Constants.URI)) {
+            return configureVlanSubProfile(vlanId, portProfile);
+        }
+        return false;
+    }
+
+    /*
+     * Configures vlan sub-profile for port-profile.
+     * - configure L2 mode for vlan sub-profile
+     * - configure trunk mode for vlan sub-profile
+     * - configure allowed VLANs for vlan sub-profile
+     */
+    private boolean configureVlanSubProfile(int vlanId, PortProfile portProfile) throws BrocadeVcsApiException {
+        SwitchportBasic switchPortBasic = new SwitchportBasic();
+        Basic basic = new Basic();
+        switchPortBasic.setBasic(basic);
+        portProfile.getVlanProfile().setSwitchportBasic(switchPortBasic);
+        // configure L2 mode for vlan sub-profile
+        if (executeUpdateObject(portProfile, Constants.URI)) {
+            VlanProfile vlanProfile = new VlanProfile();
+            Switchport switchPort = new Switchport();
+            Mode mode = new Mode();
+            mode.setVlanMode("trunk");
+            switchPort.setMode(mode);
+            vlanProfile.setSwitchport(switchPort);
+            portProfile.setVlanProfile(vlanProfile);
+
+            // configure trunk mode for vlan sub-profile
+            if (executeUpdateObject(portProfile, Constants.URI)) {
+                vlanProfile = new VlanProfile();
+                switchPort = new Switchport();
+                Trunk trunk = new Trunk();
+                Allowed allowed = new Allowed();
+                Allowed.Vlan allowedVlan = new Allowed.Vlan();
+                allowedVlan.setAdd(vlanId);
+                allowed.setVlan(allowedVlan);
+                trunk.setAllowed(allowed);
+                switchPort.setTrunk(trunk);
+                vlanProfile.setSwitchport(switchPort);
+                portProfile.setVlanProfile(vlanProfile);
+
+                //configure allowed VLANs for vlan sub-profile
+                return executeUpdateObject(portProfile, Constants.URI);
+            }
+        }
+
+        return false;
+
+    }
+
+    /*
+     * Creates a vlan interface.
+     */
+    private boolean createInterfaceVlan(int vlanId) throws BrocadeVcsApiException {
+        InterfaceVlan interfaceVlan = new InterfaceVlan();
+        Interface interfaceObj = new Interface();
+        Vlan vlan = new Vlan();
+        vlan.setName(vlanId);
+        interfaceObj.setVlan(vlan);
+        interfaceVlan.setInterface(interfaceObj);
+
+        return executeUpdateObject(interfaceVlan, Constants.URI);
+
+    }
+
+    /*
+     * Associates a MAC address to virtual network.
+     */
+    public boolean associateMacToNetwork(long networkId, String macAddress) throws BrocadeVcsApiException {
+
+        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        PortProfile portProfile = new PortProfile();
+        portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
+        Static staticObj = new Static();
+        staticObj.setMacAddress(macAddress);
+        portProfile.setStatic(staticObj);
+        portProfileGlobal.setPortProfile(portProfile);
+
+        //associates a mac address to a port-profile
+        return executeUpdateObject(portProfileGlobal, Constants.URI);
+    }
+
+    /*
+     * Disassociates a MAC address from virtual network.
+     */
+    public boolean disassociateMacFromNetwork(long networkId, String macAddress) throws BrocadeVcsApiException {
+
+        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        PortProfile portProfile = new PortProfile();
+        portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
+        Static staticObj = new Static();
+        staticObj.setOperation("delete");
+        staticObj.setMacAddress(macAddress);
+        portProfile.setStatic(staticObj);
+        portProfileGlobal.setPortProfile(portProfile);
+
+        //associates a mac address to a port-profile
+        return executeUpdateObject(portProfileGlobal, Constants.URI);
+    }
+
+    /*
+     * Deletes a new virtual network.
+     */
+    public boolean deleteNetwork(int vlanId, long networkId) throws BrocadeVcsApiException {
+
+        if (deactivatePortProfile(networkId)) {
+
+            if (deletePortProfile(networkId)) {
+                return deleteInterfaceVlan(vlanId);
+            }
+        }
+        return false;
+    }
+
+    /*
+     * Deletes a vlan interface.
+     */
+    private boolean deleteInterfaceVlan(int vlanId) throws BrocadeVcsApiException {
+        InterfaceVlan interfaceVlan = new InterfaceVlan();
+        Interface interfaceObj = new Interface();
+        Vlan vlan = new Vlan();
+        vlan.setOperation("delete");
+        vlan.setName(vlanId);
+        interfaceObj.setVlan(vlan);
+        interfaceVlan.setInterface(interfaceObj);
+
+        return executeUpdateObject(interfaceVlan, Constants.URI);
+
+    }
+
+    /*
+     * Deactivates a port-profile.
+     */
+    private boolean deactivatePortProfile(long networkId) throws BrocadeVcsApiException {
+        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        PortProfile portProfile = new PortProfile();
+        portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
+        Activate activate = new Activate();
+        activate.setOperation("delete");
+        portProfile.setActivate(activate);
+        portProfileGlobal.setPortProfile(portProfile);
+
+        //activate port-profile
+        return executeUpdateObject(portProfileGlobal, Constants.URI);
+    }
+
+    /*
+     *  Deletes AMPP port-profile.
+     */
+    private boolean deletePortProfile(long networkId) throws BrocadeVcsApiException {
+
+        PortProfile portProfile = new PortProfile();
+        portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
+        portProfile.setOperation("delete");
+        //deletes port-profile
+        return executeUpdateObject(portProfile, Constants.URI);
+    }
+
+    protected <T> boolean executeUpdateObject(T newObject, String uri) throws BrocadeVcsApiException {
+
+        boolean result = true;
+
+        if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
+            throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
+        }
+
+        HttpPatch pm = (HttpPatch)createMethod("patch", uri);
+        pm.setHeader("Accept", "application/vnd.configuration.resource+xml");
+
+        pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));
+
+        HttpResponse response = executeMethod(pm);
+
+        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
+            String errorMessage = responseToErrorMessage(response);
+            pm.releaseConnection();
+            s_logger.error("Failed to update object : " + errorMessage);
+            throw new BrocadeVcsApiException("Failed to update object : " + errorMessage);
+        }
+
+        pm.releaseConnection();
+
+        return result;
+    }
+
+    protected <T> String convertToString(T object) throws BrocadeVcsApiException {
+
+        final StringWriter stringWriter = new StringWriter();
+
+        try {
+            final JAXBContext context = JAXBContext.newInstance(object.getClass());
+            final Marshaller marshaller = context.createMarshaller();
+
+            marshaller.marshal(object, stringWriter);
+
+        } catch (JAXBException e) {
+            s_logger.error("Failed to convert object to string : " + e.getMessage());
+            throw new BrocadeVcsApiException("Failed to convert object to string : " + e.getMessage());
+        }
+
+        String str = stringWriter.toString();
+        s_logger.info(str);
+
+        return str;
+
+    }
+
+    protected Output convertToXML(String object) throws BrocadeVcsApiException {
+
+        Output output = null;
+        try {
+            JAXBContext context = JAXBContext.newInstance(Output.class);
+
+            StringReader reader = new StringReader(object);
+
+            final Unmarshaller unmarshaller = context.createUnmarshaller();
+            Object result = unmarshaller.unmarshal(reader);
+
+            if (result instanceof Output) {
+                output = (Output)result;
+                s_logger.info(output);
+            }
+
+        } catch (JAXBException e) {
+            s_logger.error("Failed to convert string to object : " + e.getMessage());
+            throw new BrocadeVcsApiException("Failed to convert string to object : " + e.getMessage());
+        }
+
+        return output;
+
+    }
+
+    protected <T> boolean executeCreateObject(T newObject, String uri) throws BrocadeVcsApiException {
+        if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
+            throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
+        }
+
+        boolean result = true;
+        HttpPost pm = (HttpPost)createMethod("post", uri);
+        pm.setHeader("Accept", "application/vnd.configuration.resource+xml");
+        pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));
+
+        HttpResponse response = executeMethod(pm);
+
+        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
+            String errorMessage = responseToErrorMessage(response);
+            pm.releaseConnection();
+            s_logger.error("Failed to create object : " + errorMessage);
+            throw new BrocadeVcsApiException("Failed to create object : " + errorMessage);
+        }
+
+        pm.releaseConnection();
+
+        return result;
+    }
+
+    protected Output executeRetreiveStatus(String uri) throws BrocadeVcsApiException {
+        if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
+            throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
+        }
+
+        BufferedReader br = null;
+        String readLine = null;
+        StringBuffer sb = null;
+
+        HttpPost pm = (HttpPost)createMethod("post", uri);
+        pm.setHeader("Accept", "application/vnd.operational-state.resource+xml");
+        pm.setEntity(new StringEntity("<show-vcs></show-vcs>", ContentType.APPLICATION_XML));
+
+        HttpResponse response = executeMethod(pm);
+
+        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
+            String errorMessage = responseToErrorMessage(response);
+            pm.releaseConnection();
+            s_logger.error("Failed to retreive status : " + errorMessage);
+            throw new BrocadeVcsApiException("Failed to retreive status : " + errorMessage);
+        }
+
+        try {
+            br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")));
+            sb = new StringBuffer();
+
+            while (((readLine = br.readLine()) != null)) {
+                s_logger.debug(readLine);
+                sb.append(readLine);
+
+            }
+        } catch (Exception e) {
+            s_logger.error("Failed to get object : " + e.getMessage());
+            throw new BrocadeVcsApiException("Failed to get object : " + e.getMessage());
+        }
+
+        pm.releaseConnection();
+
+        return convertToXML(sb.toString());
+    }
+
+    protected void executeDeleteObject(String uri) throws BrocadeVcsApiException {
+        if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
+            throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
+        }
+
+        HttpDelete dm = (HttpDelete)createMethod("delete", uri);
+        dm.setHeader("Accept", "application/vnd.configuration.resource+xml");
+
+        HttpResponse response = executeMethod(dm);
+
+        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
+            String errorMessage = responseToErrorMessage(response);
+            dm.releaseConnection();
+            s_logger.error("Failed to delete object : " + errorMessage);
+            throw new BrocadeVcsApiException("Failed to delete object : " + errorMessage);
+        }
+        dm.releaseConnection();
+    }
+
+    protected HttpResponse executeMethod(HttpRequestBase method) throws BrocadeVcsApiException {
+        HttpResponse response = null;
+        try {
+            response = _client.execute(method);
+            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
+                method.releaseConnection();
+                response = _client.execute(method);
+            }
+        } catch (HttpException e) {
+            s_logger.error("HttpException caught while trying to connect to the Brocade Switch", e);
+            method.releaseConnection();
+            throw new BrocadeVcsApiException("API call to Brocade Switch Failed", e);
+        } catch (IOException e) {
+            s_logger.error("IOException caught while trying to connect to the Brocade Switch", e);
+            method.releaseConnection();
+            throw new BrocadeVcsApiException("API call to Brocade Switch Failed", e);
+        }
+
+        return response;
+    }
+
+    private String responseToErrorMessage(HttpResponse response) {
+
+        if ("text/html".equals(response.getEntity().getContentType().getValue())) {
+            try {
+
+                BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")));
+
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while ((line = rd.readLine()) != null) {
+                    result.append(line);
+                }
+
+                return result.toString();
+            } catch (IOException e) {
+                s_logger.debug("Error while loading response body", e);
+            }
+        }
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApiException.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApiException.java
new file mode 100644
index 0000000..76f3079
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApiException.java
@@ -0,0 +1,36 @@
+// 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.brocade;
+
+public class BrocadeVcsApiException extends Exception {
+
+    public BrocadeVcsApiException() {
+    }
+
+    public BrocadeVcsApiException(String message) {
+        super(message);
+    }
+
+    public BrocadeVcsApiException(Throwable cause) {
+        super(cause);
+    }
+
+    public BrocadeVcsApiException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/Constants.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/Constants.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/Constants.java
new file mode 100644
index 0000000..5a9fa0a
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/Constants.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.network.brocade;
+
+public class Constants {
+    public static final String PROTOCOL = "http";
+
+    public static final String URI = "/rest/config/running";
+
+    public static final String STATUS_URI = "/rest/operational-state/show-vcs";
+
+    public static final int PORT = 80;
+
+    public static final String PORT_PROFILE_NAME_PREFIX = "cloudstack-profile-";
+
+    public static final String BROCADE_VCS_DEVICE_ID = "vcsdeviceid";
+    public static final String BROCADE_VCS_DEVICE_NAME = "brocadedevicename";
+
+    public static final String EVENT_EXTERNAL_VCS_CONTROLLER_ADD = "PHYSICAL.VCSCONTROLLER.ADD";
+    public static final String EVENT_EXTERNAL_VCS_CONTROLLER_DELETE = "PHYSICAL.VCSCONTROLLER.DELETE";
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDao.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDao.java
new file mode 100644
index 0000000..76e36a1
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDao.java
@@ -0,0 +1,35 @@
+//
+// 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.dao;
+
+import java.util.List;
+
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface BrocadeVcsDao extends GenericDao<BrocadeVcsDeviceVO, Long> {
+    /**
+     * list all the brocade vcs devices added in to this physical network
+     * @param physicalNetworkId physical network Id
+     * @return list of BrocadevcsDeviceVO for this zone and pod.
+     */
+    List<BrocadeVcsDeviceVO> listByPhysicalNetwork(final long physicalNetworkId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDaoImpl.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDaoImpl.java
new file mode 100644
index 0000000..ec5691a
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsDaoImpl.java
@@ -0,0 +1,53 @@
+//
+// 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.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value = BrocadeVcsDao.class)
+public class BrocadeVcsDaoImpl extends GenericDaoBase<BrocadeVcsDeviceVO, Long> implements BrocadeVcsDao {
+
+    protected final SearchBuilder<BrocadeVcsDeviceVO> physicalNetworkIdSearch;
+
+    public BrocadeVcsDaoImpl() {
+        physicalNetworkIdSearch = createSearchBuilder();
+        physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        physicalNetworkIdSearch.done();
+    }
+
+    @Override
+    public List<BrocadeVcsDeviceVO> listByPhysicalNetwork(final long physicalNetworkId) {
+        SearchCriteria<BrocadeVcsDeviceVO> sc = physicalNetworkIdSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        return search(sc, null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDao.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDao.java
new file mode 100644
index 0000000..16d2986
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDao.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.dao;
+
+import com.cloud.network.BrocadeVcsNetworkVlanMappingVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface BrocadeVcsNetworkVlanMappingDao extends GenericDao<BrocadeVcsNetworkVlanMappingVO, Long> {
+
+    /**
+     * find the mapping for a network
+     * @param networkId
+     *            the network id
+     * @return BrocadeNetworkHostMapping for this network id or null if it does not
+     *         exist
+     */
+    public BrocadeVcsNetworkVlanMappingVO findByNetworkId(long networkId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDaoImpl.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDaoImpl.java
new file mode 100644
index 0000000..88c52a6
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/dao/BrocadeVcsNetworkVlanMappingDaoImpl.java
@@ -0,0 +1,49 @@
+// 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.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.BrocadeVcsNetworkVlanMappingVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value = BrocadeVcsNetworkVlanMappingDao.class)
+public class BrocadeVcsNetworkVlanMappingDaoImpl extends GenericDaoBase<BrocadeVcsNetworkVlanMappingVO, Long> implements BrocadeVcsNetworkVlanMappingDao {
+
+    protected final SearchBuilder<BrocadeVcsNetworkVlanMappingVO> networkSearch;
+
+    public BrocadeVcsNetworkVlanMappingDaoImpl() {
+        networkSearch = createSearchBuilder();
+        networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
+        networkSearch.done();
+
+    }
+
+    @Override
+    public BrocadeVcsNetworkVlanMappingVO findByNetworkId(long networkId) {
+        SearchCriteria<BrocadeVcsNetworkVlanMappingVO> sc = networkSearch.create();
+        sc.setParameters("network_id", networkId);
+        return findOneBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElement.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElement.java
new file mode 100644
index 0000000..b551092
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElement.java
@@ -0,0 +1,467 @@
+// 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.element;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.StartupBrocadeVcsCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.commands.AddBrocadeVcsDeviceCmd;
+import com.cloud.api.commands.DeleteBrocadeVcsDeviceCmd;
+import com.cloud.api.commands.ListBrocadeVcsDeviceNetworksCmd;
+import com.cloud.api.commands.ListBrocadeVcsDevicesCmd;
+import com.cloud.api.response.BrocadeVcsDeviceResponse;
+import com.cloud.configuration.ConfigurationManager;
+import com.cloud.dc.dao.VlanDao;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.DetailVO;
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.host.dao.HostDetailsDao;
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.network.IpAddressManager;
+import com.cloud.network.Network;
+import com.cloud.network.Networks;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.Network.Capability;
+import com.cloud.network.Network.Provider;
+import com.cloud.network.Network.Service;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.dao.BrocadeVcsDao;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
+import com.cloud.network.dao.PhysicalNetworkVO;
+import com.cloud.network.resource.BrocadeVcsResource;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.resource.ResourceManager;
+import com.cloud.resource.ResourceState;
+import com.cloud.resource.ResourceStateAdapter;
+import com.cloud.resource.ServerResource;
+import com.cloud.resource.UnableDeleteHostException;
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.DB;
+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.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+
+@Component
+@Local(value = {NetworkElement.class})
+public class BrocadeVcsElement extends AdapterBase implements NetworkElement, ResourceStateAdapter, BrocadeVcsElementService {
+    private static final Logger s_logger = Logger.getLogger(BrocadeVcsElement.class);
+
+    private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
+
+    @Inject
+    NicDao _nicDao;
+    @Inject
+    ResourceManager _resourceMgr;
+    @Inject
+    PhysicalNetworkDao _physicalNetworkDao;
+    @Inject
+    PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
+    @Inject
+    protected BrocadeVcsDao _brocadeVcsDao;
+    @Inject
+    HostDetailsDao _hostDetailsDao;
+    @Inject
+    HostDao _hostDao;
+    @Inject
+    AgentManager _agentMgr;
+    @Inject
+    NetworkDao _networkDao;
+    @Inject
+    NetworkOrchestrationService _networkManager;
+    @Inject
+    NetworkModel _networkModel;
+    @Inject
+    ConfigurationManager _configMgr;
+    @Inject
+    NetworkServiceMapDao _ntwkSrvcDao;
+    @Inject
+    VlanDao _vlanDao;
+    @Inject
+    IpAddressManager _ipAddrMgr;
+
+    @Override
+    public Map<Service, Map<Capability, String>> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public Provider getProvider() {
+        return Network.Provider.BrocadeVcs;
+    }
+
+    protected boolean canHandle(Network network, Service service) {
+        s_logger.debug("Checking if BrocadeVcsElement can handle service " + service.getName() + " on network " + network.getDisplayText());
+        if (network.getBroadcastDomainType() != BroadcastDomainType.Vcs) {
+            return false;
+        }
+
+        if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) {
+            s_logger.debug("BrocadeVcsElement is not a provider for network " + network.getDisplayText());
+            return false;
+        }
+
+        if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.BrocadeVcs)) {
+            s_logger.debug("BrocadeVcsElement can't provide the " + service.getName() + " service on network " + network.getDisplayText());
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+        _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+        return true;
+    }
+
+    @Override
+    public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+            ResourceUnavailableException, InsufficientCapacityException {
+        s_logger.debug("entering BrocadeVcsElement implement function for network " + network.getDisplayText() + " (state " + network.getState() + ")");
+
+        if (!canHandle(network, Service.Connectivity)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+            ResourceUnavailableException, InsufficientCapacityException {
+
+        if (!canHandle(network, Service.Connectivity)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
+
+        if (!canHandle(network, Service.Connectivity)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
+        if (!canHandle(network, Service.Connectivity)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
+        if (!canHandle(network, Service.Connectivity)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean isReady(PhysicalNetworkServiceProvider provider) {
+        return true;
+    }
+
+    @Override
+    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
+        // Nothing to do here.
+        return true;
+    }
+
+    @Override
+    public boolean canEnableIndividualServices() {
+        return true;
+    }
+
+    @Override
+    public boolean verifyServicesCombination(Set<Service> services) {
+
+        if (!services.contains(Service.Connectivity)) {
+            s_logger.warn("Unable to provide services without Connectivity service enabled for this element");
+            return false;
+        }
+        return true;
+    }
+
+    private static Map<Service, Map<Capability, String>> setCapabilities() {
+        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
+
+        // L2 Support
+        capabilities.put(Service.Connectivity, null);
+
+        return capabilities;
+    }
+
+    @Override
+    public List<Class<?>> getCommands() {
+        List<Class<?>> cmdList = new ArrayList<Class<?>>();
+        cmdList.add(AddBrocadeVcsDeviceCmd.class);
+        cmdList.add(DeleteBrocadeVcsDeviceCmd.class);
+        cmdList.add(ListBrocadeVcsDeviceNetworksCmd.class);
+        cmdList.add(ListBrocadeVcsDevicesCmd.class);
+        return cmdList;
+    }
+
+    @Override
+    @DB
+    public BrocadeVcsDeviceVO addBrocadeVcsDevice(AddBrocadeVcsDeviceCmd cmd) {
+        ServerResource resource = new BrocadeVcsResource();
+        final String deviceName = Network.Provider.BrocadeVcs.getName();
+        NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
+        if (networkDevice == null) {
+            throw new CloudRuntimeException("No network device found for " + deviceName);
+        }
+        final Long physicalNetworkId = cmd.getPhysicalNetworkId();
+        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
+        if (physicalNetwork == null) {
+            throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId);
+        }
+        long zoneId = physicalNetwork.getDataCenterId();
+
+        final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),
+                networkDevice.getNetworkServiceProvder());
+        if (ntwkSvcProvider == null) {
+            throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() + " is not enabled in the physical network: "
+                    + physicalNetworkId + "to add this device");
+        } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
+            throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + " is in shutdown state in the physical network: "
+                    + physicalNetworkId + "to add this device");
+        }
+
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("guid", UUID.randomUUID().toString());
+        params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
+        params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
+        params.put("name", "Brocade VCS - " + cmd.getHost());
+        params.put("ip", cmd.getHost());
+        params.put("adminuser", cmd.getUsername());
+        params.put("adminpass", cmd.getPassword());
+
+        Map<String, Object> hostdetails = new HashMap<String, Object>();
+        hostdetails.putAll(params);
+
+        try {
+            resource.configure(cmd.getHost(), hostdetails);
+
+            final Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.L2Networking, params);
+            if (host != null) {
+                return Transaction.execute(new TransactionCallback<BrocadeVcsDeviceVO>() {
+                    @Override
+                    public BrocadeVcsDeviceVO doInTransaction(TransactionStatus status) {
+                        BrocadeVcsDeviceVO brocadeVcsDevice = new BrocadeVcsDeviceVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName);
+                        _brocadeVcsDao.persist(brocadeVcsDevice);
+
+                        DetailVO detail = new DetailVO(host.getId(), "brocadevcsdeviceid", String.valueOf(brocadeVcsDevice.getId()));
+                        _hostDetailsDao.persist(detail);
+
+                        return brocadeVcsDevice;
+                    }
+                });
+            } else {
+                throw new CloudRuntimeException("Failed to add Brocade VCS Switch due to internal error.");
+            }
+        } catch (ConfigurationException e) {
+            throw new CloudRuntimeException(e.getMessage());
+        }
+
+    }
+
+    @Override
+    public BrocadeVcsDeviceResponse createBrocadeVcsDeviceResponse(BrocadeVcsDeviceVO brocadeVcsDeviceVO) {
+        HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDeviceVO.getHostId());
+        _hostDao.loadDetails(brocadeVcsHost);
+
+        BrocadeVcsDeviceResponse response = new BrocadeVcsDeviceResponse();
+        response.setDeviceName(brocadeVcsDeviceVO.getDeviceName());
+        PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(brocadeVcsDeviceVO.getPhysicalNetworkId());
+        if (pnw != null) {
+            response.setPhysicalNetworkId(pnw.getUuid());
+        }
+        response.setId(brocadeVcsDeviceVO.getUuid());
+        response.setProviderName(brocadeVcsDeviceVO.getProviderName());
+        response.setHostName(brocadeVcsHost.getDetail("ip"));
+        response.setObjectName("brocadevcsdevice");
+        return response;
+    }
+
+    @Override
+    public boolean deleteBrocadeVcsDevice(DeleteBrocadeVcsDeviceCmd cmd) {
+        Long brocadeDeviceId = cmd.getBrocadeVcsDeviceId();
+        BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeDeviceId);
+        if (brocadeVcsDevice == null) {
+            throw new InvalidParameterValueException("Could not find a brocade vcs switch with id " + brocadeVcsDevice);
+        }
+
+        // Find the physical network we work for
+        Long physicalNetworkId = brocadeVcsDevice.getPhysicalNetworkId();
+        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
+        if (physicalNetwork != null) {
+            // Lets see if there are networks that use us
+            // Find the brocade networks on this physical network
+            List<NetworkVO> networkList = _networkDao.listByPhysicalNetwork(physicalNetworkId);
+            if (networkList != null) {
+                // Networks with broadcast type vcs are ours
+                for (NetworkVO network : networkList) {
+                    if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Vcs) {
+                        if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) {
+                            throw new CloudRuntimeException("This Brocade VCS Switch can not be deleted as there are one or more logical networks provisioned by cloudstack.");
+                        }
+                    }
+                }
+            }
+        }
+
+        HostVO brocadeHost = _hostDao.findById(brocadeVcsDevice.getHostId());
+        Long hostId = brocadeHost.getId();
+
+        brocadeHost.setResourceState(ResourceState.Maintenance);
+        _hostDao.update(hostId, brocadeHost);
+        _resourceMgr.deleteHost(hostId, false, false);
+
+        _brocadeVcsDao.remove(brocadeDeviceId);
+        return true;
+    }
+
+    @Override
+    public List<BrocadeVcsDeviceVO> listBrocadeVcsDevices(ListBrocadeVcsDevicesCmd cmd) {
+        Long physicalNetworkId = cmd.getPhysicalNetworkId();
+        Long brocadeVcsDeviceId = cmd.getBrocadeVcsDeviceId();
+        List<BrocadeVcsDeviceVO> responseList = new ArrayList<BrocadeVcsDeviceVO>();
+
+        if (physicalNetworkId == null && brocadeVcsDeviceId == null) {
+            throw new InvalidParameterValueException("Either physical network Id or brocade vcs switch Id must be specified");
+        }
+
+        if (brocadeVcsDeviceId != null) {
+            BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeVcsDeviceId);
+            if (brocadeVcsDevice == null) {
+                throw new InvalidParameterValueException("Could not find Brocade VCS Switch with id: " + brocadeVcsDeviceId);
+            }
+            responseList.add(brocadeVcsDevice);
+        } else {
+            PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
+            if (physicalNetwork == null) {
+                throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
+            }
+            responseList = _brocadeVcsDao.listByPhysicalNetwork(physicalNetworkId);
+        }
+
+        return responseList;
+    }
+
+    @Override
+    public List<? extends Network> listBrocadeVcsDeviceNetworks(ListBrocadeVcsDeviceNetworksCmd cmd) {
+        Long brocadeDeviceId = cmd.getBrocadeVcsDeviceId();
+        BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeDeviceId);
+        if (brocadeVcsDevice == null) {
+            throw new InvalidParameterValueException("Could not find a Brocade VCS Switch with id " + brocadeDeviceId);
+        }
+
+        // Find the physical network we work for
+        Long physicalNetworkId = brocadeVcsDevice.getPhysicalNetworkId();
+        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
+        if (physicalNetwork == null) {
+            // No such physical network, so no provisioned networks
+            return Collections.emptyList();
+        }
+
+        // Find the brocade networks on this physical network
+        List<NetworkVO> networkList = _networkDao.listByPhysicalNetwork(physicalNetworkId);
+        if (networkList == null) {
+            return Collections.emptyList();
+        }
+
+        // Networks with broadcast type vcs are ours
+        List<NetworkVO> responseList = new ArrayList<NetworkVO>();
+        for (NetworkVO network : networkList) {
+            if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Vcs) {
+                responseList.add(network);
+            }
+        }
+
+        return responseList;
+    }
+
+    @Override
+    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
+        if (!(startup[0] instanceof StartupBrocadeVcsCommand)) {
+            return null;
+        }
+        host.setType(Host.Type.L2Networking);
+        return host;
+    }
+
+    @Override
+    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
+        if (!(host.getType() == Host.Type.L2Networking)) {
+            return null;
+        }
+        return new DeleteHostAnswer(true);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElementService.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElementService.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElementService.java
new file mode 100644
index 0000000..b8db60c
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/element/BrocadeVcsElementService.java
@@ -0,0 +1,45 @@
+//
+// 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.element;
+
+import java.util.List;
+
+import com.cloud.api.commands.AddBrocadeVcsDeviceCmd;
+import com.cloud.api.commands.DeleteBrocadeVcsDeviceCmd;
+import com.cloud.api.commands.ListBrocadeVcsDeviceNetworksCmd;
+import com.cloud.api.commands.ListBrocadeVcsDevicesCmd;
+import com.cloud.api.response.BrocadeVcsDeviceResponse;
+import com.cloud.network.Network;
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.utils.component.PluggableService;
+
+public interface BrocadeVcsElementService extends PluggableService {
+
+    public BrocadeVcsDeviceVO addBrocadeVcsDevice(AddBrocadeVcsDeviceCmd cmd);
+
+    public BrocadeVcsDeviceResponse createBrocadeVcsDeviceResponse(BrocadeVcsDeviceVO brocadeDeviceVO);
+
+    boolean deleteBrocadeVcsDevice(DeleteBrocadeVcsDeviceCmd cmd);
+
+    List<? extends Network> listBrocadeVcsDeviceNetworks(ListBrocadeVcsDeviceNetworksCmd cmd);
+
+    List<BrocadeVcsDeviceVO> listBrocadeVcsDevices(ListBrocadeVcsDevicesCmd cmd);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/guru/BrocadeVcsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/guru/BrocadeVcsGuestNetworkGuru.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/guru/BrocadeVcsGuestNetworkGuru.java
new file mode 100644
index 0000000..92bf113
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/guru/BrocadeVcsGuestNetworkGuru.java
@@ -0,0 +1,267 @@
+// 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.guru;
+
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.AssociateMacToNetworkAnswer;
+import com.cloud.agent.api.AssociateMacToNetworkCommand;
+import com.cloud.agent.api.CreateNetworkAnswer;
+import com.cloud.agent.api.CreateNetworkCommand;
+import com.cloud.agent.api.DeleteNetworkAnswer;
+import com.cloud.agent.api.DeleteNetworkCommand;
+import com.cloud.agent.api.DisassociateMacFromNetworkAnswer;
+import com.cloud.agent.api.DisassociateMacFromNetworkCommand;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.network.BrocadeVcsDeviceVO;
+import com.cloud.network.BrocadeVcsNetworkVlanMappingVO;
+import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
+import com.cloud.network.Network.Service;
+import com.cloud.network.Network.State;
+import com.cloud.network.NetworkProfile;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetwork.IsolationMethod;
+import com.cloud.network.dao.BrocadeVcsDao;
+import com.cloud.network.dao.BrocadeVcsNetworkVlanMappingDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
+import com.cloud.resource.ResourceManager;
+import com.cloud.user.Account;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Local(value = NetworkGuru.class)
+public class BrocadeVcsGuestNetworkGuru extends GuestNetworkGuru {
+    private static final Logger s_logger = Logger.getLogger(BrocadeVcsGuestNetworkGuru.class);
+
+    @Inject
+    NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
+    @Inject
+    ResourceManager _resourceMgr;
+    @Inject
+    AgentManager _agentMgr;
+    @Inject
+    protected BrocadeVcsDao _brocadeVcsDao;
+    @Inject
+    protected BrocadeVcsNetworkVlanMappingDao _brocadeVcsNetworkVlanDao;
+    @Inject
+    PhysicalNetworkServiceProviderDao _pNSPDao;
+    @Inject
+    HostDao _hostDao;
+
+    public BrocadeVcsGuestNetworkGuru() {
+        super();
+        _isolationMethods = new IsolationMethod[] {IsolationMethod.VCS};
+    }
+
+    @Override
+    protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
+        // This guru handles only Guest Isolated network that supports L2 connectivity service
+        if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated
+                && isMyIsolationMethod(physicalNetwork) && _ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Connectivity)) {
+            return true;
+        } else {
+            s_logger.trace("We only take care of Guest networks of type   " + GuestType.Isolated + " in zone of type " + NetworkType.Advanced);
+            return false;
+        }
+    }
+
+    @Override
+    public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
+        // Check of the isolation type of the related physical network is VLAN
+        PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
+        DataCenter dc = _dcDao.findById(plan.getDataCenterId());
+        if (!canHandle(offering, dc.getNetworkType(), physnet)) {
+            s_logger.debug("Refusing to design this network");
+            return null;
+        }
+        s_logger.debug("Physical isolation type is VCS, asking GuestNetworkGuru to design this network");
+        NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
+        if (networkObject == null) {
+            return null;
+        }
+        // Override the broadcast domain type
+        networkObject.setBroadcastDomainType(BroadcastDomainType.Vcs);
+        networkObject.setState(State.Allocated);
+
+        return networkObject;
+    }
+
+    @Override
+    public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException {
+        assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
+
+        Network implemented = super.implement(network, offering, dest, context);
+
+        int vlanTag = Integer.parseInt(BroadcastDomainType.getValue(implemented.getBroadcastUri()));
+
+        //get physical network id
+        Long physicalNetworkId = network.getPhysicalNetworkId();
+
+        List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(physicalNetworkId);
+        if (devices.isEmpty()) {
+            s_logger.error("No Brocade VCS Switch on physical network " + physicalNetworkId);
+            return null;
+        }
+
+        for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) {
+            HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId());
+
+            // create createNetworkCmd instance and agentMgr execute it.
+            CreateNetworkCommand cmd = new CreateNetworkCommand(vlanTag, network.getId(), context.getDomain().getName() + "-" + context.getAccount().getAccountName());
+            CreateNetworkAnswer answer = (CreateNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd);
+
+            if (answer == null || !answer.getResult()) {
+                s_logger.error("CreateNetworkCommand failed");
+                s_logger.error("Unable to create network " + network.getId());
+                return null;
+            }
+
+        }
+
+        // Persist the network-vlan mapping from db
+        BrocadeVcsNetworkVlanMappingVO brocadeVcsNetworkVlanMapping = new BrocadeVcsNetworkVlanMappingVO(network.getId(), vlanTag);
+        _brocadeVcsNetworkVlanDao.persist(brocadeVcsNetworkVlanMapping);
+
+        return implemented;
+    }
+
+    @Override
+    public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
+            throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
+        super.reserve(nic, network, vm, dest, context);
+
+        DataCenter dc = _dcDao.findById(network.getDataCenterId());
+
+        String interfaceMac = nic.getMacAddress();
+
+        List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
+        if (devices.isEmpty()) {
+            s_logger.error("No Brocade VCS Switch on physical network " + network.getPhysicalNetworkId());
+            return;
+        }
+        for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) {
+            HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId());
+
+            // create AssociateMacToNetworkCmd instance and agentMgr execute it.
+            AssociateMacToNetworkCommand cmd = new AssociateMacToNetworkCommand(network.getId(), interfaceMac, context.getDomain().getName() + "-"
+                    + context.getAccount().getAccountName());
+            AssociateMacToNetworkAnswer answer = (AssociateMacToNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd);
+
+            if (answer == null || !answer.getResult()) {
+                s_logger.error("AssociateMacToNetworkCommand failed");
+                throw new InsufficientVirtualNetworkCapacityException("Unable to associate mac " + interfaceMac + " to network " + network.getId(), DataCenter.class, dc.getId());
+            }
+        }
+
+    }
+
+    @Override
+    public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
+
+        String interfaceMac = nic.getMacAddress();
+
+        List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
+        if (devices.isEmpty()) {
+            s_logger.error("No Brocade VCS Switch on physical network " + network.getPhysicalNetworkId());
+            return;
+        }
+        for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) {
+            HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId());
+
+            // create DisassociateMacFromNetworkCmd instance and agentMgr execute it.
+            DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(network.getId(), interfaceMac);
+            DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd);
+
+            if (answer == null || !answer.getResult()) {
+                s_logger.error("DisassociateMacFromNetworkCommand failed");
+                s_logger.error("Unable to disassociate mac " + interfaceMac + " from network " + network.getId());
+                return;
+            }
+        }
+        super.deallocate(network, nic, vm);
+    }
+
+    @Override
+    public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
+        return super.release(nic, vm, reservationId);
+    }
+
+    @Override
+    public void shutdown(NetworkProfile profile, NetworkOffering offering) {
+
+        super.shutdown(profile, offering);
+    }
+
+    @Override
+    public boolean trash(Network network, NetworkOffering offering) {
+
+        int vlanTag = 0;
+        // Get the network-vlan mapping from db
+        BrocadeVcsNetworkVlanMappingVO brocadeVcsNetworkVlanMapping = _brocadeVcsNetworkVlanDao.findByNetworkId(network.getId());
+
+        if (brocadeVcsNetworkVlanMapping != null) {
+            vlanTag = brocadeVcsNetworkVlanMapping.getVlanId();
+        } else {
+            s_logger.error("Not able to find vlanId for network " + network.getId());
+            return false;
+        }
+
+        List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
+        if (devices.isEmpty()) {
+            s_logger.error("No Brocade VCS Switch on physical network " + network.getPhysicalNetworkId());
+            return false;
+        }
+        for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) {
+            HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId());
+
+            // create deleteNetworkCmd instance and agentMgr execute it.
+            DeleteNetworkCommand cmd = new DeleteNetworkCommand(vlanTag, network.getId());
+            DeleteNetworkAnswer answer = (DeleteNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd);
+
+            if (answer == null || !answer.getResult()) {
+                s_logger.error("DeleteNetworkCommand failed");
+                s_logger.error("Unable to delete network " + network.getId());
+                return false;
+            }
+        }
+
+        // Remove the network-vlan mapping from db
+        _brocadeVcsNetworkVlanDao.remove(brocadeVcsNetworkVlanMapping.getId());
+        return super.trash(network, offering);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/src/com/cloud/network/resource/BrocadeVcsResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/resource/BrocadeVcsResource.java b/plugins/network-elements/brocade-vcs/src/com/cloud/network/resource/BrocadeVcsResource.java
new file mode 100644
index 0000000..0a32399
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/resource/BrocadeVcsResource.java
@@ -0,0 +1,310 @@
+// 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.resource;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.IAgentControl;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.AssociateMacToNetworkAnswer;
+import com.cloud.agent.api.AssociateMacToNetworkCommand;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.CreateNetworkAnswer;
+import com.cloud.agent.api.CreateNetworkCommand;
+import com.cloud.agent.api.DeleteNetworkAnswer;
+import com.cloud.agent.api.DeleteNetworkCommand;
+import com.cloud.agent.api.DisassociateMacFromNetworkAnswer;
+import com.cloud.agent.api.DisassociateMacFromNetworkCommand;
+import com.cloud.agent.api.MaintainAnswer;
+import com.cloud.agent.api.MaintainCommand;
+import com.cloud.agent.api.PingCommand;
+import com.cloud.agent.api.ReadyAnswer;
+import com.cloud.agent.api.ReadyCommand;
+import com.cloud.agent.api.StartupBrocadeVcsCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.network.brocade.BrocadeVcsApi;
+import com.cloud.network.brocade.BrocadeVcsApiException;
+import com.cloud.network.schema.showvcs.Output;
+import com.cloud.network.schema.showvcs.VcsNodeInfo;
+import com.cloud.resource.ServerResource;
+
+public class BrocadeVcsResource implements ServerResource {
+    private static final Logger s_logger = Logger.getLogger(BrocadeVcsResource.class);
+
+    private String _name;
+    private String _guid;
+    private String _zoneId;
+    private int _numRetries;
+
+    private BrocadeVcsApi _brocadeVcsApi;
+
+    protected BrocadeVcsApi createBrocadeVcsApi(String ip, String username, String password) {
+
+        return new BrocadeVcsApi(ip, username, password);
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+
+        _name = (String)params.get("name");
+        if (_name == null) {
+            throw new ConfigurationException("Unable to find name");
+        }
+
+        _guid = (String)params.get("guid");
+        if (_guid == null) {
+            throw new ConfigurationException("Unable to find the guid");
+        }
+
+        _zoneId = (String)params.get("zoneId");
+        if (_zoneId == null) {
+            throw new ConfigurationException("Unable to find zone");
+        }
+
+        _numRetries = 2;
+
+        String ip = (String)params.get("ip");
+        if (ip == null) {
+            throw new ConfigurationException("Unable to find IP");
+        }
+
+        String adminuser = (String)params.get("adminuser");
+        if (adminuser == null) {
+            throw new ConfigurationException("Unable to find admin username");
+        }
+
+        String adminpass = (String)params.get("adminpass");
+        if (adminpass == null) {
+            throw new ConfigurationException("Unable to find admin password");
+        }
+
+        _brocadeVcsApi = createBrocadeVcsApi(ip, adminuser, adminpass);
+
+        return true;
+    }
+
+    @Override
+    public boolean start() {
+        return true;
+    }
+
+    @Override
+    public boolean stop() {
+        return true;
+    }
+
+    @Override
+    public String getName() {
+        return _name;
+    }
+
+    @Override
+    public Type getType() {
+        return Host.Type.L2Networking;
+    }
+
+    @Override
+    public StartupCommand[] initialize() {
+        StartupBrocadeVcsCommand sc = new StartupBrocadeVcsCommand();
+        sc.setGuid(_guid);
+        sc.setName(_name);
+        sc.setDataCenter(_zoneId);
+        sc.setPrivateIpAddress("");
+        sc.setStorageIpAddress("");
+        sc.setVersion(BrocadeVcsResource.class.getPackage().getImplementationVersion());
+        return new StartupCommand[] {sc};
+    }
+
+    @Override
+    public PingCommand getCurrentStatus(long id) {
+
+        Output output;
+        try {
+            output = _brocadeVcsApi.getSwitchStatus();
+        } catch (BrocadeVcsApiException e) {
+            s_logger.error("getSwitchStatus failed", e);
+            return null;
+        }
+
+        List<VcsNodeInfo> vcsNodes = output.getVcsNodes().getVcsNodeInfo();
+        if (vcsNodes != null && !vcsNodes.isEmpty()) {
+            for (VcsNodeInfo vcsNodeInfo : vcsNodes) {
+                if (!"Online".equals(vcsNodeInfo.getNodeState())) {
+                    s_logger.error("Brocade Switch is not ready: " + id);
+                    return null;
+                }
+            }
+        }
+        return new PingCommand(Host.Type.L2Networking, id);
+
+    }
+
+    @Override
+    public Answer executeRequest(Command cmd) {
+        return executeRequest(cmd, _numRetries);
+    }
+
+    public Answer executeRequest(Command cmd, int numRetries) {
+        if (cmd instanceof ReadyCommand) {
+            return executeRequest((ReadyCommand)cmd);
+        } else if (cmd instanceof MaintainCommand) {
+            return executeRequest((MaintainCommand)cmd);
+        } else if (cmd instanceof CreateNetworkCommand) {
+            return executeRequest((CreateNetworkCommand)cmd, numRetries);
+        } else if (cmd instanceof AssociateMacToNetworkCommand) {
+            return executeRequest((AssociateMacToNetworkCommand)cmd, numRetries);
+        } else if (cmd instanceof DisassociateMacFromNetworkCommand) {
+            return executeRequest((DisassociateMacFromNetworkCommand)cmd, numRetries);
+        } else if (cmd instanceof DeleteNetworkCommand) {
+            return executeRequest((DeleteNetworkCommand)cmd, numRetries);
+        }
+        s_logger.debug("Received unsupported command " + cmd.toString());
+        return Answer.createUnsupportedCommandAnswer(cmd);
+    }
+
+    @Override
+    public void disconnected() {
+    }
+
+    @Override
+    public IAgentControl getAgentControl() {
+        return null;
+    }
+
+    @Override
+    public void setAgentControl(IAgentControl agentControl) {
+    }
+
+    private Answer executeRequest(CreateNetworkCommand cmd, int numRetries) {
+
+        try {
+            boolean result = _brocadeVcsApi.createNetwork(cmd.getVlanId(), cmd.getNetworkId());
+            return new CreateNetworkAnswer(cmd, result, "Port Profile " + cmd.getNetworkId() + " created");
+        } catch (BrocadeVcsApiException e) {
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            } else {
+                return new CreateNetworkAnswer(cmd, e);
+            }
+        }
+
+    }
+
+    private Answer executeRequest(AssociateMacToNetworkCommand cmd, int numRetries) {
+
+        try {
+
+            String mac = macReformat64To32(cmd.getInterfaceMac());
+            boolean result = _brocadeVcsApi.associateMacToNetwork(cmd.getNetworkId(), mac);
+            return new AssociateMacToNetworkAnswer(cmd, result, "Association of mac " + cmd.getInterfaceMac() + " to network " + cmd.getNetworkId() + " done");
+        } catch (BrocadeVcsApiException e) {
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            } else {
+                return new AssociateMacToNetworkAnswer(cmd, e);
+            }
+        }
+
+    }
+
+    private Answer executeRequest(DisassociateMacFromNetworkCommand cmd, int numRetries) {
+
+        try {
+
+            String mac = macReformat64To32(cmd.getInterfaceMac());
+            boolean result = _brocadeVcsApi.disassociateMacFromNetwork(cmd.getNetworkId(), mac);
+            return new DisassociateMacFromNetworkAnswer(cmd, result, "Disassociation of mac " + cmd.getInterfaceMac() + " from network " + cmd.getNetworkId() + " done");
+        } catch (BrocadeVcsApiException e) {
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            } else {
+                return new DisassociateMacFromNetworkAnswer(cmd, e);
+            }
+        }
+
+    }
+
+    private Answer executeRequest(DeleteNetworkCommand cmd, int numRetries) {
+
+        try {
+            boolean result = _brocadeVcsApi.deleteNetwork(cmd.getVlanId(), cmd.getNetworkId());
+            return new DeleteNetworkAnswer(cmd, result, "Port Profile " + cmd.getNetworkId() + " deleted");
+        } catch (BrocadeVcsApiException e) {
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            } else {
+                return new DeleteNetworkAnswer(cmd, e);
+            }
+        }
+
+    }
+
+    private String macReformat64To32(String interfaceMac) {
+        String mac = interfaceMac.replace(":", "");
+        mac = mac.substring(0, 4) + "." + mac.substring(4, 8) + "." + mac.subSequence(8, 12);
+        return mac;
+
+    }
+
+    private Answer executeRequest(ReadyCommand cmd) {
+        return new ReadyAnswer(cmd);
+    }
+
+    private Answer executeRequest(MaintainCommand cmd) {
+        return new MaintainAnswer(cmd);
+    }
+
+    private Answer retry(Command cmd, int numRetries) {
+        s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);
+        return executeRequest(cmd, numRetries);
+    }
+
+    @Override
+    public void setName(String name) {
+
+    }
+
+    @Override
+    public void setConfigParams(Map<String, Object> params) {
+
+    }
+
+    @Override
+    public Map<String, Object> getConfigParams() {
+
+        return null;
+    }
+
+    @Override
+    public int getRunLevel() {
+
+        return 0;
+    }
+
+    @Override
+    public void setRunLevel(int level) {
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/628d8e66/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java b/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
new file mode 100644
index 0000000..4223d4c
--- /dev/null
+++ b/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
@@ -0,0 +1,185 @@
+//
+// 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.brocade;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.http.StatusLine;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPatch;
+import org.apache.http.client.methods.HttpPost;
+
+import com.cloud.network.schema.showvcs.Output;
+
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BrocadeVcsApiTest {
+    protected static final long NETWORK_ID = 42L;
+    protected static final int VLAN_ID = 14;
+    private static final String MAC_ADDRESS_32 = "0050.56bf.0002";
+    protected static final String OUTPUT_XML_RESPONSE = "<output xmlns='urn:brocade.com:mgmt:brocade-vcs'> <vcs-nodes> <vcs-node-info> <node-state>Online</node-state> </vcs-node-info> </vcs-nodes> </output>";
+    BrocadeVcsApi api;
+    DefaultHttpClient client = mock(DefaultHttpClient.class);
+    HttpRequestBase method;
+    HttpResponse response;
+    HttpResponse postResponse;
+    String type;
+    String uri;
+
+    @Before
+    public void setUp() {
+        api = new BrocadeVcsApi("localhost", "admin", "password") {
+
+            @Override
+            public HttpRequestBase createMethod(final String newType, final String newUri) {
+                type = newType;
+                uri = newUri;
+                return method;
+            }
+
+            @Override
+            public HttpResponse executeMethod(HttpRequestBase method) throws BrocadeVcsApiException {
+                return response;
+            }
+
+            @Override
+            protected <T> boolean executeCreateObject(T newObject, String uri) throws BrocadeVcsApiException {
+
+                return true;
+            }
+        };
+
+        api._client = client;
+
+    }
+
+    @Test
+    public void testGetSwitchStatus() throws BrocadeVcsApiException, IOException {
+        // Prepare
+
+        method = mock(HttpPost.class);
+
+        response = mock(HttpResponse.class);
+        final StatusLine statusLine = mock(StatusLine.class);
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(response.getStatusLine()).thenReturn(statusLine);
+        when(response.getEntity()).thenReturn(new StringEntity(OUTPUT_XML_RESPONSE));
+
+        // Execute
+        Output result = api.getSwitchStatus();
+
+        // Assert
+        verify(method, times(1)).releaseConnection();
+        assertEquals("Wrong URI for get SwitchStatus REST service", Constants.STATUS_URI, uri);
+        assertEquals("Wrong HTTP method for get SwitchStatus REST service", "post", type);
+        assertEquals("Wrong state for get SwitchStatus REST service", "Online", result.getVcsNodes().getVcsNodeInfo().get(0).getNodeState());
+    }
+
+    @Test
+    public void testCreateNetwork() throws BrocadeVcsApiException, IOException {
+        // Prepare
+
+        method = mock(HttpPatch.class);
+
+        response = mock(HttpResponse.class);
+        final StatusLine statusLine = mock(StatusLine.class);
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(response.getStatusLine()).thenReturn(statusLine);
+
+        // Execute
+        api.createNetwork(VLAN_ID, NETWORK_ID);
+
+        // Assert
+        verify(method, times(6)).releaseConnection();
+        assertEquals("Wrong URI for Network creation REST service", Constants.URI, uri);
+        assertEquals("Wrong HTTP method for Network creation REST service", "patch", type);
+    }
+
+    @Test
+    public void testDeleteNetwork() throws BrocadeVcsApiException, IOException {
+        // Prepare
+
+        method = mock(HttpPatch.class);
+
+        response = mock(HttpResponse.class);
+        final StatusLine statusLine = mock(StatusLine.class);
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(response.getStatusLine()).thenReturn(statusLine);
+
+        // Execute
+        api.deleteNetwork(VLAN_ID, NETWORK_ID);
+
+        // Assert
+        verify(method, times(3)).releaseConnection();
+        assertEquals("Wrong URI for Network creation REST service", Constants.URI, uri);
+        assertEquals("Wrong HTTP method for Network creation REST service", "patch", type);
+    }
+
+    @Test
+    public void testAssociateMacToNetwork() throws BrocadeVcsApiException, IOException {
+        // Prepare
+
+        method = mock(HttpPatch.class);
+
+        response = mock(HttpResponse.class);
+        final StatusLine statusLine = mock(StatusLine.class);
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(response.getStatusLine()).thenReturn(statusLine);
+
+        // Execute
+        api.associateMacToNetwork(NETWORK_ID, MAC_ADDRESS_32);
+
+        // Assert
+        verify(method, times(1)).releaseConnection();
+        assertEquals("Wrong URI for Network creation REST service", Constants.URI, uri);
+        assertEquals("Wrong HTTP method for Network creation REST service", "patch", type);
+    }
+
+    @Test
+    public void testDisassociateMacFromNetwork() throws BrocadeVcsApiException, IOException {
+        // Prepare
+
+        method = mock(HttpPatch.class);
+
+        response = mock(HttpResponse.class);
+        final StatusLine statusLine = mock(StatusLine.class);
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(response.getStatusLine()).thenReturn(statusLine);
+
+        // Execute
+        api.disassociateMacFromNetwork(NETWORK_ID, MAC_ADDRESS_32);
+
+        // Assert
+        verify(method, times(1)).releaseConnection();
+        assertEquals("Wrong URI for Network creation REST service", Constants.URI, uri);
+        assertEquals("Wrong HTTP method for Network creation REST service", "patch", type);
+    }
+
+}
\ No newline at end of file