Hook the OpenDaylight plugin into CloudStack

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

Branch: refs/heads/opendaylight
Commit: 30d46fd2f4672d7195f444fe516ea72c82de347a
Parents: 6de795a
Author: Hugo Trippaers <[email protected]>
Authored: Thu Dec 19 11:00:36 2013 +0100
Committer: Hugo Trippaers <[email protected]>
Committed: Thu Dec 19 11:02:26 2013 +0100

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |  10 ++
 api/src/com/cloud/network/Network.java          |   7 +-
 api/src/com/cloud/network/Networks.java         |   2 +-
 api/src/com/cloud/network/PhysicalNetwork.java  |   2 +-
 api/src/com/cloud/vm/NicProfile.java            | 102 ++++++++++---------
 .../network/ExternalNetworkDeviceManager.java   |   1 +
 client/pom.xml                                  |   5 +
 client/tomcatconf/commands.properties.in        |   3 +
 setup/db/db/schema-430to440.sql                 |  12 +++
 9 files changed, 93 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java 
b/api/src/com/cloud/event/EventTypes.java
index 5a342cd..e88f010 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -455,6 +455,11 @@ public class EventTypes {
     //Alert generation
     public static final String ALERT_GENERATE = "ALERT.GENERATE";
 
+    // OpenDaylight
+    public static final String EVENT_EXTERNAL_OPENDAYLIGHT_ADD_CONTROLLER = 
"PHYSICAL.ODLCONTROLLER.ADD";
+    public static final String EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER = 
"PHYSICAL.ODLCONTROLLER.DELETE";
+    public static final String 
EVENT_EXTERNAL_OPENDAYLIGHT_CONFIGURE_CONTROLLER = 
"PHYSICAL.ODLCONTROLLER.CONFIGURE";
+
     static {
 
         // TODO: need a way to force author adding event types to declare the 
entity details as well, with out braking
@@ -760,6 +765,11 @@ public class EventTypes {
         entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_DISABLE, 
AutoScaleVmGroup.class.getName());
         entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, 
GuestVlan.class.getName());
         entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, 
GuestVlan.class.getName());
+
+        // OpenDaylight
+        entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_ADD_CONTROLLER, 
"OpenDaylightController");
+        entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER, 
"OpenDaylightController");
+        
entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_CONFIGURE_CONTROLLER, 
"OpenDaylightController");
     }
 
     public static String getEntityForEvent(String eventName) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java 
b/api/src/com/cloud/network/Network.java
index d19c999..d2c8ac0 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -47,9 +47,9 @@ public interface Network extends ControlledEntity, 
StateObject<Network.State>, I
         public static final Service Dns = new Service("Dns", 
Capability.AllowDnsSuffixModification);
         public static final Service Gateway = new Service("Gateway");
         public static final Service Firewall = new Service("Firewall", 
Capability.SupportedProtocols, Capability.MultipleIps, 
Capability.TrafficStatistics,
-            Capability.SupportedTrafficDirection, 
Capability.SupportedEgressProtocols);
+                Capability.SupportedTrafficDirection, 
Capability.SupportedEgressProtocols);
         public static final Service Lb = new Service("Lb", 
Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation, 
Capability.SupportedProtocols,
-            Capability.TrafficStatistics, 
Capability.LoadBalancingSupportedIps, Capability.SupportedStickinessMethods, 
Capability.ElasticLb, Capability.LbSchemes);
+                Capability.TrafficStatistics, 
Capability.LoadBalancingSupportedIps, Capability.SupportedStickinessMethods, 
Capability.ElasticLb, Capability.LbSchemes);
         public static final Service UserData = new Service("UserData");
         public static final Service SourceNat = new Service("SourceNat", 
Capability.SupportedSourceNatTypes, Capability.RedundantRouter);
         public static final Service StaticNat = new Service("StaticNat", 
Capability.ElasticIp);
@@ -128,6 +128,7 @@ public interface Network extends ControlledEntity, 
StateObject<Network.State>, I
         public static final Provider CiscoVnmc = new Provider("CiscoVnmc", 
true);
         // add new Ovs provider
         public static final Provider Ovs = new Provider("Ovs", false);
+        public static final Provider Opendaylight = new 
Provider("Opendaylight", false);
 
         private final String name;
         private final boolean isExternal;
@@ -213,7 +214,7 @@ public interface Network extends ControlledEntity, 
StateObject<Network.State>, I
 
         Allocated("Indicates the network configuration is in allocated but not 
setup"), Setup("Indicates the network configuration is setup"), Implementing(
                 "Indicates the network configuration is being implemented"), 
