You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ka...@apache.org on 2013/06/28 11:10:35 UTC

[1/3] CLOUDSTACK-212: migrate the namespace (network-ssp-plugin)

Updated Branches:
  refs/heads/master 0f40cfbea -> 209185217


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/guru/SspGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/guru/SspGuestNetworkGuru.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/guru/SspGuestNetworkGuru.java
new file mode 100644
index 0000000..6d5d871
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/guru/SspGuestNetworkGuru.java
@@ -0,0 +1,173 @@
+// 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.guru;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.network.element.SspElement;
+import org.apache.cloudstack.network.element.SspManager;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.network.Network;
+import com.cloud.network.NetworkMigrationResponder;
+import com.cloud.network.NetworkProfile;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetwork.IsolationMethod;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.guru.GuestNetworkGuru;
+import com.cloud.network.guru.NetworkGuru;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.ReservationContextImpl;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+/**
+ * Stratosphere SDN Platform NetworkGuru
+ */
+@Local(value=NetworkGuru.class)
+public class SspGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigrationResponder {
+    private static final Logger s_logger = Logger.getLogger(SspGuestNetworkGuru.class);
+
+    @Inject
+    SspManager _sspMgr;
+    @Inject
+    NetworkDao _networkDao;
+    @Inject
+    NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
+
+    public SspGuestNetworkGuru() {
+        super();
+        _isolationMethods = new IsolationMethod[] { IsolationMethod.SSP };
+    }
+
+    @Override
+    protected boolean canHandle(NetworkOffering offering,
+            NetworkType networkType, PhysicalNetwork physicalNetwork) {
+        s_logger.trace("canHandle");
+
+        String setting = null;
+        if(physicalNetwork != null && physicalNetwork.getIsolationMethods().contains("SSP")){
+            // Be careful, PhysicalNetwork#getIsolationMethods() returns List<String>, not List<IsolationMethod>
+            setting = "physicalnetwork setting";
+        }else if(_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.getProvider(SspElement.s_SSP_NAME))){
+            setting = "network offering setting";
+        }
+        if(setting != null){
+            if (networkType != NetworkType.Advanced){
+                s_logger.info("SSP enebled by "+setting+" but not active because networkType was "+networkType);
+            }else if(!isMyTrafficType(offering.getTrafficType())){
+                s_logger.info("SSP enabled by "+setting+" but not active because traffic type not Guest");
+            }else if(offering.getGuestType() != Network.GuestType.Isolated){
+                s_logger.info("SSP works for network isolatation.");
+            }else if(!_sspMgr.canHandle(physicalNetwork)){
+                s_logger.info("SSP manager not ready");
+            }else{
+                return true;
+            }
+        }else{
+            s_logger.debug("SSP not configured to be active");
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * FYI: What is done in parent class is allocateVnet(vlan).
+     * Effective return object members are: cidr, broadcastUri, gateway, mode, physicalNetworkId
+     * The other members will be silently ignored.
+     * This method is called at DeployVMCmd#execute (running phase) - NetworkManagerImpl#prepare
+     * @see org.apache.cloudstack.network.guru.GuestNetworkGuru#implement(com.cloud.network.Network, com.cloud.offering.NetworkOffering, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
+     */
+    @Override
+    public Network implement(Network network, NetworkOffering offering,
+            DeployDestination dest, ReservationContext context)
+                    throws InsufficientVirtualNetworkCapcityException {
+        s_logger.trace("implement "+network.toString());
+        super.implement(network, offering, dest, context);
+        _sspMgr.createNetwork(network, offering, dest, context);
+        return network;
+    }
+
+
+    @Override
+    public void shutdown(NetworkProfile profile, NetworkOffering offering) {
+        s_logger.trace("shutdown "+profile.toString());
+        _sspMgr.deleteNetwork(profile);
+        super.shutdown(profile, offering);
+    }
+
+    @Override
+    public void reserve(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            DeployDestination dest, ReservationContext context)
+                    throws InsufficientVirtualNetworkCapcityException,
+                    InsufficientAddressCapacityException {
+        super.reserve(nic, network, vm, dest, context);
+        _sspMgr.createNicEnv(network, nic, dest, context);
+    }
+
+    @Override
+    public boolean release(NicProfile nic,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            String reservationId) {
+        Network network = _networkDao.findById(nic.getNetworkId());
+        _sspMgr.deleteNicEnv(network, nic, new ReservationContextImpl(reservationId, null, null));
+        return super.release(nic, vm, reservationId);
+    }
+
+    @Override
+    public void updateNicProfile(NicProfile profile, Network network) {
+        super.updateNicProfile(profile, network);
+    }
+
+    @Override
+    public boolean prepareMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            DeployDestination dest, ReservationContext context) {
+        try {
+            reserve(nic, network, vm, dest, context);
+        } catch (InsufficientVirtualNetworkCapcityException e) {
+            s_logger.error("prepareForMigration failed", e);
+            return false;
+        } catch (InsufficientAddressCapacityException e) {
+            s_logger.error("prepareForMigration failed", e);
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void rollbackMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            ReservationContext src, ReservationContext dst) {
+        release(nic, vm, dst.getReservationId());
+    }
+
+    @Override
+    public void commitMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            ReservationContext src, ReservationContext dst) {
+        release(nic, vm, src.getReservationId());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspClientTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspClientTest.java b/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspClientTest.java
deleted file mode 100644
index 4a2b352..0000000
--- a/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspClientTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-// 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.UUID;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.URI;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-public class SspClientTest {
-    HttpClient _client = mock(HttpClient.class);
-    PostMethod _postMethod = mock(PostMethod.class);
-    PutMethod _putMethod = mock(PutMethod.class);
-    DeleteMethod _deleteMethod = mock(DeleteMethod.class);
-
-    String uuid = UUID.randomUUID().toString();
-
-    String apiUrl = "http://a.example.jp/";
-    String username = "foo";
-    String password = "bar";
-    SspClient sspClient = new SspClient(apiUrl, username, password){
-        {
-            client = _client;
-            postMethod = _postMethod;
-            putMethod = _putMethod;
-            deleteMethod = _deleteMethod;
-        }
-    };
-
-    @SuppressWarnings("deprecation")
-    private URI getUri() throws Exception{
-        return new URI(apiUrl);
-    }
-
-    @Test
-    public void loginTest() throws Exception {
-        when(_postMethod.getURI()).thenReturn(getUri());
-        when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        assertTrue(sspClient.login());
-        assertTrue(sspClient.login());
-        assertTrue(sspClient.login());
-    }
-
-    @Test
-    public void createNetworkTest() throws Exception {
-        String networkName = "example network 1";
-        String tenant_net_uuid = UUID.randomUUID().toString();
-
-        when(_postMethod.getURI()).thenReturn(getUri());
-        when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-        when(_postMethod.getResponseBodyAsString()).thenReturn(
-                "{\"uuid\":\""+tenant_net_uuid+
-                "\",\"name\":\""+networkName+
-                "\",\"tenant_uuid\":\""+uuid+"\"}");
-        SspClient.TenantNetwork tnet = sspClient.createTenantNetwork(uuid, networkName);
-        assertEquals(tnet.name, networkName);
-        assertEquals(tnet.uuid, tenant_net_uuid);
-        assertEquals(tnet.tenantUuid, uuid);
-    }
-
-    @Test
-    public void deleteNetworkTest() throws Exception {
-        String tenant_net_uuid = UUID.randomUUID().toString();
-
-        when(_deleteMethod.getURI()).thenReturn(getUri());
-        when(_deleteMethod.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-
-        sspClient.deleteTenantNetwork(tenant_net_uuid);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspElementTest.java b/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspElementTest.java
deleted file mode 100644
index 0020e20..0000000
--- a/plugins/network-elements/stratosphere-ssp/test/com/cloud/network/element/SspElementTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-// 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.Arrays;
-import java.util.HashMap;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.network.Network;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.dao.NetworkServiceMapDao;
-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.dao.SspCredentialDao;
-import com.cloud.network.dao.SspCredentialVO;
-import com.cloud.network.dao.SspTenantDao;
-import com.cloud.network.dao.SspUuidDao;
-import com.cloud.resource.ResourceManager;
-import com.cloud.vm.dao.NicDao;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
-
-public class SspElementTest {
-    SspElement _element = new SspElement();
-
-    @Before
-    public void setUp(){
-        _element._configDao = mock(ConfigurationDao.class);
-        _element._dcDao = mock(DataCenterDao.class);
-        _element._hostDao = mock(HostDao.class);
-        _element._networkMgr = mock(NetworkManager.class);
-        _element._networkModel = mock(NetworkModel.class);
-        _element._nicDao = mock(NicDao.class);
-        _element._physicalNetworkDao = mock(PhysicalNetworkDao.class);
-        _element._physicalNetworkServiceProviderDao = mock(PhysicalNetworkServiceProviderDao.class);
-        _element._resourceMgr = mock(ResourceManager.class);
-        _element._ntwkSrvcDao = mock(NetworkServiceMapDao.class);
-
-        _element._sspCredentialDao = mock(SspCredentialDao.class);
-        _element._sspTenantDao = mock(SspTenantDao.class);
-        _element._sspUuidDao = mock(SspUuidDao.class);
-    }
-
-    Long dataCenterId = new Long(21);
-    Long physicalNetworkId = new Long(22);
-    Long networkId = new Long(23);
-    PhysicalNetworkVO psvo = mock(PhysicalNetworkVO.class);
-    PhysicalNetworkServiceProviderVO nspvo = mock(PhysicalNetworkServiceProviderVO.class);
-    SspCredentialVO credential = mock(SspCredentialVO.class);
-    HostVO host = mock(HostVO.class);
-
-    public void fullyConfigured(){
-        // when physicalNetworkServiceProvider is configured
-        when(psvo.getId()).thenReturn(physicalNetworkId);
-        when(psvo.getDataCenterId()).thenReturn(dataCenterId);
-
-        when(_element._physicalNetworkDao.findById(physicalNetworkId)).thenReturn(psvo);
-
-        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Enabled);
-        when(nspvo.getPhysicalNetworkId()).thenReturn(physicalNetworkId);
-
-        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(nspvo);
-
-        // and zone api server, credentail is configured
-        when(credential.getUsername()).thenReturn("foo");
-        when(credential.getPassword()).thenReturn("bar");
-
-        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(credential);
-
-        HashMap<String,String> details = new HashMap<String, String>();
-        details.put("sspHost", "v1Api");
-        details.put("url", "http://a.example.jp/");
-
-        when(host.getDataCenterId()).thenReturn(dataCenterId);
-        when(host.getDetails()).thenReturn(details);
-        when(host.getDetail("sspHost")).thenReturn(details.get("sspHost"));
-        when(host.getDetail("url")).thenReturn(details.get("url"));
-
-        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList(host));
-
-        when(_element._ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Network.Service.Connectivity, _element.getProvider())).thenReturn(true);
-    }
-
-    @Test
-    public void isReadyTest(){
-        fullyConfigured();
-
-        // isReady is called in changing the networkserviceprovider state to Enabled.
-        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Disabled);
-
-        // ssp is ready
-        assertTrue(_element.isReady(nspvo));
-
-        // If you don't call addstratospheressp api, ssp won't be ready
-        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(null);
-        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList());
-        assertFalse(_element.isReady(nspvo));
-    }
-
-    @Test
-    public void canHandleTest() {
-        fullyConfigured();
-
-        // ssp is active
-        assertTrue(_element.canHandle(psvo));
-
-        // You can disable ssp temporary by truning the state disabled
-        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Disabled);
-        assertFalse(_element.canHandle(psvo));
-
-        // If you don't want ssp for a specific physicalnetwork, you don't need to
-        // setup physicalNetworkProvider.
-        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(null);
-        assertFalse(_element.canHandle(psvo));
-
-        // restore...
-        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Enabled);
-        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(nspvo);
-
-        // If you don't call addstratospheressp api, ssp won't be active
-        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(null);
-        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList());
-        assertFalse(_element.canHandle(psvo));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspClientTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspClientTest.java b/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspClientTest.java
new file mode 100644
index 0000000..795d1c1
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspClientTest.java
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.element;
+
+import java.util.UUID;
+
+import org.apache.cloudstack.network.element.SspClient;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class SspClientTest {
+    HttpClient _client = mock(HttpClient.class);
+    PostMethod _postMethod = mock(PostMethod.class);
+    PutMethod _putMethod = mock(PutMethod.class);
+    DeleteMethod _deleteMethod = mock(DeleteMethod.class);
+
+    String uuid = UUID.randomUUID().toString();
+
+    String apiUrl = "http://a.example.jp/";
+    String username = "foo";
+    String password = "bar";
+    SspClient sspClient = new SspClient(apiUrl, username, password){
+        {
+            client = _client;
+            postMethod = _postMethod;
+            putMethod = _putMethod;
+            deleteMethod = _deleteMethod;
+        }
+    };
+
+    @SuppressWarnings("deprecation")
+    private URI getUri() throws Exception{
+        return new URI(apiUrl);
+    }
+
+    @Test
+    public void loginTest() throws Exception {
+        when(_postMethod.getURI()).thenReturn(getUri());
+        when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        assertTrue(sspClient.login());
+        assertTrue(sspClient.login());
+        assertTrue(sspClient.login());
+    }
+
+    @Test
+    public void createNetworkTest() throws Exception {
+        String networkName = "example network 1";
+        String tenant_net_uuid = UUID.randomUUID().toString();
+
+        when(_postMethod.getURI()).thenReturn(getUri());
+        when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+        when(_postMethod.getResponseBodyAsString()).thenReturn(
+                "{\"uuid\":\""+tenant_net_uuid+
+                "\",\"name\":\""+networkName+
+                "\",\"tenant_uuid\":\""+uuid+"\"}");
+        SspClient.TenantNetwork tnet = sspClient.createTenantNetwork(uuid, networkName);
+        assertEquals(tnet.name, networkName);
+        assertEquals(tnet.uuid, tenant_net_uuid);
+        assertEquals(tnet.tenantUuid, uuid);
+    }
+
+    @Test
+    public void deleteNetworkTest() throws Exception {
+        String tenant_net_uuid = UUID.randomUUID().toString();
+
+        when(_deleteMethod.getURI()).thenReturn(getUri());
+        when(_deleteMethod.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+
+        sspClient.deleteTenantNetwork(tenant_net_uuid);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspElementTest.java b/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspElementTest.java
new file mode 100644
index 0000000..950592f
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/test/org/apache/cloudstack/network/element/SspElementTest.java
@@ -0,0 +1,153 @@
+// 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.element;
+
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.apache.cloudstack.network.dao.SspCredentialDao;
+import org.apache.cloudstack.network.dao.SspCredentialVO;
+import org.apache.cloudstack.network.dao.SspTenantDao;
+import org.apache.cloudstack.network.dao.SspUuidDao;
+import org.apache.cloudstack.network.element.SspElement;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.network.Network;
+import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.dao.NetworkServiceMapDao;
+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.resource.ResourceManager;
+import com.cloud.vm.dao.NicDao;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+public class SspElementTest {
+    SspElement _element = new SspElement();
+
+    @Before
+    public void setUp(){
+        _element._configDao = mock(ConfigurationDao.class);
+        _element._dcDao = mock(DataCenterDao.class);
+        _element._hostDao = mock(HostDao.class);
+        _element._networkMgr = mock(NetworkManager.class);
+        _element._networkModel = mock(NetworkModel.class);
+        _element._nicDao = mock(NicDao.class);
+        _element._physicalNetworkDao = mock(PhysicalNetworkDao.class);
+        _element._physicalNetworkServiceProviderDao = mock(PhysicalNetworkServiceProviderDao.class);
+        _element._resourceMgr = mock(ResourceManager.class);
+        _element._ntwkSrvcDao = mock(NetworkServiceMapDao.class);
+
+        _element._sspCredentialDao = mock(SspCredentialDao.class);
+        _element._sspTenantDao = mock(SspTenantDao.class);
+        _element._sspUuidDao = mock(SspUuidDao.class);
+    }
+
+    Long dataCenterId = new Long(21);
+    Long physicalNetworkId = new Long(22);
+    Long networkId = new Long(23);
+    PhysicalNetworkVO psvo = mock(PhysicalNetworkVO.class);
+    PhysicalNetworkServiceProviderVO nspvo = mock(PhysicalNetworkServiceProviderVO.class);
+    SspCredentialVO credential = mock(SspCredentialVO.class);
+    HostVO host = mock(HostVO.class);
+
+    public void fullyConfigured(){
+        // when physicalNetworkServiceProvider is configured
+        when(psvo.getId()).thenReturn(physicalNetworkId);
+        when(psvo.getDataCenterId()).thenReturn(dataCenterId);
+
+        when(_element._physicalNetworkDao.findById(physicalNetworkId)).thenReturn(psvo);
+
+        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Enabled);
+        when(nspvo.getPhysicalNetworkId()).thenReturn(physicalNetworkId);
+
+        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(nspvo);
+
+        // and zone api server, credentail is configured
+        when(credential.getUsername()).thenReturn("foo");
+        when(credential.getPassword()).thenReturn("bar");
+
+        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(credential);
+
+        HashMap<String,String> details = new HashMap<String, String>();
+        details.put("sspHost", "v1Api");
+        details.put("url", "http://a.example.jp/");
+
+        when(host.getDataCenterId()).thenReturn(dataCenterId);
+        when(host.getDetails()).thenReturn(details);
+        when(host.getDetail("sspHost")).thenReturn(details.get("sspHost"));
+        when(host.getDetail("url")).thenReturn(details.get("url"));
+
+        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList(host));
+
+        when(_element._ntwkSrvcDao.canProviderSupportServiceInNetwork(networkId, Network.Service.Connectivity, _element.getProvider())).thenReturn(true);
+    }
+
+    @Test
+    public void isReadyTest(){
+        fullyConfigured();
+
+        // isReady is called in changing the networkserviceprovider state to Enabled.
+        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Disabled);
+
+        // ssp is ready
+        assertTrue(_element.isReady(nspvo));
+
+        // If you don't call addstratospheressp api, ssp won't be ready
+        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(null);
+        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList());
+        assertFalse(_element.isReady(nspvo));
+    }
+
+    @Test
+    public void canHandleTest() {
+        fullyConfigured();
+
+        // ssp is active
+        assertTrue(_element.canHandle(psvo));
+
+        // You can disable ssp temporary by truning the state disabled
+        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Disabled);
+        assertFalse(_element.canHandle(psvo));
+
+        // If you don't want ssp for a specific physicalnetwork, you don't need to
+        // setup physicalNetworkProvider.
+        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(null);
+        assertFalse(_element.canHandle(psvo));
+
+        // restore...
+        when(nspvo.getState()).thenReturn(PhysicalNetworkServiceProvider.State.Enabled);
+        when(_element._physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, "StratosphereSsp")).thenReturn(nspvo);
+
+        // If you don't call addstratospheressp api, ssp won't be active
+        when(_element._sspCredentialDao.findByZone(dataCenterId.longValue())).thenReturn(null);
+        when(_element._resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId)).thenReturn(Arrays.<HostVO>asList());
+        assertFalse(_element.canHandle(psvo));
+    }
+}


