Skip to content

Commit

Permalink
Feat/blog diskless flavors (#715)
Browse files Browse the repository at this point in the history
* Start blog article on diskless flavors.
* Added a few links. Filled Why SSD flavors section.
* Rename to 2023-08-21 to reflect planned publication date.
* Picture for a diskless flavor.
* Add horizon vm instance creation screenshot.
* Add openstack SDK example
* Example script to create a diskless VM.
* openstack client usage.
* terraform, capo and k8s-capi documentation complete.
* ispell found a few typos ...
* Add TL;DR.
* Fix avatar link.
* Add missing patch.
* Add link from de to en. Two wording fixes.
* Also copy _assets/scripts directory into build.
* Lots of wording fixes from Filip. 
* Avoid the term diskful(l). Clarify flavor with disk downgrade.
  This implements two suggestions from Filip in a slightly different way.
* Another attempt to the right asset syntax.

Signed-off-by: Kurt Garloff <[email protected]>
Co-authored-by: Filip Dobrovolný <[email protected]>
  • Loading branch information
garloff and fdobrovolny authored Aug 21, 2023
1 parent 5e268ec commit 017555d
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _assets/images/blog/diskless/diskless.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions _assets/scripts/create_vm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
# Create a VM on a diskless flavor
# (c) Kurt Garloff <[email protected]>, 2023-08-20
# SPDX-License-Identifier: Apache-2.0

import openstack
import sys

# OS_CLOUD will be taken from environment
FLAVOR="SCS-1V-2"
NETWORK=""
IMAGE="Debian 12"
KEYNAME="SSHkey-gxscscapi"

def main(argv):
"""
Creates a server on a diskless flavor in a cloud env["OS_CLOUD"]
(configured in clouds.yaml+secure.yaml) with flavor FLAVOR
in network NETWORK (defaults to first if empty) with image IMAGE
injecting keypair KEYNAME.
"""
# Connect and get token
conn = openstack.connect()
conn.authorize()
# Get flavor and image IDs
flavor = conn.compute.find_flavor(FLAVOR)
if not flavor:
raise ValueError(f"No flavor {FLAVOR} found")
image = conn.compute.find_image(IMAGE)
if not image:
raise ValueError(f"No image {IMAGE} found")
# Determine network to connect to
found_network = None
for net in conn.network.networks():
if not net.is_admin_state_up or net.is_router_external:
continue
if not NETWORK or net.name == NETWORK:
found_network = net
break
if found_network is None:
raise ValueError(f"No network {NETWORK} found")
# Create VM instance
vm = conn.compute.create_server(
name="test-diskless",
networks=[{"uuid": found_network.id}],
flavor_id=flavor.id,
key_name=KEYNAME,
block_device_mapping_v2=[{'boot_index': 0,
'uuid': image.id,
'source_type': 'image',
'volume_size': 12,
'destination_type': 'volume',
'delete_on_termination': True}
]
)

if __name__ == "__main__":
main(sys.argv)
11 changes: 11 additions & 0 deletions _assets/scripts/openstackclient-diskless-boot.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- openstackclient/compute/v2/server.py.orig 2021-03-20 10:17:40.000000000 +0100
+++ openstackclient/compute/v2/server.py 2023-07-03 15:59:27.301268807 +0200
@@ -802,7 +802,7 @@ class CreateServer(command.ShowOne):
help=_('Create server with this flavor (name or ID)'),
)
disk_group = parser.add_mutually_exclusive_group(
- required=True,
+ required=False,
)
disk_group.add_argument(
'--image',
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ assets:
- _assets/vendor
- _assets/slides
- _assets/fonts
- _assets/scripts
- _assets/css/_sass
source_maps: false
cache: false
Expand Down
1 change: 1 addition & 0 deletions _i18n/de/_posts/blog/2023-08-21-diskless-flavors.md
Loading

0 comments on commit 017555d

Please sign in to comment.