cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [48/50] [abbrv] Merge javelin into master
Date Fri, 01 Feb 2013 23:27:31 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/com/cloud/network/PhysicalNetwork.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/com/cloud/offering/NetworkOffering.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/client/pom.xml
----------------------------------------------------------------------
diff --cc client/pom.xml
index df82402,27bca3d..3ae9dc5
--- a/client/pom.xml
+++ b/client/pom.xml
@@@ -262,22 -336,38 +341,38 @@@
                </target>
              </configuration>
            </execution>
 -          <execution>
 -            <id>process-nonoss</id>
 -            <phase>process-resources</phase>
 -            <goals>
 -              <goal>run</goal>
 -            </goals>
 -            <configuration>
 -              <target if="${nonoss}">
 -                <echo>test</echo>
 -                <replaceregexp
 -                  file="${basedir}/target/generated-webapp/WEB-INF/classes/environment.properties"
 -                  match="cloud-stack-components-specification=.*"
 -                  replace="cloud-stack-components-specification=components-nonoss.xml" byline="true" />
 -              </target>
 -            </configuration>
 -          </execution>
 +           <execution>
 +                <id>process-nonoss</id>
 +                <phase>process-resources</phase>
 +                <goals>
 +                  <goal>run</goal>
 +                </goals>
 +                <configuration>
 +                  <target if="${nonoss}">
 +                    <echo>test</echo>
 +                    <replaceregexp
 +                      file="${basedir}/target/generated-webapp/WEB-INF/classes/environment.properties"
 +                      match="cloud-stack-components-specification=.*"
 +                      replace="cloud-stack-components-specification=components-nonoss.xml" byline="true" />
 +                  </target>
 +                </configuration>
 +              </execution>
+           <execution>
+             <id>process-nonoss-spring-context</id>
+             <phase>process-resources</phase>
+             <goals>
+               <goal>run</goal>
+             </goals>
+             <configuration>
+               <target if="${nonoss}">
+                 <echo>test</echo>
+                 <replaceregexp
+                   file="${basedir}/target/generated-webapp/WEB-INF/web.xml"
+                   match="classpath:applicationContext.xml, classpath:componentContext.xml"
+                   replace="classpath:applicationContext.xml, classpath:nonossComponentContext.xml" byline="true" />
+               </target>
+             </configuration>
+           </execution>
          </executions>
        </plugin>
        <!-- there are the jasypt libs requires by some of the python scripts -->

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/componentContext.xml.in
index 0000000,ca91727..82b5228
mode 000000,100644..100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@@ -1,0 -1,258 +1,269 @@@
+ <!--
+   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:tx="http://www.springframework.org/schema/tx" 
+   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/tx 
+                       http://www.springframework.org/schema/tx/spring-tx-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">                     
+ 
+ 
+   <!--
+       Compose a CloudStack deployment with selected components here
+   -->
+   <bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
+   
+   <bean id="management-server" class ="com.cloud.server.ManagementServerExtImpl" />
+   <bean id="configuration-server" class="com.cloud.server.ConfigurationServerImpl" />
+    
+   <bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
+   <bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
+   <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" />
+   <bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" />
+   <!-- bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" / -->
+   <bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
+   <bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
+   <bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
+   <bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
+   <bean id="randomlyIncreasingVMInstanceDaoImpl" class="com.cloud.vm.dao.RandomlyIncreasingVMInstanceDaoImpl" />
+   <bean id="ipv6AddressManagerImpl" class="com.cloud.network.Ipv6AddressManagerImpl" />
+   <bean id="RegionManagerImpl" class="org.apache.cloudstack.region.RegionManagerImpl" />
++
++  <bean id="ApiRateLimitService" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl">
++    <property name="name" value="ApiRateLimitService"/>
++  </bean>
+    
+   <!--
+       Network Elements
+   -->
+   <bean id="Ovs" class="com.cloud.network.element.OvsElement">
+     <property name="name" value="Ovs"/>
+   </bean>
+   <bean id="ExternalDhcpServer" class="com.cloud.network.element.ExternalDhcpElement">
+     <property name="name" value="ExternalDhcpServer"/>
+   </bean>
+   <bean id="BareMetal" class="com.cloud.network.element.BareMetalElement">
+     <property name="name" value="BareMetal"/>
+   </bean>
+   <bean id="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement">
+     <property name="name" value="SecurityGroupProvider"/>
+   </bean>
+   <bean id="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement">
+     <property name="name" value="VirtualRouter"/>
+   </bean>
+   <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
+     <property name="name" value="VpcVirtualRouter"/>
+   </bean>
+   <bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
+     <property name="name" value="NiciraNvp"/>
+   </bean>
++  <bean id="BigSwitchVnsElementService" class="com.cloud.network.element.BigSwitchVnsElement">
++    <property name="name" value="BigSwitchVnsElementService"/>
++  </bean>
+                    
+   <!--
+      Adapters
+   -->
+   <bean id="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator">
+     <property name="name" value="FirstFitRouting"/>
+   </bean>
+   
+   <!--
+     Storage pool allocators
+   -->
+   <bean id="LocalStoragePoolAllocator" class="com.cloud.storage.allocator.LocalStoragePoolAllocator">
+     <property name="name" value="LocalStorage"/>
+   </bean>
+   <bean id="FirstFitStoragePoolAllocator" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator">
+     <property name="name" value="Storage"/>
+   </bean>
+ 
+   <bean id="UserConcentratedAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
+     <property name="name" value="User First"/>
+   </bean>
+ 
+   <bean id="ConsoleProxyAllocator" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator">
+     <property name="name" value="Balance"/>
+   </bean>
+ 
+   <bean id="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
+ 
+   <bean id="ApiRateLimitServiceImpl" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
+ 
+   <bean id="ExteralIpAddressAllocator" class="com.cloud.network.ExteralIpAddressAllocator">
+     <property name="name" value="Basic"/>
+   </bean>
+ 
+   <bean id="hyervisorTemplateAdapter" class="com.cloud.template.HyervisorTemplateAdapter">
+     <property name="name" value="HypervisorAdapter"/>
+   </bean>
+ 
+   <!--
+     Authenticators
+   -->
+   <bean id="MD5UserAuthenticator" class="com.cloud.server.auth.MD5UserAuthenticator">
+     <property name="name" value="MD5"/>
+   </bean>
+ 
+   <bean id="LDAPUserAuthenticator" class="com.cloud.server.auth.LDAPUserAuthenticator">
+     <property name="name" value="LDAP"/>
+   </bean>
+ 
+   <!--
+     Investigators
+   -->
+   <bean id="CheckOnAgentInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator">
+     <property name="name" value="SimpleInvestigator"/>
+   </bean>
+ 
+   <bean id="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator">
+     <property name="name" value="XenServerInvestigator"/>
+   </bean>
+   
+   <bean id="UserVmDomRInvestigator" class="com.cloud.ha.UserVmDomRInvestigator">
+     <property name="name" value="PingInvestigator"/>
+   </bean>
+ 
+   <bean id="ManagementIPSystemVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator">
+     <property name="name" value="ManagementIPSysVMInvestigator"/>
+   </bean>
+ 
+   <!--
+     Fencers
+   -->
+   <bean id="XenServerFencer" class="com.cloud.ha.XenServerFencer">
+     <property name="name" value="XenServerFenceBuilder"/>
+   </bean>
+   <bean id="KVMFencer" class="com.cloud.ha.KVMFencer">
+     <property name="name" value="KVMFenceBuilder"/>
+   </bean>
+   <bean id="OvmFencer" class="com.cloud.ovm.hypervisor.OvmFencer">
+     <property name="name" value="OvmFenceBuilder"/>
+   </bean>
+ 
+   <bean id="XcpServerDiscoverer" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer">
+     <property name="name" value="XCP Agent"/>
+   </bean>
+ 
+   <bean id="SecondaryStorageDiscoverer" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer">
+     <property name="name" value="SecondaryStorage"/>
+   </bean>
+ 
+   <bean id="KvmServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer">
+     <property name="name" value="KVM Agent"/>
+   </bean>
+ 
+   <bean id="BareMetalDiscoverer" class="com.cloud.baremetal.BareMetalDiscoverer">
+     <property name="name" value="Bare Metal Agent"/>
+   </bean>
+ 
+   <bean id="HypervServerDiscoverer" class="com.cloud.hypervisor.hyperv.HypervServerDiscoverer">
+     <property name="name" value="SCVMMServer"/>
+   </bean>
+ 
+   <bean id="OvmDiscoverer" class="com.cloud.ovm.hypervisor.OvmDiscoverer">
+     <property name="name" value="Ovm Discover"/>
+   </bean>
+ 
+   <bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
+     <property name="name" value="First Fit"/>
+   </bean>
+ 
+   <bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
+     <property name="name" value="UserDispersing"/>
+   </bean>
+   
+   <bean id="UserConcentratedPodPlanner" class="com.cloud.deploy.UserConcentratedPodPlanner">
+     <property name="name" value="UserConcentratedPod"/>
+   </bean>
+ 
+   <bean id="BareMetalPlanner" class="com.cloud.deploy.BareMetalPlanner">
+     <property name="name" value="BareMetal Fit"/>
+   </bean>
+     
+    
+   <!--
+     Network Gurus
+   -->
+   <bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru">
+     <property name="name" value="StorageNetworkGuru"/>
+   </bean>
+   <bean id="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru">
+     <property name="name" value="ExternalGuestNetworkGuru"/>
+   </bean>
+   <bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru">
+     <property name="name" value="PublicNetworkGuru"/>
+   </bean>
+   <bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru">
+     <property name="name" value="PodBasedNetworkGuru"/>
+   </bean>
+   <bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru">
+     <property name="name" value="ControlNetworkGuru"/>
+   </bean>
+   <bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru">
+     <property name="name" value="DirectNetworkGuru"/>
+   </bean>
+   <bean id="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru">
+     <property name="name" value="DirectPodBasedNetworkGuru"/>
+   </bean>
+   <bean id="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru">
+     <property name="name" value="OvsGuestNetworkGuru"/>
+   </bean>
+   <bean id="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru">
+     <property name="name" value="PrivateNetworkGuru"/>
+   </bean>
+   <bean id="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru">
+     <property name="name" value="NiciraNvpGuestNetworkGuru"/>
+   </bean>
++  <bean id="BigSwitchVnsGuestNetworkGuru" class=".BigSwitchVnsGuestNetworkGuru">
++    <property name="name" value="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru"/>
++  </bean>
++
+  
+   <!--
+    Hypervisor Gurus
+   -->
+   <bean id="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru">
+     <property name="name" value="XenServerGuru"/>
+   </bean>
+   
+   <bean id="KVMGuru" class="com.cloud.hypervisor.KVMGuru">
+     <property name="name" value="KVMGuru"/>
+   </bean>
+   
+   <bean id="BareMetalGuru" class="com.cloud.baremetal.BareMetalGuru">
+     <property name="name" value="BareMetalGuru"/>
+   </bean>
+ 
+   <bean id="HypervGuru" class="com.cloud.hypervisor.guru.HypervGuru">
+     <property name="name" value="HypervGuru"/>
+   </bean>
+ 
+   <bean id="OvmGuru" class="com.cloud.ovm.hypervisor.OvmGuru">
+     <property name="name" value="OvmGuru"/>
+   </bean>
+   
+ </beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/client/vmops.log.2013-01-09.gz
----------------------------------------------------------------------
diff --cc client/vmops.log.2013-01-09.gz
index 0000000,0000000..573dafb
new file mode 100644
Binary files differ

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/client/vmops.log.2013-01-18.gz
----------------------------------------------------------------------
diff --cc client/vmops.log.2013-01-18.gz
index 0000000,0000000..fe5ab35
new file mode 100644
Binary files differ

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
index 3662a2e,0000000..c4c4ba9
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
@@@ -1,110 -1,0 +1,111 @@@
 +// 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.PlugService;
 +import org.apache.cloudstack.api.ServerApiException;
 +import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 +
 +import com.cloud.api.response.BigSwitchVnsDeviceResponse;
 +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.BigSwitchVnsDeviceVO;
 +import com.cloud.network.element.BigSwitchVnsElementService;
 +import com.cloud.user.UserContext;
 +import com.cloud.utils.exception.CloudRuntimeException;
 +
 +@APICommand(name = "addBigSwitchVnsDevice", responseObject=BigSwitchVnsDeviceResponse.class, description="Adds a BigSwitch VNS device")
 +public class AddBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
 +    private static final String s_name = "addbigswitchvnsdeviceresponse";
