Skip to content

Commit

Permalink
Super simple logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ejholmes committed Jan 26, 2018
1 parent 301901d commit 1040cd6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
18 changes: 18 additions & 0 deletions stacker/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
from stacker.plan2 import Step, build_plan

__version__ = "1.1.3"


def plan(description=None, action=None,
stacks=None, stack_names=None,
reverse=False):
"""A simple helper that builds a graph based plan from a set of stacks."""

steps = [
Step(stack, fn=action)
for stack in stacks]

return build_plan(
description=description,
steps=steps,
step_names=stack_names,
reverse=reverse)
16 changes: 5 additions & 11 deletions stacker/actions/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from stacker import plan
from .base import BaseAction

from ..providers.base import Template
Expand All @@ -10,10 +11,6 @@
StackDoesNotExist,
)

from ..plan2 import (
Step,
build_plan
)
from ..status import (
NotSubmittedStatus,
NotUpdatedStatus,
Expand Down Expand Up @@ -318,14 +315,11 @@ def _template(self, blueprint):
return Template(body=blueprint.rendered)

def _generate_plan(self, tail=False):
steps = [
Step(stack, fn=self._launch_stack)
for stack in self.context.get_stacks()]
plan = build_plan(
return plan(
description="Create/Update stacks",
steps=steps,
step_names=self.context.stack_names)
return plan
action=self._launch_stack,
stacks=self.context.get_stacks(),
stack_names=self.context.stack_names)

def pre_run(self, outline=False, dump=False, *args, **kwargs):
"""Any steps that need to be taken prior to running the action."""
Expand Down
16 changes: 5 additions & 11 deletions stacker/actions/destroy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from stacker import plan
from .base import BaseAction
from ..exceptions import StackDoesNotExist
from .. import util
Expand All @@ -8,10 +9,6 @@
SubmittedStatus,
SUBMITTED,
)
from ..plan2 import (
Step,
build_plan
)

from ..status import StackDoesNotExist as StackDoesNotExistStatus

Expand All @@ -35,15 +32,12 @@ class Action(BaseAction):
"""

def _generate_plan(self, tail=False):
steps = [
Step(stack, fn=self._destroy_stack)
for stack in self.context.get_stacks()]
plan = build_plan(
return plan(
description="Destroy stacks",
steps=steps,
step_names=self.context.stack_names,
action=self._destroy_stack,
stacks=self.context.get_stacks(),
stack_names=self.context.stack_names,
reverse=True)
return plan

def _destroy_stack(self, stack, **kwargs):
try:
Expand Down
16 changes: 5 additions & 11 deletions stacker/actions/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import logging
from operator import attrgetter

from stacker import plan
from . import build
from .. import exceptions
from ..plan2 import (
Step,
build_plan
)
from ..status import NotSubmittedStatus, NotUpdatedStatus, COMPLETE

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -233,14 +230,11 @@ def _diff_stack(self, stack, **kwargs):
return COMPLETE

def _generate_plan(self):
steps = [
Step(stack, fn=self._diff_stack)
for stack in self.context.get_stacks()]
plan = build_plan(
return plan(
description="Diff stacks",
steps=steps,
step_names=self.context.stack_names)
return plan
action=self._diff_stack,
stacks=self.context.get_stacks(),
stack_names=self.context.stack_names)

def run(self, *args, **kwargs):
plan = self._generate_plan()
Expand Down
1 change: 1 addition & 0 deletions stacker/plan2.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def set_status(self, status):
if status is not self.status:
logger.debug("Setting %s state to %s.", self.stack.name,
status.name)
logger.info("%s %s", status.name, self.short_name)
self.status = status
self.last_updated = time.time()

Expand Down

0 comments on commit 1040cd6

Please sign in to comment.