cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [1/6] OpenContrail network plugin
Date Fri, 01 Nov 2013 16:55:56 GMT
Updated Branches:
  refs/heads/master 1e417994d -> 6b5fab2f5


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java
new file mode 100644
index 0000000..e214eb0
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java
@@ -0,0 +1,147 @@
+// 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 org.apache.cloudstack.network.contrail.management;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ApiConnectorFactory;
+import net.juniper.contrail.api.ApiObjectBase;
+import net.juniper.contrail.api.types.VirtualMachineInterface;
+import net.juniper.contrail.api.types.VirtualNetwork;
+
+import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.component.ComponentLifecycle;
+import com.cloud.utils.db.Merovingian2;
+import com.cloud.utils.mgmt.JmxUtil;
+
+import junit.framework.TestCase;
+import static org.mockito.Mockito.*;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations="classpath:/publicNetworkContext.xml")
+
+public class PublicNetworkTest extends TestCase {
+    private static final Logger s_logger =
+            Logger.getLogger(PublicNetworkTest.class);
+
+    @Inject public ContrailManager _contrailMgr;
+    @Inject public NetworkDao _networksDao;
+
+    private static boolean _initDone = false;
+    private static int _mysql_server_port;
+    private static long _msId;
+    private static Merovingian2 _lockMaster;
+    private ManagementServerMock _server;
+    private ApiConnector _spy;
+    
+
+    @BeforeClass
+    public static void globalSetUp() throws Exception {
+        ApiConnectorFactory.setImplementation(ApiConnectorMockito.class);
+        s_logger.info("mysql server is getting launched ");
+        _mysql_server_port = TestDbSetup.init(null);
+        s_logger.info("mysql server launched on port " + _mysql_server_port);
+        _msId = ManagementServerNode.getManagementServerId();
+        _lockMaster = Merovingian2.createLockMaster(_msId);
+    }
+
+    @AfterClass
+    public static void globalTearDown() throws Exception {
+        _lockMaster.cleanupForServer(_msId);
+        JmxUtil.unregisterMBean("Locks", "Locks");
+        _lockMaster = null;
+
+        AbstractApplicationContext ctx = (AbstractApplicationContext) ComponentContext.getApplicationContext();
+        Map<String, ComponentLifecycle> lifecycleComponents = ctx.getBeansOfType(ComponentLifecycle.class);
+        for (ComponentLifecycle bean: lifecycleComponents.values()) {
+            bean.stop();
+        }
+        ctx.close();
+
+        s_logger.info("destroying mysql server instance running at port <" + _mysql_server_port
+ ">");
+        TestDbSetup.destroy(_mysql_server_port, null);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        try {
+            ComponentContext.initComponentsLifeCycle();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            s_logger.error(ex.getMessage());
+        }
+        _server = ComponentContext.inject(new ManagementServerMock());
+
+        _server.initialize(!_initDone);
+        _initDone = false;
+        _spy = ((ApiConnectorMockito)_contrailMgr.getApiConnector()).getSpy();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        _server.shutdown();
+    }
+
+    @Test
+    public void testPublicNetwork() throws IOException {
+    	DataCenter zone = _server.getZone();
+        List<NetworkVO> networks = _networksDao.listByZoneAndTrafficType(zone.getId(),
TrafficType.Public);
+        assertNotNull(networks);
+        assertFalse(networks.isEmpty());
+        UserVm vm1 = _server.createVM("test", networks.get(0));
+
+        ArgumentCaptor<ApiObjectBase> createArg = ArgumentCaptor.forClass(ApiObjectBase.class);
+        verify(_spy, times(4)).create(createArg.capture());
+        
+        List<ApiObjectBase> argumentList = createArg.getAllValues();
+        ApiObjectBase vmObj = argumentList.get(0);
+        assertEquals(VirtualNetwork.class, vmObj.getClass());
+        assertEquals("__default_Public__", vmObj.getName());
+        
+        String vmiName = null;
+        for (ApiObjectBase obj: argumentList) {
+            if (obj.getClass() == VirtualMachineInterface.class) {
+                vmiName = obj.getName();
+            }
+        }
+        assertEquals("test-0", vmiName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java
new file mode 100644
index 0000000..a184b14
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java
@@ -0,0 +1,13 @@
+package org.apache.cloudstack.network.contrail.management;
+
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class PublicNetworkTestConfiguration {
+	@Bean
+	ServerDBSync getServerDBSync() {
+		return Mockito.mock(ServerDBSync.class);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java
new file mode 100644
index 0000000..460f780
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java
@@ -0,0 +1,151 @@
+// 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 org.apache.cloudstack.network.contrail.management;
+
+import java.net.ServerSocket;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.util.Properties;
+import org.apache.commons.configuration.PropertiesConfiguration;
+
+import org.apache.log4j.Logger;
+
+public class TestDbSetup {
+
+    public static int findFreePort() throws Exception {
+
+       int port;
+       ServerSocket socket= new ServerSocket(0);
+       port = socket.getLocalPort();
+       socket.close();
+
+       return port;
+    }
+
+    public static void startMysqlServer(int port, String startMysqlScript) throws Exception
{
+
+       try {
+	   String cwd = new java.io.File(".").getCanonicalPath();
+            Runtime r = Runtime.getRuntime();
+            String script = startMysqlScript;
+            if (script == null) {
+                script = "test/resources/mysql_db_start.sh "  + port; 
+            }
+            Process process = r.exec("sh " + cwd + "/" + script);
+            process.waitFor();
+            System.out.println("new sql server instance launched on port: " + port);
+       } catch (Exception e) {
+
+            String cause = e.getMessage();
+            if (cause.equals("sh: not found"))
+                System.out.println("No sh interpreter found.");
+            throw e;
+       }
+    }
+
+    public static void stopMysqlServer(int port, String stopMysqlScript) throws Exception
{
+
+       try {
+            Runtime r = Runtime.getRuntime();
+            String script = stopMysqlScript;
+            if (script == null) {
+                script = "test/resources/mysql_db_stop.sh "  + port; 
+            }
+            Process process = r.exec("sh " + script);
+            process.waitFor();
+            System.out.println("sql server instance running at port " + port + " stopped");
+       } catch (Exception e) {
+
+            String cause = e.getMessage();
+            if (cause.equals("sh: not found"))
+                System.out.println("No sh interpreter found.");
+            throw e;
+       }
+    }
+
+    /* this is required for deploying db with new set of sql server parameters */
+    public static void copyDbPropertiesFile() throws Exception {
+       Runtime.getRuntime().exec("cp ../../../utils/conf/db.properties ../../../utils/conf/db.properties.override");
+    }
+
+    public static void updateSqlPort(int port, String propertyFileOverride) throws Exception
{
+
+       PropertiesConfiguration config = new PropertiesConfiguration(propertyFileOverride);
+       System.out.println("File: " + propertyFileOverride + "; old: db.properties port: "
+ 
+                            config.getProperty("db.cloud.port") + ", new port: " + port);
+       config.setProperty("db.cloud.port", "" + port);
+       config.setProperty("db.cloud.username", System.getProperty("user.name"));
+       config.setProperty("db.cloud.password", "");
+
+       config.setProperty("db.usage.port", "" + port);
+       config.setProperty("db.usage.username", System.getProperty("user.name"));
+       config.setProperty("db.usage.password", "");
+
+       config.setProperty("db.awsapi.port", "" + port);
+       config.setProperty("db.awsapi.username", System.getProperty("user.name"));
+       config.setProperty("db.awsapi.password", "");
+
+       config.setProperty("db.simulator.port", "" + port);
+       config.setProperty("db.simulator.username", System.getProperty("user.name"));
+       config.setProperty("db.simulator.password", "");
+
+       config.save();
+    }
+    
+    public static void initCloudstackDb() throws Exception {
+        try {
+            File dir = new File("../../../");
+            Runtime r = Runtime.getRuntime();
+            Process process = r.exec("mvn -P developer -pl developer -Ddeploydb ", null,
dir);
+            dumpProcessOutput(process);
+            process.waitFor();
+        } catch (Exception e) {
+            String cause = e.getMessage();
+            System.out.println("e: " + cause);
+            throw e;
+        }
+    }
+
+
+    public static void dumpProcessOutput(Process p) throws Exception {
+
+       BufferedReader istream = null;
+       istream = new BufferedReader(new InputStreamReader(p.getInputStream()));
+       String line = null;
+       while ((line = istream.readLine()) != null) {
+            System.out.println(line);
+       }
+    }
+
+    public static int init(String startScript) throws Exception {
+        int port = TestDbSetup.findFreePort();
+        TestDbSetup.startMysqlServer(port, startScript);
+        copyDbPropertiesFile();  
+        /* both of these files needs to have mysql port, username password details */
+        TestDbSetup.updateSqlPort(port, "db.properties");  /* for cloudstack runtime */
+        TestDbSetup.updateSqlPort(port, "../../../utils/conf/db.properties.override"); /*
for deploying db */
+        TestDbSetup.initCloudstackDb();
+        return port;
+    } 
+
+    public static void destroy(int port, String stopScript) throws Exception {
+        TestDbSetup.stopMysqlServer(port, stopScript);
+    } 
+}
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/VirtualNetworkModelTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/VirtualNetworkModelTest.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/VirtualNetworkModelTest.java
new file mode 100644
index 0000000..02835e5
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/VirtualNetworkModelTest.java
@@ -0,0 +1,62 @@
+// 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 org.apache.cloudstack.network.contrail.management;
+
+import java.util.UUID;
+
+import org.apache.cloudstack.network.contrail.management.ContrailManager;
+import org.apache.cloudstack.network.contrail.management.ModelDatabase;
+import org.apache.cloudstack.network.contrail.model.VirtualNetworkModel;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.dao.NetworkVO;
+
+import junit.framework.TestCase;
+
+public class VirtualNetworkModelTest extends TestCase {
+    private static final Logger s_logger =
+            Logger.getLogger(VirtualNetworkModelTest.class);
+
+    @Test
+    public void testDBLookup() {
+        ModelDatabase db = new ModelDatabase();
+        NetworkVO network = Mockito.mock(NetworkVO.class);
+        VirtualNetworkModel storageModel = new VirtualNetworkModel(network, null, ContrailManager.managementNetworkName,
+                TrafficType.Storage);
+        db.getVirtualNetworks().add(storageModel);
+        VirtualNetworkModel mgmtModel = new VirtualNetworkModel(network, null, ContrailManager.managementNetworkName,
+                TrafficType.Management);
+        db.getVirtualNetworks().add(mgmtModel);
+        VirtualNetworkModel guestModel1 = new VirtualNetworkModel(network, UUID.randomUUID().toString(),
"test",
+                TrafficType.Guest);
+        db.getVirtualNetworks().add(guestModel1);
+        VirtualNetworkModel guestModel2 = new VirtualNetworkModel(network, UUID.randomUUID().toString(),
"test",
+                TrafficType.Guest);
+        db.getVirtualNetworks().add(guestModel2);
+        s_logger.debug("networks: " + db.getVirtualNetworks().size());
+        assertEquals(4, db.getVirtualNetworks().size());
+        assertSame(storageModel, db.lookupVirtualNetwork(null, storageModel.getName(), TrafficType.Storage));
+        assertSame(mgmtModel, db.lookupVirtualNetwork(null, mgmtModel.getName(), TrafficType.Management));
+        assertSame(guestModel1, db.lookupVirtualNetwork(guestModel1.getUuid(), null, TrafficType.Guest));
+        assertSame(guestModel2, db.lookupVirtualNetwork(guestModel2.getUuid(), null, TrafficType.Guest));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/commonContext.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/commonContext.xml b/plugins/network-elements/juniper-contrail/test/resources/commonContext.xml
new file mode 100644
index 0000000..c577513
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/commonContext.xml
@@ -0,0 +1,172 @@
+<!-- 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">
+
+  <context:annotation-config />
+<!--
+  <context:component-scan base-package="org.apache.cloudstack, com.cloud" />
+-->
+  <!--
+    @DB support
+  -->
+
+   <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
+   <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
+  <bean id="contrailEventInterceptor" class="org.apache.cloudstack.network.contrail.management.EventUtils.EventInterceptor"
/>
+
+  <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
+    <property name="Interceptors">
+      <list>
+        <ref bean="transactionContextBuilder" />
+        <ref bean="actionEventInterceptor" />
+	<ref bean="contrailEventInterceptor" />
+      </list>
+    </property>
+  </bean>
+
+  <bean id="eventBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase"
/>
+
+  <bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
+
+  <bean id="actionEventUtils" class="com.cloud.event.ActionEventUtils" />
+  <bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
+
+  <!--<bean id="eventUtils" class="com.cloud.event.EventUtils" />-->
+
+  <bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
+  <bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
+  <bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
+  <bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
+  <bean id="launchPermissionDaoImpl" class="com.cloud.storage.dao.LaunchPermissionDaoImpl"
/>
+  <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl"
/>
+  <bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
+  <bean id="apiResponseHelper" class="com.cloud.api.ApiResponseHelper" />
+  <bean id="nicDaoImpl" class="com.cloud.vm.dao.NicDaoImpl" />
+
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+
+  <bean id="IntegrationTestConfiguration"
+	class="org.apache.cloudstack.network.contrail.management.IntegrationTestConfiguration"/>
+
+  <bean id="HypervisorGuru"
+       class="com.cloud.hypervisor.XenServerGuru"/>
+
+  <!-- Management traffic -->
+  <bean id="PodBasedNetworkGuru"
+	class="com.cloud.network.guru.PodBasedNetworkGuru"/>
+
+  <bean id="ControlNetworkGuru"
+	class="com.cloud.network.guru.ControlNetworkGuru"/>
+
+  <bean id="PublicNetworkGuru"
+	class="com.cloud.network.guru.PublicNetworkGuru"/>
+
+  <bean id="StorageNetworkGuru"
+	class="com.cloud.network.guru.StorageNetworkGuru"/>
+
+  <bean id="DirectNetworkGuru"
+	class="com.cloud.network.guru.DirectNetworkGuru"/>
+
+  <bean id="VpcVirtualRouterElement"
+	class="com.cloud.network.element.VpcVirtualRouterElement"/>
+
+  <bean id="VirtualRouterElement"
+	class="com.cloud.network.element.VirtualRouterElement"/>
+
+  <!--
+  <bean id="Ipv6AddressManager"
+	class="com.cloud.network.Ipv6AddressManagerImpl"/>
+  -->
+
+
+  <bean id="com.cloud.network.security.SecurityGroupManager"
+	class="com.cloud.network.security.SecurityGroupManagerImpl"/>
+
+  <bean id="SecurityGroupElement"
+	class="com.cloud.network.element.SecurityGroupElement"/>
+	
+  <bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
+      <property name="name" value="InternalLbVm"/>
+  </bean>
+  <!--
+
+  <bean id="UserAuthenticator"
+	class="com.cloud.server.auth.PlainTextUserAuthenticator"/>
+  <bean id="ManagementServer"
+	class="com.cloud.server.ManagementServerImpl"/>
+
+  <bean id="SecondaryStorageVmManager"
+	class="com.cloud.storage.secondary.SecondaryStorageManagerImpl"/>
+
+  <bean id="PodAllocator"
+	class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator"/>
+  -->
+  <bean id="com.cloud.vm.UserVmManager"
+	class="com.cloud.vm.UserVmManagerImpl"/>
+
+  <bean id="com.cloud.vm.VirtualMachineManager"
+	class="com.cloud.vm.VirtualMachineManagerImpl"/>
+
+  <!--
+  <bean id="com.cloud.vm.dao.UserVmDao"
+	class="com.cloud.vm.dao.UserVmDaoImpl"/>
+  -->
+  <bean id="ContrailElement"
+        class="org.apache.cloudstack.network.contrail.management.ContrailElementImpl"/>
+
+  <bean id="ContrailGuru"
+        class="org.apache.cloudstack.network.contrail.management.ContrailGuru"/>
+
+  <bean id="networkElements" class="com.cloud.utils.component.AdapterList">
+    <property name="Adapters">
+      <list>
+          <ref bean="ContrailElement"/>
+          <ref bean="VirtualRouterElement"/>
+          <ref bean="SecurityGroupElement"/>
+          <ref bean="VpcVirtualRouterElement"/>
+          <ref bean="InternalLbVm"/>
+      </list>
+    </property>
+  </bean>
+
+  <bean id="networkGurus" class="com.cloud.utils.component.AdapterList">
+    <property name="Adapters">
+      <list>
+          <ref bean="ContrailGuru"/>
+          <ref bean="PublicNetworkGuru"/>
+          <ref bean="PodBasedNetworkGuru"/>
+          <ref bean="ControlNetworkGuru"/>
+          <ref bean="StorageNetworkGuru"/>
+      </list>
+    </property>
+  </bean>
+
+
+  <bean id="networkModelImpl" class="com.cloud.network.NetworkModelImpl">
+    <property name="NetworkElements" value="#{networkElements.Adapters}" />
+  </bean>
+
+  <bean id="networkOrchestrator" class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator"
>
+    <property name="NetworkElements" value="#{networkElements.Adapters}" />
+    <property name="NetworkGurus" value="#{networkGurus.Adapters}" />
+  </bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/contrail.properties
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/contrail.properties
b/plugins/network-elements/juniper-contrail/test/resources/contrail.properties
new file mode 100644
index 0000000..0c5207e
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/contrail.properties
@@ -0,0 +1,19 @@
+# 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.
+
+api.hostname = 
+api.port = 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/db.properties
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/db.properties b/plugins/network-elements/juniper-contrail/test/resources/db.properties
new file mode 100644
index 0000000..e07d80c
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/db.properties
@@ -0,0 +1,66 @@
+# 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.
+
+cluster.servlet.port=9090
+
+# CloudStack database settings
+db.cloud.username=cloud
+db.cloud.password=cloud
+db.root.password=
+db.cloud.host=localhost
+db.cloud.port=3306
+db.cloud.name=cloud
+
+# CloudStack database tuning parameters
+db.cloud.maxActive=250
+db.cloud.maxIdle=30
+db.cloud.maxWait=10000
+db.cloud.autoReconnect=true
+db.cloud.validationQuery=SELECT 1
+db.cloud.testOnBorrow=true
+db.cloud.testWhileIdle=true
+db.cloud.timeBetweenEvictionRunsMillis=40000
+db.cloud.minEvictableIdleTimeMillis=240000
+db.cloud.poolPreparedStatements=false
+db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096
+
+# usage database settings
+db.usage.username=cloud
+db.usage.password=cloud
+db.usage.host=localhost
+db.usage.port=3306
+db.usage.name=cloud_usage
+
+# usage database tuning parameters
+db.usage.maxActive=100
+db.usage.maxIdle=30
+db.usage.maxWait=10000
+db.usage.autoReconnect=true
+
+# awsapi database settings
+db.awsapi.name=cloudbridge
+
+# Simulator database settings
+db.simulator.username=cloud
+db.simulator.password=cloud
+db.simulator.host=localhost
+db.simulator.port=3306
+db.simulator.name=simulator
+db.simulator.maxActive=250
+db.simulator.maxIdle=30
+db.simulator.maxWait=10000
+db.simulator.autoReconnect=true

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/log4j.properties b/plugins/network-elements/juniper-contrail/test/resources/log4j.properties
new file mode 100644
index 0000000..138a961
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/log4j.properties
@@ -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.
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.appender.stdout.threshold=INFO
+log4j.rootLogger=INFO, stdout, rolling
+log4j.appender.rolling=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+log4j.appender.rolling.layout.ConversionPattern=%d %-5p [%c{3}] (%t:%x) %m%n
+log4j.appender.rolling.file.threshold=DEBUG
+log4j.appender.rolling.File=./logs/testclient.log
+log4j.appender.rolling.DatePattern='.'yyy-MM-dd
+log4j.appender.rolling.file.append=false
+log4j.category.org.apache=INFO, rolling, stdout
+#log4j.category.com.cloud.utils.db.Transaction=ALL
+log4j.category.org.apache.cloudstack.network.contrail=ALL
+log4j.category.com.cloud.network=ALL
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/mysql_db_start.sh
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/mysql_db_start.sh b/plugins/network-elements/juniper-contrail/test/resources/mysql_db_start.sh
new file mode 100644
index 0000000..265cdea
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/mysql_db_start.sh
@@ -0,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.
+
+if [ "$#" -ne 1 ] ; then
+   echo "Usage: $0 <port>" >&2
+   exit 1
+fi
+
+PORT=$1
+echo "starting mysql on port: "$PORT
+
+echo "creating temporary mysql db directories /tmp/mysql"$PORT
+mkdir /tmp/mysql$PORT
+mkdir /tmp/mysql$PORT/data
+
+echo "install db";
+
+mysql_install_db --user=$USER --datadir=/tmp/mysql$PORT/data
+mysqld_safe --datadir=/tmp/mysql$PORT/data --socket=/tmp/mysql$PORT/mysqld.sock --port=$PORT
--log-error=/tmp/mysql$PORT/mysql.log --pid-file=/tmp/mysql$PORT/mysql.pid --user=$USER &
+
+attempts=0
+while [ $attempts -lt 30 ]; do
+    db=$(mysql -h 127.0.0.1 -P $PORT --user=$USER -e "show databases;")
+    status=$?
+    if [ $status == 0 ]; then
+	break
+    fi
+    attempts=`expr $attempts + 1`
+    sleep 1
+done
+
+echo "new mysql server is started on port "$PORT
+echo $db
+
+echo "commands ...."
+echo "to connect(from local host): mysql -h 127.0.0.1 -P "$PORT 
+echo "to stop: mysqladmin -S /tmp/mysql"$PORT"/mysqld.sock shutdown -u root"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/mysql_db_stop.sh
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/mysql_db_stop.sh b/plugins/network-elements/juniper-contrail/test/resources/mysql_db_stop.sh
new file mode 100644
index 0000000..62d70d3
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/mysql_db_stop.sh
@@ -0,0 +1,31 @@
+# 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.
+
+if [ "$#" -ne 1 ] ; then
+   echo "Usage: $0 <port>" >&2
+   exit 1
+fi
+
+echo "Stopping mysql server on port "$1
+
+mysqladmin -S /tmp/mysql$1/mysqld.sock shutdown -u root
+
+rm -rf /tmp/mysql$1
+
+echo "Deleting db directories"
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml
b/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml
new file mode 100644
index 0000000..f412bc0
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <import resource="commonContext.xml"/>
+    <bean id="ProviderTestConfiguration"
+    	class="org.apache.cloudstack.network.contrail.management.ProviderTestConfiguration"/>
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/network-elements/juniper-contrail/test/resources/publicNetworkContext.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/resources/publicNetworkContext.xml
b/plugins/network-elements/juniper-contrail/test/resources/publicNetworkContext.xml
new file mode 100644
index 0000000..3b67b51
--- /dev/null
+++ b/plugins/network-elements/juniper-contrail/test/resources/publicNetworkContext.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <import resource="commonContext.xml"/>
+    <bean id="PublicNetworkTestConfiguration"
+    	class="org.apache.cloudstack.network.contrail.management.PublicNetworkTestConfiguration"/>
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b5fab2f/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index ca41dff..e33ebd8 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -42,6 +42,7 @@
     <module>hypervisors/ucs</module>
     <module>network-elements/elastic-loadbalancer</module>
     <module>network-elements/ovs</module>
+    <module>network-elements/juniper-contrail</module>
     <module>network-elements/nicira-nvp</module>
     <module>network-elements/bigswitch-vns</module>
     <module>network-elements/midonet</module>


Mime
View raw message