-     @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
++    @Inject BigSwitchVnsElementService _bigswitchVnsElementService;
 +
 +    /////////////////////////////////////////////////////
 +    //////////////// 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 BigSwitch VNS Controller.")
 +    private String host;
 +
 +    /////////////////////////////////////////////////////
 +    /////////////////// Accessors ///////////////////////
 +    /////////////////////////////////////////////////////
 +
 +    public Long getPhysicalNetworkId() {
 +        return physicalNetworkId;
 +    }
 +
 +    public String getHost() {
 +        return host;
 +    }
 +
 +    /////////////////////////////////////////////////////
 +    /////////////// API Implementation///////////////////
 +    /////////////////////////////////////////////////////
 +
 +    @Override
 +    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
 +        try {
 +            BigSwitchVnsDeviceVO bigswitchVnsDeviceVO = _bigswitchVnsElementService.addBigSwitchVnsDevice(this);
 +            if (bigswitchVnsDeviceVO != null) {
 +                BigSwitchVnsDeviceResponse response = _bigswitchVnsElementService.createBigSwitchVnsDeviceResponse(bigswitchVnsDeviceVO);
 +                response.setObjectName("bigswitchvnsdevice");
 +                response.setResponseName(getCommandName());
 +                this.setResponseObject(response);
 +            } else {
 +                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch VNS device 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 UserContext.current().getCaller().getId();
 +    }
 +
 +    @Override
 +    public String getEventType() {
 +        return VnsConstants.EVENT_EXTERNAL_VNS_CONTROLLER_ADD;
 +    }
 +
 +    @Override
 +    public String getEventDescription() {
 +        return "Adding a BigSwitch VNS Controller";
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
index 83adb22,0000000..06eee15
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
@@@ -1,99 -1,0 +1,100 @@@
 +// 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.PlugService;
 +import org.apache.cloudstack.api.ServerApiException;
 +import org.apache.cloudstack.api.response.SuccessResponse;
 +
 +import com.cloud.exception.ConcurrentOperationException;
 +import com.cloud.exception.InsufficientCapacityException;
 +import com.cloud.exception.InvalidParameterValueException;
 +import com.cloud.exception.ResourceAllocationException;
 +import com.cloud.exception.ResourceUnavailableException;
 +import com.cloud.network.element.BigSwitchVnsElementService;
 +import com.cloud.user.UserContext;
 +import com.cloud.utils.exception.CloudRuntimeException;
 +
 +@APICommand(name = "deleteBigSwitchVnsDevice", responseObject=SuccessResponse.class, description=" delete a bigswitch vns device")
 +public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
 +    private static final String s_name = "deletebigswitchvnsdeviceresponse";
-     @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
++    @Inject BigSwitchVnsElementService _bigswitchVnsElementService;
 +
 +    /////////////////////////////////////////////////////
 +    //////////////// API parameters /////////////////////
 +    /////////////////////////////////////////////////////
 +
 +    @Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.LONG, required=true, description="BigSwitch device ID")
 +    private Long bigswitchVnsDeviceId;
 +
 +    /////////////////////////////////////////////////////
 +    /////////////////// Accessors ///////////////////////
 +    /////////////////////////////////////////////////////
 +
 +    public Long getBigSwitchVnsDeviceId() {
 +        return bigswitchVnsDeviceId;
 +    }
 +
 +    /////////////////////////////////////////////////////
 +    /////////////// API Implementation///////////////////
 +    /////////////////////////////////////////////////////
 +
 +    @Override
 +    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
 +        try {
 +            boolean result = _bigswitchVnsElementService.deleteBigSwitchVnsDevice(this);
 +            if (result) {
 +                SuccessResponse response = new SuccessResponse(getCommandName());
 +                response.setResponseName(getCommandName());
 +                this.setResponseObject(response);
 +            } else {
 +                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch device.");
 +            }
 +        }  catch (InvalidParameterValueException invalidParamExcp) {
 +            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
 +        } catch (CloudRuntimeException runtimeExcp) {
 +            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
 +        }
 +    }
 +
 +    @Override
 +    public String getCommandName() {
 +        return s_name;
 +    }
 +
 +    @Override
 +    public long getEntityOwnerId() {
 +        return UserContext.current().getCaller().getId();
 +    }
 +
 +    @Override
 +    public String getEventType() {
 +        return VnsConstants.EVENT_EXTERNAL_VNS_CONTROLLER_DELETE;
 +    }
 +
 +    @Override
 +    public String getEventDescription() {
 +        return "Deleting BigSwitch Vns Controller";
 +    }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
index d9a209e,0000000..c0710ea
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
@@@ -1,109 -1,0 +1,110 @@@
 +// Licensed to the Apache Software Foundation (ASF) under one
 +// or more contributor license agreements.  See the NOTICE file
 +// distributed with this work for additional information
 +// regarding copyright ownership.  The ASF licenses this file
 +// to you under the Apache License, Version 2.0 (the
 +// "License"); you may not use this file except in compliance
 +// with the License.  You may obtain a copy of the License at
 +//
 +//   http://www.apache.org/licenses/LICENSE-2.0
 +//
 +// Unless required by applicable law or agreed to in writing,
 +// software distributed under the License is distributed on an
 +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +// KIND, either express or implied.  See the License for the
 +// specific language governing permissions and limitations
 +// under the License.
 +package com.cloud.api.commands;
 +
 +import 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.PlugService;
 +import org.apache.cloudstack.api.ServerApiException;
 +import org.apache.cloudstack.api.response.ListResponse;
 +import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 +import org.apache.log4j.Logger;
 +
 +import com.cloud.api.response.BigSwitchVnsDeviceResponse;
 +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.BigSwitchVnsDeviceVO;
 +import com.cloud.network.element.BigSwitchVnsElementService;
 +import com.cloud.utils.exception.CloudRuntimeException;
 +
 +@APICommand(name = "listBigSwitchVnsDevices", responseObject=BigSwitchVnsDeviceResponse.class, description="Lists BigSwitch Vns devices")
 +public class ListBigSwitchVnsDevicesCmd extends BaseListCmd {
 +	public static final Logger s_logger = Logger.getLogger(ListBigSwitchVnsDevicesCmd.class.getName());
 +    private static final String s_name = "listbigswitchvnsdeviceresponse";
-     @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
++    @Inject BigSwitchVnsElementService _bigswitchVnsElementService;
 +
 +   /////////////////////////////////////////////////////
 +    //////////////// API parameters /////////////////////
 +    /////////////////////////////////////////////////////
 +
 +    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID,
 +		entityType = PhysicalNetworkResponse.class,
 +            description="the Physical Network ID")
 +    private Long physicalNetworkId;
 +
 +    @Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID,
 +               type=CommandType.LONG,
 +               description="bigswitch vns device ID")
 +    private Long bigswitchVnsDeviceId;
 +
 +    /////////////////////////////////////////////////////
 +    /////////////////// Accessors ///////////////////////
 +    /////////////////////////////////////////////////////
 +
 +    public Long getBigSwitchVnsDeviceId() {
 +        return bigswitchVnsDeviceId;
 +    }
 +
 +    public Long getPhysicalNetworkId() {
 +        return physicalNetworkId;
 +    }
 +
 +    /////////////////////////////////////////////////////
 +    /////////////// API Implementation///////////////////
 +    /////////////////////////////////////////////////////
 +
 +    @Override
 +    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException,
 +    ConcurrentOperationException, ResourceAllocationException {
 +        try {
 +            List<BigSwitchVnsDeviceVO> bigswitchDevices = _bigswitchVnsElementService.listBigSwitchVnsDevices(this);
 +            ListResponse<BigSwitchVnsDeviceResponse> response = new ListResponse<BigSwitchVnsDeviceResponse>();
 +            List<BigSwitchVnsDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchVnsDeviceResponse>();
 +
 +            if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
 +                for (BigSwitchVnsDeviceVO bigswitchDeviceVO : bigswitchDevices) {
 +			BigSwitchVnsDeviceResponse bigswitchDeviceResponse =
 +				_bigswitchVnsElementService.createBigSwitchVnsDeviceResponse(bigswitchDeviceVO);
 +                    bigswitchDevicesResponse.add(bigswitchDeviceResponse);
 +                }
 +            }
 +
 +            response.setResponses(bigswitchDevicesResponse);
 +            response.setResponseName(getCommandName());
 +            this.setResponseObject(response);
 +        }  catch (InvalidParameterValueException invalidParamExcp) {
 +            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
 +        } catch (CloudRuntimeException runtimeExcp) {
 +            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
 +        }
 +    }
 +
 +    @Override
 +    public String getCommandName() {
 +        return s_name;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
index 955bdda,0000000..dad9f36
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
@@@ -1,48 -1,0 +1,51 @@@
 +// 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.BigSwitchVnsDeviceVO;
 +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=BigSwitchVnsDao.class)
 +public class BigSwitchVnsDaoImpl extends GenericDaoBase<BigSwitchVnsDeviceVO, Long>
 +        implements BigSwitchVnsDao {
 +
 +    protected final SearchBuilder<BigSwitchVnsDeviceVO> physicalNetworkIdSearch;
 +
 +    public BigSwitchVnsDaoImpl() {
 +        physicalNetworkIdSearch = createSearchBuilder();
 +        physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
 +        physicalNetworkIdSearch.done();
 +    }
 +
 +    @Override
 +    public List<BigSwitchVnsDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
 +        SearchCriteria<BigSwitchVnsDeviceVO> sc = physicalNetworkIdSearch.create();
 +        sc.setParameters("physicalNetworkId", physicalNetworkId);
 +        return search(sc, null);
 +    }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
