-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.0] ironic: Install deploy image with ironic #2406
base: stable/5.0-pike
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# | ||
# Copyright 2019 SUSE | ||
# | ||
# 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. | ||
# | ||
# Cookbook Name:: ironic | ||
# Recipe:: post_install | ||
# | ||
|
||
keystone_settings = KeystoneHelper.keystone_settings(node, @cookbook_name) | ||
|
||
# the image is uploaded via the glance API | ||
glance_config = Barclamp::Config.load("openstack", "glance", node[:ironic][:glance_instance]) | ||
glance_insecure = CrowbarOpenStackHelper.insecure(glance_config) | ||
openstack_args_glance = glance_insecure || keystone_settings["insecure"] ? "--insecure" : "" | ||
|
||
env = "OS_USERNAME='#{keystone_settings["service_user"]}' " | ||
env << "OS_PASSWORD='#{keystone_settings["service_password"]}' " | ||
env << "OS_PROJECT_NAME='#{keystone_settings["service_tenant"]}' " | ||
env << "OS_AUTH_URL='#{keystone_settings["internal_auth_url"]}' " | ||
env << "OS_INTERFACE=internal " | ||
env << "OS_IDENTITY_API_VERSION=3 " | ||
|
||
kernel_image_prefix = "ir-deploy-kernel" | ||
ramdisk_image_prefix = "ir-deploy-ramdisk" | ||
image_path = "/srv/tftpboot/openstack-ironic-image" | ||
|
||
# vmlinux symlink from openstack-ironic-image points to something like: | ||
# openstack-ironic-image.x86_64-9.0.0.kernel.4.12.14-95.13-default | ||
# find all x.y.z version substrings and pick the first one to be used | ||
# as version suffix | ||
image_version_cmd = "$(readlink #{image_path}/vmlinux | egrep -o '[0-9]+\\.[0-9]+\\.[0-9]+' | head -n1)" | ||
|
||
openstack_cmd = "#{env} openstack" | ||
|
||
bash "upload_ironic_deploy_kernel_image" do | ||
code "#{openstack_cmd} #{openstack_args_glance} image create \ | ||
--disk-format aki --container-format aki --public \ | ||
--file #{image_path}/vmlinux #{kernel_image_prefix}-#{image_version_cmd}" | ||
not_if "#{openstack_cmd} #{openstack_args_glance} image list -f value -c Name | grep -q #{kernel_image_prefix}-#{image_version_cmd}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [134/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) |
||
action :nothing | ||
end | ||
|
||
bash "upload_ironic_deploy_ramdisk_image" do | ||
code "#{openstack_cmd} #{openstack_args_glance} image create \ | ||
--disk-format ari --container-format ari --public \ | ||
--file #{image_path}/initrd #{ramdisk_image_prefix}-#{image_version_cmd}" | ||
not_if "#{openstack_cmd} #{openstack_args_glance} image list -f value -c Name | grep -q #{ramdisk_image_prefix}-#{image_version_cmd}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [135/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) |
||
action :nothing | ||
end | ||
|
||
# This is to trigger the above resource to run :delayed, so that they run at | ||
# the end of the chef-client run, after the ironic services have been restarted | ||
# (in case of a config change) | ||
execute "trigger-ironic-post-commands" do | ||
command "true" | ||
notifies :run, "bash[upload_ironic_deploy_kernel_image]", :delayed | ||
notifies :run, "bash[upload_ironic_deploy_ramdisk_image]", :delayed | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [104/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)