Browse Source

Import plugin's code

Change-Id: I6c9ea6894e44802a57e5dd6aedc64f230467b5c5
Margarita Shakhova 1 year ago
parent
commit
aefabfa51a
33 changed files with 918 additions and 0 deletions
  1. 176
    0
      LICENSE
  2. 73
    0
      README.md
  3. 12
    0
      components.yaml
  4. 2
    0
      deployment_scripts/puppet/manifests/ceph_auth.pp
  5. 2
    0
      deployment_scripts/puppet/manifests/ceph_primary.pp
  6. 3
    0
      deployment_scripts/puppet/manifests/controller.pp
  7. 6
    0
      deployment_scripts/puppet/manifests/keys.pp
  8. 2
    0
      deployment_scripts/puppet/manifests/osd.pp
  9. 2
    0
      deployment_scripts/puppet/manifests/osd_id.pp
  10. 2
    0
      deployment_scripts/puppet/manifests/regions.pp
  11. 127
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/partitions.rb
  12. 10
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/pools.rb
  13. 5
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/rbd_secret.rb
  14. 6
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_all_osd_id.rb
  15. 21
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_disks.rb
  16. 10
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_osd_id.rb
  17. 18
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_primary_node.rb
  18. 21
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_target_disk.rb
  19. 23
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/ceph_auth.pp
  20. 96
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/ceph_primary.pp
  21. 52
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/controller.pp
  22. 1
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/init.pp
  23. 31
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/osd.pp
  24. 55
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/osd_id.pp
  25. 16
    0
      deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/regions.pp
  26. 73
    0
      deployment_tasks.yaml
  27. 21
    0
      environment_config.yaml
  28. 31
    0
      metadata.yaml
  29. 6
    0
      node_roles.yaml
  30. 0
    0
      repositories/centos/.gitkeep
  31. 0
    0
      repositories/ubuntu/.gitkeep
  32. 1
    0
      tasks.yaml
  33. 14
    0
      volumes.yaml

+ 176
- 0
LICENSE View File

@@ -0,0 +1,176 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+

+ 73
- 0
README.md View File

@@ -0,0 +1,73 @@
1
+Ceph Multibackend plugin for Fuel
2
+=================================
3
+
4
+Overview
5
+--------
6
+
7
+Ceph Multibackend plugin for Fuel extends Mirantis OpenStack functionality by adding
8
+support for Ceph backend in Glance using ceph second pool. It adds new role "Ceph Glance
9
+Backende" with volume partition assignment. This role can be used ONLY with standart 
10
+"Ceph OSD" role on node. 
11
+
12
+
13
+Compatible Fuel versions
14
+------------------------
15
+
16
+9.0
17
+
18
+
19
+User Guide
20
+----------
21
+
22
+1. Create an environment with the Ceph default image backend for Glance.
23
+2. Enable the plugin on the Settings/Storage tab of the Fuel web UI and fill in form
24
+    fields:
25
+   * Ceph pool name - name for new ceph pool
26
+3. Select new node with roles Ceph OSD *AND* Ceph Glance Backend
27
+4. Configure Disks on new node, chose at least one whole disk for role Ceph Glance Backend
28
+  and one for role Ceph-OSD
29
+5. Deploy the environment.
30
+
31
+
32
+Installation Guide
33
+==================
34
+
35
+Ceph Multibackend Plugin for Fuel installation
36
+----------------------------------------------
37
+
38
+To install Ceph Multibackend plugin, follow these steps:
39
+
40
+1. Download the plugin
41
+    git clone https://github.com/openstack/fuel-plugin-ceph-multibackend
42
+
43
+2. Copy the plugin on already installed Fuel Master node; ssh can be used for
44
+    that. If you do not have the Fuel Master node yet, see
45
+    [Quick Start Guide](https://software.mirantis.com/quick-start/):
46
+
47
+        # scp fuel-plugin-ceph_multibackend-1.7.1-1.noarch.rpm root@<Fuel_master_ip>:/tmp
48
+
49
+3. Log into the Fuel Master node. Install the plugin:
50
+
51
+        # cd /tmp
52
+        # fuel plugins --install fuel-plugin-ceph_multibackend-1.7.1-1.noarch.rpm
53
+
54
+4. Check if the plugin was installed successfully:
55
+
56
+        # fuel plugins
57
+        id | name                            | version | package_version
58
+        ---|---------------------------------|---------|----------------
59
+        1  | fuel-plugin-ceph_multibackend   | 1.7.1  | 4.0.0
60
+
61
+
62
+Requirements
63
+------------
64
+
65
+| Requirement                      | Version/Comment |
66
+|:---------------------------------|:----------------|
67
+| Mirantis OpenStack compatibility | 9.0             |
68
+
69
+
70
+Limitations
71
+-----------
72
+
73
+Role Ceph Glance Backend can be used only on nodes with active Ceph OSD role.

+ 12
- 0
components.yaml View File

@@ -0,0 +1,12 @@
1
+- name: 'storage:image:ceph2'
2
+  label: 'Ceph SSD'
3
+  description: 'Separate osd pool for Ceph Images. Requires Ceph Image Storage option.'
4
+  requires:
5
+    - name: 'storage:image:ceph'
6
+  compatible:
7
+    - name: 'hypervisor:libvirt:*'
8
+    - name: 'storage:block:ceph'
9
+    - name: 'storage:object:ceph'
10
+    - name: 'storage:image:ceph'
11
+    - name: 'storage:ephemeral:ceph'
12
+

+ 2
- 0
deployment_scripts/puppet/manifests/ceph_auth.pp View File

@@ -0,0 +1,2 @@
1
+include fuel-plugin-ceph_multibackend::ceph_auth
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/ceph_auth.pp')

+ 2
- 0
deployment_scripts/puppet/manifests/ceph_primary.pp View File

@@ -0,0 +1,2 @@
1
+include fuel-plugin-ceph_multibackend::ceph_primary
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/ceph_primary.pp')

+ 3
- 0
deployment_scripts/puppet/manifests/controller.pp View File

@@ -0,0 +1,3 @@
1
+include fuel-plugin-ceph_multibackend::controller
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/controller.pp')
3
+

+ 6
- 0
deployment_scripts/puppet/manifests/keys.pp View File

@@ -0,0 +1,6 @@
1
+ notice('MODULAR: fuel-plugin-ceph_multibackend/keys.pp')
2
+
3
+ exec { "gather keys":
4
+         command => "ceph-deploy --ceph-conf ~/ceph.conf gatherkeys localhost",
5
+         path    => "/usr/bin",
6
+ }

+ 2
- 0
deployment_scripts/puppet/manifests/osd.pp View File

@@ -0,0 +1,2 @@
1
+include fuel-plugin-ceph_multibackend::osd
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/osd.pp')

+ 2
- 0
deployment_scripts/puppet/manifests/osd_id.pp View File

@@ -0,0 +1,2 @@
1
+include fuel-plugin-ceph_multibackend::osd_id
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/osd_id.pp')

+ 2
- 0
deployment_scripts/puppet/manifests/regions.pp View File

@@ -0,0 +1,2 @@
1
+include fuel-plugin-ceph_multibackend::regions
2
+notice('MODULAR: fuel-plugin-ceph_multibackend/regions.pp')

+ 127
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/partitions.rb View File

@@ -0,0 +1,127 @@
1
+#
2
+# partitions.rb
3
+# BY kwilczynski (https://github.com/kwilczynski/facter-facts/blob/master/partitions.rb)
4
+# This fact provides an alphabetic list of blocks per disk and/or partition,
5
+# partitions per disk and disks.
6
+#
7
+# We support most of generic SATA and PATA disks, plus Hewlett-Packard
8
+# Smart Array naming format ...  This also should work for systems running
9
+# as Virtual Machine guest at least for Xen and KVM ...
10
+#
11
+
12
+if Facter.value(:kernel) == 'Linux'
13
+  # We store a list of disks (or block devices if you wish) here ...
14
+  disks = []
15
+
16
+  # We store number of blocks per disk and/or partition here ...
17
+  blocks = {}
18
+
19
+  # We store a list of partitions on per-disk basis here ...
20
+  partitions = Hash.new { |k,v| k[v] = [] }
21
+
22
+  #
23
+  # Support for the following might not be of interest ...
24
+  #
25
+  # MMC is Multi Media Card which can be either SD or microSD, etc ...
26
+  # MTD is Memory Technology Device also known as Flash Memory
27
+  #
28
+  exclude = %w(backdev.* dm-\d loop mmcblk mtdblock ram ramzswap)
29
+
30
+  #
31
+  # Modern Linux kernels provide "/proc/partitions" in the following format:
32
+  #
33
+  #  major minor  #blocks  name
34
+  #
35
+  #     8        0  244198584 sda
36
+  #     8        1    3148708 sda1
37
+  #     8        2  123804922 sda2
38
+  #     8        3  116214210 sda3
39
+  #     8        4    1028160 sda4
40
+  #
41
+
42
+  # Make regular expression form our patterns ...
43
+  exclude = Regexp.union(*exclude.collect { |i| Regexp.new(i) })
44
+
45
+  #
46
+  # We utilise rely on "cat" for reading values from entries under "/proc".
47
+  # This is due to some problems with IO#read in Ruby and reading content of
48
+  # the "proc" file system that was reported more than once in the past ...
49
+  #
50
+  Facter::Util::Resolution.exec('cat /proc/partitions 2> /dev/null').each_line do |line|
51
+    # Remove bloat ...
52
+    line.strip!
53
+
54
+    # Line of interest should start with a number ...
55
+    next if line.empty? or line.match(/^[a-zA-Z]+/)
56
+
57
+    # We have something, so let us apply our device type filter ...
58
+    next if line.match(exclude)
59
+
60
+    # Only blocks and partitions matter ...
61
+    block     = line.split(/\s+/)[2]
62
+    partition = line.split(/\s+/)[3]
63
+
64
+    if partition.match(/^cciss/)
65
+      #
66
+      # Special case for Hewlett-Packard Smart Array which probably
67
+      # nobody is using any more nowadays anyway ...
68
+      #
69
+      partition = partition.split('/')[1]
70
+
71
+      if match = partition.match(/^([a-zA-Z0-9]+)[pP][0-9]+/)
72
+        # Handle the case when "cciss/c0d0p1" is given ...
73
+        disk = match[1]
74
+      elsif partition.match(/^[a-zA-Z0-9]+/)
75
+        # Handle the case when "cciss/c0d0" is given ...
76
+        disk = partition
77
+      end
78
+    else
79
+      # Take care of any partitions create atop of the
80
+      # Linux Software RAID decies like e.g. /dev/md0, etc.
81
+      if match = partition.match(/^(md\d+)/)
82
+        disk = match[1]
83
+      else
84
+        # Everything else ...
85
+        disk = partition.scan(/^[a-zA-Z]+/)
86
+      end
87
+    end
88
+
89
+    # Convert back into a string value ...
90
+    disk = Array(disk).first.to_s
91
+
92
+    # We have something rather odd that did not parse at all, so ignore ...
93
+    next if disk.empty?
94
+
95
+    # All disks ... This might even be sda, sdaa, sdab, sdac, etc ...
96
+    disks << disk
97
+
98
+    # Store details about number of blocks per disk and/or partition ...
99
+    blocks[partition] = block
100
+
101
+    # A disk is not a partition, therefore we ignore ...
102
+    partitions[disk] << partition unless partition == disk
103
+  end
104
+
105
+  Facter.add('disks') do
106
+    confine :kernel => :linux
107
+    setcode { disks.sort.uniq.join(',') }
108
+  end
109
+
110
+  blocks.each do |k,v|
111
+    Facter.add("blocks_#{k}") do
112
+      confine :kernel => :linux
113
+      setcode { v }
114
+    end
115
+  end
116
+
117
+  partitions.each do |k,v|
118
+    Facter.add("partitions_#{k}") do
119
+      confine :kernel => :linux
120
+
121
+      # To ensure proper sorting order by the interface name ...
122
+      v = v.sort_by { |i| i.scan(/\d+/).shift.to_i }
123
+
124
+      setcode { v.sort.join(',') }
125
+    end
126
+  end
127
+end

+ 10
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/pools.rb View File

@@ -0,0 +1,10 @@
1
+Facter.add(:volume_rbd_pool) do
2
+  setcode do
3
+    volume_rbd_pool = Facter::Util::Resolution.exec('rados lspools | grep volume; echo $?')
4
+  end
5
+end
6
+Facter.add(:image_rbd_pool) do
7
+  setcode do
8
+    image_rbd_pool = Facter::Util::Resolution.exec('rados lspools | grep image; echo $?')
9
+  end
10
+end

+ 5
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/facter/rbd_secret.rb View File

@@ -0,0 +1,5 @@
1
+Facter.add(:rbd_secret) do
2
+  setcode do
3
+    rbd_secret = Facter::Util::Resolution.exec('grep ^rbd_secret_uuid /etc/cinder/cinder.conf | cut -d"=" -f2 | head -1')
4
+  end
5
+end

+ 6
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_all_osd_id.rb View File

@@ -0,0 +1,6 @@
1
+module Puppet::Parser::Functions
2
+newfunction(:get_all_osd_id, :type => :rvalue)  do |args|
3
+  all_osd_id = `find /var/log/lost+found/ -maxdepth 1 | cut -d"/" -f5`
4
+  return all_osd_id
5
+  end
6
+end

+ 21
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_disks.rb View File

@@ -0,0 +1,21 @@
1
+module Puppet::Parser::Functions
2
+newfunction(:get_disks, :type => :rvalue, :doc => <<-EOS
3
+Return a list of disks (node roles are keys) that have the given node role.
4
+example:
5
+  get_disks_list_by_role($node_volumes, 'cinder')
6
+EOS
7
+) do |args|
8
+  disks_metadata, role = args
9
+  disks = Array.new
10
+  disks_metadata.each do |disk|
11
+     disk['volumes'].each do |volume|
12
+       if volume['name'] == role and volume['size'] != 0 then
13
+         disks << disk['name']
14
+       end
15
+      end
16
+    end
17
+   return disks
18
+   end
19
+
20
+end
21
+# vim: set ts=2 sw=2 et :

+ 10
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_osd_id.rb View File

@@ -0,0 +1,10 @@
1
+module Puppet::Parser::Functions
2
+newfunction(:get_osd_id, :type => :rvalue)  do |args|
3
+  device  = args
4
+  dev = device.join("")
5
+  osd_id = `mount | grep #{dev} | cut -d" " -f3 | cut -d"-" -f2`
6
+  osd_id.delete!("\n")
7
+  return osd_id
8
+ end
9
+end
10
+# vim: set ts=2 sw=2 et :

+ 18
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_primary_node.rb View File

@@ -0,0 +1,18 @@
1
+module Puppet::Parser::Functions
2
+newfunction(:get_primary_node, :type => :rvalue, :doc => <<-EOS
3
+Return a primary node fqdn that have specific node role.
4
+example:
5
+  get_target_disk($nodes_hash, 'primaray-controller')
6
+EOS
7
+) do |args|
8
+  node_hash, role = args
9
+  noda = Array.new
10
+  node_hash.each do |node|
11
+       if node['role'] == role then
12
+         noda << node['fqdn']
13
+       end
14
+    end
15
+   return noda
16
+   end
17
+end
18
+# vim: set ts=2 sw=2 et

+ 21
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/lib/puppet/parser/functions/get_target_disk.rb View File

@@ -0,0 +1,21 @@
1
+module Puppet::Parser::Functions
2
+newfunction(:get_target_disk, :type => :rvalue, :doc => <<-EOS
3
+Return a list of disks (node roles are keys) that have the given node role.
4
+example:
5
+  get_target_disk($node_volumes, 'cinder')
6
+EOS
7
+) do |args|
8
+  disks_metadata, role = args
9
+  disks = Array.new
10
+  disks_metadata.each do |disk|
11
+     disk['volumes'].each do |volume|
12
+       if volume['name'] == role and volume['size'] != 0 then
13
+         disks << disk['name']
14
+       end
15
+      end
16
+    end
17
+   return disks
18
+   end
19
+
20
+end
21
+# vim: set ts=2 sw=2 et :

+ 23
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/ceph_auth.pp View File

@@ -0,0 +1,23 @@
1
+class fuel-plugin-ceph_multibackend::ceph_auth {
2
+
3
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
4
+ $ssd_pool=$plugin_settings['ceph_pool']
5
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
6
+
7
+ #image_rbd_pool and volume_rbd_pool from facter, in case of fuel > 9.0
8
+ if $image_rbd_pool == '0' {
9
+   exec { "Update auth caps for ssd pool":
10
+                command => "ceph auth caps client.images osd \"allow class-read object_prefix rbd_children, allow rwx pool=$ssd_pool\" mon \"allow r\"",
11
+        }
12
+ }
13
+ if $volume_rbd_pool == '0' {
14
+   exec { "Update auth caps for volumes client":
15
+                command => "ceph auth caps client.volumes osd \"allow class-read object_prefix rbd_children, allow rwx pool=$ssd_pool, allow rwx pool=volumes, allow rwx pool=images, allow rwx pool=compute\" mon \"allow r\"",
16
+        }
17
+ }
18
+
19
+ exec { "Update auth caps for compute client":
20
+                command => "ceph auth caps client.compute osd \"allow class-read object_prefix rbd_children, allow rwx pool=$ssd_pool, allow rwx pool=volumes, allow rwx pool=images, allow rwx pool=compute\" mon \"allow r\"",
21
+ }
22
+
23
+}

+ 96
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/ceph_primary.pp View File

@@ -0,0 +1,96 @@
1
+class fuel-plugin-ceph_multibackend::ceph_primary {
2
+ include ::cinder::params
3
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
4
+
5
+ $access_hash = hiera(access)
6
+ $pass = $access_hash['password']
7
+ $user = $access_hash['user']
8
+ $tenant = $access_hash['tenant']
9
+ $service_endpoint = hiera(service_endpoint)
10
+ $management_vip = hiera(management_vip)
11
+ $auth_uri = "http://$service_endpoint:5000/"
12
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
13
+ $ssd_pool=$plugin_settings['ceph_pool']
14
+ $ssd_pg_num = $plugin_settings['ceph_ssd_pg_num']
15
+ $HDD_pg_num = $plugin_settings['ceph_HDD_pg_num']
16
+ $file_ma_crush_new_map_exists = inline_template("<% if File.exist?('/var/log/lost+found/ma-crush-new-map') -%>true<% end -%>")
17
+ $file_cinder_type_lock_exists = inline_template("<% if File.exist?('/var/log/lost+found/cinder_ceph_type.lock') -%>true<% end -%>")
18
+
19
+if $management_vip == $service_endpoint { #in case of local keystone
20
+$region='RegionOne'
21
+}
22
+else { #in case of detach keystone
23
+$region=hiera(region)
24
+}
25
+
26
+if $file_ma_crush_new_map_exists == ''
27
+{
28
+  exec { "add HDD region to root":
29
+        command => "ceph osd crush move HDD root=default",
30
+  }
31
+->
32
+  exec { "add SSD region to root":
33
+        command => "ceph osd crush move SSD root=default",
34
+  }
35
+->
36
+  exec { "Get Crushmap":
37
+        command => "ceph osd getcrushmap -o /var/log/lost+found/ma-crush-map",
38
+       }
39
+->
40
+  exec { "Decompile crushmap":
41
+            command => "crushtool -d /var/log/lost+found/ma-crush-map -o /var/log/lost+found/ma-crush-map.txt"
42
+  }
43
+->
44
+  file_line { "Adding ssd rule":
45
+               path => "/var/log/lost+found/ma-crush-map.txt",
46
+               line => "rule ssd {\n        ruleset 255\n        type replicated\n        min_size 1\n        max_size 10\n        step take SSD\n        step choose firstn 0 type osd\n        step emit\n}",
47
+               after => "# rules",
48
+            }
49
+->
50
+  file_line { "Adding HDD rule":
51
+               path => "/var/log/lost+found/ma-crush-map.txt",
52
+               line => "rule HDD {\n        ruleset 254\n        type replicated\n        min_size 1\n        max_size 10\n        step take HDD\n        step choose firstn 0 type osd\n        step emit\n}",
53
+               after => "# rules",
54
+            }
55
+->
56
+  exec { "Compile Crushmap":
57
+               command => "crushtool -c /var/log/lost+found/ma-crush-map.txt -o /var/log/lost+found/ma-crush-new-map",
58
+       }
59
+->
60
+  exec { "Upload Crushmap":
61
+               command => "ceph osd setcrushmap -i /var/log/lost+found/ma-crush-new-map",
62
+       }
63
+->
64
+  exec { "Make ssd pool":
65
+               command => "ceph osd pool create $ssd_pool $ssd_pg_num",
66
+       }
67
+->
68
+  exec { "Make HDD pool":
69
+               command => "ceph osd pool create HDD $HDD_pg_num",
70
+       }
71
+->
72
+
73
+  exec { "Set crushmap ruleset for ssd":
74
+               command => "ceph osd pool set $ssd_pool crush_ruleset 255",
75
+       }
76
+->
77
+  exec { "Set crushmap ruleset for HDD":
78
+               command => "ceph osd pool set HDD crush_ruleset 254",
79
+       }
80
+
81
+   if $file_cinder_type_lock_exists == '' {
82
+
83
+  exec {"cinder type":
84
+               command => "cinder --os-username $user --os-password $pass --os-project-name $tenant --os-tenant-name $tenant --os-auth-url $auth_uri --os-region-name $region type-create SSD_volumes_ceph",
85
+         }->
86
+  exec{"cinder type-key":
87
+               command => "cinder --os-username $user --os-password $pass --os-project-name $tenant --os-tenant-name $tenant --os-auth-url $auth_uri --os-region-name $region type-key SSD_volumes_ceph set volume_backend_name=RBD-fast",
88
+             }
89
+      file {"/var/log/lost+found/cinder_ceph_type.lock":
90
+             path => "/var/log/lost+found/cinder_ceph_type.lock",
91
+             ensure => "file",
92
+  }
93
+
94
+}
95
+}
96
+}

+ 52
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/controller.pp View File

@@ -0,0 +1,52 @@
1
+class fuel-plugin-ceph_multibackend::controller {
2
+
3
+ include ::glance::params
4
+ include ::cinder::params
5
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
6
+ $ssd_pool=$plugin_settings['ceph_pool']
7
+ glance_api_config {
8
+         "glance_store/rbd_store_pool": value => "$ssd_pool";
9
+}
10
+ Glance_api_config<||> ~> Service['glance-api']
11
+
12
+ service { 'glance-api':
13
+    ensure  => 'running',
14
+    enable  => true,
15
+  }
16
+
17
+
18
+ file_line{"RBD-fast backend":
19
+   ensure => present,
20
+   path   => "/etc/cinder/cinder.conf",
21
+   line   => "[RBD-fast]",
22
+ }
23
+ ->
24
+ file_line {"enable second volume backend":
25
+   path  => "/etc/cinder/cinder.conf",
26
+   match => "^enabled_backends = RBD-backend$",
27
+   line  => "enabled_backends = RBD-backend, RBD-fast",
28
+ }
29
+ ->
30
+ cinder_config {
31
+   "RBD-fast/volume_backend_name":      value => "RBD-fast";
32
+   "RBD-fast/rbd_pool":                 value => "$ssd_pool";
33
+   "RBD-fast/rbd_user":                 value => "volumes";
34
+   "RBD-fast/rbd_secret_uuid":          value => "$rbd_secret";
35
+   "RBD-fast/backend_host":             value => "rbd:volumes";
36
+   "RBD-fast/volume_driver":            value => "cinder.volume.drivers.rbd.RBDDriver";
37
+   "RBD-fast/rbd_ceph_conf":            value => "/etc/ceph/ceph.conf";
38
+   "RBD-backend/rbd_pool":              value => "volumes";
39
+ }
40
+
41
+ Cinder_config<||> ~> Service['cinder-volume']
42
+ Cinder_config<||> ~> Service['cinder-scheduler']
43
+ service { 'cinder-volume':
44
+    ensure  => 'running',
45
+    enable  => true,
46
+  }
47
+ service { 'cinder-scheduler':
48
+    ensure  => 'running',
49
+    enable  => true,
50
+  }
51
+
52
+}

+ 1
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/init.pp View File

@@ -0,0 +1 @@
1
+class fuel-plugin-ceph_multibackend {}

+ 31
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/osd.pp View File

@@ -0,0 +1,31 @@
1
+class fuel-plugin-ceph_multibackend::osd {
2
+
3
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
4
+ $node_volumes = hiera('node_volumes', [])
5
+ $dev = get_target_disk($node_volumes, 'ceph-backend2')
6
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
7
+ $file_osd_id_exists = inline_template("<% if File.exist?('/var/log/lost+found/osd_create.lock') -%>true<% end -%>")
8
+
9
+ define process_osd {
10
+
11
+   $part = "partitions_${name}"
12
+   $target_part = inline_template("<%= scope.lookupvar(part) %>")
13
+   $target_part_arr = split($target_part,",")
14
+   $arr_len=size($target_part_arr)
15
+
16
+   exec { "Prepare OSD $name":
17
+             command => "ceph-deploy --ceph-conf /root/ceph.conf osd prepare localhost:$name$arr_len" 
18
+        }
19
+   ->
20
+   exec { "Activate OSD $name":
21
+             command => "ceph-deploy --ceph-conf /root/ceph.conf osd activate localhost:$name$arr_len",
22
+             tries => 2,
23
+        }
24
+}
25
+
26
+if $file_osd_id_exists == ''
27
+{
28
+   process_osd { $dev : }
29
+}
30
+
31
+}

+ 55
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/osd_id.pp View File

@@ -0,0 +1,55 @@
1
+class fuel-plugin-ceph_multibackend::osd_id {
2
+
3
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
4
+ $node_volumes = hiera('node_volumes', [])
5
+ $dev = get_target_disk($node_volumes, 'ceph-backend2')
6
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
7
+ $file_osd_id_exists = inline_template("<% if File.exist?('/var/log/lost+found/osd_create.lock') -%>true<% end -%>")
8
+ $node_name=hiera(node_name)
9
+
10
+ define crush_osd {
11
+
12
+  $osd_id = get_osd_id($name)
13
+  $node_name=hiera(node_name)
14
+
15
+  exec { "Removing ssd $name osd from host HDD bucket":
16
+                 command => "ceph osd crush remove osd.$osd_id $node_name.HDD",
17
+  }
18
+  ->
19
+  exec { "Adding ssd $name item to SSD bucket":
20
+                 command => "ceph osd crush add osd.$osd_id 1.0 host=$node_name.SSD",
21
+  }
22
+ }
23
+
24
+if $file_osd_id_exists == ''
25
+ {
26
+ exec { "Creating new SSD bucket":
27
+                 command => "ceph osd crush add-bucket $node_name.SSD host",
28
+  }
29
+  ->
30
+  exec { "Renaming old bucket":
31
+                 command => "ceph osd crush rename-bucket $node_name $node_name.HDD",
32
+  }
33
+  ->
34
+  exec { "Adding ssd host to SSD region":
35
+                 command => "ceph osd crush move $node_name.SSD region=SSD",
36
+  }
37
+  ->
38
+  exec { "Adding HDD host to HDD region":
39
+                 command => "ceph osd crush move $node_name.HDD region=HDD",
40
+  }
41
+  ->
42
+  crush_osd { $dev : }
43
+  ->
44
+  file {"/var/log/lost+found":
45
+           ensure => 'directory',
46
+  }
47
+  ->
48
+  file {"/var/log/lost+found/osd_create.lock":
49
+           ensure => 'file',
50
+           path => "/var/log/lost+found/osd_create.lock",
51
+  }
52
+
53
+ }
54
+
55
+}

+ 16
- 0
deployment_scripts/puppet/modules/fuel-plugin-ceph_multibackend/manifests/regions.pp View File

@@ -0,0 +1,16 @@
1
+class fuel-plugin-ceph_multibackend::regions {
2
+
3
+ Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
4
+ $plugin_settings = hiera('fuel-plugin-ceph_multibackend')
5
+
6
+  exec { "creating SSD region":
7
+                 command => "ceph osd crush add-bucket SSD region",
8
+  }->
9
+  exec { "creating HDD region":
10
+                 command => "ceph osd crush add-bucket HDD region",
11
+  }
12
+  file {"/var/log/lost+found":
13
+         ensure => 'directory',
14
+  }
15
+
16
+}

+ 73
- 0
deployment_tasks.yaml View File

@@ -0,0 +1,73 @@
1
+- id: fp-ceph_multibackend-regions
2
+  role: ['primary-controller']
3
+  type: puppet
4
+  version: 2.0.0
5
+  parameters:
6
+    puppet_manifest: puppet/manifests/regions.pp
7
+    puppet_modules: puppet/modules:/etc/puppet/modules
8
+    timeout: 360
9
+  requires: [post_deployment_start]
10
+  required_for: [ceph_ready_check,upload_cirros]
11
+- id: fp-ceph_multibackend-keys
12
+  role: ['ceph-backend2']
13
+  type: puppet
14
+  version: 2.0.0
15
+  parameters:
16
+    puppet_manifest: puppet/manifests/keys.pp
17
+    puppet_modules: puppet/modules:/etc/puppet/modules
18
+    timeout: 300
19
+  requires: [post_deployment_start,ceph_create_pools]
20
+  required_for: [upload_cirros,fp-ceph_multibackend-ceph-storage]
21
+- id: fp-ceph_multibackend-ceph-storage
22
+  role: ['ceph-backend2']
23
+  type: puppet
24
+  version: 2.0.0
25
+  parameters:
26
+    puppet_manifest: puppet/manifests/osd.pp
27
+    puppet_modules: puppet/modules:/etc/puppet/modules
28
+    timeout: 1500
29
+  requires: [post_deployment_start,ceph_create_pools,fp-ceph_multibackend-keys]
30
+  required_for: [upload_cirros,fp-ceph_multibackend-ceph-osd-id]
31
+- id: fp-ceph_multibackend-ceph-osd-id
32
+  role: ['ceph-backend2']
33
+  type: puppet
34
+  version: 2.0.0
35
+  parameters:
36
+    puppet_manifest: puppet/manifests/osd_id.pp
37
+    puppet_modules: puppet/modules:/etc/puppet/modules
38
+    timeout: 360
39
+  requires: [post_deployment_start,ceph_create_pools,fp-ceph_multibackend-ceph-storage,fp-ceph_multibackend-regions]
40
+  required_for: [fp-ceph_multibackend-ceph-primary,upload_cirros]
41
+- id: fp-ceph_multibackend-ceph-primary
42
+  role: ['primary-controller']
43
+  type: puppet
44
+  version: 2.0.0
45
+  parameters:
46
+    puppet_manifest: puppet/manifests/ceph_primary.pp
47
+    puppet_modules: puppet/modules:/etc/puppet/modules
48
+    timeout: 360
49
+  requires: [post_deployment_start,ceph_create_pools,fp-ceph_multibackend-ceph-storage,fp-ceph_multibackend-ceph-osd-id]
50
+  required_for: [ceph_ready_check,upload_cirros]
51
+  cross-depends:
52
+    - name: fp-ceph_multibackend-ceph-osd-id
53
+      role: ['ceph-backend2']
54
+- id: fp-ceph_multibackend-ceph-controller
55
+  role: ['primary-controller','controller']
56
+  type: puppet
57
+  version: 2.0.0
58
+  parameters:
59
+    puppet_manifest: puppet/manifests/controller.pp
60
+    puppet_modules: puppet/modules:/etc/puppet/modules
61
+    timeout: 360
62
+  requires: [post_deployment_start,ceph_create_pools]
63
+  required_for: [upload_cirros]
64
+- id: fp-ceph_multibackend-ceph-auth-update
65
+  role: ['primary-controller']
66
+  type: puppet
67
+  version: 2.0.0
68
+  parameters:
69
+    puppet_manifest: puppet/manifests/ceph_auth.pp
70
+    puppet_modules: puppet/modules:/etc/puppet/modules
71
+    timeout: 360
72
+  requires: [post_deployment_start,ceph-compute]
73
+  required_for: [upload_cirros]

+ 21
- 0
environment_config.yaml View File

@@ -0,0 +1,21 @@
1
+attributes:
2
+  metadata:
3
+    group: 'storage'
4
+  ceph_pool:
5
+    value: "SSD"
6
+    label: "Ceph pool name"
7
+    description: "Ceph pool name"
8
+    weight: 50
9
+    type: "text"
10
+  ceph_ssd_pg_num:
11
+    value: "1024"
12
+    label: "Number of Ceph placement group for SSD pool"
13
+    description: "osd_count*100/replica_count rounded to nearest power of two"
14
+    weight: 51
15
+    type: "text"
16
+  ceph_hdd_pg_num:
17
+    value: "8192"
18
+    label: "Number of Ceph placement group for HDD pool"
19
+    description: "osd_count*100/replica_count rounded to nearest power of two"
20
+    weight: 52
21
+    type: "text"

+ 31
- 0
metadata.yaml View File

@@ -0,0 +1,31 @@
1
+# Plugin name
2
+name: fuel-plugin-ceph-multibackend
3
+title: Ceph multibackend for Cinder
4
+# Plugin version
5
+version: 1.8.4
6
+# Description
7
+description: Enables Ceph Multibackend in Cinder
8
+# Required fuel version
9
+fuel_version: ['9.0']
10
+# Groups
11
+groups: ['storage::cinder']
12
+# Licenses
13
+licenses: ['Apache License, Version 2.0']
14
+# Authors
15
+authors:
16
+  - Margarita Shakhova <margarita.shakhova@gmail.com>
17
+homepage: https://github.com/openstack/fuel-plugin-ceph-multibackend
18
+# Change `false` to `true` if the plugin can be installed in the environment
19
+# after the deployment.
20
+is_hotpluggable: true
21
+
22
+# The plugin is compatible with releases in the list
23
+releases:
24
+  - os: ubuntu
25
+    version: mitaka-9.0
26
+    mode: ['ha']
27
+    deployment_scripts_path: deployment_scripts/
28
+    repository_path: repositories/ubuntu
29
+
30
+# Version of plugin package
31
+package_version: '4.0.0'

+ 6
- 0
node_roles.yaml View File

@@ -0,0 +1,6 @@
1
+ceph-backend2:
2
+  name: "Ceph SSD"
3
+  description: Ceph SSD backend
4
+  has_primary: false
5
+  public_ip_required: false
6
+  weight: 100

+ 0
- 0
repositories/centos/.gitkeep View File


+ 0
- 0
repositories/ubuntu/.gitkeep View File


+ 1
- 0
tasks.yaml View File

@@ -0,0 +1 @@
1
+[]

+ 14
- 0
volumes.yaml View File

@@ -0,0 +1,14 @@
1
+volumes:
2
+  - id: "ceph-backend2"
3
+    type: "partition"
4
+    min_size:
5
+      generator: "calc_gb_to_mb"
6
+      generator_args: [2]
7
+    label: "Ceph Glance Backend"
8
+    mount: "none"
9
+    file_system: "xfs"
10
+
11
+volumes_roles_mapping:
12
+  ceph-backend2:
13
+    - {allocate_size: "min", id: "os"}
14
+    - {allocate_size: "all", id: "ceph-backend2"}

Loading…
Cancel
Save