[2/3] CLOUDSTACK-212: migrate the namespace (network-ssp-plugin)

Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/guru/SspGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/guru/SspGuestNetworkGuru.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/guru/SspGuestNetworkGuru.java
deleted file mode 100644
index b504a4b..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/guru/SspGuestNetworkGuru.java
+++ /dev/null
@@ -1,171 +0,0 @@
-// 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 javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
-import com.cloud.network.Network;
-import com.cloud.network.NetworkMigrationResponder;
-import com.cloud.network.NetworkProfile;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.network.PhysicalNetwork.IsolationMethod;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.element.SspElement;
-import com.cloud.network.element.SspManager;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.ReservationContextImpl;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-/**
- * Stratosphere SDN Platform NetworkGuru
- */
-@Local(value=NetworkGuru.class)
-public class SspGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigrationResponder {
-    private static final Logger s_logger = Logger.getLogger(SspGuestNetworkGuru.class);
-
-    @Inject
-    SspManager _sspMgr;
-    @Inject
-    NetworkDao _networkDao;
-    @Inject
-    NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
-
-    public SspGuestNetworkGuru() {
-        super();
-        _isolationMethods = new IsolationMethod[] { IsolationMethod.SSP };
-    }
-
-    @Override
-    protected boolean canHandle(NetworkOffering offering,
-            NetworkType networkType, PhysicalNetwork physicalNetwork) {
-        s_logger.trace("canHandle");
-
-        String setting = null;
-        if(physicalNetwork != null && physicalNetwork.getIsolationMethods().contains("SSP")){
-            // Be careful, PhysicalNetwork#getIsolationMethods() returns List<String>, not List<IsolationMethod>
-            setting = "physicalnetwork setting";
-        }else if(_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.getProvider(SspElement.s_SSP_NAME))){
-            setting = "network offering setting";
-        }
-        if(setting != null){
-            if (networkType != NetworkType.Advanced){
-                s_logger.info("SSP enebled by "+setting+" but not active because networkType was "+networkType);
-            }else if(!isMyTrafficType(offering.getTrafficType())){
-                s_logger.info("SSP enabled by "+setting+" but not active because traffic type not Guest");
-            }else if(offering.getGuestType() != Network.GuestType.Isolated){
-                s_logger.info("SSP works for network isolatation.");
-            }else if(!_sspMgr.canHandle(physicalNetwork)){
-                s_logger.info("SSP manager not ready");
-            }else{
-                return true;
-            }
-        }else{
-            s_logger.debug("SSP not configured to be active");
-        }
-        return false;
-    }
-
-    /* (non-Javadoc)
-     * FYI: What is done in parent class is allocateVnet(vlan).
-     * Effective return object members are: cidr, broadcastUri, gateway, mode, physicalNetworkId
-     * The other members will be silently ignored.
-     * This method is called at DeployVMCmd#execute (running phase) - NetworkManagerImpl#prepare
-     * @see com.cloud.network.guru.GuestNetworkGuru#implement(com.cloud.network.Network, com.cloud.offering.NetworkOffering, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
-     */
-    @Override
-    public Network implement(Network network, NetworkOffering offering,
-            DeployDestination dest, ReservationContext context)
-                    throws InsufficientVirtualNetworkCapcityException {
-        s_logger.trace("implement "+network.toString());
-        super.implement(network, offering, dest, context);
-        _sspMgr.createNetwork(network, offering, dest, context);
-        return network;
-    }
-
-
-    @Override
-    public void shutdown(NetworkProfile profile, NetworkOffering offering) {
-        s_logger.trace("shutdown "+profile.toString());
-        _sspMgr.deleteNetwork(profile);
-        super.shutdown(profile, offering);
-    }
-
-    @Override
-    public void reserve(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            DeployDestination dest, ReservationContext context)
-                    throws InsufficientVirtualNetworkCapcityException,
-                    InsufficientAddressCapacityException {
-        super.reserve(nic, network, vm, dest, context);
-        _sspMgr.createNicEnv(network, nic, dest, context);
-    }
-
-    @Override
-    public boolean release(NicProfile nic,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            String reservationId) {
-        Network network = _networkDao.findById(nic.getNetworkId());
-        _sspMgr.deleteNicEnv(network, nic, new ReservationContextImpl(reservationId, null, null));
-        return super.release(nic, vm, reservationId);
-    }
-
-    @Override
-    public void updateNicProfile(NicProfile profile, Network network) {
-        super.updateNicProfile(profile, network);
-    }
-
-    @Override
-    public boolean prepareMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            DeployDestination dest, ReservationContext context) {
-        try {
-            reserve(nic, network, vm, dest, context);
-        } catch (InsufficientVirtualNetworkCapcityException e) {
-            s_logger.error("prepareForMigration failed", e);
-            return false;
-        } catch (InsufficientAddressCapacityException e) {
-            s_logger.error("prepareForMigration failed", e);
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public void rollbackMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            ReservationContext src, ReservationContext dst) {
-        release(nic, vm, dst.getReservationId());
-    }
-
-    @Override
-    public void commitMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            ReservationContext src, ReservationContext dst) {
-        release(nic, vm, src.getReservationId());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/AddSspCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/AddSspCmd.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/AddSspCmd.java
new file mode 100644
index 0000000..d42ee67
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/AddSspCmd.java
@@ -0,0 +1,138 @@
+// 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.api.commands;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.response.SspResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.network.element.SspService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.cloud.user.UserContext;
+
+
+@APICommand(name="addStratosphereSsp", responseObject=SspResponse.class, description="Adds stratosphere ssp server")
+public class AddSspCmd extends BaseCmd {
+    private static final Logger s_logger = Logger.getLogger(AddSspCmd.class.getName());
+    @Inject
+    SspService _service;
+    @Inject
+    DataCenterDao _dcDao;
+
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+            required=true, description="the zone ID")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="stratosphere ssp server url")
+    private String url;
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=false, description="stratosphere ssp api username")
+    private String username;
+
+    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="stratosphere ssp api password")
+    private String password;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="stratosphere ssp api name")
+    private String name; // required because HostVO name field defined as NOT NULL.
+
+    @Parameter(name="tenantuuid", type=CommandType.STRING, required=false, description="stratosphere ssp tenant uuid")
+    private String tenantUuid; // required in creating ssp tenant_network
+
+    @Override
+    public String getCommandName() {
+        return getClass().getAnnotation(APICommand.class).name();
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return UserContext.current().getCaller().getId();
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+    InsufficientCapacityException, ConcurrentOperationException,
+    ResourceAllocationException, NetworkRuleConflictException {
+        s_logger.trace("execute");
+        Host host = _service.addSspHost(this);
+        SspResponse response = new SspResponse();
+        response.setResponseName(getCommandName());
+        response.setObjectName("ssphost");
+        response.setUrl(this.getUrl());
+        response.setZoneId(_dcDao.findById(getZoneId()).getUuid());
+        response.setHostId(host.getUuid());
+        this.setResponseObject(response);
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(Long zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTenantUuid() {
+        return tenantUuid;
+    }
+
+    public void setTenantUuid(String tenantUuid) {
+        this.tenantUuid = tenantUuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/DeleteSspCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/DeleteSspCmd.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/DeleteSspCmd.java
new file mode 100644
index 0000000..bfbd5d9
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/commands/DeleteSspCmd.java
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.commands;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.network.element.SspService;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.UserContext;
+
+@APICommand(name="deleteStratosphereSsp", responseObject=SuccessResponse.class, description="Removes stratosphere ssp server")
+public class DeleteSspCmd extends BaseCmd {
+    private static final Logger s_logger = Logger.getLogger(AddSspCmd.class.getName());
+    @Inject
+    SspService _service;
+
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
+            required=true, description="the host ID of ssp server")
+    private Long hostId;
+
+    @Override
+    public String getCommandName() {
+        return getClass().getAnnotation(APICommand.class).name();
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return UserContext.current().getCaller().getId();
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+    InsufficientCapacityException, ConcurrentOperationException,
+    ResourceAllocationException, NetworkRuleConflictException {
+        s_logger.trace("execute");
+        SuccessResponse resp = new SuccessResponse();
+        resp.setSuccess(_service.deleteSspHost(this));
+        this.setResponseObject(resp);
+    }
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public void setHostId(Long hostId) {
+        this.hostId = hostId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/response/SspResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/response/SspResponse.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/response/SspResponse.java
new file mode 100644
index 0000000..770ef0f
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/api/response/SspResponse.java
@@ -0,0 +1,77 @@
+// 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.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.host.HostVO;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value=HostVO.class)
+public class SspResponse extends BaseResponse {
+    @SerializedName(ApiConstants.HOST_ID)
+    @Param(description="server id of the stratosphere ssp server")
+    private String hostId;
+
+    @SerializedName(ApiConstants.ZONE_ID)
+    @Param(description="zone which this ssp controls")
+    private String zoneId;
+
+    @SerializedName(ApiConstants.URL)
+    @Param(description="url of ssp endpoint")
+    private String url;
+
+    @SerializedName(ApiConstants.NAME)
+    @Param(description="name")
+    private String name;
+
+
+    public String getHostId() {
+        return hostId;
+    }
+
+    public void setHostId(String hostId) {
+        this.hostId = hostId;
+    }
+
+    public String getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(String zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDao.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDao.java
new file mode 100644
index 0000000..4927da1
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDao.java
@@ -0,0 +1,33 @@
+// 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.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface SspCredentialDao extends GenericDao<SspCredentialVO, Long> {
+    /**
+     * Find an ssp credential for a specific cloudstack zone.
+     *
+     * For now, credential is a pair of username and password.
+     * We might want to fetch different pairs for each cloudstack users
+     * in future work.
+     *
+     * @param zoneId zone Id
+     * @return credential object
+     */
+    public SspCredentialVO findByZone(long zoneId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDaoImpl.java
new file mode 100644
index 0000000..035fd56
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialDaoImpl.java
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.dao;
+
+import javax.ejb.Local;
+
+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;
+
+@Local(SspCredentialDao.class)
+public class SspCredentialDaoImpl extends GenericDaoBase<SspCredentialVO, Long> implements SspCredentialDao {
+    private final SearchBuilder<SspCredentialVO> PnetSearch;
+
+    public SspCredentialDaoImpl() {
+        PnetSearch = createSearchBuilder();
+        PnetSearch.and("dataCenterId", PnetSearch.entity().getZoneId(), Op.EQ);
+        PnetSearch.done();
+    }
+
+    @Override
+    public SspCredentialVO findByZone(long zoneId) {
+        SearchCriteria<SspCredentialVO> sc = PnetSearch.create();
+        sc.setParameters("dataCenterId", zoneId);
+        return findOneBy(sc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialVO.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialVO.java
new file mode 100644
index 0000000..9c6cf14
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspCredentialVO.java
@@ -0,0 +1,67 @@
+// 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.dao;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="external_stratosphere_ssp_credentials")
+public class SspCredentialVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="data_center_id")
+    private long dataCenterId; // Actually, this is zoneId
+
+    // XXX: We might want to restrict access to this by cloudstack privileges.
+    @Column(name="username")
+    private String username;
+
+    @Column(name="password")
+    private String password;
+
+    public long getZoneId() {
+        return dataCenterId;
+    }
+
+    public void setZoneId(long zoneId) {
+        this.dataCenterId = zoneId;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDao.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDao.java
new file mode 100644
index 0000000..7bccdaa
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDao.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface SspTenantDao extends GenericDao<SspTenantVO, Long> {
+    /**
+     * Find an ssp tenant uuid for a specific cloudstack zone.
+     *
+     * The ssp tenant uuid will be used in ssp tenant_network creation.
+     * For now, we map ssp tenant to cloudstack zone. Instead, we might
+     * want to map ssp tenant to cloudstack domain, or ssp tenant to
+     * cloudstack project in future.
+     *
+     * @param zoneId zone id
+     * @return tenant uuid string
+     */
+    public String findUuidByZone(long zoneId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDaoImpl.java
new file mode 100644
index 0000000..8d40256
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantDaoImpl.java
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.dao;
+
+import javax.ejb.Local;
+
+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;
+
+@Local(SspTenantDao.class)
+public class SspTenantDaoImpl extends GenericDaoBase<SspTenantVO, Long>
+        implements SspTenantDao {
+
+    private final SearchBuilder<SspTenantVO> zoneSearch;
+
+    public SspTenantDaoImpl(){
+        zoneSearch = createSearchBuilder();
+        zoneSearch.and("zoneId", zoneSearch.entity().getZoneId(), Op.EQ);
+        zoneSearch.done();
+    }
+
+    @Override
+    public String findUuidByZone(long zoneId) {
+        SearchCriteria<SspTenantVO> sc = zoneSearch.create();
+        sc.setParameters("zoneId", zoneId);
+        SspTenantVO ret = findOneBy(sc);
+        if(ret != null){
+            return ret.getUuid();
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantVO.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantVO.java
new file mode 100644
index 0000000..b573b62
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspTenantVO.java
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.dao;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="external_stratosphere_ssp_tenants")
+public class SspTenantVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="zone_id")
+    private long zoneId;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    public long getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(long zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDao.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDao.java
new file mode 100644
index 0000000..039028a
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDao.java
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.dao;
+
+import java.util.List;
+
+import com.cloud.network.Network;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.vm.NicProfile;
+
+/**
+ * Mapping for SSP UUID and cloudstack entities
+ */
+public interface SspUuidDao extends GenericDao<SspUuidVO, Long> {
+    public String findUuidByNetwork(Network network);
+    public String findUuidByNicProfile(NicProfile nicProfile);
+    public Long findNetworkIdByUuid(String uuid);
+    public Long findNicProfileIdByUuid(String uuid);
+    public int removeUuid(String uuid);
+
+    public List<SspUuidVO> listUUidVoByNicProfile(NicProfile nicProfile);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDaoImpl.java
new file mode 100644
index 0000000..e8b9340
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidDaoImpl.java
@@ -0,0 +1,116 @@
+// 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.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.network.Network;
+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;
+import com.cloud.vm.NicProfile;
+
+@Local(SspUuidDao.class)
+public class SspUuidDaoImpl extends GenericDaoBase<SspUuidVO, Long> implements SspUuidDao {
+
+    private static final Logger s_logger = Logger.getLogger(SspUuidDaoImpl.class);
+
+    protected final SearchBuilder<SspUuidVO> native2uuid;
+    protected final SearchBuilder<SspUuidVO> uuid2native;
+    protected final SearchBuilder<SspUuidVO> uuidfetch;
+
+    public SspUuidDaoImpl() {
+        native2uuid = createSearchBuilder();
+        native2uuid.and("obj_class", native2uuid.entity().getObjClass(), Op.EQ);
+        native2uuid.and("obj_id", native2uuid.entity().getObjId(), Op.EQ);
+        native2uuid.done();
+
+        uuid2native = createSearchBuilder();
+        uuid2native.and("obj_class", uuid2native.entity().getObjClass(), Op.EQ);
+        uuid2native.and("uuid", uuid2native.entity().getUuid(), Op.EQ);
+        uuid2native.done();
+
+        uuidfetch = createSearchBuilder();
+        uuidfetch.and("uuid", uuidfetch.entity().getUuid(), Op.EQ);
+        uuidfetch.done();
+    }
+
+    @Override
+    public String findUuidByNetwork(Network network) {
+        SearchCriteria<SspUuidVO> cs = native2uuid.create();
+        cs.setParameters("obj_class", SspUuidVO.objClassNetwork);
+        cs.setParameters("obj_id", network.getId());
+        SspUuidVO vo = findOneBy(cs);
+        if(vo != null){
+            return vo.getUuid();
+        }
+        return null;
+    }
+
+    @Override
+    public String findUuidByNicProfile(NicProfile nicProfile) {
+        SearchCriteria<SspUuidVO> cs = native2uuid.create();
+        cs.setParameters("obj_class", SspUuidVO.objClassNicProfile);
+        cs.setParameters("obj_id", nicProfile.getId());
+        SspUuidVO vo = findOneBy(cs);
+        if(vo != null){
+            return vo.getUuid();
+        }
+        return null;
+    }
+
+    @Override
+    public List<SspUuidVO> listUUidVoByNicProfile(NicProfile nicProfile) {
+        SearchCriteria<SspUuidVO> cs = native2uuid.create();
+        cs.setParameters("obj_class", SspUuidVO.objClassNicProfile);
+        cs.setParameters("obj_id", nicProfile.getId());
+        return listBy(cs);
+    }
+
+    @Override
+    public Long findNetworkIdByUuid(String uuid) {
+        return findByUuid(SspUuidVO.objClassNetwork, uuid);
+    }
+
+    @Override
+    public Long findNicProfileIdByUuid(String uuid) {
+        return findByUuid(SspUuidVO.objClassNicProfile, uuid);
+    }
+
+    private Long findByUuid(String clazz, String uuid){
+        SearchCriteria<SspUuidVO> cs = uuid2native.create();
+        cs.setParameters("obj_class", clazz);
+        cs.setParameters("uuid", uuid);
+        SspUuidVO vo = findOneBy(cs);
+        if(vo != null){
+            return vo.getObjId();
+        }
+        return null;
+    }
+
+
+    public int removeUuid(String uuid){
+        SearchCriteria<SspUuidVO> cs = uuidfetch.create();
+        cs.setParameters("uuid", uuid);
+        return this.remove(cs);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidVO.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidVO.java
new file mode 100644
index 0000000..f5dc235
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/dao/SspUuidVO.java
@@ -0,0 +1,73 @@
+// 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.dao;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="external_stratosphere_ssp_uuids")
+public class SspUuidVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name="obj_class")
+    private String objClass;
+
+    @Column(name="obj_id")
+    private long objId;
+
+    static public final String objClassNetwork = "net";
+    static public final String objClassNicProfile = "nic";
+
+    @Column(name="reservation_id")
+    private String reservationId;
+
+    public String getUuid() {
+        return uuid;
+    }
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+    public String getObjClass() {
+        return objClass;
+    }
+    public void setObjClass(String objClass) {
+        this.objClass = objClass;
+    }
+    public long getObjId() {
+        return objId;
+    }
+    public void setObjId(long objId) {
+        this.objId = objId;
+    }
+    public String getReservationId() {
+        return reservationId;
+    }
+    public void setReservationId(String reservationId) {
+        this.reservationId = reservationId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspClient.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspClient.java
new file mode 100644
index 0000000..ee4d455
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspClient.java
@@ -0,0 +1,272 @@
+// 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.element;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Stratosphere sdn platform api client
+ */
+public class SspClient {
+    private static final Logger s_logger = Logger.getLogger(SspClient.class);
+    private static final HttpConnectionManager s_httpclient_manager = new MultiThreadedHttpConnectionManager();
+    private static final HttpClientParams s_httpclient_params = new HttpClientParams();
+    static {
+        s_httpclient_params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+    }
+
+    private final String apiUrl;
+    private final String username;
+    private final String password;
+
+    protected HttpClient client;
+    protected PostMethod postMethod;
+    protected DeleteMethod deleteMethod;
+    protected PutMethod putMethod;
+
+    public SspClient(String apiUrl, String username, String password) {
+        super();
+        this.apiUrl = apiUrl;
+        this.username = username;
+        this.password = password;
+        client = new HttpClient(s_httpclient_params, s_httpclient_manager);
+        postMethod = new PostMethod(apiUrl);
+        deleteMethod = new DeleteMethod(apiUrl);
+        putMethod = new PutMethod(apiUrl);
+    }
+
+    public boolean login(){
+        PostMethod method = postMethod;
+        method.setPath("/ws.v1/login"); // NOTE: /ws.v1/login is correct
+        method.addParameter("username", username);
+        method.addParameter("password", password);
+
+        try {
+            client.executeMethod(method);
+        } catch (HttpException e) {
+            s_logger.info("Login "+username+" to "+apiUrl+" failed", e);
+            return false;
+        } catch (IOException e) {
+            s_logger.info("Login "+username+" to "+apiUrl+" failed", e);
+            return false;
+        } finally {
+            method.releaseConnection();
+        }
+        String apiCallPath = null;
+        try {
+            apiCallPath = method.getName() + " " + method.getURI().toString();
+        } catch (URIException e) {
+            s_logger.error("method getURI failed", e);
+        }
+        s_logger.info("ssp api call:" + apiCallPath + " user="+username+" status="+method.getStatusLine());
+        if(method.getStatusCode() == HttpStatus.SC_OK){
+            return true;
+        }
+        return false;
+    }
+
+    private String executeMethod(HttpMethod method){
+        String apiCallPath = null;
+        try {
+            apiCallPath = method.getName() + " " + method.getURI().toString();
+        } catch (URIException e) {
+            s_logger.error("method getURI failed", e);
+        }
+
+        String response = null;
+        try {
+            client.executeMethod(method);
+            response = method.getResponseBodyAsString();
+        } catch (HttpException e) {
+            s_logger.error("ssp api call failed "+apiCallPath, e);
+            return null;
+        } catch (IOException e) {
+            s_logger.error("ssp api call failed "+apiCallPath, e);
+            return null;
+        } finally {
+            method.releaseConnection();
+        }
+
+        if(method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED){
+            if(!login()){
+                return null;
+            }
+
+            try {
+                client.executeMethod(method);
+                response = method.getResponseBodyAsString();
+            } catch (HttpException e) {
+                s_logger.error("ssp api call failed "+apiCallPath, e);
+                return null;
+            } catch (IOException e) {
+                s_logger.error("ssp api call failed "+apiCallPath, e);
+                return null;
+            } finally {
+                method.releaseConnection();
+            }
+        }
+        s_logger.info("ssp api call:" + apiCallPath + " user="+username+" status="+method.getStatusLine());
+        if(method instanceof EntityEnclosingMethod){
+            EntityEnclosingMethod emethod = (EntityEnclosingMethod)method;
+            RequestEntity reqEntity = emethod.getRequestEntity();
+            if(reqEntity instanceof StringRequestEntity){
+                StringRequestEntity strReqEntity = (StringRequestEntity)reqEntity;
+                s_logger.debug("ssp api request body:"+strReqEntity.getContent());
+            }else{
+                s_logger.debug("ssp api request body:"+emethod.getRequestEntity());
+            }
+        }
+        s_logger.debug("ssp api response body:" + response);
+        return response;
+    }
+
+    public class TenantNetwork {
+        public String uuid;
+        public String name;
+        @SerializedName("tenant_uuid")
+        public String tenantUuid;
+    }
+
+    public TenantNetwork createTenantNetwork(String tenantUuid, String networkName){
+        TenantNetwork req = new TenantNetwork();
+        req.name = networkName;
+        req.tenantUuid = tenantUuid;
+
+        PostMethod method = postMethod;
+        method.setPath("/ssp.v1/tenant-networks");
+        StringRequestEntity entity = null;
+        try {
+            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            s_logger.error("failed creating http request body", e);
+            return null;
+        }
+        method.setRequestEntity(entity);
+
+        String response = executeMethod(method);
+        if(response != null && method.getStatusCode() == HttpStatus.SC_CREATED){
+            return new Gson().fromJson(response, TenantNetwork.class);
+        }
+        return null;
+    }
+
+    public boolean deleteTenantNetwork(String tenantNetworkUuid){
+        DeleteMethod method = deleteMethod;
+        method.setPath("/ssp.v1/tenant-networks/"+tenantNetworkUuid);
+
+        executeMethod(method);
+        if(method.getStatusCode() == HttpStatus.SC_NO_CONTENT){
+            return true;
+        }
+        return false;
+    }
+
+    public class TenantPort {
+        public String uuid;
+        public String name;
+        @SerializedName("network_uuid")
+        public String networkUuid;
+        @SerializedName("attachment_type")
+        public String attachmentType;
+        @SerializedName("attachment_ip_address")
+        public String hypervisorIpAddress;
+        @SerializedName("vlan_id")
+        public Integer vlanId;
+    }
+
+    public TenantPort createTenantPort(String tenantNetworkUuid){
+        TenantPort req = new TenantPort();
+        req.networkUuid = tenantNetworkUuid;
+        req.attachmentType = "NoAttachment";
+
+        PostMethod method = postMethod;
+        method.setPath("/ssp.v1/tenant-ports");
+        StringRequestEntity entity = null;
+        try {
+            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            s_logger.error("failed creating http request body", e);
+            return null;
+        }
+        method.setRequestEntity(entity);
+
+        String response = executeMethod(method);
+        if(response != null && method.getStatusCode() == HttpStatus.SC_CREATED){
+            return new Gson().fromJson(response, TenantPort.class);
+        }
+        return null;
+    }
+
+    public boolean deleteTenantPort(String tenantPortUuid){
+        DeleteMethod method = deleteMethod;
+        method.setPath("/ssp.v1/tenant-ports/"+tenantPortUuid);
+
+        executeMethod(method);
+        if(method.getStatusCode() == HttpStatus.SC_NO_CONTENT){
+            return true;
+        }
+        return false;
+    }
+
+    public TenantPort updateTenantVifBinding(String portUuid, String hypervisorIpAddress){
+        TenantPort req = new TenantPort();
+        if(hypervisorIpAddress != null){
+            req.attachmentType = "VifAttachment";
+            req.hypervisorIpAddress = hypervisorIpAddress;
+        }else{
+            req.attachmentType = "NoAttachment";
+        }
+
+        PutMethod method = putMethod;
+        method.setPath("/ssp.v1/tenant-ports/"+portUuid);
+        StringRequestEntity entity = null;
+        try {
+            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            s_logger.error("failed creating http request body", e);
+            return null;
+        }
+        method.setRequestEntity(entity);
+
+        String response = executeMethod(method);
+        if(response != null && method.getStatusCode() == HttpStatus.SC_OK){
+            return new Gson().fromJson(response, TenantPort.class);
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspElement.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspElement.java
new file mode 100644
index 0000000..823c16b
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspElement.java
@@ -0,0 +1,619 @@
+// 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.element;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+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.api.commands.AddSspCmd;
+import org.apache.cloudstack.api.commands.DeleteSspCmd;
+import org.apache.cloudstack.network.dao.SspCredentialDao;
+import org.apache.cloudstack.network.dao.SspCredentialVO;
+import org.apache.cloudstack.network.dao.SspTenantDao;
+import org.apache.cloudstack.network.dao.SspTenantVO;
+import org.apache.cloudstack.network.dao.SspUuidDao;
+import org.apache.cloudstack.network.dao.SspUuidVO;
+import org.apache.log4j.Logger;
+
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.dc.dao.DataCenterDao;
+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.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+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.NetworkManager;
+import com.cloud.network.NetworkMigrationResponder;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PhysicalNetworkServiceProvider.State;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
+import com.cloud.network.element.ConnectivityProvider;
+import com.cloud.network.element.NetworkElement;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.NicVO;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.resource.ResourceManager;
+
+/**
+ * Stratosphere sdn platform network element
+ *
+ * This class will be called per network setup operations.
+ * This class also have ssp specific methods.
+ *
+ * Current implementation use HostVO for storage of api endpoint information,
+ * but note this is not necessary. The other way is create our own database
+ * table for that information.
+ */
+@Local(value={NetworkElement.class, SspManager.class})
+public class SspElement extends AdapterBase implements ConnectivityProvider, SspManager, SspService, NetworkMigrationResponder {
+    private static final Logger s_logger = Logger.getLogger(SspElement.class);
+    public static final String s_SSP_NAME = "StratosphereSsp";
+
+    @Inject
+    NetworkServiceMapDao _ntwkSrvcDao;
+    @Inject
+    NetworkModel _networkModel;
+    @Inject
+    NetworkManager _networkMgr;
+    @Inject
+    ResourceManager _resourceMgr;
+    @Inject
+    PhysicalNetworkDao _physicalNetworkDao;
+    @Inject
+    PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
+    @Inject
+    SspCredentialDao _sspCredentialDao;
+    @Inject
+    SspTenantDao _sspTenantDao;
+    @Inject
+    SspUuidDao _sspUuidDao;
+    @Inject
+    DataCenterDao _dcDao;
+    @Inject
+    HostDao _hostDao;
+    @Inject
+    ConfigurationDao _configDao;
+    @Inject
+    NicDao _nicDao = null;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params)
+            throws ConfigurationException {
+        return super.configure(name, params);
+    }
+
+    @Override
+    public Map<Service, Map<Capability, String>> getCapabilities() {
+        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
+        capabilities.put(Service.Connectivity, new HashMap<Capability,String>()); // XXX: We might need some more category here.
+        return capabilities;
+    }
+
+    @Override
+    public Provider getProvider() {
+        Provider provider = null;
+        synchronized(s_SSP_NAME){
+            provider = Provider.getProvider(s_SSP_NAME);
+            if(provider==null){
+                provider = new Provider(s_SSP_NAME, true);
+                s_logger.debug("registering Network.Provider "+s_SSP_NAME);
+            }
+        }
+        return provider;
+    }
+
+    private List<SspClient> fetchSspClients(Long physicalNetworkId, Long dataCenterId, boolean enabled_only){
+        ArrayList<SspClient> clients = new ArrayList<SspClient>();
+
+        boolean provider_found = false;
+        PhysicalNetworkServiceProviderVO provider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, s_SSP_NAME);
+        if(enabled_only){
+            if(provider != null && provider.getState() == State.Enabled){
+                provider_found = true;
+            }
+        }else{
+            provider_found = true;
+        }
+
+        if(physicalNetworkId != null && provider_found){
+            SspCredentialVO credential = _sspCredentialDao.findByZone(dataCenterId);
+            List<HostVO> hosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId);
+            for(HostVO host : hosts){
+                assert(credential != null);
+                _hostDao.loadDetails(host);
+                if("v1Api".equals(host.getDetail("sspHost"))){
+                    clients.add(new SspClient(host.getDetail("url"), credential.getUsername(), credential.getPassword()));
+                }
+            }
+        }
+        if(clients.size()==0){
+            String global_apiUrl = _configDao.getValueAndInitIfNotExist("ssp.url", "Network", null);
+            String global_username = _configDao.getValueAndInitIfNotExist("ssp.username", "Network", null);
+            String global_password = _configDao.getValueAndInitIfNotExist("ssp.password", "Network", null);
+            if(global_apiUrl != null && global_username != null && global_password != null){
+                clients.add(new SspClient(global_apiUrl, global_username, global_password));
+            }
+        }
+        return clients;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cloudstack.network.element.NetworkElement#isReady(com.cloud.network.PhysicalNetworkServiceProvider)
+     */
+    @Override
+    public boolean isReady(PhysicalNetworkServiceProvider provider) {
+        PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(provider.getPhysicalNetworkId());
+        assert(physicalNetwork!=null);
+        if(physicalNetwork != null){
+            if(fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), false).size() > 0){
+                return true;
+            }
+            s_logger.warn("Ssp api endpoint not found. "+physicalNetwork.toString());
+        }else{
+            s_logger.warn("PhysicalNetwork is NULL.");
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * If this element is ready, then it can be enabled.
+     * @see org.apache.cloudstack.network.element.SspManager#isEnabled(com.cloud.network.PhysicalNetwork)
+     */
+    @Override
+    public boolean canHandle(PhysicalNetwork physicalNetwork){
+        if(physicalNetwork != null){
+            if(fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), true).size() > 0){
+                return true;
+            }
+            s_logger.warn("enabled Ssp api endpoint not found. "+physicalNetwork.toString());
+        }else{
+            s_logger.warn("PhysicalNetwork is NULL.");
+        }
+        return false;
+    }
+
+    private boolean canHandle(Network network){
+        if(canHandle(_physicalNetworkDao.findById(network.getPhysicalNetworkId()))){
+            if(!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.Connectivity, getProvider())){
+                s_logger.info("SSP is implicitly active for "+network);
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public Host addSspHost(AddSspCmd cmd) {
+        SspClient client = new SspClient(cmd.getUrl(), cmd.getUsername(), cmd.getPassword());
+        if(!client.login()){
+            throw new CloudRuntimeException("Ssp login failed.");
+        }
+
+        long zoneId = cmd.getZoneId();
+        SspCredentialVO credential = _sspCredentialDao.findByZone(zoneId);
+        if(credential==null){
+            if(cmd.getUsername()==null || cmd.getPassword()==null){
+                throw new InvalidParameterValueException("Initial credential required for zone: " + zoneId);
+            }
+            credential = new SspCredentialVO();
+            credential.setZoneId(zoneId);
+            credential.setUsername(cmd.getUsername());
+            credential.setPassword(cmd.getPassword());
+            _sspCredentialDao.persist(credential);
+        }else{
+            if(cmd.getUsername()!=null || cmd.getPassword()!=null){
+                s_logger.warn("Tenant credential already configured for zone:"+zoneId);
+            }
+        }
+
+        String tenantUuid = _sspTenantDao.findUuidByZone(zoneId);
+        if(tenantUuid==null){
+            if(cmd.getTenantUuid()==null){
+                throw new InvalidParameterValueException("Initial tenant uuid required for zone: " + zoneId);
+            }
+            SspTenantVO tenant = new SspTenantVO();
+            tenant.setZoneId(zoneId);
+            tenant.setUuid(cmd.getTenantUuid());
+            _sspTenantDao.persist(tenant);
+        }else{
+            if(cmd.getTenantUuid()!=null){
+                s_logger.warn("Tenant uuid already configured for zone:"+zoneId);
+            }
+        }
+
+        String normalizedUrl = null;
+        String hostname = null;
+        try {
+            URL url = new URL(cmd.getUrl());
+            normalizedUrl = url.toString();
+            hostname = url.getHost();
+        } catch (MalformedURLException e1) {
+            throw new CloudRuntimeException("Invalid url "+cmd.getUrl());
+        }
+
+        List<HostVO> hosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, zoneId);
+        for(HostVO host : hosts){
+            assert(credential != null);
+            _hostDao.loadDetails(host);
+            if("v1Api".equals(host.getDetail("sspHost"))){
+                if(normalizedUrl.equals(host.getDetail("url"))){
+                    s_logger.warn("Ssp host already registered "+normalizedUrl);
+                    return host;
+                }
+            }
+        }
+        // SspHost HostVO will be created per zone and url.
+        HostVO host = new HostVO(UUID.randomUUID().toString());
+        host.setDataCenterId(zoneId);
+        host.setType(Host.Type.L2Networking);
+        host.setPrivateIpAddress(hostname); // db schema not null. It may be a name, not IP address.
+        //        host.setPrivateMacAddress(""); // db schema nullable
+        //        host.setPrivateNetmask(""); // db schema nullable
+        host.setVersion("1"); // strange db schema not null
+        host.setName(cmd.getName());
+
+        host.setDetails(new HashMap<String, String>());
+        host.setDetail("sspHost", "v1Api");
+        host.setDetail("url", normalizedUrl);
+        return _hostDao.persist(host);
+    }
+
+    @Override
+    public boolean deleteSspHost(DeleteSspCmd cmd) {
+        s_logger.info("deleteStratosphereSsp");
+        return _hostDao.remove(cmd.getHostId());
+    }
+
+    public boolean createNetwork(Network network, NetworkOffering offering,
+            DeployDestination dest, ReservationContext context){
+        if(_sspUuidDao.findUuidByNetwork(network) != null){
+            s_logger.info("Network already has ssp TenantNetwork uuid :"+network.toString());
+            return true;
+        }
+        if(!canHandle(network)){
+            return false;
+        }
+
+        String tenantUuid = _sspTenantDao.findUuidByZone(network.getDataCenterId());
+        if(tenantUuid==null){
+            tenantUuid = _configDao.getValueAndInitIfNotExist("ssp.tenant", "Network", null);
+        }
+
+        boolean processed = false;
+        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+            SspClient.TenantNetwork sspNet = client.createTenantNetwork(tenantUuid, network.getName());
+            if(sspNet != null){
+                SspUuidVO uuid = new SspUuidVO();
+                uuid.setUuid(sspNet.uuid);
+                uuid.setObjClass(SspUuidVO.objClassNetwork);
+                uuid.setObjId(network.getId());
+                _sspUuidDao.persist(uuid);
+                return true;
+            }
+            processed = true;
+        }
+        if(processed){
+            s_logger.error("Could not allocate an uuid for network "+network.toString());
+            return false;
+        }else{
+            s_logger.error("Skipping #createNetwork() for "+network.toString());
+            return true;
+        }
+    }
+
+    public boolean deleteNetwork(Network network){
+        String tenantNetworkUuid = _sspUuidDao.findUuidByNetwork(network);
+        if(tenantNetworkUuid != null){
+            boolean processed = false;
+            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+                if(client.deleteTenantNetwork(tenantNetworkUuid)){
+                    _sspUuidDao.removeUuid(tenantNetworkUuid);
+                    processed = true;
+                    break;
+                }
+            }
+            if(!processed){
+                s_logger.error("Ssp api tenant network deletion failed "+network.toString());
+            }
+        }else{
+            s_logger.debug("Silently skipping #deleteNetwork() for "+network.toString());
+        }
+        return true;
+    }
+
+    // we use context.reservationId for dedup of guru & element operations.
+    public boolean createNicEnv(Network network, NicProfile nic, DeployDestination dest, ReservationContext context){
+        String tenantNetworkUuid = _sspUuidDao.findUuidByNetwork(network);
+        if(tenantNetworkUuid == null){
+            s_logger.debug("Skipping #createNicEnv() for nic on "+network.toString());
+            return true;
+        }
+
+        String reservationId = context.getReservationId();
+        List<SspUuidVO> tenantPortUuidVos = _sspUuidDao.listUUidVoByNicProfile(nic);
+        for(SspUuidVO tenantPortUuidVo : tenantPortUuidVos){
+            if(reservationId.equals(tenantPortUuidVo.getReservationId())){
+                s_logger.info("Skipping because reservation found "+reservationId);
+                return true;
+            }
+        }
+
+        String tenantPortUuid = null;
+        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+            SspClient.TenantPort sspPort = client.createTenantPort(tenantNetworkUuid);
+            if(sspPort != null){
+                tenantPortUuid = sspPort.uuid;
+                nic.setReservationId(reservationId);
+
+                SspUuidVO uuid = new SspUuidVO();
+                uuid.setUuid(tenantPortUuid);
+                uuid.setObjClass(SspUuidVO.objClassNicProfile);
+                uuid.setObjId(nic.getId());
+                uuid.setReservationId(reservationId);
+                _sspUuidDao.persist(uuid);
+                break;
+            }
+        }
+        if(tenantPortUuid == null){
+            s_logger.debug("#createNicEnv() failed for nic on "+network.toString());
+            return false;
+        }
+
+        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+            SspClient.TenantPort sspPort = client.updateTenantVifBinding(tenantPortUuid, dest.getHost().getPrivateIpAddress());
+            if(sspPort != null){
+                if(sspPort.vlanId != null){
+                    nic.setBroadcastType(BroadcastDomainType.Vlan);
+                    nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(String.valueOf(sspPort.vlanId)));
+                }
+                return true;
+            }
+        }
+        s_logger.error("Updating vif failed "+nic.toString());
+        return false;
+    }
+
+    public boolean deleteNicEnv(Network network, NicProfile nic, ReservationContext context){
+        if(context==null){
+            s_logger.error("ReservationContext was null for "+nic+" "+network);
+            return false;
+        }
+        String reservationId = context.getReservationId();
+
+        SspUuidVO deleteTarget = null;
+        SspUuidVO remainingTarget = null;
+        List<SspUuidVO> tenantPortUuidVos = _sspUuidDao.listUUidVoByNicProfile(nic);
+        for(SspUuidVO tenantPortUuidVo : tenantPortUuidVos){
+            if(reservationId.equals(tenantPortUuidVo.getReservationId())){
+                deleteTarget = tenantPortUuidVo;
+            }else{
+                remainingTarget = tenantPortUuidVo;
+            }
+        }
+
+        if(deleteTarget != null){ // delete the target ssp uuid (tenant-port)
+            String tenantPortUuid = deleteTarget.getUuid();
+            boolean processed = false;
+            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+                SspClient.TenantPort sspPort = client.updateTenantVifBinding(tenantPortUuid, null);
+                if(sspPort != null){
+                    processed = true;
+                    break;
+                }
+            }
+            if(!processed){
+                s_logger.warn("Ssp api nic detach failed "+nic.toString());
+            }
+            processed = false;
+            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
+                if(client.deleteTenantPort(tenantPortUuid)){
+                    _sspUuidDao.removeUuid(tenantPortUuid);
+                    processed = true;
+                    break;
+                }
+            }
+            if(!processed){
+                s_logger.warn("Ssp api tenant port deletion failed "+nic.toString());
+            }
+            _sspUuidDao.removeUuid(tenantPortUuid);
+        }
+        if(remainingTarget != null){
+            NicVO nicVo = _nicDao.findById(nic.getId());
+            nicVo.setReservationId(remainingTarget.getReservationId());
+            _nicDao.persist(nicVo); // persist the new reservationId
+        }
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * Implements a network using ssp element.
+     *
+     * This method will be called right after NetworkGuru#implement().
+     * see also {@link #shutdown(Network, ReservationContext, boolean)}
+     * @see org.apache.cloudstack.network.element.NetworkElement#implement(com.cloud.network.Network, com.cloud.offering.NetworkOffering, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
+     */
+    @Override
+    public boolean implement(Network network, NetworkOffering offering,
+            DeployDestination dest, ReservationContext context)
+                    throws ConcurrentOperationException, ResourceUnavailableException,
+                    InsufficientCapacityException {
+        s_logger.info("implement");
+        return createNetwork(network, offering, dest, context);
+    }
+
+    /* (non-Javadoc)
+     * Shutdown the network implementation
+     *
+     * This method will be called right BEFORE NetworkGuru#shutdown().
+     * The entities was acquired by {@link #implement(Network, NetworkOffering, DeployDestination, ReservationContext)}
+     * @see org.apache.cloudstack.network.element.NetworkElement#shutdown(com.cloud.network.Network, com.cloud.vm.ReservationContext, boolean)
+     */
+    @Override
+    public boolean shutdown(Network network, ReservationContext context,
+            boolean cleanup) throws ConcurrentOperationException,
+            ResourceUnavailableException {
+        s_logger.trace("shutdown");
+        return deleteNetwork(network);
+    }
+
+    /* (non-Javadoc)
+     * Prepares a network environment for a VM nic.
+     *
+     * This method will be called right after NetworkGuru#reserve().
+     * The entities will be released by {@link #release(Network, NicProfile, VirtualMachineProfile, ReservationContext)}
+     * @see org.apache.cloudstack.network.element.NetworkElement#prepare(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
+     */
+    @Override
+    public boolean prepare(Network network, NicProfile nic,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            DeployDestination dest, ReservationContext context)
+                    throws ConcurrentOperationException, ResourceUnavailableException,
+                    InsufficientCapacityException {
+        s_logger.trace("prepare");
+        return createNicEnv(network, nic, dest, context);
+    }
+
+    /* (non-Javadoc)
+     * Release the network environment that was prepared for a VM nic.
+     *
+     * This method will be called right AFTER NetworkGuru#release().
+     * The entities was acquired in {@link #prepare(Network, NicProfile, VirtualMachineProfile, DeployDestination, ReservationContext)}
+     * @see org.apache.cloudstack.network.element.NetworkElement#release(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.vm.ReservationContext)
+     */
+    @Override
+    public boolean release(Network network, NicProfile nic,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            ReservationContext context) throws ConcurrentOperationException,
+            ResourceUnavailableException {
+        s_logger.trace("release");
+        return deleteNicEnv(network, nic, context);
+    }
+
+    /* (non-Javadoc)
+     * Destroy a network implementation.
+     *
+     * This method will be called right BEFORE NetworkGuru#trash() in "Expunge" phase.
+     * @see org.apache.cloudstack.network.element.NetworkElement#destroy(com.cloud.network.Network)
+     */
+    @Override
+    public boolean destroy(Network network, ReservationContext context)
+            throws ConcurrentOperationException, ResourceUnavailableException {
+        s_logger.trace("destroy");
+        // nothing to do here.
+        return true;
+    }
+
+    @Override
+    public boolean shutdownProviderInstances(
+            PhysicalNetworkServiceProvider provider, ReservationContext context)
+                    throws ConcurrentOperationException, ResourceUnavailableException {
+        s_logger.trace("shutdownProviderInstances");
+        return true;
+    }
+
+    @Override
+    public boolean canEnableIndividualServices() {
+        s_logger.trace("canEnableIndividualServices");
+        return true; // because there is only Connectivity
+    }
+
+    @Override
+    public boolean verifyServicesCombination(Set<Service> services) {
+        s_logger.trace("verifyServicesCombination "+services.toString());
+        return true;
+    }
+
+    @Override
+    public boolean prepareMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            DeployDestination dest, ReservationContext context) {
+        try {
+            prepare(network, nic, vm, dest, context);
+        } catch (ConcurrentOperationException e) {
+            s_logger.error("prepareForMigration failed.", e);
+            return false;
+        } catch (ResourceUnavailableException e) {
+            s_logger.error("prepareForMigration failed.", e);
+            return false;
+        } catch (InsufficientCapacityException e) {
+            s_logger.error("prepareForMigration failed.", e);
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void rollbackMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            ReservationContext src, ReservationContext dst) {
+        try {
+            release(network, nic, vm, dst);
+        } catch (ConcurrentOperationException e) {
+            s_logger.error("rollbackMigration failed.", e);
+        } catch (ResourceUnavailableException e) {
+            s_logger.error("rollbackMigration failed.", e);
+        }
+    }
+
+    @Override
+    public void commitMigration(NicProfile nic, Network network,
+            VirtualMachineProfile<? extends VirtualMachine> vm,
+            ReservationContext src, ReservationContext dst) {
+        try {
+            release(network, nic, vm, src);
+        } catch (ConcurrentOperationException e) {
+            s_logger.error("commitMigration failed.", e);
+        } catch (ResourceUnavailableException e) {
+            s_logger.error("commitMigration failed.", e);
+        }
+    }
+
+    @Override
+    public List<Class<?>> getCommands() {
+        return Arrays.<Class<?>>asList(AddSspCmd.class, DeleteSspCmd.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspManager.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspManager.java
new file mode 100644
index 0000000..d96bd7f
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspManager.java
@@ -0,0 +1,71 @@
+// 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.element;
+
+import com.cloud.deploy.DeployDestination;
+import com.cloud.network.Network;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.utils.component.Manager;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+
+public interface SspManager extends Manager {
+    /**
+     * Checks Ssp is activated or not
+     * @param physicalNetwork
+     * @return true if physicalNetworkProvider is configured
+     */
+    public boolean canHandle(PhysicalNetwork physicalNetwork);
+
+    /**
+     * Tell ssp to create a network
+     * @param network
+     * @param offering
+     * @param dest
+     * @param context
+     * @return
+     */
+    public boolean createNetwork(Network network, NetworkOffering offering,
+            DeployDestination dest, ReservationContext context);
+
+    /**
+     * Tell ssp to delete a network
+     * @param network
+     * @return
+     */
+    public boolean deleteNetwork(Network network);
+
+    /**
+     * Create a nic entry in ssp
+     * @param network
+     * @param nic
+     * @param dest
+     * @param context
+     * @return true on success
+     */
+    public boolean createNicEnv(Network network, NicProfile nic, DeployDestination dest, ReservationContext context);
+
+    /**
+     * Delete a nic entry from ssp
+     * @param network
+     * @param nic
+     * @param context
+     * @return
+     */
+    public boolean deleteNicEnv(Network network, NicProfile nic, ReservationContext context);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspService.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspService.java b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspService.java
new file mode 100644
index 0000000..3330045
--- /dev/null
+++ b/plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspService.java
@@ -0,0 +1,47 @@
+// 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.element;
+
+import org.apache.cloudstack.api.commands.AddSspCmd;
+import org.apache.cloudstack.api.commands.DeleteSspCmd;
+
+import com.cloud.host.Host;
+import com.cloud.utils.component.PluggableService;
+
+/**
+ * Stratosphere sdn platform plugin service.
+ */
+public interface SspService extends PluggableService {
+    /**
+     * Add an ssp api endpoint information as an host
+     *
+     * Adds a api endpoint information in database and
+     * make it usable.
+     * @param cmd
+     * @return
+     */
+    public Host addSspHost(AddSspCmd cmd);
+
+    /**
+     * Delete an ssp api endpoint information
+     *
+     * Deletes the information from database.
+     * @param cmd
+     * @return
+     */
+    public boolean deleteSspHost(DeleteSspCmd cmd);
+}


[3/3] git commit: updated refs/heads/master to 2091852

Posted by ka...@apache.org.
CLOUDSTACK-212: migrate the namespace (network-ssp-plugin)

migrate the ssp plugin namespace from com.cloud to org.apache.cloudstack

Signed-off-by: Hiroaki KAWAI <ka...@stratosphere.co.jp>


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

Branch: refs/heads/master
Commit: 2091852175797eeed0c3952f4fd3da74a13fb623
Parents: 0f40cfb
Author: Hiroaki KAWAI <ka...@stratosphere.co.jp>
Authored: Fri Jun 28 17:34:36 2013 +0900
Committer: Hiroaki KAWAI <ka...@stratosphere.co.jp>
Committed: Fri Jun 28 18:10:28 2013 +0900

----------------------------------------------------------------------
 client/tomcatconf/componentContext.xml.in       |  10 +-
 .../src/com/cloud/api/commands/AddSspCmd.java   | 138 -----
 .../com/cloud/api/commands/DeleteSspCmd.java    |  74 ---
 .../src/com/cloud/api/response/SspResponse.java |  77 ---
 .../com/cloud/network/dao/SspCredentialDao.java |  33 -
 .../cloud/network/dao/SspCredentialDaoImpl.java |  42 --
 .../com/cloud/network/dao/SspCredentialVO.java  |  67 --
 .../src/com/cloud/network/dao/SspTenantDao.java |  34 -
 .../com/cloud/network/dao/SspTenantDaoImpl.java |  48 --
 .../src/com/cloud/network/dao/SspTenantVO.java  |  55 --
 .../src/com/cloud/network/dao/SspUuidDao.java   |  36 --
 .../com/cloud/network/dao/SspUuidDaoImpl.java   | 116 ----
 .../src/com/cloud/network/dao/SspUuidVO.java    |  73 ---
 .../com/cloud/network/element/SspClient.java    | 272 --------
 .../com/cloud/network/element/SspElement.java   | 617 ------------------
 .../com/cloud/network/element/SspManager.java   |  71 ---
 .../com/cloud/network/element/SspService.java   |  46 --
 .../cloud/network/guru/SspGuestNetworkGuru.java | 171 -----
 .../cloudstack/api/commands/AddSspCmd.java      | 138 +++++
 .../cloudstack/api/commands/DeleteSspCmd.java   |  74 +++
 .../cloudstack/api/response/SspResponse.java    |  77 +++
 .../network/dao/SspCredentialDao.java           |  33 +
 .../network/dao/SspCredentialDaoImpl.java       |  42 ++
 .../cloudstack/network/dao/SspCredentialVO.java |  67 ++
 .../cloudstack/network/dao/SspTenantDao.java    |  34 +
 .../network/dao/SspTenantDaoImpl.java           |  48 ++
 .../cloudstack/network/dao/SspTenantVO.java     |  55 ++
 .../cloudstack/network/dao/SspUuidDao.java      |  36 ++
 .../cloudstack/network/dao/SspUuidDaoImpl.java  | 116 ++++
 .../cloudstack/network/dao/SspUuidVO.java       |  73 +++
 .../cloudstack/network/element/SspClient.java   | 272 ++++++++
 .../cloudstack/network/element/SspElement.java  | 619 +++++++++++++++++++
 .../cloudstack/network/element/SspManager.java  |  71 +++
 .../cloudstack/network/element/SspService.java  |  47 ++
 .../network/guru/SspGuestNetworkGuru.java       | 173 ++++++
 .../cloud/network/element/SspClientTest.java    |  92 ---
 .../cloud/network/element/SspElementTest.java   | 152 -----
 .../network/element/SspClientTest.java          |  93 +++
 .../network/element/SspElementTest.java         | 153 +++++
 39 files changed, 2226 insertions(+), 2219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index c720155..d2c2dee 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -73,13 +73,13 @@
   <!--
     Stratosphere SSP support components
   -->
-  <bean id="sspCredentialDaoImpl" class="com.cloud.network.dao.SspCredentialDaoImpl"/>
-  <bean id="sspTenantDaoImpl" class="com.cloud.network.dao.SspTenantDaoImpl"/>
-  <bean id="sspUuidDaoImpl" class="com.cloud.network.dao.SspUuidDaoImpl"/>
-  <bean id="SspGuestNetworkGuru" class="com.cloud.network.guru.SspGuestNetworkGuru">
+  <bean id="sspCredentialDaoImpl" class="org.apache.cloudstack.network.dao.SspCredentialDaoImpl"/>
+  <bean id="sspTenantDaoImpl" class="org.apache.cloudstack.network.dao.SspTenantDaoImpl"/>
+  <bean id="sspUuidDaoImpl" class="org.apache.cloudstack.network.dao.SspUuidDaoImpl"/>
+  <bean id="SspGuestNetworkGuru" class="org.apache.cloudstack.network.guru.SspGuestNetworkGuru">
     <property name="name" value="SspGuestNetworkGuru"/>
   </bean>
-  <bean id="StratosphereSsp" class="com.cloud.network.element.SspElement">
+  <bean id="StratosphereSsp" class="org.apache.cloudstack.network.element.SspElement">
     <property name="name" value="StratosphereSsp"/>
   </bean>
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/AddSspCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/AddSspCmd.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/AddSspCmd.java
deleted file mode 100644
index 3034f9b..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/AddSspCmd.java
+++ /dev/null
@@ -1,138 +0,0 @@
-// 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.BaseCmd;
-import org.apache.cloudstack.api.response.ZoneResponse;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.log4j.Logger;
-
-import com.cloud.api.response.SspResponse;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.network.element.SspService;
-import com.cloud.user.UserContext;
-
-
-@APICommand(name="addStratosphereSsp", responseObject=SspResponse.class, description="Adds stratosphere ssp server")
-public class AddSspCmd extends BaseCmd {
-    private static final Logger s_logger = Logger.getLogger(AddSspCmd.class.getName());
-    @Inject
-    SspService _service;
-    @Inject
-    DataCenterDao _dcDao;
-
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
-            required=true, description="the zone ID")
-    private Long zoneId;
-
-    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="stratosphere ssp server url")
-    private String url;
-
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=false, description="stratosphere ssp api username")
-    private String username;
-
-    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="stratosphere ssp api password")
-    private String password;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="stratosphere ssp api name")
-    private String name; // required because HostVO name field defined as NOT NULL.
-
-    @Parameter(name="tenantuuid", type=CommandType.STRING, required=false, description="stratosphere ssp tenant uuid")
-    private String tenantUuid; // required in creating ssp tenant_network
-
-    @Override
-    public String getCommandName() {
-        return getClass().getAnnotation(APICommand.class).name();
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
-    }
-
-    @Override
-    public void execute() throws ResourceUnavailableException,
-    InsufficientCapacityException, ConcurrentOperationException,
-    ResourceAllocationException, NetworkRuleConflictException {
-        s_logger.trace("execute");
-        Host host = _service.addSspHost(this);
-        SspResponse response = new SspResponse();
-        response.setResponseName(getCommandName());
-        response.setObjectName("ssphost");
-        response.setUrl(this.getUrl());
-        response.setZoneId(_dcDao.findById(getZoneId()).getUuid());
-        response.setHostId(host.getUuid());
-        this.setResponseObject(response);
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public void setZoneId(Long zoneId) {
-        this.zoneId = zoneId;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getTenantUuid() {
-        return tenantUuid;
-    }
-
-    public void setTenantUuid(String tenantUuid) {
-        this.tenantUuid = tenantUuid;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/DeleteSspCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/DeleteSspCmd.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/DeleteSspCmd.java
deleted file mode 100644
index 1f3bba6..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/commands/DeleteSspCmd.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.response.SuccessResponse;
-import org.apache.cloudstack.api.response.HostResponse;
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.element.SspService;
-import com.cloud.user.UserContext;
-
-@APICommand(name="deleteStratosphereSsp", responseObject=SuccessResponse.class, description="Removes stratosphere ssp server")
-public class DeleteSspCmd extends BaseCmd {
-    private static final Logger s_logger = Logger.getLogger(AddSspCmd.class.getName());
-    @Inject
-    SspService _service;
-
-    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
-            required=true, description="the host ID of ssp server")
-    private Long hostId;
-
-    @Override
-    public String getCommandName() {
-        return getClass().getAnnotation(APICommand.class).name();
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
-    }
-
-    @Override
-    public void execute() throws ResourceUnavailableException,
-    InsufficientCapacityException, ConcurrentOperationException,
-    ResourceAllocationException, NetworkRuleConflictException {
-        s_logger.trace("execute");
-        SuccessResponse resp = new SuccessResponse();
-        resp.setSuccess(_service.deleteSspHost(this));
-        this.setResponseObject(resp);
-    }
-
-    public Long getHostId() {
-        return hostId;
-    }
-
-    public void setHostId(Long hostId) {
-        this.hostId = hostId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/response/SspResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/response/SspResponse.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/response/SspResponse.java
deleted file mode 100644
index ac9dee7..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/api/response/SspResponse.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.response;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseResponse;
-import org.apache.cloudstack.api.EntityReference;
-
-import com.cloud.host.HostVO;
-import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
-
-@EntityReference(value=HostVO.class)
-public class SspResponse extends BaseResponse {
-    @SerializedName(ApiConstants.HOST_ID)
-    @Param(description="server id of the stratosphere ssp server")
-    private String hostId;
-
-    @SerializedName(ApiConstants.ZONE_ID)
-    @Param(description="zone which this ssp controls")
-    private String zoneId;
-
-    @SerializedName(ApiConstants.URL)
-    @Param(description="url of ssp endpoint")
-    private String url;
-
-    @SerializedName(ApiConstants.NAME)
-    @Param(description="name")
-    private String name;
-
-
-    public String getHostId() {
-        return hostId;
-    }
-
-    public void setHostId(String hostId) {
-        this.hostId = hostId;
-    }
-
-    public String getZoneId() {
-        return zoneId;
-    }
-
-    public void setZoneId(String zoneId) {
-        this.zoneId = zoneId;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDao.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDao.java
deleted file mode 100644
index 213b817..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDao.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface SspCredentialDao extends GenericDao<SspCredentialVO, Long> {
-    /**
-     * Find an ssp credential for a specific cloudstack zone.
-     *
-     * For now, credential is a pair of username and password.
-     * We might want to fetch different pairs for each cloudstack users
-     * in future work.
-     *
-     * @param zoneId zone Id
-     * @return credential object
-     */
-    public SspCredentialVO findByZone(long zoneId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDaoImpl.java
deleted file mode 100644
index 0206dee..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialDaoImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import javax.ejb.Local;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Local(SspCredentialDao.class)
-public class SspCredentialDaoImpl extends GenericDaoBase<SspCredentialVO, Long> implements SspCredentialDao {
-    private final SearchBuilder<SspCredentialVO> PnetSearch;
-
-    public SspCredentialDaoImpl() {
-        PnetSearch = createSearchBuilder();
-        PnetSearch.and("dataCenterId", PnetSearch.entity().getZoneId(), Op.EQ);
-        PnetSearch.done();
-    }
-
-    @Override
-    public SspCredentialVO findByZone(long zoneId) {
-        SearchCriteria<SspCredentialVO> sc = PnetSearch.create();
-        sc.setParameters("dataCenterId", zoneId);
-        return findOneBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialVO.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialVO.java
deleted file mode 100644
index 9511e84..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspCredentialVO.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="external_stratosphere_ssp_credentials")
-public class SspCredentialVO {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name="id")
-    private long id;
-
-    @Column(name="data_center_id")
-    private long dataCenterId; // Actually, this is zoneId
-
-    // XXX: We might want to restrict access to this by cloudstack privileges.
-    @Column(name="username")
-    private String username;
-
-    @Column(name="password")
-    private String password;
-
-    public long getZoneId() {
-        return dataCenterId;
-    }
-
-    public void setZoneId(long zoneId) {
-        this.dataCenterId = zoneId;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDao.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDao.java
deleted file mode 100644
index 2a3bfdc..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface SspTenantDao extends GenericDao<SspTenantVO, Long> {
-    /**
-     * Find an ssp tenant uuid for a specific cloudstack zone.
-     *
-     * The ssp tenant uuid will be used in ssp tenant_network creation.
-     * For now, we map ssp tenant to cloudstack zone. Instead, we might
-     * want to map ssp tenant to cloudstack domain, or ssp tenant to
-     * cloudstack project in future.
-     *
-     * @param zoneId zone id
-     * @return tenant uuid string
-     */
-    public String findUuidByZone(long zoneId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDaoImpl.java
deleted file mode 100644
index 7018ce5..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantDaoImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import javax.ejb.Local;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Local(SspTenantDao.class)
-public class SspTenantDaoImpl extends GenericDaoBase<SspTenantVO, Long>
-        implements SspTenantDao {
-
-    private final SearchBuilder<SspTenantVO> zoneSearch;
-
-    public SspTenantDaoImpl(){
-        zoneSearch = createSearchBuilder();
-        zoneSearch.and("zoneId", zoneSearch.entity().getZoneId(), Op.EQ);
-        zoneSearch.done();
-    }
-
-    @Override
-    public String findUuidByZone(long zoneId) {
-        SearchCriteria<SspTenantVO> sc = zoneSearch.create();
-        sc.setParameters("zoneId", zoneId);
-        SspTenantVO ret = findOneBy(sc);
-        if(ret != null){
-            return ret.getUuid();
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantVO.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantVO.java
deleted file mode 100644
index 026d338..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspTenantVO.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="external_stratosphere_ssp_tenants")
-public class SspTenantVO {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name="id")
-    private long id;
-
-    @Column(name="zone_id")
-    private long zoneId;
-
-    @Column(name="uuid")
-    private String uuid;
-
-    public long getZoneId() {
-        return zoneId;
-    }
-
-    public void setZoneId(long zoneId) {
-        this.zoneId = zoneId;
-    }
-
-    public String getUuid() {
-        return uuid;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDao.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDao.java
deleted file mode 100644
index 325ba66..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDao.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import java.util.List;
-
-import com.cloud.network.Network;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.NicProfile;
-
-/**
- * Mapping for SSP UUID and cloudstack entities
- */
-public interface SspUuidDao extends GenericDao<SspUuidVO, Long> {
-    public String findUuidByNetwork(Network network);
-    public String findUuidByNicProfile(NicProfile nicProfile);
-    public Long findNetworkIdByUuid(String uuid);
-    public Long findNicProfileIdByUuid(String uuid);
-    public int removeUuid(String uuid);
-
-    public List<SspUuidVO> listUUidVoByNicProfile(NicProfile nicProfile);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDaoImpl.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDaoImpl.java
deleted file mode 100644
index 85c8491..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidDaoImpl.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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.apache.log4j.Logger;
-
-import com.cloud.network.Network;
-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;
-import com.cloud.vm.NicProfile;
-
-@Local(SspUuidDao.class)
-public class SspUuidDaoImpl extends GenericDaoBase<SspUuidVO, Long> implements SspUuidDao {
-
-    private static final Logger s_logger = Logger.getLogger(SspUuidDaoImpl.class);
-
-    protected final SearchBuilder<SspUuidVO> native2uuid;
-    protected final SearchBuilder<SspUuidVO> uuid2native;
-    protected final SearchBuilder<SspUuidVO> uuidfetch;
-
-    public SspUuidDaoImpl() {
-        native2uuid = createSearchBuilder();
-        native2uuid.and("obj_class", native2uuid.entity().getObjClass(), Op.EQ);
-        native2uuid.and("obj_id", native2uuid.entity().getObjId(), Op.EQ);
-        native2uuid.done();
-
-        uuid2native = createSearchBuilder();
-        uuid2native.and("obj_class", uuid2native.entity().getObjClass(), Op.EQ);
-        uuid2native.and("uuid", uuid2native.entity().getUuid(), Op.EQ);
-        uuid2native.done();
-
-        uuidfetch = createSearchBuilder();
-        uuidfetch.and("uuid", uuidfetch.entity().getUuid(), Op.EQ);
-        uuidfetch.done();
-    }
-
-    @Override
-    public String findUuidByNetwork(Network network) {
-        SearchCriteria<SspUuidVO> cs = native2uuid.create();
-        cs.setParameters("obj_class", SspUuidVO.objClassNetwork);
-        cs.setParameters("obj_id", network.getId());
-        SspUuidVO vo = findOneBy(cs);
-        if(vo != null){
-            return vo.getUuid();
-        }
-        return null;
-    }
-
-    @Override
-    public String findUuidByNicProfile(NicProfile nicProfile) {
-        SearchCriteria<SspUuidVO> cs = native2uuid.create();
-        cs.setParameters("obj_class", SspUuidVO.objClassNicProfile);
-        cs.setParameters("obj_id", nicProfile.getId());
-        SspUuidVO vo = findOneBy(cs);
-        if(vo != null){
-            return vo.getUuid();
-        }
-        return null;
-    }
-
-    @Override
-    public List<SspUuidVO> listUUidVoByNicProfile(NicProfile nicProfile) {
-        SearchCriteria<SspUuidVO> cs = native2uuid.create();
-        cs.setParameters("obj_class", SspUuidVO.objClassNicProfile);
-        cs.setParameters("obj_id", nicProfile.getId());
-        return listBy(cs);
-    }
-
-    @Override
-    public Long findNetworkIdByUuid(String uuid) {
-        return findByUuid(SspUuidVO.objClassNetwork, uuid);
-    }
-
-    @Override
-    public Long findNicProfileIdByUuid(String uuid) {
-        return findByUuid(SspUuidVO.objClassNicProfile, uuid);
-    }
-
-    private Long findByUuid(String clazz, String uuid){
-        SearchCriteria<SspUuidVO> cs = uuid2native.create();
-        cs.setParameters("obj_class", clazz);
-        cs.setParameters("uuid", uuid);
-        SspUuidVO vo = findOneBy(cs);
-        if(vo != null){
-            return vo.getObjId();
-        }
-        return null;
-    }
-
-
-    public int removeUuid(String uuid){
-        SearchCriteria<SspUuidVO> cs = uuidfetch.create();
-        cs.setParameters("uuid", uuid);
-        return this.remove(cs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidVO.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidVO.java
deleted file mode 100644
index 83c9fea..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/dao/SspUuidVO.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.dao;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="external_stratosphere_ssp_uuids")
-public class SspUuidVO {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name="id")
-    private long id;
-
-    @Column(name="uuid")
-    private String uuid;
-
-    @Column(name="obj_class")
-    private String objClass;
-
-    @Column(name="obj_id")
-    private long objId;
-
-    static public final String objClassNetwork = "net";
-    static public final String objClassNicProfile = "nic";
-
-    @Column(name="reservation_id")
-    private String reservationId;
-
-    public String getUuid() {
-        return uuid;
-    }
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-    public String getObjClass() {
-        return objClass;
-    }
-    public void setObjClass(String objClass) {
-        this.objClass = objClass;
-    }
-    public long getObjId() {
-        return objId;
-    }
-    public void setObjId(long objId) {
-        this.objId = objId;
-    }
-    public String getReservationId() {
-        return reservationId;
-    }
-    public void setReservationId(String reservationId) {
-        this.reservationId = reservationId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspClient.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspClient.java
deleted file mode 100644
index 5c9c003..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspClient.java
+++ /dev/null
@@ -1,272 +0,0 @@
-// 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.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.log4j.Logger;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Stratosphere sdn platform api client
- */
-public class SspClient {
-    private static final Logger s_logger = Logger.getLogger(SspClient.class);
-    private static final HttpConnectionManager s_httpclient_manager = new MultiThreadedHttpConnectionManager();
-    private static final HttpClientParams s_httpclient_params = new HttpClientParams();
-    static {
-        s_httpclient_params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-    }
-
-    private final String apiUrl;
-    private final String username;
-    private final String password;
-
-    protected HttpClient client;
-    protected PostMethod postMethod;
-    protected DeleteMethod deleteMethod;
-    protected PutMethod putMethod;
-
-    public SspClient(String apiUrl, String username, String password) {
-        super();
-        this.apiUrl = apiUrl;
-        this.username = username;
-        this.password = password;
-        client = new HttpClient(s_httpclient_params, s_httpclient_manager);
-        postMethod = new PostMethod(apiUrl);
-        deleteMethod = new DeleteMethod(apiUrl);
-        putMethod = new PutMethod(apiUrl);
-    }
-
-    public boolean login(){
-        PostMethod method = postMethod;
-        method.setPath("/ws.v1/login"); // NOTE: /ws.v1/login is correct
-        method.addParameter("username", username);
-        method.addParameter("password", password);
-
-        try {
-            client.executeMethod(method);
-        } catch (HttpException e) {
-            s_logger.info("Login "+username+" to "+apiUrl+" failed", e);
-            return false;
-        } catch (IOException e) {
-            s_logger.info("Login "+username+" to "+apiUrl+" failed", e);
-            return false;
-        } finally {
-            method.releaseConnection();
-        }
-        String apiCallPath = null;
-        try {
-            apiCallPath = method.getName() + " " + method.getURI().toString();
-        } catch (URIException e) {
-            s_logger.error("method getURI failed", e);
-        }
-        s_logger.info("ssp api call:" + apiCallPath + " user="+username+" status="+method.getStatusLine());
-        if(method.getStatusCode() == HttpStatus.SC_OK){
-            return true;
-        }
-        return false;
-    }
-
-    private String executeMethod(HttpMethod method){
-        String apiCallPath = null;
-        try {
-            apiCallPath = method.getName() + " " + method.getURI().toString();
-        } catch (URIException e) {
-            s_logger.error("method getURI failed", e);
-        }
-
-        String response = null;
-        try {
-            client.executeMethod(method);
-            response = method.getResponseBodyAsString();
-        } catch (HttpException e) {
-            s_logger.error("ssp api call failed "+apiCallPath, e);
-            return null;
-        } catch (IOException e) {
-            s_logger.error("ssp api call failed "+apiCallPath, e);
-            return null;
-        } finally {
-            method.releaseConnection();
-        }
-
-        if(method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED){
-            if(!login()){
-                return null;
-            }
-
-            try {
-                client.executeMethod(method);
-                response = method.getResponseBodyAsString();
-            } catch (HttpException e) {
-                s_logger.error("ssp api call failed "+apiCallPath, e);
-                return null;
-            } catch (IOException e) {
-                s_logger.error("ssp api call failed "+apiCallPath, e);
-                return null;
-            } finally {
-                method.releaseConnection();
-            }
-        }
-        s_logger.info("ssp api call:" + apiCallPath + " user="+username+" status="+method.getStatusLine());
-        if(method instanceof EntityEnclosingMethod){
-            EntityEnclosingMethod emethod = (EntityEnclosingMethod)method;
-            RequestEntity reqEntity = emethod.getRequestEntity();
-            if(reqEntity instanceof StringRequestEntity){
-                StringRequestEntity strReqEntity = (StringRequestEntity)reqEntity;
-                s_logger.debug("ssp api request body:"+strReqEntity.getContent());
-            }else{
-                s_logger.debug("ssp api request body:"+emethod.getRequestEntity());
-            }
-        }
-        s_logger.debug("ssp api response body:" + response);
-        return response;
-    }
-
-    public class TenantNetwork {
-        public String uuid;
-        public String name;
-        @SerializedName("tenant_uuid")
-        public String tenantUuid;
-    }
-
-    public TenantNetwork createTenantNetwork(String tenantUuid, String networkName){
-        TenantNetwork req = new TenantNetwork();
-        req.name = networkName;
-        req.tenantUuid = tenantUuid;
-
-        PostMethod method = postMethod;
-        method.setPath("/ssp.v1/tenant-networks");
-        StringRequestEntity entity = null;
-        try {
-            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            s_logger.error("failed creating http request body", e);
-            return null;
-        }
-        method.setRequestEntity(entity);
-
-        String response = executeMethod(method);
-        if(response != null && method.getStatusCode() == HttpStatus.SC_CREATED){
-            return new Gson().fromJson(response, TenantNetwork.class);
-        }
-        return null;
-    }
-
-    public boolean deleteTenantNetwork(String tenantNetworkUuid){
-        DeleteMethod method = deleteMethod;
-        method.setPath("/ssp.v1/tenant-networks/"+tenantNetworkUuid);
-
-        executeMethod(method);
-        if(method.getStatusCode() == HttpStatus.SC_NO_CONTENT){
-            return true;
-        }
-        return false;
-    }
-
-    public class TenantPort {
-        public String uuid;
-        public String name;
-        @SerializedName("network_uuid")
-        public String networkUuid;
-        @SerializedName("attachment_type")
-        public String attachmentType;
-        @SerializedName("attachment_ip_address")
-        public String hypervisorIpAddress;
-        @SerializedName("vlan_id")
-        public Integer vlanId;
-    }
-
-    public TenantPort createTenantPort(String tenantNetworkUuid){
-        TenantPort req = new TenantPort();
-        req.networkUuid = tenantNetworkUuid;
-        req.attachmentType = "NoAttachment";
-
-        PostMethod method = postMethod;
-        method.setPath("/ssp.v1/tenant-ports");
-        StringRequestEntity entity = null;
-        try {
-            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            s_logger.error("failed creating http request body", e);
-            return null;
-        }
-        method.setRequestEntity(entity);
-
-        String response = executeMethod(method);
-        if(response != null && method.getStatusCode() == HttpStatus.SC_CREATED){
-            return new Gson().fromJson(response, TenantPort.class);
-        }
-        return null;
-    }
-
-    public boolean deleteTenantPort(String tenantPortUuid){
-        DeleteMethod method = deleteMethod;
-        method.setPath("/ssp.v1/tenant-ports/"+tenantPortUuid);
-
-        executeMethod(method);
-        if(method.getStatusCode() == HttpStatus.SC_NO_CONTENT){
-            return true;
-        }
-        return false;
-    }
-
-    public TenantPort updateTenantVifBinding(String portUuid, String hypervisorIpAddress){
-        TenantPort req = new TenantPort();
-        if(hypervisorIpAddress != null){
-            req.attachmentType = "VifAttachment";
-            req.hypervisorIpAddress = hypervisorIpAddress;
-        }else{
-            req.attachmentType = "NoAttachment";
-        }
-
-        PutMethod method = putMethod;
-        method.setPath("/ssp.v1/tenant-ports/"+portUuid);
-        StringRequestEntity entity = null;
-        try {
-            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            s_logger.error("failed creating http request body", e);
-            return null;
-        }
-        method.setRequestEntity(entity);
-
-        String response = executeMethod(method);
-        if(response != null && method.getStatusCode() == HttpStatus.SC_OK){
-            return new Gson().fromJson(response, TenantPort.class);
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspElement.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspElement.java
deleted file mode 100644
index 016ae14..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspElement.java
+++ /dev/null
@@ -1,617 +0,0 @@
-// 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.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-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.log4j.Logger;
-
-import com.cloud.api.commands.AddSspCmd;
-import com.cloud.api.commands.DeleteSspCmd;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.dao.DataCenterDao;
-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.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-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.NetworkManager;
-import com.cloud.network.NetworkMigrationResponder;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.PhysicalNetworkServiceProvider.State;
-import com.cloud.network.dao.NetworkServiceMapDao;
-import com.cloud.network.dao.PhysicalNetworkDao;
-import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
-import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
-import com.cloud.network.dao.SspCredentialDao;
-import com.cloud.network.dao.SspCredentialVO;
-import com.cloud.network.dao.SspTenantDao;
-import com.cloud.network.dao.SspTenantVO;
-import com.cloud.network.dao.SspUuidDao;
-import com.cloud.network.dao.SspUuidVO;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicVO;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.NicDao;
-import com.cloud.resource.ResourceManager;
-
-/**
- * Stratosphere sdn platform network element
- *
- * This class will be called per network setup operations.
- * This class also have ssp specific methods.
- *
- * Current implementation use HostVO for storage of api endpoint information,
- * but note this is not necessary. The other way is create our own database
- * table for that information.
- */
-@Local(value={NetworkElement.class, SspManager.class})
-public class SspElement extends AdapterBase implements ConnectivityProvider, SspManager, SspService, NetworkMigrationResponder {
-    private static final Logger s_logger = Logger.getLogger(SspElement.class);
-    public static final String s_SSP_NAME = "StratosphereSsp";
-
-    @Inject
-    NetworkServiceMapDao _ntwkSrvcDao;
-    @Inject
-    NetworkModel _networkModel;
-    @Inject
-    NetworkManager _networkMgr;
-    @Inject
-    ResourceManager _resourceMgr;
-    @Inject
-    PhysicalNetworkDao _physicalNetworkDao;
-    @Inject
-    PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
-    @Inject
-    SspCredentialDao _sspCredentialDao;
-    @Inject
-    SspTenantDao _sspTenantDao;
-    @Inject
-    SspUuidDao _sspUuidDao;
-    @Inject
-    DataCenterDao _dcDao;
-    @Inject
-    HostDao _hostDao;
-    @Inject
-    ConfigurationDao _configDao;
-    @Inject
-    NicDao _nicDao = null;
-
-    @Override
-    public boolean configure(String name, Map<String, Object> params)
-            throws ConfigurationException {
-        return super.configure(name, params);
-    }
-
-    @Override
-    public Map<Service, Map<Capability, String>> getCapabilities() {
-        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
-        capabilities.put(Service.Connectivity, new HashMap<Capability,String>()); // XXX: We might need some more category here.
-        return capabilities;
-    }
-
-    @Override
-    public Provider getProvider() {
-        Provider provider = null;
-        synchronized(s_SSP_NAME){
-            provider = Provider.getProvider(s_SSP_NAME);
-            if(provider==null){
-                provider = new Provider(s_SSP_NAME, true);
-                s_logger.debug("registering Network.Provider "+s_SSP_NAME);
-            }
-        }
-        return provider;
-    }
-
-    private List<SspClient> fetchSspClients(Long physicalNetworkId, Long dataCenterId, boolean enabled_only){
-        ArrayList<SspClient> clients = new ArrayList<SspClient>();
-
-        boolean provider_found = false;
-        PhysicalNetworkServiceProviderVO provider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetworkId, s_SSP_NAME);
-        if(enabled_only){
-            if(provider != null && provider.getState() == State.Enabled){
-                provider_found = true;
-            }
-        }else{
-            provider_found = true;
-        }
-
-        if(physicalNetworkId != null && provider_found){
-            SspCredentialVO credential = _sspCredentialDao.findByZone(dataCenterId);
-            List<HostVO> hosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, dataCenterId);
-            for(HostVO host : hosts){
-                assert(credential != null);
-                _hostDao.loadDetails(host);
-                if("v1Api".equals(host.getDetail("sspHost"))){
-                    clients.add(new SspClient(host.getDetail("url"), credential.getUsername(), credential.getPassword()));
-                }
-            }
-        }
-        if(clients.size()==0){
-            String global_apiUrl = _configDao.getValueAndInitIfNotExist("ssp.url", "Network", null);
-            String global_username = _configDao.getValueAndInitIfNotExist("ssp.username", "Network", null);
-            String global_password = _configDao.getValueAndInitIfNotExist("ssp.password", "Network", null);
-            if(global_apiUrl != null && global_username != null && global_password != null){
-                clients.add(new SspClient(global_apiUrl, global_username, global_password));
-            }
-        }
-        return clients;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.network.element.NetworkElement#isReady(com.cloud.network.PhysicalNetworkServiceProvider)
-     */
-    @Override
-    public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(provider.getPhysicalNetworkId());
-        assert(physicalNetwork!=null);
-        if(physicalNetwork != null){
-            if(fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), false).size() > 0){
-                return true;
-            }
-            s_logger.warn("Ssp api endpoint not found. "+physicalNetwork.toString());
-        }else{
-            s_logger.warn("PhysicalNetwork is NULL.");
-        }
-        return false;
-    }
-
-    /* (non-Javadoc)
-     * If this element is ready, then it can be enabled.
-     * @see com.cloud.network.element.SspManager#isEnabled(com.cloud.network.PhysicalNetwork)
-     */
-    @Override
-    public boolean canHandle(PhysicalNetwork physicalNetwork){
-        if(physicalNetwork != null){
-            if(fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), true).size() > 0){
-                return true;
-            }
-            s_logger.warn("enabled Ssp api endpoint not found. "+physicalNetwork.toString());
-        }else{
-            s_logger.warn("PhysicalNetwork is NULL.");
-        }
-        return false;
-    }
-
-    private boolean canHandle(Network network){
-        if(canHandle(_physicalNetworkDao.findById(network.getPhysicalNetworkId()))){
-            if(!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.Connectivity, getProvider())){
-                s_logger.info("SSP is implicitly active for "+network);
-            }
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public Host addSspHost(AddSspCmd cmd) {
-        SspClient client = new SspClient(cmd.getUrl(), cmd.getUsername(), cmd.getPassword());
-        if(!client.login()){
-            throw new CloudRuntimeException("Ssp login failed.");
-        }
-
-        long zoneId = cmd.getZoneId();
-        SspCredentialVO credential = _sspCredentialDao.findByZone(zoneId);
-        if(credential==null){
-            if(cmd.getUsername()==null || cmd.getPassword()==null){
-                throw new InvalidParameterValueException("Initial credential required for zone: " + zoneId);
-            }
-            credential = new SspCredentialVO();
-            credential.setZoneId(zoneId);
-            credential.setUsername(cmd.getUsername());
-            credential.setPassword(cmd.getPassword());
-            _sspCredentialDao.persist(credential);
-        }else{
-            if(cmd.getUsername()!=null || cmd.getPassword()!=null){
-                s_logger.warn("Tenant credential already configured for zone:"+zoneId);
-            }
-        }
-
-        String tenantUuid = _sspTenantDao.findUuidByZone(zoneId);
-        if(tenantUuid==null){
-            if(cmd.getTenantUuid()==null){
-                throw new InvalidParameterValueException("Initial tenant uuid required for zone: " + zoneId);
-            }
-            SspTenantVO tenant = new SspTenantVO();
-            tenant.setZoneId(zoneId);
-            tenant.setUuid(cmd.getTenantUuid());
-            _sspTenantDao.persist(tenant);
-        }else{
-            if(cmd.getTenantUuid()!=null){
-                s_logger.warn("Tenant uuid already configured for zone:"+zoneId);
-            }
-        }
-
-        String normalizedUrl = null;
-        String hostname = null;
-        try {
-            URL url = new URL(cmd.getUrl());
-            normalizedUrl = url.toString();
-            hostname = url.getHost();
-        } catch (MalformedURLException e1) {
-            throw new CloudRuntimeException("Invalid url "+cmd.getUrl());
-        }
-
-        List<HostVO> hosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, zoneId);
-        for(HostVO host : hosts){
-            assert(credential != null);
-            _hostDao.loadDetails(host);
-            if("v1Api".equals(host.getDetail("sspHost"))){
-                if(normalizedUrl.equals(host.getDetail("url"))){
-                    s_logger.warn("Ssp host already registered "+normalizedUrl);
-                    return host;
-                }
-            }
-        }
-        // SspHost HostVO will be created per zone and url.
-        HostVO host = new HostVO(UUID.randomUUID().toString());
-        host.setDataCenterId(zoneId);
-        host.setType(Host.Type.L2Networking);
-        host.setPrivateIpAddress(hostname); // db schema not null. It may be a name, not IP address.
-        //        host.setPrivateMacAddress(""); // db schema nullable
-        //        host.setPrivateNetmask(""); // db schema nullable
-        host.setVersion("1"); // strange db schema not null
-        host.setName(cmd.getName());
-
-        host.setDetails(new HashMap<String, String>());
-        host.setDetail("sspHost", "v1Api");
-        host.setDetail("url", normalizedUrl);
-        return _hostDao.persist(host);
-    }
-
-    @Override
-    public boolean deleteSspHost(DeleteSspCmd cmd) {
-        s_logger.info("deleteStratosphereSsp");
-        return _hostDao.remove(cmd.getHostId());
-    }
-
-    public boolean createNetwork(Network network, NetworkOffering offering,
-            DeployDestination dest, ReservationContext context){
-        if(_sspUuidDao.findUuidByNetwork(network) != null){
-            s_logger.info("Network already has ssp TenantNetwork uuid :"+network.toString());
-            return true;
-        }
-        if(!canHandle(network)){
-            return false;
-        }
-
-        String tenantUuid = _sspTenantDao.findUuidByZone(network.getDataCenterId());
-        if(tenantUuid==null){
-            tenantUuid = _configDao.getValueAndInitIfNotExist("ssp.tenant", "Network", null);
-        }
-
-        boolean processed = false;
-        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-            SspClient.TenantNetwork sspNet = client.createTenantNetwork(tenantUuid, network.getName());
-            if(sspNet != null){
-                SspUuidVO uuid = new SspUuidVO();
-                uuid.setUuid(sspNet.uuid);
-                uuid.setObjClass(SspUuidVO.objClassNetwork);
-                uuid.setObjId(network.getId());
-                _sspUuidDao.persist(uuid);
-                return true;
-            }
-            processed = true;
-        }
-        if(processed){
-            s_logger.error("Could not allocate an uuid for network "+network.toString());
-            return false;
-        }else{
-            s_logger.error("Skipping #createNetwork() for "+network.toString());
-            return true;
-        }
-    }
-
-    public boolean deleteNetwork(Network network){
-        String tenantNetworkUuid = _sspUuidDao.findUuidByNetwork(network);
-        if(tenantNetworkUuid != null){
-            boolean processed = false;
-            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-                if(client.deleteTenantNetwork(tenantNetworkUuid)){
-                    _sspUuidDao.removeUuid(tenantNetworkUuid);
-                    processed = true;
-                    break;
-                }
-            }
-            if(!processed){
-                s_logger.error("Ssp api tenant network deletion failed "+network.toString());
-            }
-        }else{
-            s_logger.debug("Silently skipping #deleteNetwork() for "+network.toString());
-        }
-        return true;
-    }
-
-    // we use context.reservationId for dedup of guru & element operations.
-    public boolean createNicEnv(Network network, NicProfile nic, DeployDestination dest, ReservationContext context){
-        String tenantNetworkUuid = _sspUuidDao.findUuidByNetwork(network);
-        if(tenantNetworkUuid == null){
-            s_logger.debug("Skipping #createNicEnv() for nic on "+network.toString());
-            return true;
-        }
-
-        String reservationId = context.getReservationId();
-        List<SspUuidVO> tenantPortUuidVos = _sspUuidDao.listUUidVoByNicProfile(nic);
-        for(SspUuidVO tenantPortUuidVo : tenantPortUuidVos){
-            if(reservationId.equals(tenantPortUuidVo.getReservationId())){
-                s_logger.info("Skipping because reservation found "+reservationId);
-                return true;
-            }
-        }
-
-        String tenantPortUuid = null;
-        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-            SspClient.TenantPort sspPort = client.createTenantPort(tenantNetworkUuid);
-            if(sspPort != null){
-                tenantPortUuid = sspPort.uuid;
-                nic.setReservationId(reservationId);
-
-                SspUuidVO uuid = new SspUuidVO();
-                uuid.setUuid(tenantPortUuid);
-                uuid.setObjClass(SspUuidVO.objClassNicProfile);
-                uuid.setObjId(nic.getId());
-                uuid.setReservationId(reservationId);
-                _sspUuidDao.persist(uuid);
-                break;
-            }
-        }
-        if(tenantPortUuid == null){
-            s_logger.debug("#createNicEnv() failed for nic on "+network.toString());
-            return false;
-        }
-
-        for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-            SspClient.TenantPort sspPort = client.updateTenantVifBinding(tenantPortUuid, dest.getHost().getPrivateIpAddress());
-            if(sspPort != null){
-                if(sspPort.vlanId != null){
-                    nic.setBroadcastType(BroadcastDomainType.Vlan);
-                    nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(String.valueOf(sspPort.vlanId)));
-                }
-                return true;
-            }
-        }
-        s_logger.error("Updating vif failed "+nic.toString());
-        return false;
-    }
-
-    public boolean deleteNicEnv(Network network, NicProfile nic, ReservationContext context){
-        if(context==null){
-            s_logger.error("ReservationContext was null for "+nic+" "+network);
-            return false;
-        }
-        String reservationId = context.getReservationId();
-
-        SspUuidVO deleteTarget = null;
-        SspUuidVO remainingTarget = null;
-        List<SspUuidVO> tenantPortUuidVos = _sspUuidDao.listUUidVoByNicProfile(nic);
-        for(SspUuidVO tenantPortUuidVo : tenantPortUuidVos){
-            if(reservationId.equals(tenantPortUuidVo.getReservationId())){
-                deleteTarget = tenantPortUuidVo;
-            }else{
-                remainingTarget = tenantPortUuidVo;
-            }
-        }
-
-        if(deleteTarget != null){ // delete the target ssp uuid (tenant-port)
-            String tenantPortUuid = deleteTarget.getUuid();
-            boolean processed = false;
-            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-                SspClient.TenantPort sspPort = client.updateTenantVifBinding(tenantPortUuid, null);
-                if(sspPort != null){
-                    processed = true;
-                    break;
-                }
-            }
-            if(!processed){
-                s_logger.warn("Ssp api nic detach failed "+nic.toString());
-            }
-            processed = false;
-            for(SspClient client : fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)){
-                if(client.deleteTenantPort(tenantPortUuid)){
-                    _sspUuidDao.removeUuid(tenantPortUuid);
-                    processed = true;
-                    break;
-                }
-            }
-            if(!processed){
-                s_logger.warn("Ssp api tenant port deletion failed "+nic.toString());
-            }
-            _sspUuidDao.removeUuid(tenantPortUuid);
-        }
-        if(remainingTarget != null){
-            NicVO nicVo = _nicDao.findById(nic.getId());
-            nicVo.setReservationId(remainingTarget.getReservationId());
-            _nicDao.persist(nicVo); // persist the new reservationId
-        }
-        return true;
-    }
-
-    /* (non-Javadoc)
-     * Implements a network using ssp element.
-     *
-     * This method will be called right after NetworkGuru#implement().
-     * see also {@link #shutdown(Network, ReservationContext, boolean)}
-     * @see com.cloud.network.element.NetworkElement#implement(com.cloud.network.Network, com.cloud.offering.NetworkOffering, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
-     */
-    @Override
-    public boolean implement(Network network, NetworkOffering offering,
-            DeployDestination dest, ReservationContext context)
-                    throws ConcurrentOperationException, ResourceUnavailableException,
-                    InsufficientCapacityException {
-        s_logger.info("implement");
-        return createNetwork(network, offering, dest, context);
-    }
-
-    /* (non-Javadoc)
-     * Shutdown the network implementation
-     *
-     * This method will be called right BEFORE NetworkGuru#shutdown().
-     * The entities was acquired by {@link #implement(Network, NetworkOffering, DeployDestination, ReservationContext)}
-     * @see com.cloud.network.element.NetworkElement#shutdown(com.cloud.network.Network, com.cloud.vm.ReservationContext, boolean)
-     */
-    @Override
-    public boolean shutdown(Network network, ReservationContext context,
-            boolean cleanup) throws ConcurrentOperationException,
-            ResourceUnavailableException {
-        s_logger.trace("shutdown");
-        return deleteNetwork(network);
-    }
-
-    /* (non-Javadoc)
-     * Prepares a network environment for a VM nic.
-     *
-     * This method will be called right after NetworkGuru#reserve().
-     * The entities will be released by {@link #release(Network, NicProfile, VirtualMachineProfile, ReservationContext)}
-     * @see com.cloud.network.element.NetworkElement#prepare(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.deploy.DeployDestination, com.cloud.vm.ReservationContext)
-     */
-    @Override
-    public boolean prepare(Network network, NicProfile nic,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            DeployDestination dest, ReservationContext context)
-                    throws ConcurrentOperationException, ResourceUnavailableException,
-                    InsufficientCapacityException {
-        s_logger.trace("prepare");
-        return createNicEnv(network, nic, dest, context);
-    }
-
-    /* (non-Javadoc)
-     * Release the network environment that was prepared for a VM nic.
-     *
-     * This method will be called right AFTER NetworkGuru#release().
-     * The entities was acquired in {@link #prepare(Network, NicProfile, VirtualMachineProfile, DeployDestination, ReservationContext)}
-     * @see com.cloud.network.element.NetworkElement#release(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.vm.ReservationContext)
-     */
-    @Override
-    public boolean release(Network network, NicProfile nic,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            ReservationContext context) throws ConcurrentOperationException,
-            ResourceUnavailableException {
-        s_logger.trace("release");
-        return deleteNicEnv(network, nic, context);
-    }
-
-    /* (non-Javadoc)
-     * Destroy a network implementation.
-     *
-     * This method will be called right BEFORE NetworkGuru#trash() in "Expunge" phase.
-     * @see com.cloud.network.element.NetworkElement#destroy(com.cloud.network.Network)
-     */
-    @Override
-    public boolean destroy(Network network, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException {
-        s_logger.trace("destroy");
-        // nothing to do here.
-        return true;
-    }
-
-    @Override
-    public boolean shutdownProviderInstances(
-            PhysicalNetworkServiceProvider provider, ReservationContext context)
-                    throws ConcurrentOperationException, ResourceUnavailableException {
-        s_logger.trace("shutdownProviderInstances");
-        return true;
-    }
-
-    @Override
-    public boolean canEnableIndividualServices() {
-        s_logger.trace("canEnableIndividualServices");
-        return true; // because there is only Connectivity
-    }
-
-    @Override
-    public boolean verifyServicesCombination(Set<Service> services) {
-        s_logger.trace("verifyServicesCombination "+services.toString());
-        return true;
-    }
-
-    @Override
-    public boolean prepareMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            DeployDestination dest, ReservationContext context) {
-        try {
-            prepare(network, nic, vm, dest, context);
-        } catch (ConcurrentOperationException e) {
-            s_logger.error("prepareForMigration failed.", e);
-            return false;
-        } catch (ResourceUnavailableException e) {
-            s_logger.error("prepareForMigration failed.", e);
-            return false;
-        } catch (InsufficientCapacityException e) {
-            s_logger.error("prepareForMigration failed.", e);
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public void rollbackMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            ReservationContext src, ReservationContext dst) {
-        try {
-            release(network, nic, vm, dst);
-        } catch (ConcurrentOperationException e) {
-            s_logger.error("rollbackMigration failed.", e);
-        } catch (ResourceUnavailableException e) {
-            s_logger.error("rollbackMigration failed.", e);
-        }
-    }
-
-    @Override
-    public void commitMigration(NicProfile nic, Network network,
-            VirtualMachineProfile<? extends VirtualMachine> vm,
-            ReservationContext src, ReservationContext dst) {
-        try {
-            release(network, nic, vm, src);
-        } catch (ConcurrentOperationException e) {
-            s_logger.error("commitMigration failed.", e);
-        } catch (ResourceUnavailableException e) {
-            s_logger.error("commitMigration failed.", e);
-        }
-    }
-
-    @Override
-    public List<Class<?>> getCommands() {
-        return Arrays.<Class<?>>asList(AddSspCmd.class, DeleteSspCmd.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspManager.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspManager.java
deleted file mode 100644
index ab8b1b2..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspManager.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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 com.cloud.deploy.DeployDestination;
-import com.cloud.network.Network;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.component.Manager;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-
-public interface SspManager extends Manager {
-    /**
-     * Checks Ssp is activated or not
-     * @param physicalNetwork
-     * @return true if physicalNetworkProvider is configured
-     */
-    public boolean canHandle(PhysicalNetwork physicalNetwork);
-
-    /**
-     * Tell ssp to create a network
-     * @param network
-     * @param offering
-     * @param dest
-     * @param context
-     * @return
-     */
-    public boolean createNetwork(Network network, NetworkOffering offering,
-            DeployDestination dest, ReservationContext context);
-
-    /**
-     * Tell ssp to delete a network
-     * @param network
-     * @return
-     */
-    public boolean deleteNetwork(Network network);
-
-    /**
-     * Create a nic entry in ssp
-     * @param network
-     * @param nic
-     * @param dest
-     * @param context
-     * @return true on success
-     */
-    public boolean createNicEnv(Network network, NicProfile nic, DeployDestination dest, ReservationContext context);
-
-    /**
-     * Delete a nic entry from ssp
-     * @param network
-     * @param nic
-     * @param context
-     * @return
-     */
-    public boolean deleteNicEnv(Network network, NicProfile nic, ReservationContext context);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20918521/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspService.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspService.java b/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspService.java
deleted file mode 100644
index a5f62cb..0000000
--- a/plugins/network-elements/stratosphere-ssp/src/com/cloud/network/element/SspService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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 com.cloud.api.commands.AddSspCmd;
-import com.cloud.api.commands.DeleteSspCmd;
-import com.cloud.host.Host;
-import com.cloud.utils.component.PluggableService;
-
-/**
- * Stratosphere sdn platform plugin service.
- */
-public interface SspService extends PluggableService {
-    /**
-     * Add an ssp api endpoint information as an host
-     *
-     * Adds a api endpoint information in database and
-     * make it usable.
-     * @param cmd
-     * @return
-     */
-    public Host addSspHost(AddSspCmd cmd);
-
-    /**
-     * Delete an ssp api endpoint information
-     *
-     * Deletes the information from database.
-     * @param cmd
-     * @return
-     */
-    public boolean deleteSspHost(DeleteSspCmd cmd);
-}