Implemented("Indicates the network configuration is in use"), Shutdown(
-                "Indicates the network configuration is being destroyed"), 
Destroy("Indicates that the network is destroyed");
+                        "Indicates the network configuration is being 
destroyed"), Destroy("Indicates that the network is destroyed");
 
         protected static final StateMachine2<State, Network.Event, Network> 
s_fsm = new StateMachine2<State, Network.Event, Network>();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/api/src/com/cloud/network/Networks.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Networks.java 
b/api/src/com/cloud/network/Networks.java
index e4034a5..b2c04cd 100755
--- a/api/src/com/cloud/network/Networks.java
+++ b/api/src/com/cloud/network/Networks.java
@@ -94,7 +94,7 @@ public class Networks {
                 return uri.getSchemeSpecificPart();
             }
         },
-        Mido("mido", String.class), Pvlan("pvlan", String.class), 
Vxlan("vxlan", Long.class), UnDecided(null, null);
+        Mido("mido", String.class), Pvlan("pvlan", String.class), 
Vxlan("vxlan", Long.class), UnDecided(null, null), OpenDaylight("opendaylight", 
String.class);
 
         private final String scheme;
         private final Class<?> type;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/api/src/com/cloud/network/PhysicalNetwork.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/PhysicalNetwork.java 
