← Back to team overview

cf-charmers team mailing list archive

Re: [Merge] lp:~johnsca/charms/trusty/cloudfoundry/trunk-webadmin into lp:~cf-charmers/charms/trusty/cloudfoundry/trunk

 


Diff comments:

> === modified file 'cloudfoundry/contexts.py'
> --- cloudfoundry/contexts.py	2014-10-27 19:48:56 +0000
> +++ cloudfoundry/contexts.py	2014-10-30 15:24:36 +0000
> @@ -31,6 +31,13 @@
>                                                 rid=rid, unit=unit))
>          return list(units)
>  
> +    def get_first(self, key=None):
> +        data = self[self.name][0]
> +        return data[key] if key is not None else data
> +
> +    def get_all(self, key):
> +        return [u[key] for u in self[self.name]]
> +
>  
>  class StoredContext(dict):
>      """
> @@ -100,7 +107,7 @@
>      def get_data(self):
>          RelationContext.get_data(self)
>          if self.is_ready():
> -            for unit in self['db']:
> +            for unit in self[self.name]:
>                  if 'port' not in unit:
>                      unit['port'] = '3306'
>                  unit['dsn'] = self.dsn_template.format(**unit)
> @@ -114,7 +121,7 @@
>  
>  class UAARelation(RelationContext):
>      name = 'uaa'
> -    interface = 'http'
> +    interface = 'uaa'
>      required_keys = ['login_client_secret', 'admin_client_secret', 'cc_client_secret', 'cc_token_secret',
>                       'service_broker_client_secret', 'servicesmgmt_client_secret', 'port']
>      port = 8081
> @@ -168,6 +175,20 @@
>          }
>  
>  
> +class UAADBRelation(MysqlRelation):
> +    name = 'uaa-db'

If you want to use this relation with services.py module from core charmhelpers, you shouldn't use dashes in a names. The same is also relevant to cc-db.

> +
> +    @classmethod
> +    def send_data(cls, job_name):
> +        # proxy data from the MysqlRelation to this relation
> +        # using send_data instead of provide_data to delay it until data_ready
> +        mysql = MysqlRelation()
> +        if mysql.is_ready():
> +            data = mysql.get_first()
> +            for rid in hookenv.relation_ids(cls.name):
> +                hookenv.relation_set(rid, data)
> +
> +
>  class LoginRelation(RelationContext):
>      name = 'login'
>      interface = 'http'
> @@ -362,17 +383,18 @@
>          }
>  
>  
> -class CloudControllerDBRelation(RelationContext):
> +class CloudControllerDBRelation(MysqlRelation):
>      name = 'cc-db'
> -    interface = 'controller-db'
> -    required_keys = MysqlRelation.required_keys
>  
>      @classmethod
>      def send_data(cls, job_name):
> +        # proxy data from the MysqlRelation to this relation
>          # using send_data instead of provide_data to delay it until data_ready
> -        data = MysqlRelation()['db'][0]
> -        for rid in hookenv.relation_ids(cls.name):
> -            hookenv.relation_set(rid, data)
> +        mysql = MysqlRelation()
> +        if mysql.is_ready():
> +            data = mysql.get_first()
> +            for rid in hookenv.relation_ids(cls.name):
> +                hookenv.relation_set(rid, data)
>  
>  
>  class RouterRelation(RelationContext):
> 
> === modified file 'cloudfoundry/services.py'
> --- cloudfoundry/services.py	2014-09-25 15:23:46 +0000
> +++ cloudfoundry/services.py	2014-10-30 15:24:36 +0000
> @@ -271,11 +271,14 @@
>          'jobs': [
>              {'job_name': 'uaa',
>               'mapping': {'db': mapper.uaadb},
> -             'provided_data': [contexts.UAARelation],
> +             'provided_data': [contexts.UAARelation,
> +                               contexts.UAADBRelation],
>               'required_data': [contexts.MysqlRelation,
>                                 contexts.NatsRelation,
> -                               contexts.UAARelation.remote_view]
> -             }
> +                               contexts.UAARelation.remote_view],
> +             'data_ready': [
> +                 contexts.UAADBRelation.send_data,
> +             ]},
>          ]
>      },
>  
> 
> === modified file 'cloudfoundry/utils.py'
> --- cloudfoundry/utils.py	2014-10-27 19:48:56 +0000
> +++ cloudfoundry/utils.py	2014-10-30 15:24:36 +0000
> @@ -10,7 +10,6 @@
>  from contextlib import contextmanager
>  from functools import partial, wraps
>  
> -import jujuclient
>  import requests
>  import yaml
>  
> @@ -232,6 +231,7 @@
>  
>  
>  def get_client():
> +    import jujuclient
>      global _client
>      if _client is None:
>          def env_connection():
> 


-- 
https://code.launchpad.net/~johnsca/charms/trusty/cloudfoundry/trunk-webadmin/+merge/240033
Your team Cloud Foundry Charmers is subscribed to branch lp:~cf-charmers/charms/trusty/cloudfoundry/trunk.


Follow ups

References