summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Hussey <sh8121@att.com>2018-09-25 17:02:33 -0500
committerScott Hussey <sh8121@att.com>2018-09-26 08:57:10 -0500
commit2c9ec2503a557e854ba2d503e27625871e81bab9 (patch)
tree3d4d062205d759020172498c72c59799f9e0fd3d
parenta3c88be95a0decb6e2576bdba3eaf6743baf8442 (diff)
(fix) Fix missing parameter for node pkg list
- When compiling a list of packages to be installed on deploying nodes the function call to render all bootactions was missing a parameter introduced in [0] to secure the bootaction. - Add unit testing for this flow Change-Id: I9f59819d6b79290a9f72db2a5a4c3422f2c79739
Notes
Notes (review): Code-Review+2: Aaron Sheffield <ajs@sheffieldfamily.net> Code-Review+2: Bryan Strassner <bryan.strassner@gmail.com> Workflow+1: Bryan Strassner <bryan.strassner@gmail.com> Code-Review+1: Serge Kovaleff <sk607s@att.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 26 Sep 2018 21:12:24 +0000 Reviewed-on: https://review.openstack.org/605246 Project: openstack/airship-drydock Branch: refs/heads/master
-rw-r--r--python/drydock_provisioner/control/bootaction.py6
-rw-r--r--python/drydock_provisioner/orchestrator/orchestrator.py4
-rw-r--r--python/tests/unit/test_bootaction_asset_render.py20
-rw-r--r--python/tests/yaml_samples/deckhand_fullsite.yaml4
4 files changed, 31 insertions, 3 deletions
diff --git a/python/drydock_provisioner/control/bootaction.py b/python/drydock_provisioner/control/bootaction.py
index d4ee733..72aa434 100644
--- a/python/drydock_provisioner/control/bootaction.py
+++ b/python/drydock_provisioner/control/bootaction.py
@@ -23,8 +23,8 @@ import ulid2
23import falcon 23import falcon
24 24
25from drydock_provisioner.objects.fields import ActionResult 25from drydock_provisioner.objects.fields import ActionResult
26from drydock_provisioner.objects.fields import BootactionAssetType
26import drydock_provisioner.objects as objects 27import drydock_provisioner.objects as objects
27
28from .base import StatefulResource 28from .base import StatefulResource
29 29
30logger = logging.getLogger('drydock') 30logger = logging.getLogger('drydock')
@@ -261,7 +261,9 @@ class BootactionUtils(object):
261 tarbytes = io.BytesIO() 261 tarbytes = io.BytesIO()
262 tarball = tarfile.open( 262 tarball = tarfile.open(
263 mode='w:gz', fileobj=tarbytes, format=tarfile.GNU_FORMAT) 263 mode='w:gz', fileobj=tarbytes, format=tarfile.GNU_FORMAT)
264 asset_list = asset_list or [] 264 asset_list = [
265 a for a in asset_list if a.type != BootactionAssetType.PackageList
266 ]
265 for a in asset_list: 267 for a in asset_list:
266 fileobj = io.BytesIO(a.rendered_bytes) 268 fileobj = io.BytesIO(a.rendered_bytes)
267 tarasset = tarfile.TarInfo(name=a.path) 269 tarasset = tarfile.TarInfo(name=a.path)
diff --git a/python/drydock_provisioner/orchestrator/orchestrator.py b/python/drydock_provisioner/orchestrator/orchestrator.py
index e28ed15..6ea9f66 100644
--- a/python/drydock_provisioner/orchestrator/orchestrator.py
+++ b/python/drydock_provisioner/orchestrator/orchestrator.py
@@ -627,10 +627,14 @@ class Orchestrator(object):
627 627
628 for ba in site_design.bootactions: 628 for ba in site_design.bootactions:
629 if nodename in ba.target_nodes: 629 if nodename in ba.target_nodes:
630 # NOTE(sh8121att) the ulid generation below
631 # is throw away data as these assets are only used to
632 # get a full list of packages to deploy
630 assets = ba.render_assets( 633 assets = ba.render_assets(
631 nodename, 634 nodename,
632 site_design, 635 site_design,
633 ulid2.generate_binary_ulid(), 636 ulid2.generate_binary_ulid(),
637 ulid2.generate_binary_ulid(),
634 task.design_ref, 638 task.design_ref,
635 type_filter=hd_fields.BootactionAssetType.PackageList) 639 type_filter=hd_fields.BootactionAssetType.PackageList)
636 for a in assets: 640 for a in assets:
diff --git a/python/tests/unit/test_bootaction_asset_render.py b/python/tests/unit/test_bootaction_asset_render.py
index eb378f5..036f0f2 100644
--- a/python/tests/unit/test_bootaction_asset_render.py
+++ b/python/tests/unit/test_bootaction_asset_render.py
@@ -17,6 +17,8 @@ import ulid2
17import os 17import os
18 18
19from drydock_provisioner.statemgmt.state import DrydockState 19from drydock_provisioner.statemgmt.state import DrydockState
20from drydock_provisioner.objects import Task
21from drydock_provisioner.objects import fields as hd_fields
20 22
21 23
22class TestBootactionRenderAction(object): 24class TestBootactionRenderAction(object):
@@ -78,7 +80,8 @@ class TestBootactionRenderAction(object):
78 action_key, design_ref) 80 action_key, design_ref)
79 81
80 assert action_key.hex() in assets[2].rendered_bytes.decode('utf-8') 82 assert action_key.hex() in assets[2].rendered_bytes.decode('utf-8')
81 assert ulid2.ulid_to_base32(action_id) in assets[2].rendered_bytes.decode('utf-8') 83 assert ulid2.ulid_to_base32(
84 action_id) in assets[2].rendered_bytes.decode('utf-8')
82 85
83 def test_bootaction_network_context(self, input_files, 86 def test_bootaction_network_context(self, input_files,
84 deckhand_orchestrator, setup): 87 deckhand_orchestrator, setup):
@@ -131,3 +134,18 @@ class TestBootactionRenderAction(object):
131 node_ctx = ba.asset_list[0]._get_node_context('compute01', design_data) 134 node_ctx = ba.asset_list[0]._get_node_context('compute01', design_data)
132 135
133 assert node_ctx['domain'] == node_domain 136 assert node_ctx['domain'] == node_domain
137
138 def test_bootaction_pkg_list(self, input_files, deckhand_orchestrator,
139 setup):
140 """Test that a list of packages to be installed on a ndoe can be compiled from boot actions."""
141 input_file = input_files.join("deckhand_fullsite.yaml")
142
143 design_ref = "file://%s" % str(input_file)
144
145 test_task = Task(
146 action=hd_fields.OrchestratorAction.Noop, design_ref=design_ref)
147
148 pkg_list = deckhand_orchestrator.find_node_package_lists(
149 'compute01', test_task)
150
151 assert len(pkg_list) == 2
diff --git a/python/tests/yaml_samples/deckhand_fullsite.yaml b/python/tests/yaml_samples/deckhand_fullsite.yaml
index e259a46..a8f6b06 100644
--- a/python/tests/yaml_samples/deckhand_fullsite.yaml
+++ b/python/tests/yaml_samples/deckhand_fullsite.yaml
@@ -548,6 +548,10 @@ data:
548 data_pipeline: 548 data_pipeline:
549 - utf8_decode 549 - utf8_decode
550 - template 550 - template
551 - type: pkg_list
552 data:
553 2ping: '3.2.1-1'
554 '0xffff': null
551--- 555---
552schema: 'drydock/BootAction/v1' 556schema: 'drydock/BootAction/v1'
553metadata: 557metadata: