Browse Source

Nitrous plugin will install Base OS, multipath options, create VMs and their network settings for Fuel provisioning and deployment.

US809843

Change-Id: I18c8c10021da170ad9aaa29fe1410c4b4072ece5
Dinesh Yadav 2 years ago
parent
commit
df37614679

+ 202
- 0
LICENSE View File

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

+ 23
- 0
components.yaml View File

@@ -0,0 +1,23 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#  
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+- name: additional_service:nitrous
16
+  compatible:
17
+    - name: 'hypervisor:kvm'
18
+    - name: 'hypervisor:qemu'
19
+  requires: []
20
+  incompatible:
21
+    - name: 'hypervisor:vmware'
22
+  label: "Nitrous"
23
+  description: "Configures bare metal servers and Fuel deployable VMs."

+ 25
- 0
deployment_scripts/puppet/manifests/nitrous.pp View File

@@ -0,0 +1,25 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+notice('MODULAR: nitrous/nitrous.pp')
16
+
17
+include nitrous
18
+
19
+class { 'nitrous::packages': }
20
+class { 'nitrous::config': }
21
+
22
+ exec { '/etc/ops_create.sh' :
23
+   path    => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
24
+   require => Class['nitrous'],
25
+ }

+ 0
- 0
deployment_scripts/puppet/modules/nitrous/files/.gitkeep View File


+ 26
- 0
deployment_scripts/puppet/modules/nitrous/lib/puppet/parser/functions/find_node.rb View File

@@ -0,0 +1,26 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+module Puppet::Parser::Functions
16
+  newfunction(:find_node, :type => :rvalue, :doc => <<-EOS
17
+EOS
18
+  ) do |args|
19
+    nodes = args[0]
20
+    required_name = args[1]
21
+    fail "Nodes should be an Array! Got: #{nodes.inspect}" unless nodes.is_a? Array
22
+    nodes.find do |node|
23
+      node['mac_address'] == required_name
24
+    end
25
+  end
26
+end

+ 68
- 0
deployment_scripts/puppet/modules/nitrous/lib/puppet/parser/functions/opsvm_filter.rb View File

@@ -0,0 +1,68 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+module Puppet::Parser::Functions
16
+  newfunction(:opsvm_filter, :type => :rvalue, :doc => <<-EOS
17
+Filter the ops_server_config array and convert to the structure readable by the opsvm script.
18
+  EOS
19
+  ) do |args|
20
+    ops_server_config = args[0]
21
+    pxe_br = args[2]
22
+    kvm_filter = args[1]
23
+    mgt_br = args[3]
24
+    fail "The ops_server_config should be an Array! Got: #{ops_server_config}" unless ops_server_config.is_a? Array
25
+    kvm_hosts = []
26
+    ops_server_config.each do |op_host|
27
+      next unless op_host['kvm'] == kvm_filter
28
+
29
+      host_hash = {}
30
+      host_hash['name'] = op_host['name'] if op_host['name']
31
+      host_hash['cpu'] = op_host.fetch('cpu', 2)
32
+      host_hash['ram'] = op_host.fetch('ram', 2).to_i * 1024
33
+
34
+      networks = []
35
+      pxe_network = {}
36
+      pxe_network['network'] = "#{pxe_br}"
37
+      pxe_network['mac'] = op_host['mac_address']
38
+      networks << pxe_network
39
+      mgmt_network = {}
40
+      mgmt_network['network'] = "#{mgt_br}"
41
+      networks << mgmt_network
42
+
43
+      host_hash['networks'] = networks
44
+
45
+      volumes = []
46
+      app_volume = {}
47
+      app_volume['size'] = op_host.fetch('app_disk', 10).to_i * 1024 * 1024 * 1024
48
+      app_volume['name'] = op_host['app_volume_name']
49
+      app_volume['name'] = "app_disk_#{host_hash['name']}" unless app_volume['name']
50
+      volumes << app_volume
51
+      os_volume = {}
52
+      os_volume['size'] = op_host.fetch('os_disk', 10).to_i * 1024 * 1024 * 1024
53
+      os_volume['name'] = op_host['os_volume_name']
54
+      os_volume['name'] = "os_disk_#{host_hash['name']}" unless os_volume['name']
55
+      volumes << os_volume
56
+      log_volume = {}
57
+      log_volume['size'] = op_host.fetch('log_disk', 10).to_i * 1024 * 1024 * 1024
58
+      log_volume['name'] = op_host['log_volume_name']
59
+      log_volume['name'] = "log_disk_#{host_hash['name']}" unless log_volume['name']
60
+      volumes << log_volume
61
+
62
+      host_hash['volumes'] = volumes
63
+
64
+      kvm_hosts << host_hash
65
+    end
66
+    kvm_hosts
67
+  end
68
+end

+ 198
- 0
deployment_scripts/puppet/modules/nitrous/lib/puppet/provider/opsvm_pool/virsh.rb View File

@@ -0,0 +1,198 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+require 'rexml/document'
16
+require 'tempfile'
17
+
18
+Puppet::Type.type(:opsvm_pool).provide(:virsh) do
19
+
20
+  commands :virsh => 'virsh'
21
+
22
+  def self.instances
23
+    list = virsh('-q', 'pool-list', '--all')
24
+    list.split(/\n/)[0..-1].map do |line|
25
+      values = line.strip.split(/ +/)
26
+      new(
27
+        :name      => values[0],
28
+        :active    => values[1].match(/^act/)? :true : :false,
29
+        :autostart => values[2].match(/no/) ? :false : :true,
30
+        :provider  => self.name
31
+      )
32
+    end
33
+  end
34
+
35
+  def status
36
+    list = virsh('-q', 'pool-list', '--all')
37
+    list.split(/\n/)[0..-1].detect do |line|
38
+      fields = line.strip.split(/ +/)
39
+      if (fields[0].match(/^#{resource[:name]}$/))
40
+        return :present
41
+      end
42
+    end
43
+  return :absent
44
+
45
+  end
46
+
47
+  def self.prefetch(resources)
48
+    pools = instances
49
+    resources.keys.each do |name|
50
+      if provider = pools.find{ |pool| pool.name == name}
51
+        resources[name].provider = provider
52
+      end
53
+    end
54
+  end
55
+
56
+  def create
57
+    defined = self.definePool
58
+    if !defined
59
+      # for some reason the pool has not been defined
60
+      # malformed xml
61
+      # or failed tmpfile creationa
62
+      # or ?
63
+      raise Puppet::Error.new("Unable to define the pool")
64
+    end
65
+    self.buildPool
66
+
67
+    @property_hash[:ensure] = :present
68
+    should_active = @resource.should(:active)
69
+    unless self.active == should_active
70
+      self.active = should_active
71
+    end
72
+    should_autostart = @resource.should(:autostart)
73
+    unless self.autostart == should_autostart
74
+      self.autostart = should_autostart
75
+    end
76
+  end
77
+
78
+  def destroy
79
+    self.destroyPool
80
+    @property_hash.clear
81
+  end
82
+
83
+  def definePool
84
+    result = false
85
+    begin
86
+      tmpFile = Tempfile.new("pool.#{resource[:name]}")
87
+      xml = buildPoolXML resource
88
+      tmpFile.write(xml)
89
+      tmpFile.rewind
90
+      virsh('pool-define', tmpFile.path)
91
+      result = true
92
+    ensure
93
+      tmpFile.close
94
+      tmpFile.unlink
95
+    end
96
+    return result
97
+  end
98
+
99
+  def buildPool
100
+    begin
101
+      virsh('pool-build', '--pool', resource[:name])
102
+    rescue
103
+      # Unable to build the pool maybe because
104
+      # it is already defined (it this case we should consider
105
+      # to continue execution)
106
+      # or there is permission issue on the fs
107
+      # or ?
108
+      # in these cases we should consider raising something
109
+      notice("Unable to build the pool")
110
+    end
111
+
112
+  end
113
+
114
+  def destroyPool
115
+    begin
116
+      virsh('pool-destroy', resource[:name])
117
+    rescue Puppet::ExecutionFailure => e
118
+      notice(e.message)
119
+    end
120
+    virsh('pool-undefine', resource[:name])
121
+  end
122
+
123
+  def active
124
+    @property_hash[:active] || :false
125
+  end
126
+
127
+  def active=(active)
128
+    if (active == :true)
129
+      virsh 'pool-start', '--pool', resource[:name]
130
+      @property_hash[:active] = 'true'
131
+    else
132
+      virsh 'pool-destroy', '--pool', resource[:name]
133
+      @property_hash[:active] = 'false'
134
+    end
135
+  end
136
+
137
+  def autostart
138
+    @property_hash[:autostart] || :false
139
+  end
140
+
141
+  def autostart=(autostart)
142
+    if (autostart == :true)
143
+      virsh 'pool-autostart', '--pool', resource[:name]
144
+      @property_hash[:autostart] = :true
145
+    else
146
+      virsh 'pool-autostart', '--pool', resource[:name], '--disable'
147
+      @property_hash[:autostart] = :false
148
+    end
149
+  end
150
+
151
+
152
+  def exists?
153
+    @property_hash[:ensure] != :absent
154
+  end
155
+
156
+  def buildPoolXML(resource)
157
+    root = REXML::Document.new
158
+    pool = root.add_element 'pool', {'type' => resource[:type]}
159
+    name = pool.add_element 'name'
160
+    name.add_text resource[:name]
161
+
162
+    srcHost = resource[:sourcehost]
163
+    srcPath = resource[:sourcepath]
164
+    srcDev = resource[:sourcedev]
165
+    srcName = resource[:sourcename]
166
+    srcFormat = resource[:sourceformat]
167
+
168
+    if (srcHost || srcPath || srcDev || srcName || srcFormat)
169
+      source = pool.add_element 'source'
170
+
171
+      source.add_element('host', {'name' => srcHost})     if srcHost
172
+      source.add_element('dir', {'path' => srcPath})      if srcPath
173
+      source.add_element('format', {'type' => srcFormat}) if (srcFormat)
174
+
175
+      if (srcDev)
176
+        Array(srcDev).each do |dev|
177
+          source.add_element('device', {'path' => dev})
178
+        end
179
+      end
180
+
181
+      if (srcName)
182
+        srcNameEl = source.add_element 'name'
183
+        srcNameEl.add_text srcName
184
+      end
185
+    end
186
+
187
+    target = resource[:target]
188
+    if target
189
+      targetEl = pool.add_element 'target'
190
+      targetPathEl = targetEl.add_element 'path'
191
+      targetPathEl.add_text target
192
+    end
193
+
194
+    return root.to_s
195
+
196
+  end # buildPoolXML
197
+
198
+end

+ 118
- 0
deployment_scripts/puppet/modules/nitrous/lib/puppet/type/opsvm_pool.rb View File

@@ -0,0 +1,118 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+Puppet::Type.newtype(:opsvm_pool) do
16
+@doc = %q{Manages opsvm pools
17
+
18
+          Example : 
19
+            opsvm_pool { 'default' : 
20
+              ensure => absent
21
+            }
22
+
23
+            opsvm_pool { 'mydirpool' :
24
+              ensure    => present,
25
+              active    => true,
26
+              autostart => true,
27
+              type      => 'dir',
28
+              target    => '/tmp/mypool',
29
+            }
30
+
31
+            opsvm_pool { 'vm_storage':
32
+              ensure    => 'present',
33
+              active    => 'true',
34
+              type      => 'logical',
35
+              sourcedev => ['/dev/sdb', '/dev/sdc'],
36
+              target    => '/dev/vg0'
37
+            }
38
+
39
+
40
+        }
41
+
42
+  ensurable do
43
+
44
+    desc 'Creation or the removal of a pool`present` means that the pool will be defined and created
45
+    `absent` means that the pool will be purged from the system'
46
+
47
+    defaultto(:present)
48
+    newvalue(:present) do
49
+      provider.create
50
+    end
51
+
52
+    newvalue(:absent) do
53
+      if (provider.exists?)
54
+        provider.destroy
55
+      end
56
+    end
57
+
58
+    def retrieve
59
+      provider.status
60
+    end
61
+
62
+  end
63
+
64
+  newparam(:name, :namevar => true) do
65
+    desc 'The pool name.'
66
+    newvalues(/^\S+$/)
67
+  end
68
+
69
+  newparam(:type) do
70
+    desc 'The pool type.'
71
+    newvalues(:dir, :netfs, :fs, :logical, :disk, :iscsi, :mpath, :rbd, :sheepdog)
72
+  end
73
+
74
+  newparam(:sourcehost) do
75
+    desc 'The source host.'   
76
+    newvalues(/^\S+$/)
77
+  end
78
+
79
+  newparam(:sourcepath) do
80
+    desc 'The source path.'
81
+    newvalues(/(\/)?(\w)/)
82
+  end
83
+
84
+  newparam(:sourcedev) do
85
+    desc 'The source device.'
86
+    newvalues(/(\/)?(\w)/)
87
+  end
88
+
89
+  newparam(:sourcename) do
90
+    desc 'The source name.'
91
+    newvalues(/^\S+$/)
92
+  end
93
+
94
+  newparam(:sourceformat) do
95
+    desc 'The source format.'
96
+    newvalues(:auto, :nfs, :glusterfs, :cifs)
97
+  end
98
+  
99
+  newparam(:target) do
100
+    desc 'The target.'
101
+    newvalues(/(\/)?(\w)/)
102
+  end
103
+
104
+  newproperty(:active) do
105
+    desc 'Whether the pool should be started.'
106
+    defaultto(:true)
107
+    newvalues(:true)
108
+    newvalues(:false)
109
+  end
110
+
111
+  newproperty(:autostart) do
112
+    desc 'Whether the pool should be autostarted.'
113
+    defaultto(:false)
114
+    newvalues(:true)
115
+    newvalues(:false)
116
+  end
117
+
118
+end

+ 65
- 0
deployment_scripts/puppet/modules/nitrous/manifests/config.pp View File

@@ -0,0 +1,65 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+class nitrous::config {
16
+ 
17
+  $ops_hosts = $::nitrous::kvm_hosts
18
+  $ops_endpoints_keys = $::nitrous::endpoints_keys
19
+  $pool_type = $::nitrous::opsvm_pool_type
20
+
21
+  file { 'opsvms_settings' :
22
+    ensure  => 'present',
23
+    path    => '/etc/hiera/plugins/fuel_opsvms.yaml',
24
+    owner   => 'root',
25
+    group   => 'root',
26
+    mode    => '0644',
27
+    content => inline_template('<%= require "yaml"; YAML.dump(@ops_hosts) + "\n" %>'),
28
+  }
29
+
30
+  file_line { 'kvm_user':
31
+    path  => '/etc/libvirt/qemu.conf',
32
+    line  => 'user = "root"',
33
+    match => '#user = "root"',
34
+  } ~>
35
+
36
+  service {'libvirtd':
37
+    ensure => 'running',
38
+  }
39
+
40
+  opsvm_pool { 'default' :
41
+    ensure => present,
42
+    type   => "$pool_type",
43
+    active => true,
44
+    target => '/opt/opsvm',
45
+  }
46
+
47
+  if !($::nitrous::node_name == '') {
48
+    exec { "/bin/hostname $::nitrous::node_name" :
49
+      path => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
50
+    }
51
+  } else {
52
+      warning('Node is not available, please check Nitrous config.')
53
+    }
54
+
55
+  puppet::ops_endpoints_keys::keys { $ops_endpoints_keys: }
56
+  define puppet::ops_endpoints_keys::keys ($ops_endpoints_keys = $title) {
57
+    if ($::nitrous::net_bridge == 'linuxbr') {
58
+      opsvm_net { "$ops_endpoints_keys" :
59
+        forward_mode => 'bridge',
60
+        bridge       => "$ops_endpoints_keys",
61
+        autostart    => true,
62
+      } 
63
+    }
64
+  } 
65
+}

+ 125
- 0
deployment_scripts/puppet/modules/nitrous/manifests/init.pp View File

@@ -0,0 +1,125 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+class nitrous {
16
+
17
+  $hiera_values = hiera_hash('nitrous', {})
18
+  $nitrous_config = $hiera_values['node_additional_config']
19
+  $nodes_hash = parseyaml($nitrous_config)
20
+  $nodes_array = pick($nodes_hash['nodes'], [])
21
+
22
+  $authors = 'Dinesh Yadav(dy270k@att.com)'
23
+  $plugin_version = $hiera_values['metadata']['plugin_version']
24
+
25
+  $agent_conf = '/etc/puppet/puppet.conf'
26
+  $env_conf = '/etc/rc.local'
27
+  $libvirt_conf = '/etc/libvirt'
28
+  $line = $hiera_values['puppet_master_entry']
29
+  $proxy_line = $hiera_values['aic_env_proxy']
30
+  $site_yaml = '/etc/hiera/plugins/site.yaml'
31
+
32
+  $network_scheme = hiera_hash('network_scheme', {})
33
+  $net_bridge = $hiera_values['selective_default_bridge']
34
+  $endpoints = pick($network_scheme['endpoints'])
35
+  $endpoints_keys = keys($endpoints)
36
+  $node_nic = upcase($::macaddress_br_fw_admin)
37
+  $bond_nic = upcase($::macaddress_bond0)
38
+
39
+  $nitrous_node = find_node($nodes_array, $node_nic)
40
+  $node_name = downcase($nitrous_node['name'])
41
+  $kvm_hostname = "$node_name"
42
+  $ops_vms_array = parseyaml($hiera_values["ops_server_config"])
43
+
44
+  $initiator_config='/etc/iscsi/initiatorname.iscsi'
45
+  $storage = $nitrous_node['storage']
46
+  $luns = $storage['luns']
47
+  $storage_type = $storage['initiator_name']
48
+  $storage_array = pick($nodes_hash['storage'], [])
49
+  $target_node = $storage_array['targets']
50
+  $opsvm_pool_type = $hiera_values['selective_opsvm_pool']
51
+
52
+  $kvm_hosts = opsvm_filter($ops_vms_array, $kvm_hostname, br-fw-admin, br-mgmt)
53
+  $vlan_tag = split($stg_nm, '\.')
54
+  $vlan_id = $::nitrous::vlan_tag[1]
55
+  $nic_bond = pick($network_scheme['transformations'])
56
+  $mgmt = $nic_bond[6]
57
+  $mgmt_brg = pick($mgmt['bridge'])
58
+  $mgmt_nm = pick($mgmt['name'])
59
+  $stg = $nic_bond[7]
60
+  $stg_brg = pick($stg['bridge'])
61
+  $stg_nm = pick($stg['name'])
62
+  $prv = $nic_bond[8]
63
+  $prv_brg = pick($prv['bridge'])
64
+  $prv_nm = pick($prv['name'])
65
+
66
+  if !($proxy_line == 'undef') {
67
+    file_line { 'env_proxy':
68
+      ensure  => 'present',
69
+      line    => "export http_proxy=$:nitrous::proxy_line",
70
+      path    => "$::nitrous::env_conf",
71
+   }
72
+  }
73
+
74
+  exec { "src_bash":
75
+    command => "bash -c 'source $env_conf'",
76
+    path    => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
77
+  }
78
+
79
+  file_line { 'agent_conf' :
80
+    ensure  => 'present',
81
+    line    => "server = $line",
82
+    path    => "$agent_conf",
83
+    after   => 'pluginsync = True',
84
+  }
85
+
86
+  file { "$site_yaml":
87
+    ensure  => 'present',
88
+    owner   => 'root',
89
+    group   => 'root',
90
+    mode    => '0766',
91
+    content => template('nitrous/nitrous.yaml.erb'),
92
+  }
93
+
94
+  if !($vlan_id == '') {
95
+    file { '/usr/local/bin/rm_vlan.sh':
96
+      ensure  => 'present',
97
+      owner   => 'root',
98
+      group   => 'root',
99
+      mode    => '0766',
100
+      content => template('nitrous/vlan.erb'),
101
+    }
102
+   exec { 'remove_vlan':
103
+     command => '/usr/local/bin/rm_vlan.sh',
104
+     path    => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
105
+   } 
106
+   exec { 'add_brg':
107
+     command => "brctl addif br-mgmt bond0",
108
+     path    => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
109
+   } 
110
+  }
111
+
112
+  file { '/usr/bin/opsvm':
113
+    ensure  => 'present',
114
+    owner   => 'root',
115
+    group   => 'root',
116
+    mode    => '0766',
117
+    content => template('nitrous/opsvm.erb'),
118
+  }
119
+
120
+  anchor {'nitrous_begin' : } ->
121
+  Class['nitrous::packages'] ->
122
+  Class['nitrous::config'] ->
123
+  anchor {'nitrous_end' : }
124
+
125
+ }

+ 46
- 0
deployment_scripts/puppet/modules/nitrous/manifests/opsvm_net.pp View File

@@ -0,0 +1,46 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+define nitrous::opsvm_net (
16
+  $bridge,
17
+  $forward_mode     = 'bridge',
18
+  $virtualport_type = undef,
19
+  $portgroups       = [],
20
+  $autostart        = true,
21
+ ) {
22
+  exec {"opsvm-network-${name}":
23
+    command  => join(['f=$(mktemp) && echo "',
24
+                      template('nitrous/netbr.erb'),
25
+                      '" > $f && virsh net-define $f && rm $f']),
26
+    provider => 'shell',
27
+    creates  => "${nitrous::libvirt_conf}/qemu/networks/${name}.xml",
28
+  }
29
+
30
+  if ($autostart) {
31
+    exec {"opsvm-network-autostart-${name}":
32
+      command => "virsh net-autostart ${name}",
33
+      provider => 'shell',
34
+      creates => "${nitrous::libvirt_conf}/qemu/networks/autostart/${name}.xml",
35
+      require => Exec["opsvm-network-${name}"],
36
+   }
37
+
38
+  exec {"opsvm-network-start-${name}":
39
+    command => "virsh net-start ${name}",
40
+    provider => 'shell',
41
+    unless  => "virsh net-list | tail -n +3 | cut -d ' ' -f 2 | \
42
+                 grep -q ^${name}$",
43
+    require => Exec["opsvm-network-${name}"],
44
+  }
45
+ }
46
+}

+ 24
- 0
deployment_scripts/puppet/modules/nitrous/manifests/packages.pp View File

@@ -0,0 +1,24 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+class nitrous::packages {
16
+ 
17
+# Resources defaults
18
+
19
+  $required_pkgs = ['qemu-kvm', 'libvirt-bin', 'db-util', 'db5.3-util', 'debhelper', 'dh-apparmor', 'gettext', 'ieee-data', 'intltool-debian', 'libcroco3', 'libunistring0', 'open-iscsi', 'po-debconf', 'python-crypto', 'python-ecdsa', 'python-libvirt', 'python-markupsafe', 'python-netaddr', 'python-netifaces', 'python-paramiko', 'qemu-utils', 'sasl2-bin', 'libasprintf-dev', 'libgettextpo-dev', 'libmail-sendmail-perl', 'sharutils','virtinst', 'ebtables', 'dnsmasq', 'libpcre3', 'cloud-guest-utils', 'cloud-image-utils', 'cloud-utils', 'euca2ools', 'fabric', 'ipmitool', 'genisoimage', 'libattr1', 'libreadline6', 'libsqlite3-0','mime-support', 'module-assistant', 'openvswitch-datapath-source', 'python-ipaddr', 'python-lxml', 'python-mako','python-nose', 'python-oauth', 'python-oauthlib', 'python-pexpect', 'python-requestbuilder', 'python-requests-oauthlib', 'readline-common' ]
20
+
21
+  package { $required_pkgs :
22
+    ensure => installed 
23
+  }
24
+}

+ 27
- 0
deployment_scripts/puppet/modules/nitrous/templates/netbr.erb View File

@@ -0,0 +1,27 @@
1
+<%=
2
+# Copyright (c) 2016 AT&T Inc.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+# http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+%>
16
+<network>
17
+  <name><%= @name %></name>
18
+  <% if @forward_mode -%>
19
+  <forward mode='<%= @forward_mode %>'/>
20
+  <% end -%>
21
+  <% if @bridge -%>
22
+  <bridge name='<%= @bridge %>'/>
23
+  <% end -%>
24
+  <% if @virtualport_type -%>
25
+  <virtualport type='<%= @virtualport_type %>'/>
26
+  <% end -%>
27
+</network>

+ 15
- 0
deployment_scripts/puppet/modules/nitrous/templates/nitrous.yaml.erb View File

@@ -0,0 +1,15 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+# 
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+# 
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+# 
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+---
15
+<%= @nitrous_config %>

+ 692
- 0
deployment_scripts/puppet/modules/nitrous/templates/opsvm.erb View File

@@ -0,0 +1,692 @@
1
+#!/usr/bin/env ruby
2
+#
3
+# Copyright (c) 2016 AT&T Inc.
4
+# 
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# 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, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+require 'optparse'
18
+require 'yaml'
19
+require 'open3'
20
+require 'securerandom'
21
+
22
+# Libvirt API interface functions
23
+module LibVirt
24
+
25
+  # Delete a domain by it's name
26
+  # @param [String] domain_name
27
+  def domain_delete(domain_name)
28
+    commands = [
29
+        'virsh',
30
+        'undefine',
31
+        domain_name,
32
+    ]
33
+    debug "Domain delete: #{commands.join ' '}"
34
+    _output, success = run commands
35
+    error "Failed to delete domain: #{domain_name}" unless success
36
+    success
37
+  end
38
+
39
+  # Start a domain by it's name
40
+  # @param [String] domain_name
41
+  def domain_start(domain_name)
42
+    commands = [
43
+        'virsh',
44
+        'start',
45
+        domain_name,
46
+    ]
47
+    debug "Domain start: #{commands.join ' '}"
48
+    _output, success = run commands
49
+    warning "Failed to start domain: #{domain_name}" unless success
50
+    success
51
+  end
52
+
53
+  # Set autostart for a domain by it's name
54
+  # @param [String] domain_name
55
+  def domain_autostart(domain_name)
56
+    commands = [
57
+        'virsh',
58
+        'autostart',
59
+        domain_name,
60
+    ]
61
+    debug "Domain autostart: #{commands.join ' '}"
62
+    _output, success = run commands
63
+    warning "Failed to autostart domain: #{domain_name}" unless success
64
+    success
65
+  end
66
+
67
+  # Unset autostart for a domain by it's name
68
+  # @param [String] domain_name
69
+  def domain_no_autostart(domain_name)
70
+    commands = [
71
+        'virsh',
72
+        '--disable',
73
+        'autostart',
74
+        domain_name,
75
+    ]
76
+    debug "Domain no autostart: #{commands.join ' '}"
77
+    _output, success = run commands
78
+    warning "Failed to stop autostart domain: #{domain_name}" unless success
79
+    success
80
+  end
81
+
82
+  # Stop a domain by it's name
83
+  # @param [String] domain_name
84
+  def domain_stop(domain_name)
85
+    commands = [
86
+        'virsh',
87
+        'destroy',
88
+        domain_name,
89
+    ]
90
+    debug "Domain stop: #{commands.join ' '}"
91
+    _output, success = run commands
92
+    warning "Failed to stop domain: #{domain_name}" unless success
93
+    success
94
+  end
95
+
96
+  # Get a list of all defined domains, states and ids (if running)
97
+  # @return [Hash<String => Hash>]
98
+  def domain_list
99
+    command = %w(virsh list --all)
100
+    domains = {}
101
+    output, success = run command
102
+    error 'Failed to get domain list! Is you libvirt service running?' unless success
103
+    output.split("\n").each do |line|
104
+      line_array = line.split
105
+      id = line_array[0]
106
+      name = line_array[1]
107
+      state = line_array[2..-1]
108
+      next unless id and name and state
109
+      id = id.chomp.strip
110
+      name = name.chomp.strip
111
+      state = state.join(' ').chomp.strip
112
+      next if id == 'Id'
113
+      domain_hash = {}
114
+      domain_hash['state'] = state
115
+      domain_hash['id'] = id unless id == '-'
116
+      domains[name] = domain_hash
117
+    end
118
+    domains
119
+  end
120
+
121
+  # Check if a domain is started for it's name
122
+  # @param [String] domain_name
123
+  # @return [true,false]
124
+  def domain_started?(domain_name)
125
+    domain_state(domain_name) == 'running'
126
+  end
127
+
128
+  # Get a state of a domain by it's name
129
+  # @param [String] domain_name
130
+  # @return [String]
131
+  def domain_state(domain_name)
132
+    domain_attributes = domain_list.fetch domain_name, {}
133
+    domain_attributes.fetch 'state', 'missing'
134
+  end
135
+
136
+  # Check if a domain is defined by it's name
137
+  # @param [String] domain_name
138
+  # @return [true,false]
139
+  def domain_defined?(domain_name)
140
+    domain_list.key? domain_name
141
+  end
142
+
143
+  # Create a new libvirt volume if a pool
144
+  # @param [String] volume_name
145
+  # @param [String] virt_type
146
+  # @param [String,Numeric] volume_size
147
+  # @return [true,false] success?
148
+  def volume_create(volume_name, virt_type, volume_size)
149
+    commands = [
150
+        'virsh',
151
+        'vol-create-as',
152
+        virt_type,
153
+        volume_name,
154
+        volume_size,
155
+    ]
156
+
157
+    debug "Volume create: #{commands.join ' '}"
158
+    _output, success = run commands
159
+    error "Failed to create volume: #{volume_name}" unless success
160
+    success
161
+  end
162
+
163
+  # Get a path of a volume in a pool by it's name
164
+  # Returns nil if there is no such volume
165
+  # @param [String] volume_name
166
+  # @param [String] pool_name
167
+  # @return [String,nil]
168
+  def volume_path(volume_name, pool_name)
169
+    volume_list(pool_name).fetch(volume_name, nil)
170
+  end
171
+
172
+  # Delete a volume in a pool by its name
173
+  # @param [String] volume_name
174
+  # @param [String] pool_name
175
+  # @return [true,false] success?
176
+  def volume_delete(volume_name, pool_name)
177
+    commands = [
178
+        'virsh',
179
+        'vol-delete',
180
+        '--pool', pool_name,
181
+        volume_name
182
+    ]
183
+    debug "Delete volume: #{commands.join ' '}"
184
+    _output, success = run commands
185
+    error "Failed to delete volume: #{volume_name}" unless success
186
+    success
187
+  end
188
+
189
+  # List all volumes in a pool
190
+  # @param [String] pool_name
191
+  # @return [Hash<String => String>] Volume name and path
192
+  def volume_list(pool_name)
193
+    commands = [
194
+        'virsh',
195
+        'vol-list',
196
+        '--pool', pool_name,
197
+    ]
198
+    output, success = run commands
199
+    error "Failed to get volume list of pool: #{pool_name}!" unless success
200
+    volumes = {}
201
+    output.split("\n").each do |line|
202
+      line_array = line.split
203
+      name = line_array[0]
204
+      path = line_array[1]
205
+      next unless name and path
206
+      name = name.chomp.strip
207
+      path = path.chomp.strip
208
+      next if name == 'Name'
209
+      volumes[name] = path
210
+    end
211
+    volumes
212
+  end
213
+
214
+  # Check if a volume in a pool is defined
215
+  # @param [String] volume_name
216
+  # @param [String] pool_name
217
+  # @return [true,false]
218
+  def volume_defined?(volume_name, pool_name)
219
+    volume_list(pool_name).key? volume_name
220
+  end
221
+
222
+  # Generate a new serial for a disk
223
+  # @return [String]
224
+  def generate_disk_serial
225
+    ::SecureRandom.uuid
226
+  end
227
+
228
+  # Create a new domain using it's attributes structure
229
+  # @param [String] domain_name
230
+  # @param [Hash] domain_attributes
231
+  # @return [true,false] success?
232
+  def domain_create(domain_name, domain_attributes)
233
+    name = domain_attributes.fetch 'name', domain_name
234
+    fail 'There is no domain name!' unless name
235
+    ram = domain_attributes.fetch 'ram', '1024'
236
+    cpu = domain_attributes.fetch 'cpu', '2'
237
+    volumes = domain_attributes.fetch 'volumes', {}
238
+    networks = domain_attributes.fetch 'networks', {}
239
+    commands = [
240
+        'virt-install',
241
+        '--name', name,
242
+        '--ram', ram,
243
+        '--vcpus', "#{cpu},cores=#{cpu}",
244
+        '--os-type', 'linux',
245
+        '--virt-type', options[:virt],
246
+        '--pxe',
247
+        '--boot', 'network,hd',
248
+        '--noautoconsole',
249
+        '--graphics', 'vnc,listen=0.0.0.0',
250
+        '--autostart',
251
+    ]
252
+
253
+    volumes.each do |volume|
254
+      volume['serial'] = generate_disk_serial unless volume['serial']
255
+      volume['cache'] = 'none' unless volume['cache']
256
+      volume['bus'] = 'virtio' unless volume['bus']
257
+
258
+      unless volume['path']
259
+        warning "Volume: #{volume.inspect} has no path defined! Skipping!"
260
+        next
261
+      end
262
+
263
+      disk_string = volume.reject do |attribute_name, _attribute_value|
264
+        %w(size name).include? attribute_name
265
+      end.map do |attribute_name, attribute_value|
266
+        "#{attribute_name}=#{attribute_value}"
267
+      end.join ','
268
+
269
+      commands += ['--disk', disk_string]
270
+    end
271
+
272
+    networks.each do |network|
273
+      network['model'] = 'virtio' unless network['model']
274
+
275
+      unless network['network']
276
+        warning "Network: #{network.inspect} has no 'network' defined! Skipping!"
277
+        next
278
+      end
279
+
280
+      network_string = network.map do |attribute_name, attribute_value|
281
+        "#{attribute_name}=#{attribute_value}"
282
+      end.join ','
283
+      commands += ['--network', network_string]
284
+    end
285
+
286
+    debug "Domain create: #{commands.join ' '}"
287
+    _output, success = run commands
288
+    error "Failed to create the domain: #{name}" unless success
289
+    success
290
+  end
291
+end
292
+
293
+# Configuration and settings related functions
294
+module Configuration
295
+
296
+  # The structure describing the domains to manage
297
+  # @return [Hash]
298
+  def domain_settings
299
+    error "There is no YAML file: #{options[:yaml]}" unless File.exists? options[:yaml]
300
+    begin
301
+      data = YAML.load_file options[:yaml]
302
+    rescue => exception
303
+      error "Could not read YAML file: #{options[:yaml]}: #{exception}"
304
+    end
305
+    error "Data format of YAML file: #{options[:yaml]} is incorrect!" unless data.is_a? Array
306
+    data
307
+  end
308
+
309
+  # Console options structure
310
+  # @return [Hash]
311
+  def options
312
+    return @options if @options
313
+    @options = {}
314
+
315
+    OptionParser.new do |opts|
316
+      opts.banner = 'opsvm [options] (domain)'
317
+
318
+      opts.on('-D', '--delete', 'Delete the created domains and volumes') do
319
+        @options[:delete] = true
320
+      end
321
+
322
+      opts.on('-R', '--recreate', 'Delete and create the domains and volumes') do
323
+        @options[:recreate] = true
324
+      end
325
+
326
+      opts.on('-s', '--stop', 'Stop all created domains') do
327
+        @options[:stop] = true
328
+      end
329
+
330
+      opts.on('-r', '--start', 'Start all created domains') do
331
+        @options[:start] = true
332
+      end
333
+
334
+      opts.on('-l', '--list', 'List the domains and volumes') do
335
+        @options[:list] = true
336
+        @options[:all] = true
337
+      end
338
+
339
+      opts.on('-c', '--config', 'Show the requested configuration of the domains and volumes') do
340
+        @options[:config] = true
341
+      end
342
+
343
+      opts.on('-a', '--all', 'Process all domains') do
344
+        @options[:all] = true
345
+      end
346
+
347
+      opts.on('-d', '--debug', 'Show debug messages') do
348
+        @options[:debug] = true
349
+      end
350
+
351
+      opts.on('-C', '--console', 'Run the debug console') do
352
+        @options[:debug] = true
353
+        @options[:console] = true
354
+      end
355
+
356
+      opts.on('-y', '--yaml FILE', 'Settings YAML file') do |value|
357
+        @options[:yaml] = value
358
+      end
359
+
360
+      opts.on('-q', '--qemu', 'Use QEMU instead of KVM') do
361
+        @options[:virt] = 'qemu'
362
+      end
363
+
364
+      opts.on('-p', '--pool POOL', 'The name of the libvirt storage pool') do |value|
365
+        @options[:pool] = value
366
+      end
367
+
368
+    end.parse!
369
+
370
+    @options
371
+  end
372
+
373
+  def munge_options
374
+    return unless options.is_a? Hash
375
+    options[:yaml] = '/etc/hiera/plugins/fuel_opsvms.yaml' unless options[:yaml]
376
+    options[:pool] = 'default' unless options[:pool]
377
+    options[:virt] = 'kvm' unless options[:virt]
378
+    options[:hosts] = ARGV.compact.uniq
379
+    
380
+    unless options[:all] or (options[:hosts] and options[:hosts].any?)
381
+      error "You have to provided any hosts names to work with.
382
+             Please, give obne or more host name or use '-a' to work on all defined hosts!
383
+             Defined hosts: #{domain_names.join ', '}"
384
+    end
385
+    debug "Options: #{options.inspect}"
386
+  end
387
+
388
+end
389
+
390
+# Main KVM control logic class
391
+class KvmControl
392
+  attr_writer :options
393
+  include Configuration
394
+  include LibVirt
395
+
396
+  # The filtered list of domains
397
+  # It should contain only the domains from the command line
398
+  # or all domains if the "-a" is set.
399
+  def domains
400
+    domain_settings.select do |domain|
401
+      options[:all] or options[:hosts].include? domain['name']
402
+    end
403
+  end
404
+
405
+  # Get an array of defined domain names
406
+  # @return [Array<Staring>]
407
+  def domain_names
408
+    domain_settings.map do |domain|
409
+      domain['name']
410
+    end.compact.uniq
411
+  end
412
+
413
+  # Run the debug console
414
+  def console
415
+    require 'pry'
416
+    binding.pry
417
+    exit(0)
418
+  end
419
+
420
+  # Show the configuration
421
+  def show_config
422
+    info YAML.dump domains
423
+    exit(0)
424
+  end
425
+
426
+  # The 'list' action
427
+  # Lists all domains and their statuses
428
+  def action_list
429
+    domain_statuses = domain_list
430
+    max_length = domain_names.max_by { |d| d.length }.length
431
+
432
+    domain_names.each do |domain_name|
433
+      domain_attributes = domain_statuses.fetch(domain_name, {})
434
+      domain_state = domain_attributes.fetch 'state', 'missing'
435
+      info "#{domain_name.ljust max_length} - #{domain_state}"
436
+    end
437
+    exit(0)
438
+  end
439
+
440
+  # The 'delete' action
441
+  # Stops domains and deletes volumes and domains
442
+  def action_delete
443
+    domains_stop
444
+    domains_delete
445
+    volumes_delete
446
+  end
447
+
448
+  # The 'create action'
449
+  # Creates volumes and domains,
450
+  # starts domains and marks them for autostart
451
+  def action_create
452
+    volumes_create
453
+    domains_create
454
+    domains_autostart
455
+    domains_stop
456
+    domains_start
457
+  end
458
+
459
+  # The 'recreate' action
460
+  # Calls 'delete' and 'create' actions
461
+  def action_recreate
462
+    action_delete
463
+    action_create
464
+  end
465
+
466
+  # The 'stop' action
467
+  # Stop all domains in the working set
468
+  def action_stop
469
+    domains_stop
470
+  end
471
+
472
+  # The 'start' action
473
+  # Start all domains in the working set
474
+  def action_start
475
+    domains_start
476
+  end
477
+
478
+  # Create all domains in the working set
479
+  def domains_create
480
+    debug 'Call: domains_create'
481
+    domains.each do |domain|
482
+      domain_name = domain.fetch 'name'
483
+      next unless domain_name
484
+      if domain_defined? domain_name
485
+        warning "Domain: #{domain_name} is already defined! Skipping!"
486
+        next
487
+      end
488
+      resolve_volume_paths domain['volumes']
489
+      domain_create domain_name, domain
490
+    end
491
+  end
492
+
493
+  # Resolve the path of a libvirt volumes by their names
494
+  # If volume has a path already defined it will be skipped
495
+  # @param [Array] volumes
496
+  def resolve_volume_paths(volumes)
497
+    return unless volumes.is_a? Array
498
+    volumes.each do |volume|
499
+      next if volume['path']
500
+      volume['path'] = volume_path volume['name'], options[:pool]
501
+    end
502
+  end
503
+
504
+  # Create volumes for the domains in the working set
505
+  def volumes_create
506
+    domains.each do |domain|
507
+      volumes = domain.fetch 'volumes', {}
508
+      volumes.each do |volume|
509
+        volume_size = volume.fetch 'size'
510
+        volume_name = volume.fetch 'name'
511
+        next unless volume_name and volume_size
512
+        if volume_defined? volume_name, options[:pool]
513
+          warning "Volume: #{volume_name} of the pool: #{options[:pool]} is already created! Skipping!"
514
+          next
515
+        end
516
+        if volume['path']
517
+          info "Volume: #{volume_name} has a path already defined. Assuming it's already created!"
518
+          next
519
+        end
520
+        volume_create volume_name, options[:pool], volume_size
521
+      end
522
+    end
523
+  end
524
+
525
+  # Delete all volumes of domains in the working set
526
+  def volumes_delete
527
+    debug 'Call: volumes_delete'
528
+    domains.each do |domain|
529
+      volumes = domain.fetch 'volumes', {}
530
+      volumes.each do |volume|
531
+        volume_name = volume.fetch 'name'
532
+        next unless volume_name
533
+        unless volume_defined? volume_name, options[:pool]
534
+          info "Volume: #{volume_name} of the pool: #{options[:pool]} is not defined! Skipping!"
535
+          next
536
+        end
537
+        volume_delete volume_name, options[:pool]
538
+      end
539
+    end
540
+  end
541
+
542
+  # Delete all domains in the working set
543
+  def domains_delete
544
+    debug 'Call: domains_delete'
545
+    domains.each do |domain|
546
+      domain_name = domain.fetch 'name'
547
+      next unless domain_name
548
+      unless domain_defined? domain_name
549
+        warning "Domain: #{domain_name} is not defined! Skipping!"
550
+        next
551
+      end
552
+      domain_delete domain_name
553
+    end
554
+  end
555
+
556
+  # Start all domains in the working set
557
+  def domains_start
558
+    debug 'Call: domains_start'
559
+    domains.each do |domain|
560
+      domain_name = domain.fetch 'name'
561
+      next unless domain_name
562
+      unless domain_defined? domain_name
563
+        warning "Domain: #{domain_name} is not defined! Skipping!"
564
+        next
565
+      end
566
+      if domain_started? domain_name
567
+        warning "Domain: #{domain_name} is already started! Skipping!"
568
+        next
569
+      end
570
+      domain_start domain_name
571
+    end
572
+  end
573
+
574
+  # Unset autostart mark from all domain in the working set
575
+  def domains_no_autostart
576
+    debug 'Call: domains_no_autostart'
577
+    domains.each do |domain|
578
+      domain_name = domain.fetch 'name'
579
+      next unless domain_name
580
+      unless domain_defined? domain_name
581
+        warning "Domain: #{domain_name} is not defined! Skipping!"
582
+        next
583
+      end
584
+      domain_no_autostart domain_name
585
+    end
586
+  end
587
+
588
+  # Mark all domains in the working set for autostart
589
+  def domains_autostart
590
+    debug 'Call: domains_autostart'
591
+    domains.each do |domain|
592
+      domain_name = domain.fetch 'name'
593
+      next unless domain_name
594
+      unless domain_defined? domain_name
595
+        warning "Domain: #{domain_name} is not defined! Skipping!"
596
+        next
597
+      end
598
+      domain_autostart domain_name
599
+    end
600
+  end
601
+
602
+  # Stop all domains in the working set
603
+  def domains_stop
604
+    debug 'Call: domains_stop'
605
+    domains.each do |domain|
606
+      domain_name = domain.fetch 'name'
607
+      next unless domain_name
608
+      unless domain_defined? domain_name
609
+        warning "Domain: #{domain_name} is not defined! Skipping!"
610
+        next
611
+      end
612
+      unless domain_started? domain_name
613
+        warning "Domain: #{domain_name} is not started! Skipping!"
614
+        next
615
+      end
616
+      domain_stop domain_name
617
+    end
618
+  end
619
+
620
+  # Run the command
621
+  # @param [Array] commands
622
+  # @return [Array] Array of stdout and success boolean value
623
+  def run(*commands)
624
+    commands.flatten!
625
+    commands.map!(&:to_s)
626
+    out, status = Open3.capture2 *commands
627
+    [out, status.exitstatus == 0]
628
+  end
629
+
630
+  def debug(message)
631
+    $stdout.puts message if options[:debug]
632
+  end
633
+
634
+  def warning(message)
635
+    $stdout.puts "WARNING: #{message}"
636
+  end
637
+
638
+  def info(message)
639
+    $stdout.puts message
640
+  end
641
+
642
+  def error(message)
643
+    $stderr.puts "ERROR: #{message}"
644
+    exit(0)
645
+  end
646
+
647
+  # The main function
648
+  def main
649
+    munge_options
650
+
651
+    if options[:console]
652
+      console
653
+      exit(0)
654
+    end
655
+
656
+    if options[:config]
657
+      show_config
658
+      exit(0)
659
+    end
660
+
661
+    if options[:list]
662
+      action_list
663
+    end
664
+
665
+    if options[:delete]
666
+      action_delete
667
+      exit(0)
668
+    end
669
+
670
+    if options[:recreate]
671
+      action_recreate
672
+      exit(0)
673
+    end
674
+
675
+    if options[:stop]
676
+      action_stop
677
+      exit(0)
678
+    end
679
+
680
+    if options[:start]
681
+      action_start
682
+      exit(0)
683
+    end
684
+
685
+    action_create
686
+  end
687
+end
688
+
689
+if $0 == __FILE__
690
+  opsvm = KvmControl.new
691
+  opsvm.main
692
+end

+ 40
- 0
deployment_scripts/puppet/modules/nitrous/templates/vlan.erb View File

@@ -0,0 +1,40 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2016 AT&T Inc.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# 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, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+brctl delif <%= @mgmt_brg %> <%= @mgmt_nm %>
18
+if [ $? == 0 ]; then
19
+echo "Deleted <%= @mgmt_nm %>" > /var/log/nitrous-vlan.log
20
+vconfig rem <%= @mgmt_nm %>
21
+ if [ $? == 0 ]; then
22
+   echo "Removed <%= @mgmt_nm %>" >> /var/log/nitrous-vlan.log
23
+ fi
24
+fi
25
+brctl delif <%= @stg_brg %>  <%= @stg_nm %>
26
+if [ $? == 0 ]; then
27
+echo "Deleted <%= @stg_nm %>" >> /var/log/nitrous-vlan.log
28
+vconfig rem <%= @stg_nm %>
29
+ if [ $? == 0 ]; then
30
+   echo "Removed <%= @stg_nm %>" >> /var/log/nitrous-vlan.log
31
+ fi
32
+fi
33
+brctl delif <%= @prv_brg %> <%= @prv_nm %>
34
+if [ $? == 0 ]; then
35
+echo "Deleted <%= @prv_nm %>" >> /var/log/nitrous-vlan.log
36
+vconfig rem <%= @prv_nm %>
37
+if [ $? == 0 ]; then
38
+   echo "Removed <%= @prv_nm %>" >> /var/log/nitrous-vlan.log
39
+ fi
40
+fi

+ 49
- 0
deployment_tasks.yaml View File

@@ -0,0 +1,49 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+- id: nitrous
16
+  type: group
17
+  role: [nitrous]
18
+  tasks: [hiera, globals, tools, logging, netconfig, hosts, deploy_start]
19
+  parameters:
20
+    strategy:
21
+      type: parallel
22
+
23
+- id: nitrous-deployment-puppet
24
+  type: puppet
25
+  role: [nitrous]
26
+  version: 2.0.0
27
+  required_for: [deploy_end]
28
+  requires: [deploy_start]
29
+  parameters:
30
+    puppet_manifest: puppet/manifests/nitrous.pp
31
+    puppet_modules: puppet/modules:/etc/puppet/modules
32
+    timeout: 720
33
+
34
+- id: nitrous-post-deployment-sh
35
+  type: shell
36
+  version: 2.0.0
37
+  role: [nitrous]
38
+  cross-depends:
39
+    - name: post_deployment_start
40
+  cross-depended-by:
41
+    - name: post_deployment_end
42
+  requires: [post_deploy_start]
43
+  required_for: [post_deploy_end]
44
+  parameters:
45
+    cmd: |
46
+      echo -e "#!/bin/sh \n\n/bin/sleep 60 && /usr/bin/opsvm -a >>/var/log/nitrous.log" > /etc/ops_create.sh && chmod +x /etc/ops_create.sh;
47
+    retries: 0
48
+    interval: 10
49
+    timeout: 120

+ 498
- 0
environment_config.yaml View File

@@ -0,0 +1,498 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+attributes:
16
+  metadata:
17
+    # Settings group can be one of "general", "security", "compute", "network",
18
+    # "storage", "logging", "openstack_services" and "other".
19
+    group: 'other'
20
+  puppet_master_address:
21
+    value: 'localhost'
22
+    label: 'Puppet master address'
23
+    description: 'This will make entry of puppet master in Nitrous nodes.'
24
+    weight: 21
25
+    type: "text"
26
+  env_proxy:
27
+    value: 'undef'
28
+    label: 'Enviornment Proxy'
29
+    description: 'Use if the server requires a proxy.  The default value is "undef".'
30
+    weight: 22
31
+    type: "text"
32
+  node_additional_config:
33
+    label: "Nitrous config"
34
+    type: "textarea"
35
+    validate: "yaml"
36
+    weight: 30
37
+    value: |
38
+      webvirt: xxx.xxx.xxx.xx
39
+      dhcp_helper: xxx.xxx.xxx.11
40
+      site_name: YOUR_SITENAME
41
+      ubuntu_repo: http://archive.ubuntu.com/ubuntu/
42
+      domain_name: YOUR_DOMAIN
43
+      network:
44
+        bonds:
45
+        - bond-mode: active-backup
46
+          members:
47
+          - em1
48
+          - em2
49
+          name: bond0
50
+          vlans:
51
+          - name: 100
52
+            native: true
53
+        - bond-mode: 802.3ad
54
+          members:
55
+          - p1p1
56
+          - p1p2
57
+          - p2p1
58
+          - p2p2
59
+          mtu: '9000'
60
+          name: bond1
61
+          vlans:
62
+          - name: 101  #Management
63
+          - name: 102  #Storage
64
+          - name: 103  #Private
65
+        dhcp-ranges:
66
+        - end: 10.1.0.252
67
+          gateway: 10.1.0.1
68
+          mask: 255.255.255.255
69
+          name: rack01
70
+          start: 10.1.0.12
71
+        dns-nameservers:
72
+        - 8.8.8.8
73
+      storage:
74
+        iscsi_reservation_enabled: false
75
+        lun_mapping:
76
+          #ADD YOUR STORAGE LUN INFORMATION
77
+        storage_backend: local
78
+        storage_blacklist_enabled: true
79
+        storage_subnets:
80
+        - xxx.xx.xxx.0/24
81
+        storage_type: idc
82
+        storage_vlan: 102
83
+        targets:
84
+        - xxx.xx.xxx.xx
85
+      nodes:
86
+      - host_profile: cp-hp2
87
+        ipmi_address: xxx.xxx.xxx.1
88
+        ipmi_password: YOUR_PASSWORD
89
+        ipmi_username: YOUR_USERNAME
90
+        mac_address: xx:xx:xx:xx:xx:xx
91
+        name: svr01r01a001
92
+        power_type: ipmi
93
+        pxe_address: 10.1.0.5
94
+        pxe_subnet: rack01
95
+        server_hardware: DellR900
96
+        storage:
97
+          initiator_name: iqn.xxxx-xx.abc.abcdefg:svr01r01a001-6383eecf
98
+          luns:
99
+            #ADD YOUR STORAGE LUN INFORMATION
100
+        type: seed
101
+        vlans:
102
+        - address:
103
+            address: 10.1.0.5
104
+            gateway: 10.1.0.1
105
+            netmask: 255.255.255.255
106
+          name: 100
107
+        - address:
108
+            address: 10.1.1.5
109
+            gateway: 10.1.1.3
110
+            netmask: 255.255.255.255
111
+          name: 101
112
+        - address:
113
+            address: 10.1.2.5
114
+            gateway: 10.1.2.3
115
+            netmask: 255.255.255.255
116
+          name: 102
117
+        - address:
118
+            address: 10.1.3.5
119
+            gateway: 10.1.3.3
120
+            netmask: 255.255.255.255
121
+          name: 103
122
+      - host_profile: cp-hp2
123
+        ipmi_address: xxx.xxx.xxx.2
124
+        ipmi_password: YOUR_PASSWORD
125
+        ipmi_username: YOUR_USERNAME
126
+        mac_address: xx:xx:xx:xx:xx:xx
127
+        name: svr01r01a002
128
+        power_type: ipmi
129
+        pxe_address: 10.1.0.6
130
+        pxe_subnet: rack01
131
+        server_hardware: DellR900
132
+        storage:
133
+          initiator_name: iqn.xxxx-xx.abc.abcdefg:svr01r01a002-0bfa33c0
134
+          luns:
135
+            #ADD YOUR STORAGE LUN INFORMATION
136
+        type: lcp
137
+        vlans:
138
+        - address:
139
+            address: 10.1.0.6
140
+            gateway: 10.1.0.1
141
+            netmask: 255.255.255.255
142
+          name: 100
143
+        - address:
144
+            address: 10.1.1.6
145
+            gateway: 10.1.1.3
146
+            netmask: 255.255.255.255
147
+          name: 101
148
+        - address:
149
+            address: 10.1.2.6
150
+            gateway: 10.1.2.3
151
+            netmask: 255.255.255.255
152
+          name: 102
153
+        - address:
154
+            address: 10.1.3.6
155
+            gateway: 10.1.3.3
156
+            netmask: 255.255.255.255
157
+          name: 103
158
+      - host_profile: cp-hp2
159
+        ipmi_address: xxx.xxx.xxx.3
160
+        ipmi_password: YOUR_PASSWORD
161
+        ipmi_username: YOUR_USERNAME
162
+        mac_address: xx:xx:xx:xx:xx:xx
163
+        name: svr01r01a003
164
+        power_type: ipmi
165
+        pxe_address: 10.1.0.7
166
+        pxe_subnet: rack01
167
+        server_hardware: DellR900
168
+        storage:
169
+          initiator_name: iqn.xxxx-xx.abc.abcdefg:svr01r01a003-cab3c6a4
170
+          luns:
171
+            #ADD YOUR STORAGE LUN INFORMATION
172
+        type: lcp
173
+        vlans:
174
+        - address:
175
+            address: 10.1.0.7
176
+            gateway: 10.1.0.1
177
+            netmask: 255.255.255.255
178
+          name: 100
179
+        - address:
180
+            address: 10.1.1.7
181
+            gateway: 10.1.1.3
182
+            netmask: 255.255.255.255
183
+          name: 101
184
+        - address:
185
+            address: 10.1.2.7
186
+            gateway: 10.1.2.3
187
+            netmask: 255.255.255.255
188
+          name: 102
189
+        - address:
190
+            address: 10.1.3.7
191
+            gateway: 10.1.3.3
192
+            netmask: 255.255.255.255
193
+          name: 103
194
+      - availability_zone: null
195
+        host_profile: nv-hp1
196
+        ipmi_address: xxx.xxx.xxx.4
197
+        ipmi_password: YOUR_PASSWORD
198
+        ipmi_username: YOUR_USERNAME
199
+        mac_address: xx:xx:xx:xx:xx:xx
200
+        name: svr01r01a004
201
+        power_type: ipmi
202
+        pxe_address: 10.1.0.8
203
+        pxe_subnet: rack04
204
+        server_hardware: DellR900
205
+        storage:
206
+          initiator_name: iqn.xxxx-xx.abc.abcdefg:svr01r01a004-98c8ace6
207
+        type: compute
208
+        vlans:
209
+        - address:
210
+            address: 10.1.0.8
211
+            gateway: 10.1.0.1
212
+            netmask: 255.255.255.255
213
+          name: 100
214
+        - address:
215
+            address: 10.1.1.8
216
+            gateway: 10.1.1.3
217
+            netmask: 255.255.255.255
218
+          name: 101
219
+        - address:
220
+            address: 10.1.2.8
221
+            gateway: 10.1.2.3
222
+            netmask: 255.255.255.255
223
+          name: 102
224
+        - address:
225
+            address: 10.1.3.8
226
+            gateway: 10.1.3.3
227
+            netmask: 255.255.255.255
228
+          name: 103
229
+      image_base_path: /var/lib/libvirt/images/
230
+      host_aggregates:
231
+      - host_profiles:
232
+        - nd-hp1
233
+        - nd-hp2
234
+        meta:
235
+        - nd: true
236
+        - cpu_allocation_ratio: 1.0
237
+        name: svr01-nd-ha01
238
+      - host_profiles:
239
+        - nv-hp1
240
+        meta:
241
+        - nv: true
242
+        - cpu_allocation_ratio: 1.0
243
+        name: svr01-nv-ha01
244
+      - host_profiles:
245
+        - gv-hp1
246
+        meta:
247
+        - gv: true
248
+        - c2: true
249
+        - cpu_allocation_ratio: 2.0
250
+        name: svr01-gv-ha01
251
+  selective_default_bridge:
252
+    label: "Select network bridge for KVM Host"
253
+    description: 'Default network bridge is "Linux", select as per your requirement.'
254
+    type: "radio"
255
+    weight: 40
256
+    value: "linuxbr"
257
+    values:
258
+      - data:  "linuxbr"
259
+        label: "Linux Bridge"
260
+      - data:  "ovsbr"
261
+        label: "OVS Bridge"
262
+  selective_opsvm_pool:
263
+    label: "Select storage pool for OpenStack Vms"
264
+    description: 'Default pool type for OpenStack vms is directory(dir), please select storage pool type as per your equirement.'
265
+    type: "radio"
266
+    weight: 50
267
+    value: "dir"
268
+    values:
269
+      - data:  "dir"
270
+        label: "Directory"
271
+      - data:  "mpath"
272
+        label: "Multipath"
273
+  ops_server_config:
274
+    label: "OpenStack Vms config"
275
+    type: "textarea"
276
+    validate: "yaml"
277
+    weight: 60
278
+    value: |
279
+      - app_volume_name: null
280
+        cpu: 8
281
+        app_disk: 120
282
+        log_disk: 15
283
+        os_disk: 80
284
+        ignore: false
285
+        is_vm: true
286
+        kvm: svr01r01a002
287
+        mac_address: 52:54:00:e5:e4:06
288
+        name: mosc01
289
+        network_profile: vm_ops-profile
290
+        os_volume_name: mpath_mosc01
291
+        ram: 32
292
+        server_type: controller
293
+      - app_volume_name: null
294
+        cpu: 8
295
+        app_disk: 120
296
+        log_disk: 15
297
+        os_disk: 80
298
+        ignore: true
299
+        is_vm: false
300
+        kvm: svr01r01a003
301
+        mac_address: 52:54:00:c2:dd:c5
302
+        name: mosc02
303
+        network_profile: vm_ops-profile
304
+        os_volume_name: mpath_mosc02
305
+        ram: 32
306
+        server_type: controller
307
+      - app_volume_name: null
308
+        cpu: 8
309
+        app_disk: 120
310
+        log_disk: 15
311
+        os_disk: 80
312
+        ignore: true
313
+        is_vm: false
314
+        kvm: svr01r01a002
315
+        mac_address: 52:54:00:b3:dc:b2
316
+        name: mosc03
317
+        network_profile: vm_ops-profile
318
+        os_volume_name: mpath_mosc03
319
+        ram: 32
320
+        server_type: controller        
321
+      - app_volume_name: null
322
+        cpu: 8
323
+        app_disk: 120
324
+        log_disk: 15
325
+        os_disk: 80
326
+        ignore: false
327
+        is_vm: true
328
+        kvm: svr01r01a002
329
+        mac_address: 52:54:00:3b:e5:fb
330
+        name: dbmq01
331
+        network_profile: vm_ops-profile
332
+        os_volume_name: mpath_dbmq01
333
+        ram: 32
334
+        server_type: dbmq
335
+      - app_volume_name: null
336
+        cpu: 8
337
+        app_disk: 120
338
+        log_disk: 15
339
+        os_disk: 80
340
+        ignore: true
341
+        is_vm: false
342
+        kvm: svr01r01a003
343
+        mac_address: 52:54:00:92:35:52
344
+        name: dbmq02
345
+        network_profile: vm_ops-profile
346
+        os_volume_name: mpath_dbmq02
347
+        ram: 32
348
+        server_type: dbmq
349
+      - app_volume_name: null
350
+        cpu: 8
351
+        app_disk: 120
352
+        log_disk: 15
353
+        os_disk: 80
354
+        ignore: true
355
+        is_vm: false
356
+        kvm: svr01r01a003
357
+        mac_address: 52:54:00:aa:53:25
358
+        name: dbmq03
359
+        network_profile: vm_ops-profile
360
+        os_volume_name: mpath_dbmq03
361
+        ram: 32
362
+        server_type: dbmq       
363
+      - app_volume_name: null
364
+        cpu: 8
365
+        app_disk: 120
366
+        log_disk: 15
367
+        os_disk: 80
368
+        ignore: true
369
+        is_vm: false
370
+        kvm: svr01r01a002
371
+        mac_address: 52:54:00:7d:8c:ad
372
+        name: mong01
373
+        network_profile: vm_ops-profile
374
+        os_volume_name: mpath_mong01
375
+        ram: 32
376
+        server_type: mongo_db
377
+      - app_volume_name: null
378
+        cpu: 8
379
+        app_disk: 120
380
+        log_disk: 15
381
+        os_disk: 80
382
+        ignore: true
383
+        is_vm: false
384
+        kvm: svr01r01a003
385
+        mac_address: 52:54:00:21:5d:b3
386
+        name: mong02
387
+        network_profile: vm_ops-profile
388
+        os_volume_name: mpath_mong02
389
+        ram: 32
390
+        server_type: mongo_db
391
+      - app_volume_name: null
392
+        cpu: 8
393
+        app_disk: 120
394
+        log_disk: 15
395
+        os_disk: 80
396
+        ignore: true
397
+        is_vm: false
398
+        kvm: svr01r01a003
399
+        mac_address: 52:54:00:00:86:3e
400
+        name: mong03
401
+        network_profile: vm_ops-profile
402
+        os_volume_name: mpath_mong03
403
+        ram: 32
404
+        server_type: mongo_db
405
+      - app_volume_name: null
406
+        cpu: 8
407
+        app_disk: 120
408
+        log_disk: 15
409
+        os_disk: 80
410
+        ignore: false
411
+        is_vm: true
412
+        kvm: svr01r01a002
413
+        mac_address: 52:54:00:f0:2b:5d
414
+        name: hapr01
415
+        network_profile: vm_ops-profile
416
+        os_volume_name: mpath_hapr01
417
+        ram: 32
418
+        server_type: haproxy
419
+      - app_volume_name: null
420
+        cpu: 8
421
+        app_disk: 120
422
+        log_disk: 15
423
+        os_disk: 80
424
+        ignore: true
425
+        is_vm: false
426
+        kvm: svr01r01a003
427
+        mac_address: 52:54:00:9a:d8:61
428
+        name: hapr02
429
+        network_profile: vm_ops-profile
430
+        os_volume_name: mpath_hapr02
431
+        ram: 32
432
+        server_type: haproxy
433
+      - app_volume_name: null
434
+        cpu: 8
435
+        app_disk: 120
436
+        log_disk: 15
437
+        os_disk: 80
438
+        ignore: true
439
+        is_vm: false
440
+        kvm: svr01r01a002
441
+        mac_address: 52:54:00:5c:b3:eb
442
+        name: hapr03
443
+        network_profile: vm_ops-profile
444
+        os_volume_name: mpath_hapr03
445
+        ram: 32
446
+        server_type: haproxy
447
+      - app_volume_name: null
448
+        cpu: 8
449
+        app_disk: 120
450
+        log_disk: 15
451
+        os_disk: 80
452
+        ignore: false
453
+        is_vm: true
454
+        kvm: svr01r01a002
455
+        mac_address: 52:54:00:07:f1:bd
456
+        name: kshz01
457
+        network_profile: vm_ops-profile
458
+        os_volume_name: mpath_kshz01
459
+        ram: 32
460
+        server_type: identity
461
+      - app_volume_name: null
462
+        cpu: 8
463
+        app_disk: 120
464
+        log_disk: 15
465
+        os_disk: 80
466
+        ignore: true
467
+        is_vm: false
468
+        kvm: svr01r01a003
469
+        mac_address: 52:54:00:75:24:24
470
+        name: kshz02
471
+        network_profile: vm_ops-profile
472
+        os_volume_name: mpath_kshz02
473
+        ram: 32
474
+        server_type: identity
475
+      - app_volume_name: null
476
+        cpu: 8
477
+        app_disk: 120
478
+        log_disk: 15
479
+        os_disk: 80
480
+        ignore: true
481
+        is_vm: false
482
+        kvm: svr01r01a003
483
+        mac_address: 52:54:00:5d:08:78
484
+        name: kshz03
485
+        network_profile: vm_ops-profile
486
+        os_volume_name: mpath_kshz03
487
+        ram: 32
488
+        server_type: identity
489
+      - app_volume_name: null
490
+        cpu: 0
491
+        ignore: true
492
+        is_vm: false
493
+        kvm: xx:xx:xx:xx:xx:xx
494
+        name: svr01r01a004
495
+        network_profile: dellr900_nv-hp1
496
+        os_volume_name: null
497
+        ram: 0
498
+        server_type: compute

+ 43
- 0
metadata.yaml View File

@@ -0,0 +1,43 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+name: nitrous
16
+title: Nitrous plugin for Bare Metal provisioning.
17
+version: '1.0.0'
18
+description: Nitrous plugin will install Base OS, multipath options, create VMs and their network settings for Fuel provisioning and deployment.
19
+fuel_version: ['9.0']
20
+licenses: ['Apache License Version 2.0']
21
+authors: ['Dinesh Yadav (dy270k@att.com), AT&T Inc.']
22
+homepage: 'https://github.com/openstack/fuel-plugin-nitrous'
23
+groups: []
24
+is_hotpluggable: false
25
+
26
+releases:
27
+  - os: ubuntu
28
+    version: kilo-9.0
29
+    mode: ['ha', 'multinode']
30
+    deployment_scripts_path: deployment_scripts/
31
+    repository_path: repositories/ubuntu
32
+  - os: ubuntu
33
+    version: liberty-9.0
34
+    mode: ['ha', 'multinode']
35
+    deployment_scripts_path: deployment_scripts/
36
+    repository_path: repositories/ubuntu
37
+  - os: ubuntu
38
+    version: mitaka-9.0
39
+    mode: ['ha', 'multinode']
40
+    deployment_scripts_path: deployment_scripts/
41
+    repository_path: repositories/ubuntu
42
+
43
+package_version: '4.0.0'

+ 28
- 0
network_roles.yaml View File

@@ -0,0 +1,28 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+- id: "example_net_role"
16
+  # Role mapping to network
17
+  default_mapping: "public"
18
+  properties:
19
+    # Should be true if network role requires subnet being set
20
+    subnet: true
21
+    # Should be true if network role requires gateway being set
22
+    gateway: false
23
+    # List of VIPs to be allocated
24
+    vip:
25
+         # Unique VIP name
26
+       - name: "vip_name"
27
+         # Optional linux namespace for VIP
28
+         namespace: "haproxy"

+ 20
- 0
node_roles.yaml View File

@@ -0,0 +1,20 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+nitrous:
16
+  name: Nitrous
17
+  description: Base OS installation on bare metal with KVM/QEMU/libvirt hypervisor and creates VMs for Fuel provisioning and deployment.
18
+  has_primary: false
19
+  public_ip_required: false
20
+  weight: 100

+ 43
- 0
post_install.sh View File

@@ -0,0 +1,43 @@
1
+#!/bin/bash
2
+#
3
+# Copyright (c) 2016 AT&T Inc.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# 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, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+DEBUG=true
18
+REL_NAME='Ubuntu 14.04'
19
+
20
+FUEL='/usr/bin/fuel'
21
+REL=`$FUEL rel | grep -i "${REL_NAME}.* available " | awk '{print $1}'`
22
+FUEL_REL=`$FUEL rel | grep -i "${REL_NAME}.* available " | awk '{print $NF}'`
23
+
24
+function debug {
25
+  if $DEBUG; then
26
+    echo $@
27
+  fi
28
+}
29
+
30
+function set_min_controller_count {
31
+  count=$1
32
+  workdir=$(mktemp -d /tmp/modifyenv.XXXX)
33
+  local os_roles=(ceph-osd cinder compute controller cinder-block-device ironic mongo)
34
+  for role in ${os_roles[@]}; do
35
+    $FUEL role --rel $REL --role $role --file $workdir/${role}.yaml
36
+    sed -i "s/    min: ./    min: ${count}/" $workdir/${role}.yaml
37
+    $FUEL role --rel $REL --update --file $workdir/${role}.yaml
38
+  done
39
+  rm -rf $workdir
40
+}
41
+
42
+set_min_controller_count 0
43
+$FUEL rel --sync-deployment-tasks --dir /etc/puppet/$FUEL_REL

+ 21
- 0
pre_build_hook View File

@@ -0,0 +1,21 @@
1
+#!/bin/bash
2
+#
3
+# Copyright 2016 AT&T, Inc.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License");
6
+# you may not use this file except in compliance with the License.
7
+# 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, software
12
+# distributed under the License is distributed on an "AS IS" BASIS,
13
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+# See the License for the specific language governing permissions and
15
+# limitations under the License
16
+
17
+# Add here any the actions which are required before plugin build
18
+# like packages building, packages downloading from mirrors and so on.
19
+# The script should return 0 if there were no errors.
20
+
21
+set -eux

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


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


+ 40
- 0
tasks.yaml View File

@@ -0,0 +1,40 @@
1
+# Copyright (c) 2016 AT&T Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+# WARNING: `tasks.yaml` will be deprecated in further releases.
16
+# Please, use `deployment_tasks.yaml` to describe tasks instead.
17
+
18
+# This tasks will be applied on controller nodes,
19
+# here you can also specify several roles, for example
20
+# ['cinder', 'compute'] will be applied only on
21
+# cinder and compute nodes
22
+- role: ['controller']
23
+  stage: post_deployment
24
+  type: shell
25
+  parameters:
26
+    cmd: bash deploy.sh
27
+    timeout: 42
28
+# Task is applied for all roles
29
+- role: '*'
30
+  stage: pre_deployment
31
+  type: shell
32
+  parameters:
33
+    cmd: echo all > /tmp/plugin.all
34
+    timeout: 42
35
+# "reboot" task reboots the nodes and waits until they get back online
36
+# - role: '*'
37
+#   stage: pre_deployment
38
+#   type: reboot
39
+#   parameters:
40
+#     timeout: 600

+ 34
- 0
volumes.yaml View File

@@ -0,0 +1,34 @@
1
+# Copyright 2016 AT&T, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+volumes_roles_mapping:
16
+  nitrous:
17
+    - {allocate_size: "min", id: "os"}
18
+    - {allocate_size: "min", id: "logs"}
19
+    - {allocate_size: "all", id: "nitrous"}
20
+volumes:
21
+  - id: "nitrous"
22
+    type: "vg"
23
+    min_size:
24
+     generator: "calc_gb_to_mb"
25
+     generator_args: [10]
26
+    label: "Nitrous Vol"
27
+    volumes:
28
+     - mount: "/opt"
29
+       type: "lv"
30
+       name: "nitrous"
31
+       size:
32
+        generator: "calc_total_vg"
33
+        generator_args: ["nitrous"]
34
+       file_system: "ext4"

Loading…
Cancel
Save