From 589745707c06ee55a4927adee537426bdb2431ce Mon Sep 17 00:00:00 2001 From: Alexander Saprykin Date: Fri, 1 Jul 2016 17:59:03 +0200 Subject: [PATCH] Add networking sfc library Library provides set of classes for MuranoPL language to manage Networking SFC objects in Neutron: * FlowClassifier * PortChain * PortPair * PortPairGroup Adds utility classes to extend MuranoPL core library: * Instance * NeutronPort Change-Id: I3f3d24dffbe572ea13da599920cc501d41085643 --- .../Classes/FlowClassifier.yaml | 93 +++++++++++++++++++ networking_sfc_library/Classes/Instance.yaml | 47 ++++++++++ .../Classes/NeutronPort.yaml | 67 +++++++++++++ networking_sfc_library/Classes/PortChain.yaml | 67 +++++++++++++ networking_sfc_library/Classes/PortPair.yaml | 60 ++++++++++++ .../Classes/PortPairGroup.yaml | 60 ++++++++++++ networking_sfc_library/manifest.yaml | 33 +++++++ 7 files changed, 427 insertions(+) create mode 100644 networking_sfc_library/Classes/FlowClassifier.yaml create mode 100644 networking_sfc_library/Classes/Instance.yaml create mode 100644 networking_sfc_library/Classes/NeutronPort.yaml create mode 100644 networking_sfc_library/Classes/PortChain.yaml create mode 100644 networking_sfc_library/Classes/PortPair.yaml create mode 100644 networking_sfc_library/Classes/PortPairGroup.yaml create mode 100644 networking_sfc_library/manifest.yaml diff --git a/networking_sfc_library/Classes/FlowClassifier.yaml b/networking_sfc_library/Classes/FlowClassifier.yaml new file mode 100644 index 0000000..dfe3c74 --- /dev/null +++ b/networking_sfc_library/Classes/FlowClassifier.yaml @@ -0,0 +1,93 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + +Name: FlowClassifier + +Properties: + id: + Contract: $.string() + Usage: Out + + name: + Contract: $.string() + + description: + Contract: $.string() + + ethertype: + Contract: $.string().notNull() + Default: 'IPv4' + + protocol: + Contract: $.string() + + sourcePortMin: + Contract: $.int() + + sourcePortMax: + Contract: $.int() + + destinationPortMin: + Contract: $.int() + + destinationPortMax: + Contract: $.int() + + sourceIpPrefix: + Contract: $.string() + + destinationIpPrefix: + Contract: $.string() + + logicalSourcePort: + Contract: $.class(NeutronPort).notNull() + + logicalDestinationPort: + Contract: $.class(NeutronPort).notNull() + +Methods: + .init: + Body: + - $env: $.find(std:Environment).require() + - $.sfcClient: new('io.murano.extensions.networking_sfc.NetworkingSfcClient', $env) + + deploy: + Body: + - If: $.getAttr(deployed, false) + Then: + - Return: null + + - $data: $.sfcClient.createFlowClassifier( + name => $.name, description => $.description, + ethertype => $.ethertype, protocol => $.protocol, + source_port_range_min => $.sourcePortMin, + source_port_range_max => $.sourcePortMax, + destination_port_range_min => $.destinationPortMin, + destination_port_range_max => $.destinationPortMax, + source_ip_prefix => $.sourceIpPrefix, + destination_ip_prefix => $.destinationIpPrefix, + logical_source_port => $.logicalSourcePort.openstackId, + logical_destination_port => $.logicalDestinationPort.openstackId) + - $.id: $data.id + - $.setAttr(deployed, true) + + .destroy: + Body: + - If: $.getAttr(deployed, false) + Then: + - $.sfcClient.deleteFlowClassifier($.id) diff --git a/networking_sfc_library/Classes/Instance.yaml b/networking_sfc_library/Classes/Instance.yaml new file mode 100644 index 0000000..56947ef --- /dev/null +++ b/networking_sfc_library/Classes/Instance.yaml @@ -0,0 +1,47 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + res: io.murano.resources + +Name: Instance + +Extends: res:LinuxMuranoInstance + +Properties: + ports: + Contract: [$.class(NeutronPort).notNull()] + Default: [] + +Methods: + prepareStackTemplate: + Arguments: + instanceTemplate: + Contract: {} + Body: + - For: port + In: $.ports + Do: + - $port.deploy() + - $template: + resources: + $.name: + properties: + networks: + - port: + $port.getRef() + - $instanceTemplate: $instanceTemplate.mergeWith($template) + - Return: $instanceTemplate diff --git a/networking_sfc_library/Classes/NeutronPort.yaml b/networking_sfc_library/Classes/NeutronPort.yaml new file mode 100644 index 0000000..3eae29e --- /dev/null +++ b/networking_sfc_library/Classes/NeutronPort.yaml @@ -0,0 +1,67 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + res: io.murano.resources + +Name: NeutronPort + +Properties: + network: + Contract: $.class(res:Network).notNull() + name: + Contract: $.string() + Usage: Out + openstackId: + Contract: $.string() + Usage: Out + +Methods: + .init: + Body: + - $._environment: $.find(std:Environment).require() + + deploy: + Body: + - If: $.getAttr(deployed, false) + Then: + - Return: null + + - $.name: format('port-{0}', id($)) + - $networkData: $.network.describe() + - $template: + resources: + $.name: + type: 'OS::Neutron::Port' + properties: + network_id: $networkData.netId + replacement_policy: AUTO + port_security_enabled: false + outputs: + format('{0}-id', $.name): + value: + get_resource: $.name + - $._environment.stack.updateTemplate($template) + - $._environment.stack.push() + + - $outputs: $._environment.stack.output() + - $.openstackId: $outputs.get(format('{0}-id', $.name)) + - $.setAttr(deployed, true) + + getRef: + Body: + Return: + get_resource: $.name diff --git a/networking_sfc_library/Classes/PortChain.yaml b/networking_sfc_library/Classes/PortChain.yaml new file mode 100644 index 0000000..1dba68e --- /dev/null +++ b/networking_sfc_library/Classes/PortChain.yaml @@ -0,0 +1,67 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + +Name: PortChain + +Properties: + id: + Contract: $.string() + Usage: Out + + name: + Contract: $.string() + + description: + Contract: $.string() + + portPairGroups: + Contract: [$.class(PortPairGroup).notNull()] + + flowClassifiers: + Contract: [$.class(FlowClassifier).notNull()] + +Methods: + .init: + Body: + - $env: $.find(std:Environment).require() + - $.sfcClient: new('io.murano.extensions.networking_sfc.NetworkingSfcClient', $env) + + deploy: + Body: + - If: $.getAttr(deployed, false) + Then: + - Return: null + + - $.portPairGroups.select($.deploy()) + - $portPairGroupIds: $.portPairGroups.id + + - $.flowClassifiers.select($.deploy()) + - $flowClassifierIds: $.flowClassifiers.id + + - $data: $.sfcClient.createPortChain( + name => $.name, description => $.description, + port_pair_groups => $portPairGroupIds, + flow_classifiers => $flowClassifierIds) + - $.id: $data.id + - $.setAttr(deployed, true) + + .destroy: + Body: + - If: $.getAttr(deployed, false) + Then: + - $.sfcClient.deletePortChain($.id) diff --git a/networking_sfc_library/Classes/PortPair.yaml b/networking_sfc_library/Classes/PortPair.yaml new file mode 100644 index 0000000..d529f52 --- /dev/null +++ b/networking_sfc_library/Classes/PortPair.yaml @@ -0,0 +1,60 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + +Name: PortPair + +Properties: + id: + Contract: $.string() + Usage: Out + + name: + Contract: $.string() + + description: + Contract: $.string() + + ingress: + Contract: $.class(NeutronPort).notNull() + + egress: + Contract: $.class(NeutronPort).notNull() + +Methods: + .init: + Body: + - $env: $.find(std:Environment).require() + - $.sfcClient: new('io.murano.extensions.networking_sfc.NetworkingSfcClient', $env) + + deploy: + Body: + - If: $.getAttr(deployed, false) + Then: + - Return: null + + - $data: $.sfcClient.createPortPair( + name => $.name, description => $.description, + ingress => $.ingress.openstackId, egress => $.egress.openstackId) + - $.id: $data.id + - $.setAttr(deployed, true) + + .destroy: + Body: + - If: $.getAttr(deployed, false) + Then: + - $.sfcClient.deletePortPair($.id) diff --git a/networking_sfc_library/Classes/PortPairGroup.yaml b/networking_sfc_library/Classes/PortPairGroup.yaml new file mode 100644 index 0000000..3873daa --- /dev/null +++ b/networking_sfc_library/Classes/PortPairGroup.yaml @@ -0,0 +1,60 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Namespaces: + =: org.openstack.networkingSfc + std: io.murano + +Name: PortPairGroup + +Properties: + id: + Contract: $.string() + Usage: Out + + name: + Contract: $.string() + + description: + Contract: $.string() + + portPairs: + Contract: [$.class(PortPair).notNull()] + +Methods: + .init: + Body: + - $env: $.find(std:Environment).require() + - $.sfcClient: new('io.murano.extensions.networking_sfc.NetworkingSfcClient', $env) + + deploy: + Body: + - If: $.getAttr(deployed, false) + Then: + - Return: null + + - $.portPairs.select($.deploy()) + - $portPairIds: $.portPairs.id + + - $data: $.sfcClient.createPortPairGroup( + name => $.name, description => $.description, + port_pairs => $portPairIds) + - $.id: $data.id + - $.setAttr(deployed, true) + + .destroy: + Body: + - If: $.getAttr(deployed, false) + Then: + - $.sfcClient.deletePortPairGroup($.id) diff --git a/networking_sfc_library/manifest.yaml b/networking_sfc_library/manifest.yaml new file mode 100644 index 0000000..6ed06bf --- /dev/null +++ b/networking_sfc_library/manifest.yaml @@ -0,0 +1,33 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed 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. + +Format: 1.3 +Type: Library +Name: Networking SFC Library +FullName: org.openstack.networkingSfc +Description: > + Integration with networking-sfc extension for OpenStack Neutron. +Author: 'Mirantis, Inc' +Tags: [SFC, Neutron] + +Classes: + org.openstack.networkingSfc.FlowClassifier: FlowClassifier.yaml + org.openstack.networkingSfc.Instance: Instance.yaml + org.openstack.networkingSfc.NeutronPort: NeutronPort.yaml + org.openstack.networkingSfc.PortChain: PortChain.yaml + org.openstack.networkingSfc.PortPair: PortPair.yaml + org.openstack.networkingSfc.PortPairGroup: PortPairGroup.yaml + +Require: + murano-plugin-networking-sfc: