Skip to content

Commit

Permalink
pillar example working
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfeuer committed Feb 21, 2017
1 parent 75436a1 commit 396729c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
23 changes: 13 additions & 10 deletions flyingcloud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
registry_config=None,
source_version_tag="latest",
environment=None,
pillar=None
pillar=None,
):
self.app_name = app_name
self.layer_name = layer_name
Expand All @@ -103,7 +103,9 @@ def __init__(
self.description = description
self.exposed_ports = exposed_ports or []
self.environment = environment
self.pillar = None
self.pillar = pillar
self.base_dir = None
self.pillar_dir = None

config = self.RegistryConfig.copy()
if registry_config:
Expand Down Expand Up @@ -147,9 +149,13 @@ def check_user_is_root(cls):
raise NotSudoError("You must be root (use sudo)")

def set_pillar(self, namespace):
pillar = namespace.pillar
pillar = namespace.pillar or self.pillar
self.base_dir = namespace.base_dir
if pillar:
self.pillar = pillar
pillar_basedir = os.path.join(self.base_dir, 'pillar')
self.pillar_dir = os.path.join(pillar_basedir, self.pillar)
namespace.logger.info("Using pillar '{}' and setting pillar_dir to '{}'.".format(self.pillar, self.pillar_dir))

def check_environment_variables(self, namespace):
cfg = self.registry_config
Expand Down Expand Up @@ -310,13 +316,13 @@ def salt_highstate(
volume_map = {
salt_dir: "/srv/salt",
}
if namespace.pillar_dir:
volume_map[namespace.pillar_dir] = "/srv/pillar"
if self.pillar_dir:
volume_map[self.pillar_dir] = "/srv/pillar"
try:
target_container_name = self.docker_create_container(
namespace, container_name, source_image_name,
environment=self.make_environment(namespace.env_vars, self.environment),
volume_map=volume_map,
volume_map=volume_map
)

self.docker_start(namespace, target_container_name)
Expand Down Expand Up @@ -917,10 +923,7 @@ def parse_args(self, defaults, *layer_classes, **kwargs):

self.add_additional_configuration(namespace)

if namespace.pillar:
pillar_basedir = os.path.join(defaults['base_dir'], "pillar")
namespace.pillar_dir = os.path.join(pillar_basedir, namespace.pillar)

namespace.base_dir = defaults['base_dir']
return namespace

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion flyingcloud/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def main():
description=project_info['description']
)
instance.check_environment_variables(namespace)
instance.set_pillar(namespace)
for layer in layers:
layer.set_pillar(namespace)

instance = namespace.layer_inst
instance.do_operation(namespace)
Expand Down

0 comments on commit 396729c

Please sign in to comment.