[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276971#comment-15276971
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user johnmccabe commented on the pull request:

https://github.com/apache/brooklyn-server/pull/132#issuecomment-217979935
  
Looks like we're not overriding the `null` credentials returned in the 
`NodeMetadata` in JcloudsLocation.findNodeOrThrow. These should be getting 
replaced with the user/password set in the `ConfigBag`.


> jcloudsByon location spec leaks location instances
> --
>
> Key: BROOKLYN-259
> URL: https://issues.apache.org/jira/browse/BROOKLYN-259
> Project: Brooklyn
>  Issue Type: Bug
>Affects Versions: 0.9.0
>Reporter: Aled Sage
> Fix For: 0.10.0
>
>
> When declaring in brooklyn.properties a location spec such as 
> {noformat}
> jcloudsByon(provider="aws-ec2",region="us-east-1",user="brooklyn",password="pa55w0rd",hosts="i-12345678")
> {noformat}
> It caused new locations to be created and persisted every few seconds, but 
> for those locations to be never deleted.
> ---
> This was caused by changes made in 0.9.0 to {{LocationResolver}} 
> implementations, so that it creates a {{LocationSpec}} rather than 
> instantiating a location directly. Unfortunately, 
> {{JcloudsByonLocationResolver}} had not been updated. The REST api would poll 
> this regularly to find out about the types of location, and on every poll it 
> would create new locations.
> This is similar to the problem encountered for localhost, fixed in time for 
> 0.9.0 in https://github.com/apache/brooklyn-server/pull/97.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread johnmccabe
Github user johnmccabe commented on the pull request:

https://github.com/apache/brooklyn-server/pull/132#issuecomment-217979935
  
Looks like we're not overriding the `null` credentials returned in the 
`NodeMetadata` in JcloudsLocation.findNodeOrThrow. These should be getting 
replaced with the user/password set in the `ConfigBag`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


Build failed in Jenkins: brooklyn-master-windows #105

2016-05-09 Thread Apache Jenkins Server
See 

Changes:

[alex.heneveld] simplify quick-start build instructions

--
[...truncated 47009 lines...]
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-ui\target\brooklyn-jsgui-0.10.0-SNAPSHOT.war
 to 
org.apache.brooklyn/brooklyn-jsgui/0.10.0-SNAPSHOT/brooklyn-jsgui-0.10.0-SNAPSHOT.war
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-ui\target\brooklyn-jsgui-0.10.0-SNAPSHOT-tests.jar
 to 
org.apache.brooklyn/brooklyn-jsgui/0.10.0-SNAPSHOT/brooklyn-jsgui-0.10.0-SNAPSHOT-tests.jar
Compressed 2.84 MB of artifacts by 87.0% relative to #104
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\common\pom.xml
 to 
org.apache.brooklyn/brooklyn-utils-common/0.10.0-SNAPSHOT/brooklyn-utils-common-0.10.0-SNAPSHOT.pom
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\common\target\brooklyn-utils-common-0.10.0-SNAPSHOT.jar
 to 
org.apache.brooklyn/brooklyn-utils-common/0.10.0-SNAPSHOT/brooklyn-utils-common-0.10.0-SNAPSHOT.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\common\target\brooklyn-utils-common-0.10.0-SNAPSHOT-tests.jar
 to 
org.apache.brooklyn/brooklyn-utils-common/0.10.0-SNAPSHOT/brooklyn-utils-common-0.10.0-SNAPSHOT-tests.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\common\target\brooklyn-utils-common-0.10.0-SNAPSHOT-sources.jar
 to 
org.apache.brooklyn/brooklyn-utils-common/0.10.0-SNAPSHOT/brooklyn-utils-common-0.10.0-SNAPSHOT-sources.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\common\target\brooklyn-utils-common-0.10.0-SNAPSHOT-test-sources.jar
 to 
org.apache.brooklyn/brooklyn-utils-common/0.10.0-SNAPSHOT/brooklyn-utils-common-0.10.0-SNAPSHOT-test-sources.jar
Compressed 1.16 MB of artifacts by 10.8% relative to #104
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\groovy\pom.xml
 to 
org.apache.brooklyn/brooklyn-utils-groovy/0.10.0-SNAPSHOT/brooklyn-utils-groovy-0.10.0-SNAPSHOT.pom
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\groovy\target\brooklyn-utils-groovy-0.10.0-SNAPSHOT.jar
 to 
org.apache.brooklyn/brooklyn-utils-groovy/0.10.0-SNAPSHOT/brooklyn-utils-groovy-0.10.0-SNAPSHOT.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\groovy\target\brooklyn-utils-groovy-0.10.0-SNAPSHOT-tests.jar
 to 
org.apache.brooklyn/brooklyn-utils-groovy/0.10.0-SNAPSHOT/brooklyn-utils-groovy-0.10.0-SNAPSHOT-tests.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\groovy\target\brooklyn-utils-groovy-0.10.0-SNAPSHOT-sources.jar
 to 
org.apache.brooklyn/brooklyn-utils-groovy/0.10.0-SNAPSHOT/brooklyn-utils-groovy-0.10.0-SNAPSHOT-sources.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-server\utils\groovy\target\brooklyn-utils-groovy-0.10.0-SNAPSHOT-test-sources.jar
 to 
org.apache.brooklyn/brooklyn-utils-groovy/0.10.0-SNAPSHOT/brooklyn-utils-groovy-0.10.0-SNAPSHOT-test-sources.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-library\examples\simple-web-cluster\pom.xml
 to 
org.apache.brooklyn.example/brooklyn-example-simple-web-cluster/0.10.0-SNAPSHOT/brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT.pom
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-library\examples\simple-web-cluster\target\brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT.jar
 to 
org.apache.brooklyn.example/brooklyn-example-simple-web-cluster/0.10.0-SNAPSHOT/brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-library\examples\simple-web-cluster\target\brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT-tests.jar
 to 
org.apache.brooklyn.example/brooklyn-example-simple-web-cluster/0.10.0-SNAPSHOT/brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT-tests.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-library\examples\simple-web-cluster\target\brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT-sources.jar
 to 
org.apache.brooklyn.example/brooklyn-example-simple-web-cluster/0.10.0-SNAPSHOT/brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT-sources.jar
[JENKINS] Archiving 
F:\hudson\hudson-slave\workspace\brooklyn-master-windows\brooklyn-library\examples\simple-web-cluster\target\brooklyn-example-simple-web-cluster-0.10.0-SNAPSHOT-test-sources.jar
 to 

[GitHub] brooklyn-docs pull request: tidy #1 of maven build instructions

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-docs/pull/53


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Update the tests documentation

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-docs/pull/55


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Update server-cli-reference.md

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-docs/pull/54


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Documenting `waitWindowsToStart' locat...

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-docs/pull/52


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Inclusion of catalog items inside othe...

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-docs/pull/49


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Update the tests documentation

2016-05-09 Thread tbouron
Github user tbouron commented on a diff in the pull request:

https://github.com/apache/brooklyn-docs/pull/55#discussion_r62547620
  
--- Diff: guide/yaml/test/test-entities.md ---
@@ -89,6 +93,10 @@ The `TestEffector` entity invokes the specified effector 
on a target entity. If
 - `params` - parameters to pass to the effector, these will depend on the 
entity and effector being tested. The example above shows the `url` and 
`targetName` parameters being passed to Tomcats `deploy` effector.
 - `assert` - assertion to perform on the returned result. See section on 
assertions below.
 
+
--- End diff --

The `include` seems nice but the line will become quite long depending on 
the text to pass right?

As for using HTML over md, I didn't know I could use markdown inside HTML 
so quite happy to change if you prefer.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


Build failed in Jenkins: brooklyn-master-windows #104

2016-05-09 Thread Apache Jenkins Server
See 

--
[...truncated 22522 lines...]
2016-05-09 19:17:41,626 WARN  Error invoking replaceMember at 
DynamicClusterImpl{id=i79NORsS}: In DynamicClusterImpl{id=i79NORsS}, failed to 
grow, to replace FailingEntityImpl{id=PnW0KkCq}; not removing: Error invoking 
start at FailingEntityImpl{id=QSbp1jgp}: Simulating entity stop failure for test
2016-05-09 19:17:41,628 WARN  ServiceReplacer failed for 
DynamicClusterImpl{id=i79NORsS}: Replace failure (Error invoking replaceMember 
at DynamicClusterImpl{id=i79NORsS}: In DynamicClusterImpl{id=i79NORsS}, failed 
to grow, to replace FailingEntityImpl{id=PnW0KkCq}; not removing: Error 
invoking start at FailingEntityImpl{id=QSbp1jgp}: Simulating entity stop 
failure for test) at DynamicClusterImpl{id=i79NORsS}: 
FailureDescriptor{component=FailingEntityImpl{id=PnW0KkCq}, 
description=simulate failure}
2016-05-09 19:17:41,628 WARN  Setting DynamicClusterImpl{id=i79NORsS} on-fire 
due to problems when expected running, up=true, problems: 
{ServiceReplacer=replacement failed: Replace failure (Error invoking 
replaceMember at DynamicClusterImpl{id=i79NORsS}: In 
DynamicClusterImpl{id=i79NORsS}, failed to grow, to replace 
FailingEntityImpl{id=PnW0KkCq}; not removing: Error invoking start at 
FailingEntityImpl{id=QSbp1jgp}: Simulating entity stop failure for test) at 
DynamicClusterImpl{id=i79NORsS}: 
FailureDescriptor{component=FailingEntityImpl{id=PnW0KkCq}, 
description=simulate failure}}
2016-05-09 19:17:41,629 WARN  Setting Application[evBVStyQ] on-fire due to 
problems when expected running, up=true, problems: 
{service-lifecycle-indicators-from-children-and-members=Required entity not 
healthy: DynamicClusterImpl{id=i79NORsS}}
2016-05-09 19:17:41,635 INFO  TESTNG PASSED: "Surefire test" - 
org.apache.brooklyn.policy.ha.ServiceReplacerTest.testSetsOnFireWhenFailToReplaceMemberManyTimes()
 finished in 114 ms (94 of 100)
2016-05-09 19:17:41,635 INFO  TESTNG INVOKING CONFIGURATION: "Surefire test" - 
@AfterMethod org.apache.brooklyn.policy.ha.ServiceReplacerTest.tearDown()
2016-05-09 19:17:41,650 INFO  TESTNG PASSED CONFIGURATION: "Surefire test" - 
@AfterMethod org.apache.brooklyn.policy.ha.ServiceReplacerTest.tearDown() 
finished in 14 ms
2016-05-09 19:17:41,650 INFO  TESTNG INVOKING CONFIGURATION: "Surefire test" - 
@BeforeMethod org.apache.brooklyn.policy.ha.ServiceReplacerTest.setUp()
2016-05-09 19:17:41,669 INFO  TESTNG PASSED CONFIGURATION: "Surefire test" - 
@BeforeMethod org.apache.brooklyn.policy.ha.ServiceReplacerTest.setUp() 
finished in 18 ms
2016-05-09 19:17:41,669 INFO  TESTNG INVOKING: "Surefire test" - 
org.apache.brooklyn.policy.ha.ServiceReplacerTest.testSetsOnFireWhenFailToReplaceMemberManyTimes()
 success: 100%
2016-05-09 19:17:41,693 INFO  No Camp-YAML parser registered for parsing 
catalog item DSL; skipping DSL-parsing
2016-05-09 19:17:41,708 INFO  Resize DynamicClusterImpl{id=H0AMO0PH} from 0 to 1

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[JENKINS] Recording test results
[INFO] 
[INFO] Reactor Summary:
[INFO] 
[INFO] Brooklyn REST JavaScript Web GUI ... SUCCESS [ 48.845 s]
[INFO] Brooklyn Server Root ... SUCCESS [  0.875 s]
[INFO] Brooklyn Parent Project  SUCCESS [  6.154 s]
[INFO] Brooklyn Test Support Utilities  SUCCESS [  8.279 s]
[INFO] Brooklyn Logback Includable Configuration .. SUCCESS [  1.072 s]
[INFO] Brooklyn Common Utilities .. SUCCESS [ 27.671 s]
[INFO] Brooklyn API ... SUCCESS [  4.052 s]
[INFO] CAMP Server Parent Project . SUCCESS [  0.656 s]
[INFO] CAMP Base .. SUCCESS [  3.967 s]
[INFO] Brooklyn Test Support .. SUCCESS [  2.708 s]
[INFO] Brooklyn REST Swagger Apidoc Utilities . SUCCESS [  3.050 s]
[INFO] Brooklyn Logback Configuration . SUCCESS [  1.296 s]
[INFO] CAMP Server  SUCCESS [  9.761 s]
[INFO] Brooklyn Felix Runtime . SUCCESS [  4.269 s]
[INFO] Brooklyn Groovy Utilities .. SUCCESS [  1.527 s]
[INFO] Brooklyn Core .. SUCCESS [04:23 min]
[INFO] Brooklyn Policies .. FAILURE [01:06 min]
[INFO] Brooklyn WinRM Software Entities ... SKIPPED
[INFO] Brooklyn Secure JMXMP Agent  SKIPPED
[INFO] Brooklyn JMX RMI Agent . SKIPPED
[INFO] Brooklyn Jclouds Location Targets .. SKIPPED
[INFO] Brooklyn Software Base . SKIPPED
[INFO] Brooklyn CAMP REST API . SKIPPED
[INFO] 

[GitHub] brooklyn-docs pull request: Documenting `waitWindowsToStart' locat...

2016-05-09 Thread ahgittin
Github user ahgittin commented on the pull request:

https://github.com/apache/brooklyn-docs/pull/52#issuecomment-217943628
  
LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Update server-cli-reference.md

2016-05-09 Thread ahgittin
Github user ahgittin commented on the pull request:

https://github.com/apache/brooklyn-docs/pull/54#issuecomment-217943793
  
good spot!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-docs pull request: Inclusion of catalog items inside othe...

2016-05-09 Thread ahgittin
Github user ahgittin commented on the pull request:

https://github.com/apache/brooklyn-docs/pull/49#issuecomment-217943347
  
@neykov the comments above are nice to have but can be a follow-on PR.  
this is a good addition already so merging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276549#comment-15276549
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user johnmccabe commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62524649
  
--- Diff: 
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java
 ---
@@ -61,129 +56,140 @@
  * @author aled
  */
 @SuppressWarnings({"unchecked","rawtypes"})
-public class JcloudsByonLocationResolver implements LocationResolver {
+public class JcloudsByonLocationResolver extends AbstractLocationResolver 
implements LocationResolver {
 
 public static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolver.class);
 
 public static final String BYON = "jcloudsByon";
 
-private static final Pattern PATTERN = 
Pattern.compile("("+BYON+"|"+BYON.toUpperCase()+")" + ":" + "\\((.*)\\)$");
-
-private ManagementContext managementContext;
-
 @Override
-public void init(ManagementContext managementContext) {
-this.managementContext = checkNotNull(managementContext, 
"managementContext");
+public boolean isEnabled() {
+return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
 }
 
 @Override
-public boolean isEnabled() {
-return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
+public String getPrefix() {
+return BYON;
 }
 
-// TODO Remove some duplication from JcloudsResolver; needs more 
careful review
 @Override
-public LocationSpec 
newLocationSpecFromString(String spec, Map locationFlags, 
LocationRegistry registry) {
-Map globalProperties = registry.getProperties();
+protected Class getLocationType() {
+return FixedListMachineProvisioningLocation.class;
+}
 
-Matcher matcher = PATTERN.matcher(spec);
-if (!matcher.matches()) {
-throw new IllegalArgumentException("Invalid location 
'"+spec+"'; must specify something like 
jcloudsByon(provider=\"aws-ec2\",region=\"us-east-1\",hosts=\"i-f2014593,i-d1234567\")");
-}
-
-String argsPart = matcher.group(2);
-Map argsMap = KeyValueParser.parseMap(argsPart);
-
-// prefer args map over location flags
-
-String namedLocation = (String) 
locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
+@Override
+protected SpecParser getSpecParser() {
+return new 
AbstractLocationResolver.SpecParser(getPrefix()).setExampleUsage("\"jcloudsByon(provider='aws-ec2',region='us-east-1',hosts='i-12345678,i-90123456')\"");
+}
+
+@Override
+protected ConfigBag extractConfig(Map locationFlags, String spec, 
final LocationRegistry registry) {
+ConfigBag config = super.extractConfig(locationFlags, spec, 
registry);
 
-String providerOrApi = argsMap.containsKey("provider") ? 
argsMap.get("provider") : (String)locationFlags.get("provider");
+String providerOrApi = (String) config.getStringKey("provider");
+String regionName = (String) config.getStringKey("region");
+String endpoint = (String) config.getStringKey("endpoint");
+String namedLocation = (String) 
config.get(LocationInternal.NAMED_SPEC_NAME);
+config.remove(LocationInternal.NAMED_SPEC_NAME.getName());
 
-String regionName = argsMap.containsKey("region") ? 
argsMap.get("region") : (String)locationFlags.get("region");
-
-String endpoint = argsMap.containsKey("endpoint") ? 
argsMap.get("endpoint") : (String)locationFlags.get("endpoint");
-
-String name = argsMap.containsKey("name") ? argsMap.get("name") : 
(String)locationFlags.get("name");
+Object hosts = config.getStringKey("hosts");
+config.remove("hosts");
 
-String user = argsMap.containsKey("user") ? argsMap.get("user") : 
(String)locationFlags.get("user");
+Map jcloudsProperties = new 
JcloudsPropertiesFromBrooklynProperties().getJcloudsProperties(providerOrApi, 
regionName, namedLocation, config.getAllConfig());
+config.putIfAbsent(jcloudsProperties);
 
-String privateKeyFile = argsMap.containsKey("privateKeyFile") ? 
argsMap.get("privateKeyFile") : (String)locationFlags.get("privateKeyFile");
-
-String hosts = argsMap.get("hosts");
-
 if (Strings.isEmpty(providerOrApi)) {
 throw new 

[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread johnmccabe
Github user johnmccabe commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62524649
  
--- Diff: 
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java
 ---
@@ -61,129 +56,140 @@
  * @author aled
  */
 @SuppressWarnings({"unchecked","rawtypes"})
-public class JcloudsByonLocationResolver implements LocationResolver {
+public class JcloudsByonLocationResolver extends AbstractLocationResolver 
implements LocationResolver {
 
 public static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolver.class);
 
 public static final String BYON = "jcloudsByon";
 
-private static final Pattern PATTERN = 
Pattern.compile("("+BYON+"|"+BYON.toUpperCase()+")" + ":" + "\\((.*)\\)$");
-
-private ManagementContext managementContext;
-
 @Override
-public void init(ManagementContext managementContext) {
-this.managementContext = checkNotNull(managementContext, 
"managementContext");
+public boolean isEnabled() {
+return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
 }
 
 @Override
-public boolean isEnabled() {
-return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
+public String getPrefix() {
+return BYON;
 }
 
-// TODO Remove some duplication from JcloudsResolver; needs more 
careful review
 @Override
-public LocationSpec 
newLocationSpecFromString(String spec, Map locationFlags, 
LocationRegistry registry) {
-Map globalProperties = registry.getProperties();
+protected Class getLocationType() {
+return FixedListMachineProvisioningLocation.class;
+}
 
-Matcher matcher = PATTERN.matcher(spec);
-if (!matcher.matches()) {
-throw new IllegalArgumentException("Invalid location 
'"+spec+"'; must specify something like 
jcloudsByon(provider=\"aws-ec2\",region=\"us-east-1\",hosts=\"i-f2014593,i-d1234567\")");
-}
-
-String argsPart = matcher.group(2);
-Map argsMap = KeyValueParser.parseMap(argsPart);
-
-// prefer args map over location flags
-
-String namedLocation = (String) 
locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
+@Override
+protected SpecParser getSpecParser() {
+return new 
AbstractLocationResolver.SpecParser(getPrefix()).setExampleUsage("\"jcloudsByon(provider='aws-ec2',region='us-east-1',hosts='i-12345678,i-90123456')\"");
+}
+
+@Override
+protected ConfigBag extractConfig(Map locationFlags, String spec, 
final LocationRegistry registry) {
+ConfigBag config = super.extractConfig(locationFlags, spec, 
registry);
 
-String providerOrApi = argsMap.containsKey("provider") ? 
argsMap.get("provider") : (String)locationFlags.get("provider");
+String providerOrApi = (String) config.getStringKey("provider");
+String regionName = (String) config.getStringKey("region");
+String endpoint = (String) config.getStringKey("endpoint");
+String namedLocation = (String) 
config.get(LocationInternal.NAMED_SPEC_NAME);
+config.remove(LocationInternal.NAMED_SPEC_NAME.getName());
 
-String regionName = argsMap.containsKey("region") ? 
argsMap.get("region") : (String)locationFlags.get("region");
-
-String endpoint = argsMap.containsKey("endpoint") ? 
argsMap.get("endpoint") : (String)locationFlags.get("endpoint");
-
-String name = argsMap.containsKey("name") ? argsMap.get("name") : 
(String)locationFlags.get("name");
+Object hosts = config.getStringKey("hosts");
+config.remove("hosts");
 
-String user = argsMap.containsKey("user") ? argsMap.get("user") : 
(String)locationFlags.get("user");
+Map jcloudsProperties = new 
JcloudsPropertiesFromBrooklynProperties().getJcloudsProperties(providerOrApi, 
regionName, namedLocation, config.getAllConfig());
+config.putIfAbsent(jcloudsProperties);
 
-String privateKeyFile = argsMap.containsKey("privateKeyFile") ? 
argsMap.get("privateKeyFile") : (String)locationFlags.get("privateKeyFile");
-
-String hosts = argsMap.get("hosts");
-
 if (Strings.isEmpty(providerOrApi)) {
 throw new IllegalArgumentException("Invalid location 
'"+spec+"'; provider must be defined");
 }
-if (hosts == null || hosts.isEmpty()) {
+if (hosts == null || (hosts instanceof String && 
Strings.isBlank((String)hosts))) {
  

[GitHub] brooklyn-server pull request: Remove feature brookly-software-cm

2016-05-09 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-server/pull/135


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276530#comment-15276530
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user johnmccabe commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62522025
  
--- Diff: 
locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverStubbedTest.java
 ---
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.location.jclouds;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import 
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.LoginCredentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class JcloudsByonLocationResolverStubbedTest extends 
AbstractJcloudsStubbedLiveTest {
+
+@SuppressWarnings("unused")
+private static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolverStubbedTest.class);
+
+private final String nodeId = "mynodeid";
+private final String nodePublicAddress = "173.194.32.123";
+private final String nodePrivateAddress = "172.168.10.11";
+
+protected LocalManagementContext newManagementContext() {
+// This really is stubbed; no live access to the cloud
+LocalManagementContext result = 
LocalManagementContextForTests.builder(true).build();
+BrooklynProperties brooklynProperties = 
result.getBrooklynProperties();
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".identity",
 "myidentity");
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".credential",
 "mycredential");
+return result;
+
+}
+
+@Override
+protected NodeCreator newNodeCreator() {
+return new NodeCreator() {
+@Override
+public Set 
listNodesDetailsMatching(Predicate filter) {
+NodeMetadata result = new NodeMetadataBuilder()
+.id(nodeId)
+
.credentials(LoginCredentials.builder().identity("dummy").credential("dummy").build())
+.loginPort(22)
+.status(Status.RUNNING)
+
.publicAddresses(ImmutableList.of(nodePublicAddress))
+
.privateAddresses(ImmutableList.of(nodePrivateAddress))
+.build();
+return 
ImmutableSet.copyOf(Iterables.filter(ImmutableList.of(result), filter));
+}
+@Override
+protected NodeMetadata newNode(String group, Template 
template) {
+throw new UnsupportedOperationException();
+}
+};
+}
+
+ 

[GitHub] brooklyn-server pull request: Remove feature brookly-software-cm

2016-05-09 Thread neykov
Github user neykov commented on the pull request:

https://github.com/apache/brooklyn-server/pull/135#issuecomment-217902997
  
+1 for the quick fix. A proper solution would be to move 
`karaf/apacke-brooklyn` to `brooklyn-dist`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread johnmccabe
Github user johnmccabe commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62522025
  
--- Diff: 
locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverStubbedTest.java
 ---
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.location.jclouds;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import 
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.LoginCredentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class JcloudsByonLocationResolverStubbedTest extends 
AbstractJcloudsStubbedLiveTest {
+
+@SuppressWarnings("unused")
+private static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolverStubbedTest.class);
+
+private final String nodeId = "mynodeid";
+private final String nodePublicAddress = "173.194.32.123";
+private final String nodePrivateAddress = "172.168.10.11";
+
+protected LocalManagementContext newManagementContext() {
+// This really is stubbed; no live access to the cloud
+LocalManagementContext result = 
LocalManagementContextForTests.builder(true).build();
+BrooklynProperties brooklynProperties = 
result.getBrooklynProperties();
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".identity",
 "myidentity");
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".credential",
 "mycredential");
+return result;
+
+}
+
+@Override
+protected NodeCreator newNodeCreator() {
+return new NodeCreator() {
+@Override
+public Set 
listNodesDetailsMatching(Predicate filter) {
+NodeMetadata result = new NodeMetadataBuilder()
+.id(nodeId)
+
.credentials(LoginCredentials.builder().identity("dummy").credential("dummy").build())
+.loginPort(22)
+.status(Status.RUNNING)
+
.publicAddresses(ImmutableList.of(nodePublicAddress))
+
.privateAddresses(ImmutableList.of(nodePrivateAddress))
+.build();
+return 
ImmutableSet.copyOf(Iterables.filter(ImmutableList.of(result), filter));
+}
+@Override
+protected NodeMetadata newNode(String group, Template 
template) {
+throw new UnsupportedOperationException();
+}
+};
+}
+
+@Test
+public void testResolvesHostInSpec() throws Exception {
+String spec = 

[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread johnmccabe
Github user johnmccabe commented on the pull request:

https://github.com/apache/brooklyn-server/pull/132#issuecomment-217896393
  
Throwing an NPE when deploying an app to a JcloudsByonLocation that was 
working before this PR:
```
2016-05-09 14:30:30,074 WARN  o.a.b.c.m.i.LocalLocationManager 
[brooklyn-execmanager-K1kS1uK9-466]: Failed to create location using spec 
LocationSpec{type=class 
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation}@4c055676
 (rethrowing)
java.lang.NullPointerException: null
at 
org.apache.brooklyn.location.jclouds.JcloudsLocation.createJcloudsSshMachineLocation(JcloudsLocation.java:2319)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.jclouds.JcloudsLocation.registerJcloudsSshMachineLocation(JcloudsLocation.java:2255)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.jclouds.JcloudsLocation.registerMachineLocation(JcloudsLocation.java:2106)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.jclouds.JcloudsLocation.registerMachine(JcloudsLocation.java:2097)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.jclouds.JcloudsByonLocationResolver$1.get(JcloudsByonLocationResolver.java:156)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.jclouds.JcloudsByonLocationResolver$1.get(JcloudsByonLocationResolver.java:147)
 ~[brooklyn-locations-jclouds-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation.init(FixedListMachineProvisioningLocation.java:173)
 ~[brooklyn-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.core.objs.proxy.InternalLocationFactory.createLocation(InternalLocationFactory.java:137)
 ~[brooklyn-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.core.mgmt.internal.LocalLocationManager.createLocation(LocalLocationManager.java:94)
 ~[brooklyn-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
org.apache.brooklyn.core.objs.proxy.InternalEntityFactory$1.run(InternalEntityFactory.java:331)
 [brooklyn-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
[na:1.7.0_99]
at 
org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
 [brooklyn-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
[na:1.7.0_99]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
[na:1.7.0_99]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
[na:1.7.0_99]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_99]
```
Example location:
```

brooklyn.location.named.my-named-byon=jcloudsByon:(provider="cloudstack",endpoint="xx",region="xx",networkName="xx",user="root",password="xx",hosts="xx,y,z")
brooklyn.location.named.bt-beta-byon.identity=xxx
brooklyn.location.named.bt-beta-byon.credential=xxx
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Remove feature brookly-software-cm

2016-05-09 Thread geomacy
Github user geomacy commented on the pull request:

https://github.com/apache/brooklyn-server/pull/135#issuecomment-217895958
  
👍 LGTM.  This was causing problems with a build, when tests were failing 
upon building with a clean Maven repository.  Taking the cm feature out allows 
the server tests to succeed. At some stage it would be good to produce separate 
feature.xml for features defined in brooklyn-library, and have these 
incorporated into a final feature set by brooklyn-dist, but this PR is fine for 
now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Remove feature brookly-software-cm

2016-05-09 Thread duncangrant
GitHub user duncangrant opened a pull request:

https://github.com/apache/brooklyn-server/pull/135

Remove feature brookly-software-cm



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/duncangrant/brooklyn-server 
fix/karaf-cm-feature

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-server/pull/135.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #135


commit 3f3182ebadf9fb4fdba33954ed2331a5db2ff089
Author: Duncan Grant 
Date:   2016-05-09T14:55:56Z

Remove feature brookly-software-cm




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276418#comment-15276418
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62505553
  
--- Diff: 
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java
 ---
@@ -61,129 +56,140 @@
  * @author aled
  */
 @SuppressWarnings({"unchecked","rawtypes"})
-public class JcloudsByonLocationResolver implements LocationResolver {
+public class JcloudsByonLocationResolver extends AbstractLocationResolver 
implements LocationResolver {
 
 public static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolver.class);
 
 public static final String BYON = "jcloudsByon";
 
-private static final Pattern PATTERN = 
Pattern.compile("("+BYON+"|"+BYON.toUpperCase()+")" + ":" + "\\((.*)\\)$");
-
-private ManagementContext managementContext;
-
 @Override
-public void init(ManagementContext managementContext) {
-this.managementContext = checkNotNull(managementContext, 
"managementContext");
+public boolean isEnabled() {
+return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
 }
 
 @Override
-public boolean isEnabled() {
-return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
+public String getPrefix() {
+return BYON;
 }
 
-// TODO Remove some duplication from JcloudsResolver; needs more 
careful review
 @Override
-public LocationSpec 
newLocationSpecFromString(String spec, Map locationFlags, 
LocationRegistry registry) {
-Map globalProperties = registry.getProperties();
+protected Class getLocationType() {
+return FixedListMachineProvisioningLocation.class;
+}
 
-Matcher matcher = PATTERN.matcher(spec);
-if (!matcher.matches()) {
-throw new IllegalArgumentException("Invalid location 
'"+spec+"'; must specify something like 
jcloudsByon(provider=\"aws-ec2\",region=\"us-east-1\",hosts=\"i-f2014593,i-d1234567\")");
-}
-
-String argsPart = matcher.group(2);
-Map argsMap = KeyValueParser.parseMap(argsPart);
-
-// prefer args map over location flags
-
-String namedLocation = (String) 
locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
+@Override
+protected SpecParser getSpecParser() {
+return new 
AbstractLocationResolver.SpecParser(getPrefix()).setExampleUsage("\"jcloudsByon(provider='aws-ec2',region='us-east-1',hosts='i-12345678,i-90123456')\"");
+}
+
+@Override
+protected ConfigBag extractConfig(Map locationFlags, String spec, 
final LocationRegistry registry) {
+ConfigBag config = super.extractConfig(locationFlags, spec, 
registry);
 
-String providerOrApi = argsMap.containsKey("provider") ? 
argsMap.get("provider") : (String)locationFlags.get("provider");
+String providerOrApi = (String) config.getStringKey("provider");
+String regionName = (String) config.getStringKey("region");
+String endpoint = (String) config.getStringKey("endpoint");
+String namedLocation = (String) 
config.get(LocationInternal.NAMED_SPEC_NAME);
+config.remove(LocationInternal.NAMED_SPEC_NAME.getName());
 
-String regionName = argsMap.containsKey("region") ? 
argsMap.get("region") : (String)locationFlags.get("region");
-
-String endpoint = argsMap.containsKey("endpoint") ? 
argsMap.get("endpoint") : (String)locationFlags.get("endpoint");
-
-String name = argsMap.containsKey("name") ? argsMap.get("name") : 
(String)locationFlags.get("name");
+Object hosts = config.getStringKey("hosts");
+config.remove("hosts");
 
-String user = argsMap.containsKey("user") ? argsMap.get("user") : 
(String)locationFlags.get("user");
+Map jcloudsProperties = new 
JcloudsPropertiesFromBrooklynProperties().getJcloudsProperties(providerOrApi, 
regionName, namedLocation, config.getAllConfig());
+config.putIfAbsent(jcloudsProperties);
 
-String privateKeyFile = argsMap.containsKey("privateKeyFile") ? 
argsMap.get("privateKeyFile") : (String)locationFlags.get("privateKeyFile");
-
-String hosts = argsMap.get("hosts");
-
 if (Strings.isEmpty(providerOrApi)) {
 throw new 

[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread sjcorbett
Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62505309
  
--- Diff: 
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java
 ---
@@ -61,129 +56,140 @@
  * @author aled
  */
 @SuppressWarnings({"unchecked","rawtypes"})
-public class JcloudsByonLocationResolver implements LocationResolver {
+public class JcloudsByonLocationResolver extends AbstractLocationResolver 
implements LocationResolver {
 
 public static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolver.class);
 
 public static final String BYON = "jcloudsByon";
 
-private static final Pattern PATTERN = 
Pattern.compile("("+BYON+"|"+BYON.toUpperCase()+")" + ":" + "\\((.*)\\)$");
-
-private ManagementContext managementContext;
-
 @Override
-public void init(ManagementContext managementContext) {
-this.managementContext = checkNotNull(managementContext, 
"managementContext");
+public boolean isEnabled() {
+return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
 }
 
 @Override
-public boolean isEnabled() {
-return 
LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix());
+public String getPrefix() {
+return BYON;
 }
 
-// TODO Remove some duplication from JcloudsResolver; needs more 
careful review
 @Override
-public LocationSpec 
newLocationSpecFromString(String spec, Map locationFlags, 
LocationRegistry registry) {
-Map globalProperties = registry.getProperties();
+protected Class getLocationType() {
+return FixedListMachineProvisioningLocation.class;
+}
 
-Matcher matcher = PATTERN.matcher(spec);
-if (!matcher.matches()) {
-throw new IllegalArgumentException("Invalid location 
'"+spec+"'; must specify something like 
jcloudsByon(provider=\"aws-ec2\",region=\"us-east-1\",hosts=\"i-f2014593,i-d1234567\")");
-}
-
-String argsPart = matcher.group(2);
-Map argsMap = KeyValueParser.parseMap(argsPart);
-
-// prefer args map over location flags
-
-String namedLocation = (String) 
locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
+@Override
+protected SpecParser getSpecParser() {
+return new 
AbstractLocationResolver.SpecParser(getPrefix()).setExampleUsage("\"jcloudsByon(provider='aws-ec2',region='us-east-1',hosts='i-12345678,i-90123456')\"");
+}
+
+@Override
+protected ConfigBag extractConfig(Map locationFlags, String spec, 
final LocationRegistry registry) {
+ConfigBag config = super.extractConfig(locationFlags, spec, 
registry);
 
-String providerOrApi = argsMap.containsKey("provider") ? 
argsMap.get("provider") : (String)locationFlags.get("provider");
+String providerOrApi = (String) config.getStringKey("provider");
+String regionName = (String) config.getStringKey("region");
+String endpoint = (String) config.getStringKey("endpoint");
+String namedLocation = (String) 
config.get(LocationInternal.NAMED_SPEC_NAME);
+config.remove(LocationInternal.NAMED_SPEC_NAME.getName());
 
-String regionName = argsMap.containsKey("region") ? 
argsMap.get("region") : (String)locationFlags.get("region");
-
-String endpoint = argsMap.containsKey("endpoint") ? 
argsMap.get("endpoint") : (String)locationFlags.get("endpoint");
-
-String name = argsMap.containsKey("name") ? argsMap.get("name") : 
(String)locationFlags.get("name");
+Object hosts = config.getStringKey("hosts");
+config.remove("hosts");
 
-String user = argsMap.containsKey("user") ? argsMap.get("user") : 
(String)locationFlags.get("user");
+Map jcloudsProperties = new 
JcloudsPropertiesFromBrooklynProperties().getJcloudsProperties(providerOrApi, 
regionName, namedLocation, config.getAllConfig());
+config.putIfAbsent(jcloudsProperties);
 
-String privateKeyFile = argsMap.containsKey("privateKeyFile") ? 
argsMap.get("privateKeyFile") : (String)locationFlags.get("privateKeyFile");
-
-String hosts = argsMap.get("hosts");
-
 if (Strings.isEmpty(providerOrApi)) {
 throw new IllegalArgumentException("Invalid location 
'"+spec+"'; provider must be defined");
 }
-if (hosts == null || hosts.isEmpty()) {
+if (hosts == null || (hosts instanceof String && 
Strings.isBlank((String)hosts))) {
   

[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276398#comment-15276398
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62503507
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java
 ---
@@ -147,8 +168,21 @@ public void init() {
 }
 config().set(MACHINE_SPECS, (List) null);
 
+Supplier> 
initialMachinesFactory = getConfig(INITIAL_MACHINES_FACTORY);
+if (initialMachinesFactory != null) {
+List initialMachines = 
initialMachinesFactory.get();
+if (initialMachines != null) {
+for (MachineLocation machine : initialMachines) {
+@SuppressWarnings("unchecked")
+T castMachine = (T) machine;
+machines.add(castMachine);
--- End diff --

See that's handled further anyway.


> jcloudsByon location spec leaks location instances
> --
>
> Key: BROOKLYN-259
> URL: https://issues.apache.org/jira/browse/BROOKLYN-259
> Project: Brooklyn
>  Issue Type: Bug
>Affects Versions: 0.9.0
>Reporter: Aled Sage
> Fix For: 0.10.0
>
>
> When declaring in brooklyn.properties a location spec such as 
> {noformat}
> jcloudsByon(provider="aws-ec2",region="us-east-1",user="brooklyn",password="pa55w0rd",hosts="i-12345678")
> {noformat}
> It caused new locations to be created and persisted every few seconds, but 
> for those locations to be never deleted.
> ---
> This was caused by changes made in 0.9.0 to {{LocationResolver}} 
> implementations, so that it creates a {{LocationSpec}} rather than 
> instantiating a location directly. Unfortunately, 
> {{JcloudsByonLocationResolver}} had not been updated. The REST api would poll 
> this regularly to find out about the types of location, and on every poll it 
> would create new locations.
> This is similar to the problem encountered for localhost, fixed in time for 
> 0.9.0 in https://github.com/apache/brooklyn-server/pull/97.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread sjcorbett
Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62503507
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java
 ---
@@ -147,8 +168,21 @@ public void init() {
 }
 config().set(MACHINE_SPECS, (List) null);
 
+Supplier> 
initialMachinesFactory = getConfig(INITIAL_MACHINES_FACTORY);
+if (initialMachinesFactory != null) {
+List initialMachines = 
initialMachinesFactory.get();
+if (initialMachines != null) {
+for (MachineLocation machine : initialMachines) {
+@SuppressWarnings("unchecked")
+T castMachine = (T) machine;
+machines.add(castMachine);
--- End diff --

See that's handled further anyway.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: BROOKLYN-259: Fix JcloudsByonLocatio...

2016-05-09 Thread sjcorbett
Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62503400
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java
 ---
@@ -147,8 +168,21 @@ public void init() {
 }
 config().set(MACHINE_SPECS, (List) null);
 
+Supplier> 
initialMachinesFactory = getConfig(INITIAL_MACHINES_FACTORY);
+if (initialMachinesFactory != null) {
+List initialMachines = 
initialMachinesFactory.get();
+if (initialMachines != null) {
+for (MachineLocation machine : initialMachines) {
+@SuppressWarnings("unchecked")
+T castMachine = (T) machine;
+machines.add(castMachine);
--- End diff --

Probably worth checking that `machine` is not null too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (BROOKLYN-259) jcloudsByon location spec leaks location instances

2016-05-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15276395#comment-15276395
 ] 

ASF GitHub Bot commented on BROOKLYN-259:
-

Github user sjcorbett commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/132#discussion_r62502931
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java
 ---
@@ -103,10 +105,29 @@
 @Beta
 @SuppressWarnings("serial")
 public static final ConfigKey> MACHINE_SPECS = ConfigKeys.newConfigKey(
-new TypeToken>() {}, 
-"byon.machineSpecs",
-"Specs of machines that should be immediatly 
instantiated on init",
-ImmutableList.of());
+new TypeToken>() 
{}, 
+"byon.machineSpecs",
+"Specs of machines that should be immediatly instantiated on 
init",
+ImmutableList.of());
+
+/**
+ * The initialMachinesFactory allows {@code 
JcloudsByonLocationResolver} to work, to defer 
+ * instantiating the {@code JcloudsLocation} and the {@code 
JcloudsMachineLocation} instances.
+ * (Important because the caller might not use the spec and thus might 
not unmanage the machine 
+ * instances).
+ * 
+ * We clear the initialMachinesFactory in init, so they will never be 
persisted. This will help 
+ * with backwards compatibility if we change how this is done.
+ * 
+ * By the end of init(), the {@link #machines} will contain the full 
list of locations.
+ */
+@Beta
+@SuppressWarnings("serial")
+public static final ConfigKey> INITIAL_MACHINES_FACTORY = ConfigKeys.newConfigKey(
+new TypeToken>() {}, 
+"byon.initialMachinesFactory",
+"Factory for creating the machines that should be immediatly 
instantiated on init",
--- End diff --

`immediatly`


> jcloudsByon location spec leaks location instances
> --
>
> Key: BROOKLYN-259
> URL: https://issues.apache.org/jira/browse/BROOKLYN-259
> Project: Brooklyn
>  Issue Type: Bug
>Affects Versions: 0.9.0
>Reporter: Aled Sage
> Fix For: 0.10.0
>
>
> When declaring in brooklyn.properties a location spec such as 
> {noformat}
> jcloudsByon(provider="aws-ec2",region="us-east-1",user="brooklyn",password="pa55w0rd",hosts="i-12345678")
> {noformat}
> It caused new locations to be created and persisted every few seconds, but 
> for those locations to be never deleted.
> ---
> This was caused by changes made in 0.9.0 to {{LocationResolver}} 
> implementations, so that it creates a {{LocationSpec}} rather than 
> instantiating a location directly. Unfortunately, 
> {{JcloudsByonLocationResolver}} had not been updated. The REST api would poll 
> this regularly to find out about the types of location, and on every poll it 
> would create new locations.
> This is similar to the problem encountered for localhost, fixed in time for 
> 0.9.0 in https://github.com/apache/brooklyn-server/pull/97.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] brooklyn-server pull request: Configurable removal strategies

2016-05-09 Thread nakomis
Github user nakomis commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/112#discussion_r62474640
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/entity/group/FirstFromRemovalStrategy.java
 ---
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.entity.group;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.TypeToken;
+
+public class FirstFromRemovalStrategy extends RemovalStrategy {
+
+public static final ConfigKey STRATEGIES = 
ConfigKeys.newConfigKey(new TypeToken() {}, 
"firstfrom.strategies",
+"An ordered list of removal strategies to be used to determine 
which entity to remove");
+
+@Nullable
+@Override
+public Entity apply(@Nullable Collection input) {
+List strategies = config().get(STRATEGIES);
--- End diff --

The benefit of using `BasicConfigurableObject` is that the configuration is 
the configuration (i.e. setting of ConfigKeys) is managed automatically by the 
`ConfigurationSupport`, rather than implementors having to read the values 
directly from the properties passed to the constructor


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---