← Back to team overview

cf-charmers team mailing list archive

[Merge] lp:~lomov-as/charms/trusty/cf-dea/trunk into lp:~cf-charmers/charms/trusty/cf-dea/trunk

 

Alex Lomov has proposed merging lp:~lomov-as/charms/trusty/cf-dea/trunk into lp:~cf-charmers/charms/trusty/cf-dea/trunk.

Requested reviews:
  Cloud Foundry Charmers (cf-charmers)

For more details, see:
https://code.launchpad.net/~lomov-as/charms/trusty/cf-dea/trunk/+merge/219169

Support for new cf-loggregator and cf-logrouter

Relation names are changed (check metadata.yml), charmhelpers updated, changed context for loggregator, also slight changes are made to cf-logging-dea-agent
-- 
https://code.launchpad.net/~lomov-as/charms/trusty/cf-dea/trunk/+merge/219169
Your team Cloud Foundry Charmers is requested to review the proposed merge of lp:~lomov-as/charms/trusty/cf-dea/trunk into lp:~cf-charmers/charms/trusty/cf-dea/trunk.
=== modified file 'files/dla_bin/dea_logging_agent_ctl'
--- files/dla_bin/dea_logging_agent_ctl	2014-04-20 15:10:34 +0000
+++ files/dla_bin/dea_logging_agent_ctl	2014-05-12 11:06:19 +0000
@@ -1,5 +1,4 @@
-
-	#!/bin/bash -e
+#!/bin/bash -e
 
 RUN_DIR=/var/vcap/sys/run/dea_logging_agent
 LOG_DIR=/var/vcap/sys/log/dea_logging_agent

=== modified file 'hooks/charmhelpers/contrib/cloudfoundry/common.py'
--- hooks/charmhelpers/contrib/cloudfoundry/common.py	2014-04-13 18:06:48 +0000
+++ hooks/charmhelpers/contrib/cloudfoundry/common.py	2014-05-12 11:06:19 +0000
@@ -48,9 +48,9 @@
     gid = grp.getgrnam(group).gr_gid
     for root, dirs, files in os.walk(path):
         for momo in dirs:
-            os.lchown(os.path.join(root, momo), uid, gid)
-        for momo in files:
-            os.lchown(os.path.join(root, momo), uid, gid)
+            os.chown(os.path.join(root, momo), uid, gid)
+            for momo in files:
+                os.chown(os.path.join(root, momo), uid, gid)
 
 
 @contextmanager
@@ -63,7 +63,9 @@
 
 
 def prepare_cloudfoundry_environment(config_data, packages):
-    add_source(config_data['source'], config_data.get('key'))
-    apt_update(fatal=True)
-    apt_install(packages=filter_installed_packages(packages), fatal=True)
+    if 'source' in config_data:
+        add_source(config_data['source'], config_data.get('key'))
+        apt_update(fatal=True)
+    if packages:
+        apt_install(packages=filter_installed_packages(packages), fatal=True)
     host.adduser('vcap')

=== modified file 'hooks/charmhelpers/contrib/cloudfoundry/contexts.py'
--- hooks/charmhelpers/contrib/cloudfoundry/contexts.py	2014-04-21 07:12:40 +0000
+++ hooks/charmhelpers/contrib/cloudfoundry/contexts.py	2014-05-12 11:06:19 +0000
@@ -29,19 +29,30 @@
         return hookenv.config()
 
 
+class StorableContext(object):
+    
+    def store_context(self, file_name, config_data):
+        with open(file_name, 'w') as file_stream:
+            yaml.dump(config_data, file_stream)
+
+    def read_context(self, file_name):
+        with open(file_name, 'r') as file_stream:
+            data = yaml.load(file_stream)
+            if not data:
+                raise OSError("%s is empty" % file_name)
+            return data
+
+
 # Stores `config_data` hash into yaml file with `file_name` as a name
 # if `file_name` already exists, then it loads data from `file_name`.
-class StoredContext(OSContextGenerator):
+class StoredContext(OSContextGenerator, StorableContext):
+
     def __init__(self, file_name, config_data):
         self.data = config_data
         if os.path.exists(file_name):
-            with open(file_name, 'r') as file_stream:
-                self.data = yaml.load(file_stream)
-                if not self.data:
-                    raise OSError("%s is empty" % file_name)
+            self.data = self.read_context(file_name)
         else:
-            with open(file_name, 'w') as file_stream:
-                yaml.dump(config_data, file_stream)
+            self.store_context(file_name, config_data)
             self.data = config_data
 
     def __call__(self):
@@ -65,6 +76,8 @@
     interface = 'router'
     required_keys = ['domain']
 
-class LogsContext(RelationContext):
-    interface = 'logs'
-    required_keys = ['shared_secret', 'logrouter_address']
+
+class LoggregatorContext(RelationContext):
+    interface = 'loggregator'
+    required_keys = ['shared_secret', 'loggregator_address']
+

=== modified file 'hooks/hooks.py'
--- hooks/hooks.py	2014-04-19 14:09:22 +0000
+++ hooks/hooks.py	2014-05-12 11:06:19 +0000
@@ -34,7 +34,7 @@
             'target': os.path.join(DLA_CONF_DIR, 'dea_logging_agent.json'),
             'file_properties': fileproperties,
             'contexts': [contexts.NatsContext(),
-                         contexts.LogsContext()]
+                         contexts.LoggregatorContext()]
         }]
     }], TEMPLATE_DIR)
 
@@ -68,8 +68,8 @@
     services.reconfigure_services()
 
 
-@hooks.hook('logs-relation-changed')
-def logs_relation_changed():
+@hooks.hook('loggregator-relation-changed')
+def loggregator_relation_changed():
     services.reconfigure_services()
 
 

=== modified file 'hooks/install'
--- hooks/install	2014-04-21 11:54:18 +0000
+++ hooks/install	2014-05-12 11:06:19 +0000
@@ -51,6 +51,7 @@
     for item in dirs:
         host.mkdir(item, owner='vcap', group='vcap', perms=0775)
     os.chdir(DEA_DIR)
+    # chownr '/var/vcap', 'vcap'
 
     for bin_file in glob.glob(CHARM_DIR + '/files/bin/*'):
         shutil.copy(bin_file, os.path.join(DEA_DIR, 'jobs', 'bin'))

=== added symlink 'hooks/loggregator-relation-changed'
=== target is u'hooks.py'
=== removed symlink 'hooks/logs-relation-changed'
=== target was u'hooks.py'
=== modified file 'metadata.yaml'
--- metadata.yaml	2014-05-12 07:18:47 +0000
+++ metadata.yaml	2014-05-12 11:06:19 +0000
@@ -10,5 +10,5 @@
     interface: nats
   router:
     interface: router
-  logs:
-    interface: logs
+  loggregator:
+    interface: loggregator

=== modified file 'templates/dea_logging_agent.json'
--- templates/dea_logging_agent.json	2014-04-20 04:24:44 +0000
+++ templates/dea_logging_agent.json	2014-05-12 11:06:19 +0000
@@ -1,7 +1,7 @@
 {
     "Index": 0,
-    "LoggregatorAddress": "{{ logs['logrouter_address'] }}:3456",
-    "SharedSecret": "{{ logs['shared_secret'] }}",
+    "LoggregatorAddress": "{{ loggregator['loggregator_address'] }}:3456",
+    "SharedSecret": "{{ loggregator['shared_secret'] }}",
     "NatsHost":  "{{ nats['nats_address'] }}",
     "NatsPort": {{ nats['nats_port'] }},
     "NatsUser": "{{ nats['nats_user'] }}",


References