index 35e4bdb,0000000..67d0d8d
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java
@@@ -1,543 -1,0 +1,543 @@@
 +// 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.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.network.ExternalNetworkDeviceManager.NetworkDevice;
 +import org.apache.log4j.Logger;
 +
 +import com.cloud.agent.AgentManager;
 +import com.cloud.agent.api.CreateVnsPortAnswer;
 +import com.cloud.agent.api.CreateVnsPortCommand;
 +import com.cloud.agent.api.DeleteVnsPortAnswer;
 +import com.cloud.agent.api.DeleteVnsPortCommand;
 +import com.cloud.agent.api.StartupBigSwitchVnsCommand;
 +import com.cloud.agent.api.StartupCommand;
 +import com.cloud.api.ApiDBUtils;
 +import com.cloud.api.commands.AddBigSwitchVnsDeviceCmd;
 +import com.cloud.api.commands.DeleteBigSwitchVnsDeviceCmd;
 +import com.cloud.api.commands.ListBigSwitchVnsDevicesCmd;
 +import com.cloud.api.commands.VnsConstants;
 +import com.cloud.api.response.BigSwitchVnsDeviceResponse;
 +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.BigSwitchVnsDeviceVO;
 +import com.cloud.network.Network;
 +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.NetworkVO;
 +import com.cloud.network.Networks;
 +import com.cloud.network.Networks.BroadcastDomainType;
 +import com.cloud.network.PhysicalNetwork;
 +import com.cloud.network.PhysicalNetworkServiceProvider;
- import com.cloud.network.PhysicalNetworkVO;
 +import com.cloud.network.dao.BigSwitchVnsDao;
 +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.BigSwitchVnsResource;
 +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.component.Inject;
 +import com.cloud.utils.db.DB;
 +import com.cloud.utils.db.Transaction;
 +import com.cloud.utils.exception.CloudRuntimeException;
 +import com.cloud.vm.NicProfile;
 +import com.cloud.vm.ReservationContext;
 +import com.cloud.vm.VirtualMachine;
 +import com.cloud.vm.VirtualMachineProfile;
 +
 +@Local(value = {NetworkElement.class, ConnectivityProvider.class})
 +public class BigSwitchVnsElement extends AdapterBase implements
 +             BigSwitchVnsElementService, ConnectivityProvider, ResourceStateAdapter {
 +    private static final Logger s_logger = Logger.getLogger(BigSwitchVnsElement.class);
 +
 +    private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
 +
 +    @Inject
 +    ResourceManager _resourceMgr;
 +    @Inject
 +    PhysicalNetworkDao _physicalNetworkDao;
 +    @Inject
 +    PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
 +    @Inject
 +    BigSwitchVnsDao _bigswitchVnsDao;
 +    @Inject
 +    HostDetailsDao _hostDetailsDao;
 +    @Inject
 +    HostDao _hostDao;
 +    @Inject
 +    AgentManager _agentMgr;
 +    @Inject
 +    NetworkDao _networkDao;
 +    @Inject
 +    NetworkModel _networkModel;
 +    @Inject
 +    ConfigurationManager _configMgr;
 +    @Inject
 +    NetworkServiceMapDao _ntwkSrvcDao;
 +    @Inject
 +    VlanDao _vlanDao;
 +
 +    @Override
 +    public Map<Service, Map<Capability, String>> getCapabilities() {
 +        return capabilities;
 +    }
 +
 +    @Override
 +    public Provider getProvider() {
 +        return VnsConstants.BigSwitchVns;
 +    }
 +
 +    private boolean canHandle(Network network, Service service) {
 +        s_logger.debug("Checking if BigSwitchVnsElement can handle service "
 +                        + service.getName() + " on network " + network.getDisplayText());
 +        if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) {
 +            return false;
 +        }
 +
 +        if (!_networkModel.isProviderForNetwork(getProvider(),
 +                network.getId())) {
 +            s_logger.debug("BigSwitchVnsElement is not a provider for network "
 +                    + network.getDisplayText());
 +            return false;
 +        }
 +
 +        if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(),
 +                service, VnsConstants.BigSwitchVns)) {
 +            s_logger.debug("BigSwitchVnsElement 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 BigSwitchVnsElement implement function for network "
 +                + network.getDisplayText()
 +                + " (state "
 +                + network.getState()
 +                + ")");
 +
 +        return true;
 +    }
 +
 +    @Override
 +    public boolean prepare(Network network, NicProfile nic,
 +            VirtualMachineProfile<? extends VirtualMachine> vm,
 +            DeployDestination dest, ReservationContext context)
 +            throws ConcurrentOperationException, ResourceUnavailableException,
 +            InsufficientCapacityException {
 +
 +        if (!canHandle(network, Service.Connectivity)) {
 +            return false;
 +        }
 +
 +        if (network.getBroadcastUri() == null) {
 +            s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
 +            return false;
 +        }
 +
 +        String mac = nic.getMacAddress();
 +        String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
 +
 +        List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao
 +                .listByPhysicalNetwork(network.getPhysicalNetworkId());
 +        if (devices.isEmpty()) {
 +            s_logger.error("No BigSwitch Controller on physical network "
 +                    + network.getPhysicalNetworkId());
 +            return false;
 +        }
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = devices.get(0);
 +        HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
 +
 +        CreateVnsPortCommand cmd = new CreateVnsPortCommand(
 +                network.getBroadcastUri().getSchemeSpecificPart(),
 +                vm.getUuid(),
 +                tenantId,
 +                nic.getName(),
 +                mac);
 +        CreateVnsPortAnswer answer = (CreateVnsPortAnswer) _agentMgr
 +                .easySend(bigswitchVnsHost.getId(), cmd);
 +
 +        if (answer == null || !answer.getResult()) {
 +            s_logger.error("CreatePortCommand failed");
 +            return false;
 +        }
 +
 +        return true;
 +    }
 +
 +    @Override
 +    public boolean release(Network network, NicProfile nic,
 +            VirtualMachineProfile<? extends VirtualMachine> vm,
 +            ReservationContext context) throws ConcurrentOperationException,
 +            ResourceUnavailableException {
 +
 +        if (!canHandle(network, Service.Connectivity)) {
 +            return false;
 +        }
 +
 +        if (network.getBroadcastUri() == null) {
 +            s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
 +            return false;
 +        }
 +
 +        String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
 +
 +        List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao
 +                .listByPhysicalNetwork(network.getPhysicalNetworkId());
 +        if (devices.isEmpty()) {
 +            s_logger.error("No BigSwitch Controller on physical network "
 +                    + network.getPhysicalNetworkId());
 +            return false;
 +        }
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = devices.get(0);
 +        HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
 +
 +        DeleteVnsPortCommand cmd = new DeleteVnsPortCommand(
 +                network.getBroadcastUri().getSchemeSpecificPart(),
 +                vm.getUuid(),
 +                tenantId);
 +        DeleteVnsPortAnswer answer = (DeleteVnsPortAnswer) _agentMgr
 +                .easySend(bigswitchVnsHost.getId(), cmd);
 +
 +        if (answer == null || !answer.getResult()) {
 +            s_logger.error("DeletePortCommand failed");
 +            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 : SDN provisioning
 +        capabilities.put(Service.Connectivity, null);
 +
 +        return capabilities;
 +    }
 +
 +    @Override
 +    @DB
 +    public BigSwitchVnsDeviceVO addBigSwitchVnsDevice(AddBigSwitchVnsDeviceCmd cmd) {
 +        ServerResource resource = new BigSwitchVnsResource();
 +        String deviceName = VnsConstants.BigSwitchVns.getName();
 +        NetworkDevice networkDevice = NetworkDevice
 +                .getNetworkDevice(deviceName);
 +        Long physicalNetworkId = cmd.getPhysicalNetworkId();
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = null;
 +
 +        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
 +                .findById(physicalNetworkId);
 +        if (physicalNetwork == null) {
 +            throw new InvalidParameterValueException(
 +                    "Could not find phyical network with ID: "
 +                            + physicalNetworkId);
 +        }
 +        long zoneId = physicalNetwork.getDataCenterId();
 +
 +        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");
 +        }
 +
 +        if (_bigswitchVnsDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) {
 +            throw new CloudRuntimeException(
 +                    "A BigSwitch controller device is already configured on this physical network");
 +        }
 +
 +        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", "BigSwitch Controller - " + cmd.getHost());
 +        params.put("ip", cmd.getHost());
 +        // FIXME What to do with multiple isolation types
 +        params.put("transportzoneisotype",
 +                physicalNetwork.getIsolationMethods().get(0).toLowerCase());
 +
 +        Map<String, Object> hostdetails = new HashMap<String, Object>();
 +        hostdetails.putAll(params);
 +
 +        Transaction txn = Transaction.currentTxn();
 +        try {
 +            resource.configure(cmd.getHost(), hostdetails);
 +
 +            Host host = _resourceMgr.addHost(zoneId, resource,
 +                    Host.Type.L2Networking, params);
 +            if (host != null) {
 +                txn.start();
 +
 +                bigswitchVnsDevice = new BigSwitchVnsDeviceVO(host.getId(),
 +                        physicalNetworkId, ntwkSvcProvider.getProviderName(),
 +                        deviceName);
 +                _bigswitchVnsDao.persist(bigswitchVnsDevice);
 +
 +                DetailVO detail = new DetailVO(host.getId(),
 +                        "bigswitchvnsdeviceid",
 +                        String.valueOf(bigswitchVnsDevice.getId()));
 +                _hostDetailsDao.persist(detail);
 +
 +                txn.commit();
 +                return bigswitchVnsDevice;
 +            } else {
 +                throw new CloudRuntimeException(
 +                        "Failed to add BigSwitch Vns Device due to internal error.");
 +            }
 +        } catch (ConfigurationException e) {
 +            txn.rollback();
 +            throw new CloudRuntimeException(e.getMessage());
 +        }
 +    }
 +
 +    @Override
 +    public BigSwitchVnsDeviceResponse createBigSwitchVnsDeviceResponse(
 +            BigSwitchVnsDeviceVO bigswitchVnsDeviceVO) {
 +        HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDeviceVO.getHostId());
 +        _hostDao.loadDetails(bigswitchVnsHost);
 +
 +        BigSwitchVnsDeviceResponse response = new BigSwitchVnsDeviceResponse();
 +        response.setDeviceName(bigswitchVnsDeviceVO.getDeviceName());
 +        PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(bigswitchVnsDeviceVO.getPhysicalNetworkId());
 +        if (pnw != null) {
 +            response.setPhysicalNetworkId(pnw.getUuid());
 +        }
 +		response.setId(bigswitchVnsDeviceVO.getUuid());
 +        response.setProviderName(bigswitchVnsDeviceVO.getProviderName());
 +        response.setHostName(bigswitchVnsHost.getDetail("ip"));
 +        response.setObjectName("bigswitchvnsdevice");
 +        return response;
 +    }
 +
 +    @Override
 +    public boolean deleteBigSwitchVnsDevice(DeleteBigSwitchVnsDeviceCmd cmd) {
 +        Long bigswitchVnsDeviceId = cmd.getBigSwitchVnsDeviceId();
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = _bigswitchVnsDao
 +                .findById(bigswitchVnsDeviceId);
 +        if (bigswitchVnsDevice == null) {
 +            throw new InvalidParameterValueException(
 +                    "Could not find a BigSwitch Controller with id " + bigswitchVnsDevice);
 +        }
 +
 +        // Find the physical network we work for
 +        Long physicalNetworkId = bigswitchVnsDevice.getPhysicalNetworkId();
 +        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
 +                .findById(physicalNetworkId);
 +        if (physicalNetwork != null) {
 +            List<NetworkVO> networkList = _networkDao
 +                    .listByPhysicalNetwork(physicalNetworkId);
 +
 +            // Networks with broadcast type lswitch are ours
 +            for (NetworkVO network : networkList) {
 +                if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
 +                    if ((network.getState() != Network.State.Shutdown)
 +                            && (network.getState() != Network.State.Destroy)) {
 +                        throw new CloudRuntimeException(
 +                                "This BigSwitch Controller device can not be deleted as there are one or more " +
 +                                "logical networks provisioned by cloudstack.");
 +                    }
 +                }
 +            }
 +        }
 +
 +        HostVO bigswitchHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
 +        Long hostId = bigswitchHost.getId();
 +
 +        bigswitchHost.setResourceState(ResourceState.Maintenance);
 +        _hostDao.update(hostId, bigswitchHost);
 +        _resourceMgr.deleteHost(hostId, false, false);
 +
 +        _bigswitchVnsDao.remove(bigswitchVnsDeviceId);
 +        return true;
 +    }
 +
 +    @Override
 +    public List<BigSwitchVnsDeviceVO> listBigSwitchVnsDevices(
 +            ListBigSwitchVnsDevicesCmd cmd) {
 +        Long physicalNetworkId = cmd.getPhysicalNetworkId();
 +        Long bigswitchVnsDeviceId = cmd.getBigSwitchVnsDeviceId();
 +        List<BigSwitchVnsDeviceVO> responseList = new ArrayList<BigSwitchVnsDeviceVO>();
 +
 +        if (physicalNetworkId == null && bigswitchVnsDeviceId == null) {
 +            throw new InvalidParameterValueException(
 +                    "Either physical network Id or bigswitch device Id must be specified");
 +        }
 +
 +        if (bigswitchVnsDeviceId != null) {
 +            BigSwitchVnsDeviceVO bigswitchVnsDevice = _bigswitchVnsDao
 +                    .findById(bigswitchVnsDeviceId);
 +            if (bigswitchVnsDevice == null) {
 +                throw new InvalidParameterValueException(
 +                        "Could not find BigSwitch controller with id: "
 +                                + bigswitchVnsDevice);
 +            }
 +            responseList.add(bigswitchVnsDevice);
 +        } else {
 +            PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
 +                    .findById(physicalNetworkId);
 +            if (physicalNetwork == null) {
 +                throw new InvalidParameterValueException(
 +                        "Could not find a physical network with id: "
 +                                + physicalNetworkId);
 +            }
 +            responseList = _bigswitchVnsDao
 +                    .listByPhysicalNetwork(physicalNetworkId);
 +        }
 +
 +        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 StartupBigSwitchVnsCommand)) {
 +            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);
 +    }
 +
 +	@Override
 +	public List<Class<?>> getCommands() {
 +		List<Class<?>> cmdList = new ArrayList<Class<?>>();
 +        cmdList.add(AddBigSwitchVnsDeviceCmd.class);
 +        cmdList.add(DeleteBigSwitchVnsDeviceCmd.class);
 +        cmdList.add(ListBigSwitchVnsDevicesCmd.class);
 +        return cmdList;
 +	}
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
index fe21163,0000000..b96ea56
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
@@@ -1,261 -1,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.guru;
 +
 +import com.cloud.agent.AgentManager;
 +import com.cloud.agent.api.CreateVnsNetworkAnswer;
 +import com.cloud.agent.api.CreateVnsNetworkCommand;
 +import com.cloud.agent.api.DeleteVnsNetworkCommand;
 +import com.cloud.dc.DataCenter;
 +import com.cloud.dc.DataCenter.NetworkType;
 +import com.cloud.dc.dao.DataCenterDao;
 +import com.cloud.deploy.DeployDestination;
 +import com.cloud.deploy.DeploymentPlan;
 +import com.cloud.exception.InsufficientAddressCapacityException;
 +import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
 +import com.cloud.host.HostVO;
 +import com.cloud.host.dao.HostDao;
 +import com.cloud.host.dao.HostDetailsDao;
 +import com.cloud.network.BigSwitchVnsDeviceVO;
 +import com.cloud.network.Network;
 +import com.cloud.network.NetworkProfile;
- import com.cloud.network.NetworkVO;
 +import com.cloud.network.Network.GuestType;
 +import com.cloud.network.Network.State;
 +import com.cloud.network.Networks.BroadcastDomainType;
 +import com.cloud.network.PhysicalNetwork;
 +import com.cloud.network.PhysicalNetwork.IsolationMethod;
- import com.cloud.network.PhysicalNetworkVO;
 +import com.cloud.network.dao.BigSwitchVnsDao;
++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.resource.ResourceManager;
 +import com.cloud.user.Account;
 +import com.cloud.user.dao.AccountDao;
- import com.cloud.utils.component.Inject;
 +import com.cloud.vm.NicProfile;
 +import com.cloud.vm.ReservationContext;
 +import com.cloud.vm.VirtualMachine;
 +import com.cloud.vm.VirtualMachineProfile;
 +
 +import java.net.URI;
 +import java.net.URISyntaxException;
 +import java.util.List;
 +
 +import org.apache.log4j.Logger;
 +
 +import javax.ejb.Local;
++import javax.inject.Inject;
 +
 +
 +@Local(value = NetworkGuru.class)
 +public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
 +    private static final Logger s_logger = Logger.getLogger(BigSwitchVnsGuestNetworkGuru.class);
 +
 +    @Inject
 +    DataCenterDao _zoneDao;
 +    @Inject
 +    PhysicalNetworkDao _physicalNetworkDao;
 +    @Inject
 +    AccountDao _accountDao;
 +    @Inject
 +    BigSwitchVnsDao _bigswitchVnsDao;
 +    @Inject
 +    HostDao _hostDao;
 +    @Inject
 +    ResourceManager _resourceMgr;
 +    @Inject
 +    AgentManager _agentMgr;
 +    @Inject
 +    HostDetailsDao _hostDetailsDao;
 +
 +    public BigSwitchVnsGuestNetworkGuru() {
 +        super();
 +        _isolationMethods = new IsolationMethod[] { IsolationMethod.VNS };
 +    }
 +
 +    @Override
 +    protected boolean canHandle(NetworkOffering offering, NetworkType networkType,
 +                                PhysicalNetwork physicalNetwork) {
 +        if (networkType == NetworkType.Advanced
 +                && isMyTrafficType(offering.getTrafficType())
 +                && offering.getGuestType() == Network.GuestType.Isolated
 +                && isMyIsolationMethod(physicalNetwork)) {
 +            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 VNS
 +        PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
 +        if (physnet == null ||
 +                        physnet.getIsolationMethods() == null ||
 +                        !physnet.getIsolationMethods().contains("VNS")) {
 +            s_logger.debug("Refusing to design this network, the physical isolation type is not VNS");
 +            return null;
 +        }
 +
 +        List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao.listByPhysicalNetwork(physnet.getId());
 +        if (devices.isEmpty()) {
 +            s_logger.error("No BigSwitxh Controller on physical network " + physnet.getName());
 +            return null;
 +        }
 +        s_logger.debug("BigSwitch Controller " + devices.get(0).getUuid() +
 +                        " found on physical network " + physnet.getId());
 +
 +        s_logger.debug("Physical isolation type is VNS, 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.Lswitch);
 +
 +        return networkObject;
 +    }
 +
 +    @Override
 +    public Network implement(Network network, NetworkOffering offering,
 +            DeployDestination dest, ReservationContext context)
 +            throws InsufficientVirtualNetworkCapcityException {
 +        assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
 +
 +        long dcId = dest.getDataCenter().getId();
 +
 +        //get physical network id
 +        long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId,
 +                                                        offering.getTags(),
 +                                                        offering.getTrafficType());
 +
 +        NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
 +                        network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
 +                network.getDataCenterId(), physicalNetworkId);
 +
 +        if (network.getGateway() != null) {
 +            implemented.setGateway(network.getGateway());
 +        }
 +
 +        if (network.getCidr() != null) {
 +            implemented.setCidr(network.getCidr());
 +        }
 +
 +        String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId,
 +                        network.getAccountId(), context.getReservationId());
 +        if (vnet == null) {
 +            throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
 +                        "part of network " + network + " implement ", DataCenter.class, dcId);
 +        }
 +        int vlan = Integer.parseInt(vnet);
 +
 +        // Name is either the given name or the uuid
 +        String name = network.getName();
 +        String networkUuid = implemented.getUuid();
 +        if (name == null || name.isEmpty()) {
 +            name = ((NetworkVO)network).getUuid();
 +        }
 +        if (name.length() > 64 ) {
 +            name = name.substring(0, 63); // max length 64
 +        }
 +
 +        String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
 +        List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao.listByPhysicalNetwork(physicalNetworkId);
 +        if (devices.isEmpty()) {
 +            s_logger.error("No BigSwitch Controller on physical network " + physicalNetworkId);
 +            return null;
 +        }
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = devices.get(0);
 +        HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
 +        _hostDao.loadDetails(bigswitchVnsHost);
 +
 +        CreateVnsNetworkCommand cmd = new CreateVnsNetworkCommand(networkUuid, name, tenantId, vlan);
 +        CreateVnsNetworkAnswer answer = (CreateVnsNetworkAnswer) _agentMgr.easySend(bigswitchVnsHost.getId(), cmd);
 +
 +        if (answer == null || !answer.getResult()) {
 +            s_logger.error ("CreateNetworkCommand failed");
 +            return null;
 +        }
 +
 +        try {
 +            implemented.setBroadcastUri(new URI("vns", cmd.getNetworkUuid(), null));
 +            implemented.setBroadcastDomainType(BroadcastDomainType.Lswitch);
 +            s_logger.info("Implemented OK, network " + networkUuid + " in tenant " +
 +                        tenantId + " linked to " + implemented.getBroadcastUri().toString());
 +        } catch (URISyntaxException e) {
 +            s_logger.error("Unable to store network id in broadcast uri, uuid = " + implemented.getUuid(), e);
 +        }
 +
 +        return implemented;
 +    }
 +
 +    @Override
 +    public void reserve(NicProfile nic, Network network,
 +            VirtualMachineProfile<? extends VirtualMachine> vm,
 +            DeployDestination dest, ReservationContext context)
 +            throws InsufficientVirtualNetworkCapcityException,
 +            InsufficientAddressCapacityException {
 +        // TODO Auto-generated method stub
 +        super.reserve(nic, network, vm, dest, context);
 +    }
 +
 +    @Override
 +    public boolean release(NicProfile nic,
 +            VirtualMachineProfile<? extends VirtualMachine> vm,
 +            String reservationId) {
 +        // TODO Auto-generated method stub
 +        return super.release(nic, vm, reservationId);
 +    }
 +
 +    @Override
 +    public void shutdown(NetworkProfile profile, NetworkOffering offering) {
 +        NetworkVO networkObject = _networkDao.findById(profile.getId());
 +        if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Lswitch ||
 +                networkObject.getBroadcastUri() == null) {
 +            s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
 +            return;
 +        }
 +
 +        List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao.listByPhysicalNetwork(networkObject.getPhysicalNetworkId());
 +        if (devices.isEmpty()) {
 +            s_logger.error("No BigSwitch Controller on physical network " + networkObject.getPhysicalNetworkId());
 +            return;
 +        }
 +        BigSwitchVnsDeviceVO bigswitchVnsDevice = devices.get(0);
 +        HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
 +
 +        String tenantId = profile.getNetworkDomain() + "-" + profile.getAccountId();
 +
 +        DeleteVnsNetworkCommand cmd = new DeleteVnsNetworkCommand(tenantId,
 +                        networkObject.getBroadcastUri().getSchemeSpecificPart());
 +        _agentMgr.easySend(bigswitchVnsHost.getId(), cmd);
 +
 +        super.shutdown(profile, offering);
 +    }
 +
 +    @Override
 +    public boolean trash(Network network, NetworkOffering offering,
 +            Account owner) {
 +        return super.trash(network, offering, owner);
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
index 52c9ba7,0000000..8d070b5
mode 100644,000000..100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
@@@ -1,322 -1,0 +1,323 @@@
 +// 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.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.Command;
 +import com.cloud.agent.api.CreateVnsNetworkAnswer;
 +import com.cloud.agent.api.CreateVnsNetworkCommand;
 +import com.cloud.agent.api.CreateVnsPortAnswer;
 +import com.cloud.agent.api.CreateVnsPortCommand;
 +import com.cloud.agent.api.DeleteVnsNetworkAnswer;
 +import com.cloud.agent.api.DeleteVnsNetworkCommand;
 +import com.cloud.agent.api.DeleteVnsPortAnswer;
 +import com.cloud.agent.api.DeleteVnsPortCommand;
 +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.StartupCommand;
 +import com.cloud.agent.api.StartupBigSwitchVnsCommand;
 +import com.cloud.agent.api.UpdateVnsPortAnswer;
 +import com.cloud.agent.api.UpdateVnsPortCommand;
 +import com.cloud.host.Host;
 +import com.cloud.host.Host.Type;
 +import com.cloud.network.bigswitch.BigSwitchVnsApi;
 +import com.cloud.network.bigswitch.BigSwitchVnsApiException;
 +import com.cloud.network.bigswitch.ControlClusterStatus;
 +import com.cloud.network.bigswitch.Attachment;
 +import com.cloud.network.bigswitch.Network;
 +import com.cloud.network.bigswitch.Port;
 +import com.cloud.resource.ServerResource;
++import com.cloud.utils.component.ManagerBase;
 +
- public class BigSwitchVnsResource implements ServerResource {
++public class BigSwitchVnsResource extends ManagerBase implements ServerResource {
 +    private static final Logger s_logger = Logger.getLogger(BigSwitchVnsResource.class);
 +
 +    private String _name;
 +    private String _guid;
 +    private String _zoneId;
 +    private int _numRetries;
 +
 +    private BigSwitchVnsApi _bigswitchVnsApi;
 +
 +    protected BigSwitchVnsApi createBigSwitchVnsApi() {
 +        return new BigSwitchVnsApi();
 +    }
 +
 +    @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");
 +        }
 +
 +        _bigswitchVnsApi = createBigSwitchVnsApi();
 +        _bigswitchVnsApi.setControllerAddress(ip);
 +
 +        return true;
 +    }
 +
 +    @Override
 +    public boolean start() {
 +        return true;
 +    }
 +
 +    @Override
 +    public boolean stop() {
 +        return true;
 +    }
 +
 +    @Override
 +    public String getName() {
 +        return _name;
 +    }
 +
 +    @Override
 +    public Type getType() {
 +        // Think up a better name for this Type?
 +        return Host.Type.L2Networking;
 +    }
 +
 +    @Override
 +    public StartupCommand[] initialize() {
 +        StartupBigSwitchVnsCommand sc = new StartupBigSwitchVnsCommand();
 +        sc.setGuid(_guid);
 +        sc.setName(_name);
 +        sc.setDataCenter(_zoneId);
 +        sc.setPod("");
 +        sc.setPrivateIpAddress("");
 +        sc.setStorageIpAddress("");
 +        sc.setVersion("");
 +        return new StartupCommand[] { sc };
 +    }
 +
 +        @Override
 +        public PingCommand getCurrentStatus(long id) {
 +        try {
 +            ControlClusterStatus ccs = _bigswitchVnsApi.getControlClusterStatus();
 +            if (!ccs.getStatus()) {
 +                s_logger.error("ControlCluster state is not ready: " + ccs.getStatus());
 +                return null;
 +            }
 +        } catch (BigSwitchVnsApiException e) {
 +                s_logger.error("getControlClusterStatus failed", e);
 +                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 CreateVnsNetworkCommand) {
 +            return executeRequest((CreateVnsNetworkCommand)cmd, numRetries);
 +        }
 +        else if (cmd instanceof DeleteVnsNetworkCommand) {
 +            return executeRequest((DeleteVnsNetworkCommand) cmd, numRetries);
 +        }
 +        else if (cmd instanceof CreateVnsPortCommand) {
 +            return executeRequest((CreateVnsPortCommand) cmd, numRetries);
 +        }
 +        else if (cmd instanceof DeleteVnsPortCommand) {
 +            return executeRequest((DeleteVnsPortCommand) cmd, numRetries);
 +        }
 +        else if (cmd instanceof UpdateVnsPortCommand) {
 +                return executeRequest((UpdateVnsPortCommand) 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(CreateVnsNetworkCommand cmd, int numRetries) {
 +        Network network = new Network();
 +        network.setTenant_id(cmd.getTenantUuid());
 +        network.setUuid(cmd.getNetworkUuid());
 +        network.setDisplay_name(truncate("vns-cloudstack-" + cmd.getName(), 64));
 +        network.setVlan(cmd.getVlan());
 +
 +        try {
 +            _bigswitchVnsApi.createNetwork(network);
 +            return new CreateVnsNetworkAnswer(cmd, true, "VNS " + network.getUuid() + " created");
 +        } catch (BigSwitchVnsApiException e) {
 +                if (numRetries > 0) {
 +                        return retry(cmd, --numRetries);
 +                }
 +                else {
 +                        return new CreateVnsNetworkAnswer(cmd, e);
 +                }
 +        }
 +
 +    }
 +
 +    private Answer executeRequest(DeleteVnsNetworkCommand cmd, int numRetries) {
 +        try {
 +            _bigswitchVnsApi.deleteNetwork(cmd.get_tenantUuid(), cmd.getNetworkUuid());
 +            return new DeleteVnsNetworkAnswer(cmd, true, "VNS " + cmd.getNetworkUuid() + " deleted");
 +        } catch (BigSwitchVnsApiException e) {
 +                if (numRetries > 0) {
 +                        return retry(cmd, --numRetries);
 +                }
 +                else {
 +                        return new DeleteVnsNetworkAnswer(cmd, e);
 +                }
 +        }
 +    }
 +
 +    private Answer executeRequest(CreateVnsPortCommand cmd, int numRetries) {
 +        Port port = new Port();
 +        port.setId(cmd.getPortUuid());
 +        port.setName(cmd.getPortName());
 +        port.setTenant_id(cmd.getTenantUuid());
 +
 +        try {
 +            _bigswitchVnsApi.createPort(cmd.getNetworkUuid(), port);
 +            try {
 +                Attachment attachment = new Attachment();
 +                attachment.setId(cmd.getPortUuid());
 +                attachment.setMac(cmd.getMac());
 +                _bigswitchVnsApi.modifyPortAttachment(cmd.getTenantUuid(),
 +                                cmd.getNetworkUuid(), cmd.getPortUuid(), attachment);
 +
 +            } catch (BigSwitchVnsApiException ex) {
 +                s_logger.warn("modifyPortAttachment failed after switchport was created, removing switchport");
 +                _bigswitchVnsApi.deletePort(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
 +                throw (ex); // Rethrow the original exception
 +            }
 +            return new CreateVnsPortAnswer(cmd, true, "network port " + cmd.getPortUuid() + " created");
 +        } catch (BigSwitchVnsApiException e) {
 +                if (numRetries > 0) {
 +                        return retry(cmd, --numRetries);
 +                }
 +                else {
 +                        return new CreateVnsPortAnswer(cmd, e);
 +                }
 +        }
 +    }
 +
 +    private Answer executeRequest(DeleteVnsPortCommand cmd, int numRetries) {
 +        try {
 +                _bigswitchVnsApi.deletePortAttachment(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
 +                try {
 +                        _bigswitchVnsApi.deletePort(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
 +                } catch (BigSwitchVnsApiException ex) {
 +                s_logger.warn("deletePort failed after portAttachment was removed");
 +                throw (ex); // Rethrow the original exception
 +            }
 +                return new DeleteVnsPortAnswer(cmd, true, "network port " + cmd.getPortUuid() + " deleted");
 +        } catch (BigSwitchVnsApiException e) {
 +                if (numRetries > 0) {
 +                        return retry(cmd, --numRetries);
 +                }
 +                else {
 +                        return new DeleteVnsPortAnswer(cmd, e);
 +                }
 +        }
 +    }
 +
 +    private Answer executeRequest(UpdateVnsPortCommand cmd, int numRetries) {
 +        Port port = new Port();
 +        port.setId(cmd.getPortUuid());
 +        port.setName(cmd.getPortName());
 +        port.setTenant_id(cmd.getTenantUuid());
 +
 +        try {
 +            _bigswitchVnsApi.modifyPort(cmd.getNetworkUuid(), port);
 +            return new UpdateVnsPortAnswer(cmd, true, "Network Port  " + cmd.getPortUuid() + " updated");
 +        } catch (BigSwitchVnsApiException e) {
 +                if (numRetries > 0) {
 +                        return retry(cmd, --numRetries);
 +                }
 +                else {
 +                        return new UpdateVnsPortAnswer(cmd, e);
 +                }
 +        }
 +
 +    }
 +
 +    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);
 +    }
 +
 +    private String truncate(String string, int length) {
 +        if (string.length() <= length) {
 +                return string;
 +        }
 +        else {
 +                return string.substring(0, length);
 +        }
 +    }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/plugins/pom.xml
----------------------------------------------------------------------
diff --cc plugins/pom.xml
index 198a632,4daa71d..02459b4
mode 100644,100755..100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/296c2033/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------


Mime
View raw message