Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D3AE217A43 for ; Thu, 25 Sep 2014 21:48:18 +0000 (UTC) Received: (qmail 79097 invoked by uid 500); 25 Sep 2014 21:48:18 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 79066 invoked by uid 500); 25 Sep 2014 21:48:18 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 79054 invoked by uid 99); 25 Sep 2014 21:48:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2014 21:48:18 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andrew.kennedy@cloudsoftcorp.com designates 209.85.216.180 as permitted sender) Received: from [209.85.216.180] (HELO mail-qc0-f180.google.com) (209.85.216.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2014 21:48:14 +0000 Received: by mail-qc0-f180.google.com with SMTP id l6so5487743qcy.39 for ; Thu, 25 Sep 2014 14:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudsoftcorp.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=u7ZxzVEWMWOa0dq4OxKls46L2SjRKz8KcsWiiPecL6I=; b=SRI+HtEf2ZeW6GzxgTqRJhETuk2nRhTxaO3dbvjNNzr4hkYarE/Ql/XO1cvwPGGIw9 Tc9ufNoK55Qrh/pfLsafq18OMcdO1INqZw8pHGzpjpbeYWXQ57f8RmGMl820VFboXSgD /fOL5v3Xai5rjjGi1cxphIc49zjO3FTINa2m8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=u7ZxzVEWMWOa0dq4OxKls46L2SjRKz8KcsWiiPecL6I=; b=hugx8YjrdEcIunT7qr3W423uX5BchmitIOSbWVtgWsfsxN9gxsELy99g6t16o95/CA I+2B3QtjUFqbFRqidftvSEt2OCe6vCaoMUEbAX4GNOe+YwdBS0ZqJxhLXEz2zkKwZu1M 6MtRwqte7tqiMu3o1w0KI4q48qv9QpxoxSPOV5ICp9MQLghQ3YQSzBCG/Wg2evziMKnR lr0aRRQ5yh/cf+x/GdLqYORkgZ5HT4xQUwKD/fB6RwXBxfq+/ZlrjBNiRKYpGRMKKV/y bIPajidMqoLMAC/WvQE034hP+D+mJbEwycxLHxof8TPLBkS0O6nkjHoUhRuqa9LsEkLK NqdQ== X-Gm-Message-State: ALoCoQnxykKst4MhPKV6e9d9aYMzdNMyBzLy8jWPuyEkb0s4wWJfPwcE1L0wu2KT8V1/bU1yPVlA MIME-Version: 1.0 X-Received: by 10.140.20.105 with SMTP id 96mr24674427qgi.33.1411681673220; Thu, 25 Sep 2014 14:47:53 -0700 (PDT) Received: by 10.96.24.165 with HTTP; Thu, 25 Sep 2014 14:47:53 -0700 (PDT) In-Reply-To: <54245BEA.3060603@lcc.uma.es> References: <54245BEA.3060603@lcc.uma.es> Date: Thu, 25 Sep 2014 22:47:53 +0100 Message-ID: Subject: Re: Problem using ConfigKey> From: Andrew Kennedy To: dev@brooklyn.incubator.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Jose, Hi. There are some issues using $brooklyn functions and deferred values using Map valued ConfigKeys at the moment, which I am working on resolving in pull request #182, however in the mean time I suggest you try this: Change the type of the key to MapConfigKey, declared like this: MapConfigKey DB_CONNECTION_CONFIG_PARAMS = new MapConfigKey(Object.class, "php.db.connection.config.params"); Then you should be able to specify the configuration in the YAML like this: brooklyn.config: db_connection_config_params: g_DatabaseHost: $brooklyn:component("db").attributeWhenReady("datastore.url") g_DatabasePort: $brooklyn:component("db").attributeWhenReady("mysql.port") Hopefully this is helpful. Cheers, Andrew. -- -- andrew kennedy ? cloud engineer : http://blog.abstractvisitorpattern.co.uk/ ; On 25 September 2014 19:16, Jose Carrasco wrote: > Hello, > > I am currently developing a new entities for Brooklyn (into SeaClouds > project context). > I have found a problem using the ConfigKey. > > I am using a ConfigKey> to my entity the parameters > necessaty to stablish a database > connection. I have decided to use a Map because the user could find a smart > and flexible way flexible to specify > several attributes and their values, e.g.: > > name: PHP HelloWorld > services: > - serviceType: brooklyn.entity.webapp.apache.ApacheServer > name: Apache Server > location: localhost > brooklyn.config: > http_port: 80 > app_git_repo_url:https://bitbucket.org/seaclDem/nurocasestudyphp5-5.git > > db_connection_config_params: > g_DatabaseHost: $brooklyn:formatString("%s", > component("db").attributeWhenReady("datastore.url")) > g_DatabasePort: > $brooklyn:component("db").attributeWhenReady("mysql.port") > > - serviceType: brooklyn.entity.database.mysql.MySqlNode > id: db > name: My DB > location: localhost > brooklyn.config: > datastore.creation.script.url: file:///root/Desktop/brooklynTest/create.sql > > In this example the db_connection_config_params is a MapConfigKey: > > @SetFromFlag("db_connection_config_params") > public static final ConfigKey> > DB_CONNECTION_CONFIG_PARAMS = new BasicConfigKey( > Map.class, "php.db.connection.config.params", "PHP application > file to start e.g. main.php, or launch.php"); > > Which contains two items which are used to configure the database. In this > case, the values of the > aforementioned items are provided by MySQL entity. It works ok. > Here, I find a problem getting the values of the g_DatabaseHost and > g_DatabasePort in my java code. When > I read the values of the aforementiond items the returned values are > $brooklyn:formatString("%s"). > > I have changed the YAML definition using: > > g_DatabaseHost: > $brooklyn:component("db").attributeWhenReady("datastore.url")) > g_DatabasePort: > $brooklyn:component("db").attributeWhenReady("mysql.port") > > But I have obteined > $brooklyn:component("db").attributeWhenReady("datastore.url")) and > $brooklyn:component("db").attributeWhenReady("mysql.portl")) respectively. > > I thought the problem could be the component values request (e.g. > $brooklyn:component("db"). > attributeWhenReady("datastore.url"))), then I assinged these values to > simple ConfigKey but > they worked good. > > Thus, the problem may be ConfigKey> parser does not evalue the > expresions which uses > $brooklyn:... but I do not know. > > Could anyone point me in the right direction? Thank you very much. > > Thanks a lot, > Jose. > > >