Skip to content

Commit 1f9528b

Browse files
committed
Add a network plugin for OpenDaylight
This plugin is a technology preview and designed to work with the OVSDB module
1 parent cbe2560 commit 1f9528b

24 files changed

Lines changed: 1863 additions & 0 deletions

LICENSE.header

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Licensed to the Apache Software Foundation (ASF) under one
2+
or more contributor license agreements. See the NOTICE file
3+
distributed with this work for additional information
4+
regarding copyright ownership. The ASF licenses this file
5+
to you under the Apache License, Version 2.0 (the
6+
"License"); you may not use this file except in compliance
7+
with the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing,
12+
software distributed under the License is distributed on an
13+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
KIND, either express or implied. See the License for the
15+
specific language governing permissions and limitations
16+
under the License.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
<artifactId>cloud-plugin-network-opendaylight</artifactId>
24+
<name>Apache CloudStack Plugin - Network Opendaylight</name>
25+
<parent>
26+
<groupId>org.apache.cloudstack</groupId>
27+
<artifactId>cloudstack-plugins</artifactId>
28+
<version>4.4.0-SNAPSHOT</version>
29+
<relativePath>../../pom.xml</relativePath>
30+
</parent>
31+
32+
<!-- not parenting to the maven-default pom, as we want this in services -->
33+
<build>
34+
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
35+
<scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory>
36+
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
37+
<outputDirectory>${basedir}/target/classes</outputDirectory>
38+
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
39+
<resources>
40+
<resource>
41+
<directory>${basedir}/src/main/resources</directory>
42+
</resource>
43+
</resources>
44+
<testResources>
45+
<testResource>
46+
<directory>${basedir}/src/test/resources</directory>
47+
</testResource>
48+
</testResources>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-checkstyle-plugin</artifactId>
53+
<dependencies>
54+
<dependency>
55+
<groupId>org.apache.cloudstack</groupId>
56+
<artifactId>checkstyle</artifactId>
57+
<version>${project.version}</version>
58+
</dependency>
59+
</dependencies>
60+
<executions>
61+
<execution>
62+
<phase>process-classes</phase>
63+
<goals>
64+
<goal>check</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
<configuration>
69+
<failsOnError>true</failsOnError>
70+
<configLocation>tooling/checkstyle.xml</configLocation>
71+
<consoleOutput>true</consoleOutput>
72+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
73+
<sourceDirectory>${project.basedir}</sourceDirectory>
74+
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
75+
<excludes>**\/target\/,**\/bin\/</excludes>
76+
</configuration>
77+
</plugin>
78+
<plugin>
79+
<groupId>com.mycila.maven-license-plugin</groupId>
80+
<artifactId>maven-license-plugin</artifactId>
81+
<version>1.9.0</version>
82+
<executions>
83+
<execution>
84+
<phase>process-classes</phase>
85+
<goals>
86+
<goal>format</goal>
87+
</goals>
88+
</execution>
89+
</executions>
90+
<configuration>
91+
<strictCheck>true</strictCheck>
92+
<aggregate>true</aggregate>
93+
<header>../../../LICENSE.header</header>
94+
<mapping>
95+
<xml>XML_STYLE</xml>
96+
    <java>DOUBLESLASH_STYLE</java>
97+
    <clj>SEMICOLON_STYLE</clj>
98+
</mapping>
99+
<useDefaultExcludes>false</useDefaultExcludes>
100+
<excludes>
101+
<exclude>target/**</exclude>
102+
<exclude>.settings/**</exclude>
103+
<exclude>.checkstyle</exclude>
104+
<exclude>.project</exclude>
105+
<exclude>.classpath</exclude>
106+
</excludes>
107+
</configuration>
108+
</plugin>
109+
</plugins>
110+
</build>
111+
<profiles>
112+
<profile>
113+
<id>integration</id>
114+
<build>
115+
<plugins>
116+
<plugin>
117+
<groupId>org.apache.maven.plugins</groupId>
118+
<artifactId>maven-failsafe-plugin</artifactId>
119+
<executions>
120+
<execution>
121+
<goals>
122+
<goal>integration-test</goal>
123+
<goal>verify</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
</plugins>
129+
</build>
130+
</profile>
131+
</profiles>
132+
</project>
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package org.apache.cloudstack.network.opendaylight;
21+
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
25+
import java.util.Set;
26+
27+
import javax.ejb.Local;
28+
import javax.inject.Inject;
29+
import javax.naming.ConfigurationException;
30+
31+
import org.apache.log4j.Logger;
32+
import org.springframework.stereotype.Component;
33+
34+
import org.apache.cloudstack.network.opendaylight.agent.commands.StartupOpenDaylightControllerCommand;
35+
36+
import com.cloud.agent.api.StartupCommand;
37+
import com.cloud.deploy.DeployDestination;
38+
import com.cloud.exception.ConcurrentOperationException;
39+
import com.cloud.exception.InsufficientCapacityException;
40+
import com.cloud.exception.ResourceUnavailableException;
41+
import com.cloud.host.Host;
42+
import com.cloud.host.HostVO;
43+
import com.cloud.network.Network;
44+
import com.cloud.network.Network.Capability;
45+
import com.cloud.network.Network.Provider;
46+
import com.cloud.network.Network.Service;
47+
import com.cloud.network.PhysicalNetworkServiceProvider;
48+
import com.cloud.network.element.ConnectivityProvider;
49+
import com.cloud.network.element.NetworkElement;
50+
import com.cloud.offering.NetworkOffering;
51+
import com.cloud.resource.ResourceManager;
52+
import com.cloud.resource.ResourceStateAdapter;
53+
import com.cloud.resource.ServerResource;
54+
import com.cloud.resource.UnableDeleteHostException;
55+
import com.cloud.utils.component.AdapterBase;
56+
import com.cloud.utils.exception.CloudRuntimeException;
57+
import com.cloud.vm.NicProfile;
58+
import com.cloud.vm.ReservationContext;
59+
import com.cloud.vm.VirtualMachineProfile;
60+
61+
@Component
62+
@Local(value = {NetworkElement.class, ConnectivityProvider.class})
63+
public class OpendaylightElement extends AdapterBase implements ConnectivityProvider, ResourceStateAdapter {
64+
65+
private static final Logger s_logger = Logger.getLogger(OpendaylightElement.class);
66+
private static final Map<Service, Map<Capability, String>> s_capabilities = setCapabilities();
67+
68+
@Inject
69+
ResourceManager resourceManager;
70+
71+
@Override
72+
public Map<Service, Map<Capability, String>> getCapabilities() {
73+
return s_capabilities;
74+
}
75+
76+
@Override
77+
public Provider getProvider() {
78+
return Provider.Opendaylight;
79+
}
80+
81+
@Override
82+
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
83+
boolean configured = super.configure(name, params);
84+
if (configured)
85+
resourceManager.registerResourceStateAdapter(name, this);
86+
return configured;
87+
}
88+
89+
@Override
90+
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
91+
ResourceUnavailableException, InsufficientCapacityException {
92+
// TODO Auto-generated method stub
93+
return true;
94+
}
95+
96+
@Override
97+
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
98+
ResourceUnavailableException, InsufficientCapacityException {
99+
// TODO Auto-generated method stub
100+
return true;
101+
}
102+
103+
@Override
104+
public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException,
105+
ResourceUnavailableException {
106+
// TODO Auto-generated method stub
107+
return true;
108+
}
109+
110+
@Override
111+
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
112+
return true;
113+
}
114+
115+
@Override
116+
public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
117+
return true;
118+
}
119+
120+
@Override
121+
public boolean isReady(PhysicalNetworkServiceProvider provider) {
122+
return true;
123+
}
124+
125+
@Override
126+
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
127+
ResourceUnavailableException {
128+
return true;
129+
}
130+
131+
@Override
132+
public boolean canEnableIndividualServices() {
133+
return false;
134+
}
135+
136+
@Override
137+
public boolean verifyServicesCombination(Set<Service> services) {
138+
if (services.contains(Service.Connectivity) && services.size() == 1)
139+
return true;
140+
return false;
141+
}
142+
143+
@Override
144+
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] startup) {
145+
if (!(startup[0] instanceof StartupOpenDaylightControllerCommand)) {
146+
return null;
147+
}
148+
throw new CloudRuntimeException("createHostVOForConnectedAgent is not implemented for OpendaylightElement");
149+
}
150+
151+
@Override
152+
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
153+
if (!(startup[0] instanceof StartupOpenDaylightControllerCommand)) {
154+
return null;
155+
}
156+
host.setType(Host.Type.L2Networking);
157+
return host;
158+
}
159+
160+
@Override
161+
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
162+
return new DeleteHostAnswer(true);
163+
}
164+
165+
private static Map<Service, Map<Capability, String>> setCapabilities() {
166+
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
167+
168+
// L2 Support : SDN provisioning
169+
capabilities.put(Service.Connectivity, null);
170+
171+
return capabilities;
172+
}
173+
174+
}

0 commit comments

Comments
 (0)