From 850bc9fa826393c5ab110bf49138b4d0e1c1c313 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Thu, 19 Dec 2013 11:00:36 +0100 Subject: [PATCH] Hook the OpenDaylight plugin into CloudStack --- api/src/com/cloud/event/EventTypes.java | 10 ++ api/src/com/cloud/network/Network.java | 7 +- api/src/com/cloud/network/Networks.java | 2 +- .../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 | 14 ++- 9 files changed, 94 insertions(+), 52 deletions(-) diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 5a342cd284d..e88f0104ea7 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) { diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index d19c999f16e..d2c8ac0155a 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, 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, 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, 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 s_fsm = new StateMachine2(); diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java index e4034a5d174..b2c04cda00c 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; diff --git a/api/src/com/cloud/network/PhysicalNetwork.java b/api/src/com/cloud/network/PhysicalNetwork.java index cfa236d3898..5c348c21b7a 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 { diff --git a/api/src/com/cloud/vm/NicProfile.java b/api/src/com/cloud/vm/NicProfile.java index ab18ca094f9..20588031146 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() { diff --git a/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java b/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java index 32f13f80f22..e73f5263a4f 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; diff --git a/client/pom.xml b/client/pom.xml index 33d3f1eeaeb..abbc25dbcbf 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -130,6 +130,11 @@ cloud-plugin-network-vxlan ${project.version} + + org.apache.cloudstack + cloud-plugin-network-opendaylight + ${project.version} + org.apache.cloudstack cloud-plugin-hypervisor-xen diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index a05310bff77..9f74fdb38e8 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 diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql index 17b4c6d6076..37be8317574 100644 --- a/setup/db/db/schema-430to440.sql +++ b/setup/db/db/schema-430to440.sql @@ -224,4 +224,16 @@ CREATE TABLE `cloud`.`user_details` ( `display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user', PRIMARY KEY (`id`), CONSTRAINT `fk_user_details__user_id` FOREIGN KEY `fk_user_details__user_id`(`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +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;