Initial commit.
Change-Id: I0f5653da322a4917d2b07ce090d3c88ca58fbbba
This commit is contained in:
parent
33e94bed23
commit
1328c240af
|
@ -0,0 +1,202 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2015 SwiftStack Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
SwiftStack Plugin for Fuel
|
||||
==========================
|
||||
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
SwiftStack plugin for Fuel provides the functionality to integrate SwiftStack
|
||||
Swift cluster for Mirantis OpenStack as object storage backend option.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
| Requirement | Version/Comment |
|
||||
|--------------------------------|-----------------|
|
||||
| Mirantis OpenStack compatility | 6.1 or higher |
|
||||
| A running SwiftStack Swift cluster | all versions, the `Keystone Auth` and `'Keystone Auth Token Support` middlewares must be enable |
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
The plugin is only support integration a running SwiftStack Swift cluster in first stage.
|
||||
|
||||
|
||||
Build Fuel plugin
|
||||
-----------------
|
||||
|
||||
```
|
||||
# Create a virtualenv for Fuel to build plugin
|
||||
$ sudo apt-get install python-dev python-pip python-virtualenv
|
||||
$ virtualenv fuel
|
||||
|
||||
# Clone fule-plugin-builder and SwiftStack Swift Fuel plugin
|
||||
$ git clone https://github.com/stackforge/fuel-plugins
|
||||
$ git clone https://github.com/stackforge/fuel-plugin-swiftstack
|
||||
|
||||
$ source fuel/bin/activate
|
||||
(fuel) $ cd fuel-plugins/fuel_plugin_builder/
|
||||
(fuel) fuel-plugins/fuel_plugin_builder $ pip install -e .
|
||||
|
||||
(fuel) $ cd fuel_plugin_swiftstack/
|
||||
(fuel) fuel_plugin_swiftstack $ fpb --build ./
|
||||
Plugin is built
|
||||
```
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'hiera'
|
||||
|
||||
ENV['LANG'] = 'C'
|
||||
|
||||
hiera = Hiera.new(:config => '/etc/hiera.yaml')
|
||||
swift = hiera.lookup 'swift', {} , {}
|
||||
auth_addr = hiera.lookup 'management_vip', nil, {}
|
||||
|
||||
ENV['OS_TENANT_NAME']="services"
|
||||
ENV['OS_USERNAME']="swift"
|
||||
ENV['OS_PASSWORD']="#{swift['user_password']}"
|
||||
ENV['OS_AUTH_URL']="http://#{auth_addr}:5000/v2.0"
|
||||
ENV['OS_ENDPOINT_TYPE'] = "internalURL"
|
||||
|
||||
def service_list
|
||||
stdout = `keystone service-list`
|
||||
return_code = $?.exitstatus
|
||||
names = []
|
||||
uuids = []
|
||||
types = []
|
||||
stdout.split("\n").each do |line|
|
||||
fields = line.split('|').map { |f| f.chomp.strip }
|
||||
next if fields[1] == 'id'
|
||||
next unless fields[2]
|
||||
names << fields[2]
|
||||
uuids << fields[1]
|
||||
types << fields[3]
|
||||
end
|
||||
{:names => names, :uuids => uuids, :types => types, :exit_code => return_code}
|
||||
end
|
||||
|
||||
def endpoint_list
|
||||
stdout = `keystone endpoint-list`
|
||||
return_code = $?.exitstatus
|
||||
service_ids = []
|
||||
uuids = []
|
||||
stdout.split("\n").each do |line|
|
||||
fields = line.split('|').map { |f| f.chomp.strip }
|
||||
next if fields[1] == 'id'
|
||||
next unless fields[2]
|
||||
service_ids << fields[6]
|
||||
uuids << fields[1]
|
||||
end
|
||||
{:service_ids => service_ids, :uuids => uuids, :exit_code => return_code}
|
||||
end
|
||||
|
||||
|
||||
def delete_endpoint(service_name)
|
||||
list_of_services = service_list
|
||||
list_of_endpoints = endpoint_list
|
||||
types = Hash[list_of_services[:types].map.with_index.to_a]
|
||||
service_id = list_of_services[:uuids][types[service_name]]
|
||||
endpoint_service_ids = Hash[list_of_endpoints[:service_ids].map.with_index.to_a]
|
||||
endpoint_uuid = list_of_endpoints[:uuids][endpoint_service_ids[service_id]]
|
||||
puts "Remove endpoint ('#{endpoint_uuid}') in '#{service_name}' "
|
||||
"(service_id: '#{service_id}'."
|
||||
stdout = `keystone endpoint-delete '#{endpoint_uuid}'`
|
||||
end
|
||||
|
||||
########################
|
||||
|
||||
|
||||
delete_endpoint("object-store")
|
||||
delete_endpoint("s3")
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
$fuel_settings = parseyaml(file('/etc/astute.yaml'))
|
||||
|
||||
|
||||
if $fuel_settings['swiftstack']['metadata']['enabled'] {
|
||||
|
||||
notice("Enable SwiftStack Swift cluster ingegtation in $deployment_mode")
|
||||
$deployment_mode = $fuel_settings['deployment_mode']
|
||||
$keystone_vip = $fuel_settings['management_vip']
|
||||
|
||||
$swift_api_address = $fuel_settings['swiftstack']['swift_api_address']
|
||||
$swift_user = 'swift'
|
||||
$swift_password = $fuel_settings['swift']['user_password']
|
||||
$glance_user = 'glance'
|
||||
$glance_password = $fuel_settings['glance']['user_password']
|
||||
$default_tenant = $fuel_settings['workloads_collector']['tenant']
|
||||
|
||||
class {'sscluster':
|
||||
deployment_mode => $deployment_mode,
|
||||
keystone_vip => $keystone_vip,
|
||||
api_address => $swift_api_address,
|
||||
swift_user => $swift_user,
|
||||
swift_password => $swift_password,
|
||||
glance_user => $glance_user,
|
||||
glance_password => $glance_password,
|
||||
tenant => $default_tenant,
|
||||
}
|
||||
|
||||
} else {
|
||||
notice("Disable SwiftStack Swift cluster ingegration")
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
|
||||
class sscluster (
|
||||
$deployment_mode,
|
||||
$keystone_vip,
|
||||
$api_address,
|
||||
$swift_user = 'swift',
|
||||
$swift_password = 'PASSWORD',
|
||||
$glance_user = 'glance',
|
||||
$glance_password = 'PASSWORD',
|
||||
$tenant = 'services',
|
||||
)
|
||||
{
|
||||
case $::osfamily {
|
||||
'Debian':{
|
||||
$glance_api = 'glance-api'
|
||||
$swift_proxy = 'swift-proxy'
|
||||
$swift_object = 'swift-object'
|
||||
$swift_object_auditor = 'swift-object-auditor'
|
||||
$swift_object_replicator = 'swift-object-replicator'
|
||||
$swift_container = 'swift-container'
|
||||
$swift_container_auditor = 'swift-container-auditor'
|
||||
$swift_container_replicator = 'swift-container-replicator'
|
||||
$swift_container_updater = 'swift-container-updater'
|
||||
$swift_container_sync = 'swift-container-sync'
|
||||
$swift_account = 'swift-account'
|
||||
$swift_account_auditor = 'swift-account-auditor'
|
||||
$swift_account_replicator = 'swift-account-replicator'
|
||||
$swift_account_reaper = 'swift-account-reaper'
|
||||
}
|
||||
'RedHat':{
|
||||
$glance_api = 'openstack-glance-api'
|
||||
$swift_proxy = 'openstack-swift-proxy'
|
||||
$swift_object = 'openstack-swift-object'
|
||||
$swift_object_auditor = 'openstack-swift-object-auditor'
|
||||
$swift_object_replicator = 'openstack-swift-object-replicator'
|
||||
$swift_container = 'openstack-swift-container'
|
||||
$swift_container_auditor = 'openstack-swift-container-auditor'
|
||||
$swift_container_replicator = 'openstack-swift-container-replicator'
|
||||
$swift_container_updater = 'openstack-swift-container-updater'
|
||||
$swift_container_sync = 'openstack-swift-container-sync'
|
||||
$swift_account = 'openstack-swift-account'
|
||||
$swift_account_auditor = 'openstack-swift-account-auditor'
|
||||
$swift_account_replicator = 'openstack-swift-account-replicator'
|
||||
$swift_account_reaper = 'openstack-swift-account-reaper'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian")
|
||||
}
|
||||
}
|
||||
|
||||
notice("Stop Glance API Service")
|
||||
exec { 'Stop glance-api':
|
||||
command => "service $glance_api stop",
|
||||
path => ['/usr/bin', '/sbin', '/bin'],
|
||||
}
|
||||
|
||||
notice("Switch Glance backend to Swift Cluster: ${api_address}")
|
||||
class {'glance::backend::swift':
|
||||
swift_store_user => "$tenant:$glance_user",
|
||||
swift_store_key => $glance_password,
|
||||
swift_store_auth_address => "http://$keystone_vip:5000/v2.0",
|
||||
swift_store_create_container_on_put => true,
|
||||
}
|
||||
|
||||
glance_api_config {
|
||||
'glance_store/stores': value => 'glance.store.swift.Store';
|
||||
}
|
||||
|
||||
notice("Update a keystone user for Swift Cluster: ${tenant}:${swift_user}")
|
||||
class {'swift::keystone::auth':
|
||||
auth_name => $swift_user,
|
||||
password => $swift_password,
|
||||
tenant => $tenant,
|
||||
port => '80',
|
||||
public_protocol => 'http',
|
||||
public_address => $api_address,
|
||||
admin_protocol => 'http',
|
||||
admin_address => $api_address,
|
||||
endpoint_prefix => 'KEY',
|
||||
}
|
||||
|
||||
notice("Start Glance API Service")
|
||||
service { 'glance-api':
|
||||
name => $glance_api,
|
||||
ensure => "running",
|
||||
hasstatus => true,
|
||||
}
|
||||
|
||||
if $deployment_mode == 'ha_compact' {
|
||||
service { 'swift-proxy':
|
||||
name => $swift_proxy,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
|
||||
service { 'swift-object':
|
||||
name => $swift_object,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-object-auditor':
|
||||
name => $swift_object_auditor,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-object-replicator':
|
||||
name => $swift_object_replicator,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-container':
|
||||
name => $swift_container,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-container-auditor':
|
||||
name => $swift_container_auditor,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-container-replicator':
|
||||
name => $swift_container_replicator,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-container-updater':
|
||||
name => $swift_container_updater,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-container-sync':
|
||||
name => $swift_container_sync,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
|
||||
|
||||
service { 'swift-account':
|
||||
name => $swift_account,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-account-auditor':
|
||||
name => $swift_account_auditor,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-account-replicator':
|
||||
name => $swift_account_replicator,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
service { 'swift-account-reaper':
|
||||
name => $swift_account_reaper,
|
||||
ensure => "stopped",
|
||||
enable => false,
|
||||
hasstatus => true,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'hiera'
|
||||
|
||||
ENV['LANG'] = 'C'
|
||||
|
||||
hiera = Hiera.new(:config => '/etc/hiera.yaml')
|
||||
test_vm_images = hiera.lookup 'test_vm_image', {}, {}
|
||||
glanced = hiera.lookup 'glance', {} , {}
|
||||
auth_addr = hiera.lookup 'internal_address', nil, {}
|
||||
|
||||
ENV['OS_TENANT_NAME']="services"
|
||||
ENV['OS_USERNAME']="glance"
|
||||
ENV['OS_PASSWORD']="#{glanced['user_password']}"
|
||||
ENV['OS_AUTH_URL']="http://#{auth_addr}:5000/v2.0"
|
||||
ENV['OS_ENDPOINT_TYPE'] = "internalURL"
|
||||
|
||||
raise 'Not test_vm_image data!' unless [Array, Hash].include?(test_vm_images.class) && test_vm_images.any?
|
||||
|
||||
test_vm_images = [test_vm_images] unless test_vm_images.is_a? Array
|
||||
|
||||
test_vm_images.each do |image|
|
||||
%w(
|
||||
disk_format
|
||||
img_path
|
||||
img_name
|
||||
os_name
|
||||
public
|
||||
container_format
|
||||
min_ram
|
||||
).each do |f|
|
||||
raise "Data field '#{f}' is missing!" unless image[f]
|
||||
end
|
||||
end
|
||||
|
||||
def image_list
|
||||
stdout = `glance image-list`
|
||||
return_code = $?.exitstatus
|
||||
images = []
|
||||
uuid = []
|
||||
stdout.split("\n").each do |line|
|
||||
fields = line.split('|').map { |f| f.chomp.strip }
|
||||
next if fields[1] == 'ID'
|
||||
next unless fields[2]
|
||||
images << fields[2]
|
||||
uuid << fields[1]
|
||||
end
|
||||
{:images => images, :uuid => uuid, :exit_code => return_code}
|
||||
end
|
||||
|
||||
def image_create(image_hash)
|
||||
command = <<-EOF
|
||||
/usr/bin/glance image-create \
|
||||
--name '#{image_hash['img_name']}' \
|
||||
--is-public '#{image_hash['public']}' \
|
||||
--container-format='#{image_hash['container_format']}' \
|
||||
--disk-format='#{image_hash['disk_format']}' \
|
||||
--min-ram='#{image_hash['min_ram']}' \
|
||||
#{image_hash['glance_properties']} \
|
||||
--file '#{image_hash['img_path']}'
|
||||
EOF
|
||||
puts command
|
||||
stdout = `#{command}`
|
||||
return_code = $?.exitstatus
|
||||
[ stdout, return_code ]
|
||||
end
|
||||
|
||||
# check if Glance is online
|
||||
# waited until the glance is started because when vCenter used as a glance
|
||||
# backend launch may takes up to 1 minute.
|
||||
def wait_for_glance
|
||||
5.times.each do |retries|
|
||||
sleep 10 if retries > 0
|
||||
return if image_list[:exit_code] == 0
|
||||
end
|
||||
raise 'Could not get a list of glance images!'
|
||||
end
|
||||
|
||||
# upload image to Glance
|
||||
# if it have not been already uploaded
|
||||
def upload_image(image)
|
||||
list_of_images = image_list
|
||||
if list_of_images[:images].include?(image['img_name']) && list_of_images[:exit_code] == 0
|
||||
# Check the image is stored in swift
|
||||
stdout = `swift post glance`
|
||||
stdout = `swift list glance | grep #{list_of_images[:uuid][0]}`
|
||||
return_code = $?.exitstatus
|
||||
if return_code == 0
|
||||
puts "Image '#{image['img_name']}' is already present!"
|
||||
else
|
||||
stdout = `glance image-delete #{list_of_images[:uuid][0]}`
|
||||
return_code = $?.exitstatus
|
||||
[ stdout, return_code ]
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
stdout, return_code = image_create(image)
|
||||
if return_code == 0
|
||||
puts "Image '#{image['img_name']}' was uploaded from '#{image['img_path']}'"
|
||||
else
|
||||
puts "Image '#{image['img_name']}' upload from '#{image['img_path']}' have FAILED!"
|
||||
end
|
||||
puts stdout
|
||||
return return_code
|
||||
end
|
||||
|
||||
########################
|
||||
|
||||
wait_for_glance
|
||||
errors = 0
|
||||
|
||||
test_vm_images.each do |image|
|
||||
errors += upload_image(image)
|
||||
end
|
||||
|
||||
exit 1 unless errors == 0
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
attributes:
|
||||
swift_api_address:
|
||||
value: '192.168.1.100'
|
||||
label: 'Swift API IP Address'
|
||||
description: 'Swift cluster API IP Address'
|
||||
weight: 30
|
||||
type: "text"
|
||||
regex:
|
||||
source: '^((?:\d|1?\d\d|2[0-4]\d|25[0-5])(?:\.(?:\d|1?\d\d|2[0-4]\d|25[0-5])){3})|(?:^)$'
|
||||
error: "Invalid IP address"
|
|
@ -0,0 +1,35 @@
|
|||
# Plugin name
|
||||
name: swiftstack
|
||||
# Human-readable name for your plugin
|
||||
title: Enable SwiftStack Swift cluster integration
|
||||
# Plugin version
|
||||
version: '0.1.0'
|
||||
# Description
|
||||
description: Integrate Keystone, Glance and existing SwiftStack Swift cluster
|
||||
# Required fuel version
|
||||
fuel_version: ['6.1']
|
||||
|
||||
# The plugin is compatible with releases in the list
|
||||
releases:
|
||||
- os: ubuntu
|
||||
version: 2014.2-6.1
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/ubuntu
|
||||
- os: centos
|
||||
version: 2014.2-6.1
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/centos
|
||||
|
||||
# Version of plugin package
|
||||
package_version: '2.0.0'
|
||||
# Licences
|
||||
licenses: ['Apache License Version 2.0']
|
||||
# Specify author or company name
|
||||
authors: ['SwiftStack Inc.']
|
||||
# A link to the plugin homepage
|
||||
homepage: 'https://github.com/stackforge/fuel-plugin-swiftstack'
|
||||
groups: ['storage']
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
ROOT="$(dirname `readlink -f $0`)"
|
||||
MODULES="${ROOT}"/deployment_scripts/puppet/modules
|
||||
RPM_REPO="${ROOT}"/repositories/centos/
|
||||
DEB_REPO="${ROOT}"/repositories/ubuntu/
|
||||
|
||||
|
||||
# Puppet manifests from fuel-lib
|
||||
FUEL_LIB_VERSION="6.1"
|
||||
FUEL_LIB_TARBALL_URL="https://github.com/stackforge/fuel-library/archive/${FUEL_LIB_VERSION}.tar.gz"
|
||||
|
||||
# Include dependent manifests from fuel-library
|
||||
wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
|
||||
tar -C "${MODULES}" --strip-components=3 -zxvf - \
|
||||
fuel-library-${FUEL_LIB_VERSION}/deployment/puppet/{stdlib,concat,lvm,glance,swift,inifile,keystone}
|
|
@ -0,0 +1,30 @@
|
|||
# This tasks will be applied on controller nodes,
|
||||
# here you can also specify several roles, for example
|
||||
# ['cinder', 'compute'] will be applied only on
|
||||
# cinder and compute nodes
|
||||
|
||||
|
||||
- role: ['primary-controller']
|
||||
stage: post_deployment
|
||||
type: shell
|
||||
parameters:
|
||||
cmd: ruby delete_entrypoint.rb
|
||||
timeout: 120
|
||||
|
||||
- role: ['primary-controller','controller']
|
||||
stage: post_deployment
|
||||
type: puppet
|
||||
parameters:
|
||||
puppet_manifest: puppet/manifests/sscluster.pp
|
||||
puppet_modules: puppet/modules
|
||||
timeout: 420
|
||||
|
||||
- role: ['primary-controller']
|
||||
stage: post_deployment
|
||||
type: shell
|
||||
parameters:
|
||||
cmd: ruby upload_cirros.rb
|
||||
retries: 3
|
||||
interval: 20
|
||||
timeout: 180
|
||||
|
Loading…
Reference in New Issue