b/api/src/com/cloud/network/PhysicalNetwork.java
index cfa236d..5c348c2 100644
--- a/api/src/com/cloud/network/PhysicalNetwork.java
+++ b/api/src/com/cloud/network/PhysicalNetwork.java
@@ -33,7 +33,7 @@ public interface PhysicalNetwork extends Identity, 
InternalIdentity {
     }
 
     public enum IsolationMethod {
-        VLAN, L3, GRE, STT, VNS, MIDO, SSP, VXLAN;
+        VLAN, L3, GRE, STT, VNS, MIDO, SSP, VXLAN, ODL;
     }
 
     public enum BroadcastDomainRange {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/api/src/com/cloud/vm/NicProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/NicProfile.java 
b/api/src/com/cloud/vm/NicProfile.java
index ab18ca0..2058803 100644
--- a/api/src/com/cloud/vm/NicProfile.java
+++ b/api/src/com/cloud/vm/NicProfile.java
@@ -57,6 +57,7 @@ public class NicProfile implements InternalIdentity {
     String name;
     String requestedIpv4;
     String requestedIpv6;
+    String uuid;
 
     public String getDns1() {
         return dns1;
@@ -142,6 +143,10 @@ public class NicProfile implements InternalIdentity {
         this.format = format;
     }
 
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
     public void setTrafficType(TrafficType trafficType) {
         this.trafficType = trafficType;
     }
@@ -215,29 +220,34 @@ public class NicProfile implements InternalIdentity {
         return strategy;
     }
 
+    public String getUuid() {
+        return uuid;
+    }
+
     public NicProfile(Nic nic, Network network, URI broadcastUri, URI 
isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) 
{
-        this.id = nic.getId();
-        this.networkId = network.getId();
-        this.gateway = nic.getGateway();
-        this.mode = network.getMode();
-        this.broadcastType = network.getBroadcastDomainType();
-        this.trafficType = network.getTrafficType();
-        this.ip4Address = nic.getIp4Address();
-        this.format = nic.getAddressFormat();
-        this.ip6Address = nic.getIp6Address();
-        this.macAddress = nic.getMacAddress();
-        this.reservationId = nic.getReservationId();
-        this.strategy = nic.getReservationStrategy();
-        this.deviceId = nic.getDeviceId();
-        this.defaultNic = nic.isDefaultNic();
+        id = nic.getId();
+        networkId = network.getId();
+        gateway = nic.getGateway();
+        mode = network.getMode();
+        broadcastType = network.getBroadcastDomainType();
+        trafficType = network.getTrafficType();
+        ip4Address = nic.getIp4Address();
+        format = nic.getAddressFormat();
+        ip6Address = nic.getIp6Address();
+        macAddress = nic.getMacAddress();
+        reservationId = nic.getReservationId();
+        strategy = nic.getReservationStrategy();
+        deviceId = nic.getDeviceId();
+        defaultNic = nic.isDefaultNic();
         this.broadcastUri = broadcastUri;
         this.isolationUri = isolationUri;
-        this.netmask = nic.getNetmask();
+        netmask = nic.getNetmask();
         this.isSecurityGroupEnabled = isSecurityGroupEnabled;
-        this.vmId = nic.getInstanceId();
+        vmId = nic.getInstanceId();
         this.name = name;
-        this.ip6Cidr = nic.getIp6Cidr();
-        this.ip6Gateway = nic.getIp6Gateway();
+        ip6Cidr = nic.getIp6Cidr();
+        ip6Gateway = nic.getIp6Gateway();
+        uuid = nic.getUuid();
 
         if (networkRate != null) {
             this.networkRate = networkRate;
@@ -245,7 +255,7 @@ public class NicProfile implements InternalIdentity {
     }
 
     public NicProfile(ReservationStrategy strategy, String ip4Address, String 
macAddress, String gateway, String netmask) {
-        this.format = AddressFormat.Ip4;
+        format = AddressFormat.Ip4;
         this.ip4Address = ip4Address;
         this.macAddress = macAddress;
         this.gateway = gateway;
@@ -274,11 +284,11 @@ public class NicProfile implements InternalIdentity {
     }
 
     public boolean isSecurityGroupEnabled() {
-        return this.isSecurityGroupEnabled;
+        return isSecurityGroupEnabled;
     }
 
     public void setSecurityGroupEnabled(boolean enabled) {
-        this.isSecurityGroupEnabled = enabled;
+        isSecurityGroupEnabled = enabled;
     }
 
     public String getRequestedIpv4() {
@@ -286,36 +296,36 @@ public class NicProfile implements InternalIdentity {
     }
 
     public void deallocate() {
-        this.gateway = null;
-        this.mode = null;
-        this.format = null;
-        this.broadcastType = null;
-        this.trafficType = null;
-        this.ip4Address = null;
-        this.ip6Address = null;
-        this.macAddress = null;
-        this.reservationId = null;
-        this.strategy = null;
-        this.deviceId = null;
-        this.broadcastUri = null;
-        this.isolationUri = null;
-        this.netmask = null;
-        this.dns1 = null;
-        this.dns2 = null;
+        gateway = null;
+        mode = null;
+        format = null;
+        broadcastType = null;
+        trafficType = null;
+        ip4Address = null;
+        ip6Address = null;
+        macAddress = null;
+        reservationId = null;
+        strategy = null;
+        deviceId = null;
+        broadcastUri = null;
+        isolationUri = null;
+        netmask = null;
+        dns1 = null;
+        dns2 = null;
     }
 
     @Override
     public String toString() {
         return new StringBuilder("NicProfile[").append(id)
-            .append("-")
-            .append(vmId)
-            .append("-")
-            .append(reservationId)
-            .append("-")
-            .append(ip4Address)
-            .append("-")
-            .append(broadcastUri)
-            .toString();
+                .append("-")
+                .append(vmId)
+                .append("-")
+                .append(reservationId)
+                .append("-")
+                .append(ip4Address)
+                .append("-")
+                .append(broadcastUri)
+                .toString();
     }
 
     public String getIp6Gateway() {

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 75b5504..f319a58 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -132,6 +132,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-network-opendaylight</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-hypervisor-xen</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in 
b/client/tomcatconf/commands.properties.in
index a05310b..9f74fdb 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -706,3 +706,6 @@ importLdapUsers=3
 
 #### juniper-contrail commands
 createServiceInstance=1
+
+### OpenDaylight plugin commands
+addOpenDaylightController=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30d46fd2/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index f4dc2e6..6b92348 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -214,3 +214,15 @@ CREATE VIEW `cloud`.`volume_view` AS
             and async_job.job_status = 0;
 
 UPDATE `cloud`.`configuration` SET `description` = 'If set to true, 
StartCommand, StopCommand, CopyCommand, MigrateCommand will be synchronized on 
the agent side. If set to false, these commands become asynchronous. Default 
value is true.' WHERE `name` = 'execute.in.sequence.hypervisor.commands';
+
+CREATE TABLE `cloud`.`external_opendaylight_controllers` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(255) UNIQUE,
+  `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical 
network in to which the device is added',
+  `provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name 
corresponding to this device',
+  `device_name` varchar(255) NOT NULL COMMENT 'name of the device',
+  `host_id` bigint unsigned NOT NULL COMMENT 'host id corresponding to the 
external device',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `fk_external_opendaylight_devices__host_id` FOREIGN KEY 
(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_external_opendaylight_devices__physical_network_id` FOREIGN 
KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE 
CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Reply via email to