You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/09/13 13:52:08 UTC

[1/6] brooklyn-dist git commit: Extracting catalog item into their own file

Repository: brooklyn-dist
Updated Branches:
  refs/heads/master ff34316ab -> d22a71e2c


Extracting catalog item into their own file


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/1eb9be8e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/1eb9be8e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/1eb9be8e

Branch: refs/heads/master
Commit: 1eb9be8e44f2416df8f45438c780a806d149fb83
Parents: 5380785
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Wed Sep 6 11:18:08 2017 +0100
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Wed Sep 6 11:18:08 2017 +0100

----------------------------------------------------------------------
 .../src/main/resources/catalog/catalog.bom      | 368 +++++++++++++++++++
 .../src/main/resources/etc/default.catalog.bom  | 362 +-----------------
 2 files changed, 369 insertions(+), 361 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/1eb9be8e/karaf/apache-brooklyn/src/main/resources/catalog/catalog.bom
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/resources/catalog/catalog.bom b/karaf/apache-brooklyn/src/main/resources/catalog/catalog.bom
new file mode 100644
index 0000000..c62859d
--- /dev/null
+++ b/karaf/apache-brooklyn/src/main/resources/catalog/catalog.bom
@@ -0,0 +1,368 @@
+
+# this catalog bom is an illustration supplying a few useful sample items
+# and templates to get started using Brooklyn
+
+brooklyn.catalog:
+  version: "0.12.0-SNAPSHOT" # BROOKLYN_VERSION
+  include: classpath://library-catalog-classes.bom
+
+  items:
+
+  - id: server
+    itemType: entity
+    description: |
+      Provision a server, with customizable provisioning.properties and credentials installed,
+      but no other special software process or scripts executed.
+    item:
+      type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
+      name: Server
+
+  - id: vanilla-bash-server
+    itemType: entity
+    description: |
+      Provision a server, with customizable provisioning.properties and credentials installed,
+      but no other special software process or scripts executed.
+      The script should be supplied in "launch.command" as per docs on
+      org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess.
+    item:
+      type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+      name: Server with Launch Script (bash)
+
+  - id: load-balancer
+    itemType: entity
+    description: |
+      Create a load balancer which will point at members in the group entity
+      referred to by the config key "serverPool".
+      The sensor advertising the port can be configured with the "member.sensor.portNumber" config key,
+      defaulting to `http.port`; all member entities which have published "service.up" will then be picked up.
+    item:
+      type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+      name: Load Balancer (nginx)
+
+  - id: cluster
+    itemType: entity
+    description: |
+      Create a cluster of entities, resizable, with starting size "initialSize",
+      and using a spec supplied in the "memberSpec" key.
+    item:
+      type: org.apache.brooklyn.entity.group.DynamicCluster
+
+  - id: 1-server-template
+    itemType: template
+    name: "Template 1: Server"
+    description: |
+      Sample YAML to provision a server in a cloud with illustrative VM properties
+    item:
+      name: Server (Brooklyn Example)
+
+      # this basic example shows how Brooklyn can provision a single raw VM
+      # in the cloud or location of your choice
+
+      services:
+      - type:           server
+        name:           My VM
+
+      # location can be e.g. `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`,
+      # or `localhost` or `byon:(hosts="10.9.1.1,10.9.1.2,produser2@10.9.2.{10,11,20-29}")`
+      location:
+        jclouds:aws-ec2:
+          # edit these to use your credential (or delete if credentials specified in brooklyn.properties)
+          identity:     <REPLACE>
+          credential:   <REPLACE>
+
+          region:       eu-central-1
+
+          # we want Ubuntu, with a lot of RAM
+          osFamily:     ubuntu
+          minRam:       8gb
+
+          # set up this user and password (default is to authorize a public key)
+          user:         sample
+          password:     s4mpl3
+
+  - id: 2-bash-web-server-template
+    itemType: template
+    name: "Template 2: Bash Web Server"
+    description: |
+      Sample YAML building on Template 1,
+      adding bash commands to launch a Python-based web server
+      on port 8020
+    item:
+      name: Python Web Server (Brooklyn Example)
+
+      # this example builds on the previous one,
+      # adding some scripts to initialize the VM
+
+      services:
+      - type:           vanilla-bash-server
+        name:           My Bash Web Server VM
+        brooklyn.config:
+          install.command: |
+            # install python if not present
+            which python || \
+              { sudo apt-get update && sudo apt-get install python ; } || \
+              { sudo yum update && sudo yum install python ; } || \
+              { echo WARNING: cannot install python && exit 1 ; }
+
+          customize.command: |
+            # create the web page to serve
+            cat > index.html << EOF
+
+            Hello world.
+            <p>
+            I am ${ENTITY_INFO}, ${MESSAGE:-a Brooklyn sample}.
+            <p>
+            Created at: `date`
+            <p>
+            I am running at ${HOSTNAME}, with on-box IP configuration:
+            <pre>
+            `ifconfig | grep inet`
+            </pre>
+
+            EOF
+
+          launch.command: |
+            # launch in background (ensuring no streams open), and record PID to file
+            nohup python -m SimpleHTTPServer ${PORT:-8020} < /dev/null > output.txt 2>&1 &
+            echo $! > ${PID_FILE:-pid.txt}
+            sleep 5
+            ps -p `cat ${PID_FILE:-pid.txt}`
+            if [ $? -ne 0 ] ; then
+              cat output.txt
+              echo WARNING: python web server not running
+              exit 1
+            fi
+
+          shell.env:
+            HOSTNAME:     $brooklyn:attributeWhenReady("host.name")
+            PORT:         $brooklyn:config("my.app.port")
+            ENTITY_INFO:  $brooklyn:component("this", "")
+            MESSAGE:      $brooklyn:config("my.message")
+
+          # custom
+          my.app.port:  8020
+          my.message:   "good to meet you"
+
+        brooklyn.enrichers:
+        # publish the URL as a sensor; the GUI will pick this up (main.uri)
+        - type: org.apache.brooklyn.enricher.stock.Transformer
+          brooklyn.config:
+            uniqueTag: url-generator
+            enricher.sourceSensor: host.subnet.hostname
+            # use the definition from Attributes class, as it has a RendererHint so GUI makes it a link
+            enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri")
+            enricher.targetValue:
+              $brooklyn:formatString:
+              - "http://%s:%s/"
+              - $brooklyn:attributeWhenReady("host.subnet.hostname")
+              - $brooklyn:config("my.app.port")
+
+      location:
+        jclouds:aws-ec2:
+          region:       eu-central-1
+          # edit these (or delete if credentials specified in brooklyn.properties)
+          identity:     <REPLACE>
+          credential:   <REPLACE>
+
+  - id: 3-bash-web-and-riak-template
+    itemType: template
+    name: "Template 3: Bash Web Server and Scaling Riak Cluster"
+    description: |
+      Sample YAML building on Template 2,
+      composing that blueprint with a Riak cluster and injecting the URL
+    item:
+      name: Bash Web Server and Riak Cluster (Brooklyn Example)
+
+      # this example *references* the previous one,
+      # combining it with a stock blueprint for a Riak cluster,
+      # and shows how a sensor from the latter can be injected
+
+      services:
+
+      # reference template 2, overriding message to point at riak
+      - type:           2-bash-web-server-template
+        brooklyn.config:
+          my.message:   $brooklyn:formatString("connected to Riak at %s",
+                            $brooklyn:entity("riak-cluster").attributeWhenReady("main.uri"))
+        # and clear the location defined there so it is taken from this template
+        locations:      []
+
+      # use the off-the-shelf Riak cluster
+      - type:           org.apache.brooklyn.entity.nosql.riak.RiakCluster
+        id:             riak-cluster
+        initialSize:    3
+        # and add a policy to scale based on ops per minute
+        brooklyn.policies:
+        - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
+          brooklyn.config:
+            metric: riak.node.ops.1m.perNode
+            # more than 100 ops per second (6k/min) scales out, less than 50 scales back
+            # up to a max of 8 riak nodes here (can be changed in GUI / REST API afterwards)
+            metricLowerBound: 3000
+            metricUpperBound: 6000
+            minPoolSize: 3
+            maxPoolSize: 8
+            resizeUpStabilizationDelay: 30s
+            resizeDownStabilizationDelay: 5m
+
+      location:
+        jclouds:aws-ec2:
+          region:       eu-central-1
+          # edit these (or delete if credentials specified in brooklyn.properties)
+          identity:     <REPLACE>
+          credential:   <REPLACE>
+
+  - id: 4-resilient-bash-web-cluster-template
+    itemType: template
+    name: "Template 4: Resilient Load-Balanced Bash Web Cluster with Sensors"
+    description: |
+      Sample YAML to provision a cluster of the bash/python web server nodes,
+      with sensors configured, and a load balancer pointing at them,
+      and resilience policies for node replacement and scaling
+    item:
+      name: Resilient Load-Balanced Bash Web Cluster (Brooklyn Example)
+
+      # this final example shows some of the advanced functionality:
+      # defining custom sensors, and a cluster with a "spec",
+      # policies for resilience and scaling based on that sensor,
+      # and wiring a load balancer in front of the cluster
+
+      # combining this with the riak cluster in the previous example
+      # is left as a suggested exercise for the user
+
+      services:
+
+      # define a cluster of the web nodes
+      - type:           cluster
+        name:           Cluster of Bash Web Nodes
+        id:             my-web-cluster
+        brooklyn.config:
+          initialSize:  1
+          memberSpec:
+            $brooklyn:entitySpec:
+              # template 2 is used as the spec for items in this cluster
+              # with a new message overwriting the previous,
+              # and a lot of sensors defined
+              type:           2-bash-web-server-template
+              name:           My Bash Web Server VM with Sensors
+              # and clear the location defined there so it is taken from this template
+              locations:      []
+
+              brooklyn.config:
+                my.message:   "part of the cluster"
+
+              brooklyn.initializers:
+              # make a simple request-count sensor, by counting the number of 200 responses in output.txt
+              - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
+                brooklyn.config:
+                  name: reqs.count
+                  targetType: int
+                  period: 5s
+                  command: "cat output.txt | grep HTTP | grep 200 | wc | awk '{print $1}'"
+              # and publish the port as a sensor so the load-balancer can pick it up
+              - type:           org.apache.brooklyn.core.sensor.StaticSensor
+                brooklyn.config:
+                  name:         app.port
+                  targetType:   int
+                  static.value: $brooklyn:config("my.app.port")
+
+              brooklyn.enrichers:
+              # derive reqs.per_sec from reqs.count
+              - type: org.apache.brooklyn.enricher.stock.YamlTimeWeightedDeltaEnricher
+                brooklyn.config:
+                  enricher.sourceSensor: reqs.count
+                  enricher.targetSensor: reqs.per_sec
+                  enricher.delta.period: 1s
+              # and take an average over 30s for reqs.per_sec into reqs.per_sec.windowed_30s
+              - type: org.apache.brooklyn.enricher.stock.YamlRollingTimeWindowMeanEnricher
+                brooklyn.config:
+                  enricher.sourceSensor: reqs.per_sec
+                  enricher.targetSensor: reqs.per_sec.windowed_30s
+                  enricher.window.duration: 30s
+
+              # emit failure sensor if a failure connecting to the service is sustained for 30s
+              - type: org.apache.brooklyn.policy.ha.ServiceFailureDetector
+                brooklyn.config:
+                  entityFailed.stabilizationDelay: 30s
+
+              brooklyn.policies:
+              # restart if a failure is detected (with a max of one restart in 2m, sensor will propagate otherwise)
+              - type: org.apache.brooklyn.policy.ha.ServiceRestarter
+                brooklyn.config:
+                  failOnRecurringFailuresInThisDuration: 2m
+
+        # back at the cluster, create a total per-sec and some per-node average
+        brooklyn.enrichers:
+        - type: org.apache.brooklyn.enricher.stock.Aggregator
+          brooklyn.config:
+            enricher.sourceSensor: reqs.per_sec
+            enricher.targetSensor: reqs.per_sec
+            transformation: sum
+        - type: org.apache.brooklyn.enricher.stock.Aggregator
+          brooklyn.config:
+            enricher.sourceSensor: reqs.per_sec
+            enricher.targetSensor: reqs.per_sec.per_node
+            transformation: average
+        - type: org.apache.brooklyn.enricher.stock.Aggregator
+          brooklyn.config:
+            enricher.sourceSensor: reqs.per_sec.windowed_30s
+            enricher.targetSensor: reqs.per_sec.windowed_30s.per_node
+            transformation: average
+
+        brooklyn.policies:
+        # resilience: if a per-node restart policy fails,
+        # just throw that node away and create a new one
+        - type: org.apache.brooklyn.policy.ha.ServiceReplacer
+
+        # and scale based on reqs/sec
+        - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
+          brooklyn.config:
+            # scale based on reqs/sec (though in a real-world situation,
+            # reqs.per_sec.windowed_30s.per_node might be a better choice)
+            metric: reqs.per_sec.per_node
+
+            # really low numbers, so you can trigger a scale-out just by hitting reload a lot
+            metricUpperBound: 3
+            metricLowerBound: 1
+
+            # sustain 3 reqs/sec for 2s and it will scale out
+            resizeUpStabilizationDelay: 2s
+            # only scale down when sustained for 1m
+            resizeDownStabilizationDelay: 1m
+
+            maxPoolSize: 10
+
+      # and add a load-balancer pointing at the cluster
+      - type:           load-balancer
+        id:             load-bal
+        brooklyn.config:
+          # point this load balancer at the cluster, specifying port to forward to
+          loadbalancer.serverpool:  $brooklyn:entity("my-web-cluster")
+          member.sensor.portNumber: app.port
+          # disable sticky sessions to allow easy validation of balancing via browser refresh
+          nginx.sticky: false
+
+      brooklyn.enrichers:
+      # publish a few useful info sensors and KPI's to the root of the app
+      - type: org.apache.brooklyn.enricher.stock.Propagator
+        brooklyn.config:
+          uniqueTag:    propagate-load-balancer-url
+          producer:     $brooklyn:entity("load-bal")
+          propagating:
+          - main.uri
+      - type: org.apache.brooklyn.enricher.stock.Propagator
+        brooklyn.config:
+          uniqueTag:    propagate-reqs-per-sec
+          producer:     $brooklyn:entity("my-web-cluster")
+          propagating:
+          - reqs.per_sec
+          - reqs.per_sec.windowed_30s.per_node
+
+      location:
+        jclouds:aws-ec2:
+          # edit these (or delete if credentials specified in brooklyn.properties)
+          identity:     <REPLACE>
+          credential:   <REPLACE>
+
+          region:       eu-central-1
+          minRam:       2gb

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/1eb9be8e/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom b/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
index ac658e1..b12e932 100644
--- a/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
+++ b/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
@@ -5,365 +5,5 @@
 brooklyn.catalog:
   bundle: brooklyn-default-karaf-catalog
   version: "0.12.0-SNAPSHOT" # BROOKLYN_VERSION
-  include: classpath://library-catalog-classes.bom
-
   items:
-
-  - id: server
-    itemType: entity
-    description: |
-      Provision a server, with customizable provisioning.properties and credentials installed, 
-      but no other special software process or scripts executed.
-    item:
-      type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
-      name: Server
-
-  - id: vanilla-bash-server
-    itemType: entity
-    description: |
-      Provision a server, with customizable provisioning.properties and credentials installed, 
-      but no other special software process or scripts executed.
-      The script should be supplied in "launch.command" as per docs on
-      org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess.
-    item:
-      type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
-      name: Server with Launch Script (bash)
-
-  - id: load-balancer
-    itemType: entity
-    description: |
-      Create a load balancer which will point at members in the group entity
-      referred to by the config key "serverPool". 
-      The sensor advertising the port can be configured with the "member.sensor.portNumber" config key,
-      defaulting to `http.port`; all member entities which have published "service.up" will then be picked up.
-    item:
-      type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-      name: Load Balancer (nginx)
-
-  - id: cluster
-    itemType: entity
-    description: |
-      Create a cluster of entities, resizable, with starting size "initialSize",
-      and using a spec supplied in the "memberSpec" key.
-    item:
-      type: org.apache.brooklyn.entity.group.DynamicCluster
-
-  - id: 1-server-template
-    itemType: template
-    name: "Template 1: Server"
-    description: |
-      Sample YAML to provision a server in a cloud with illustrative VM properties
-    item:
-      name: Server (Brooklyn Example)
-      
-      # this basic example shows how Brooklyn can provision a single raw VM
-      # in the cloud or location of your choice
-      
-      services:
-      - type:           server
-        name:           My VM
-      
-      # location can be e.g. `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`,
-      # or `localhost` or `byon:(hosts="10.9.1.1,10.9.1.2,produser2@10.9.2.{10,11,20-29}")` 
-      location:
-        jclouds:aws-ec2:
-          # edit these to use your credential (or delete if credentials specified in brooklyn.properties)      
-          identity:     <REPLACE>
-          credential:   <REPLACE>
-          
-          region:       eu-central-1
-          
-          # we want Ubuntu, with a lot of RAM
-          osFamily:     ubuntu
-          minRam:       8gb
-          
-          # set up this user and password (default is to authorize a public key)
-          user:         sample
-          password:     s4mpl3
-
-  - id: 2-bash-web-server-template
-    itemType: template
-    name: "Template 2: Bash Web Server"
-    description: |
-      Sample YAML building on Template 1, 
-      adding bash commands to launch a Python-based web server
-      on port 8020
-    item:
-      name: Python Web Server (Brooklyn Example)
-      
-      # this example builds on the previous one, 
-      # adding some scripts to initialize the VM
-      
-      services:
-      - type:           vanilla-bash-server
-        name:           My Bash Web Server VM
-        brooklyn.config:
-          install.command: |
-            # install python if not present
-            which python || \
-              { sudo apt-get update && sudo apt-get install python ; } || \
-              { sudo yum update && sudo yum install python ; } || \
-              { echo WARNING: cannot install python && exit 1 ; }
-
-          customize.command: |
-            # create the web page to serve
-            cat > index.html << EOF
-            
-            Hello world.
-            <p>
-            I am ${ENTITY_INFO}, ${MESSAGE:-a Brooklyn sample}.
-            <p>
-            Created at: `date`
-            <p>
-            I am running at ${HOSTNAME}, with on-box IP configuration:
-            <pre>
-            `ifconfig | grep inet`
-            </pre>
-            
-            EOF
-
-          launch.command: |
-            # launch in background (ensuring no streams open), and record PID to file
-            nohup python -m SimpleHTTPServer ${PORT:-8020} < /dev/null > output.txt 2>&1 &
-            echo $! > ${PID_FILE:-pid.txt}
-            sleep 5
-            ps -p `cat ${PID_FILE:-pid.txt}`
-            if [ $? -ne 0 ] ; then
-              cat output.txt
-              echo WARNING: python web server not running
-              exit 1
-            fi
-            
-          shell.env:
-            HOSTNAME:     $brooklyn:attributeWhenReady("host.name")
-            PORT:         $brooklyn:config("my.app.port")
-            ENTITY_INFO:  $brooklyn:component("this", "")
-            MESSAGE:      $brooklyn:config("my.message")
-            
-          # custom 
-          my.app.port:  8020
-          my.message:   "good to meet you"
-        
-        brooklyn.enrichers:
-        # publish the URL as a sensor; the GUI will pick this up (main.uri)
-        - type: org.apache.brooklyn.enricher.stock.Transformer
-          brooklyn.config:
-            uniqueTag: url-generator
-            enricher.sourceSensor: host.subnet.hostname
-            # use the definition from Attributes class, as it has a RendererHint so GUI makes it a link
-            enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri")
-            enricher.targetValue: 
-              $brooklyn:formatString:
-              - "http://%s:%s/" 
-              - $brooklyn:attributeWhenReady("host.subnet.hostname")
-              - $brooklyn:config("my.app.port")
-      
-      location:
-        jclouds:aws-ec2:
-          region:       eu-central-1
-          # edit these (or delete if credentials specified in brooklyn.properties)      
-          identity:     <REPLACE>
-          credential:   <REPLACE>
-        
-  - id: 3-bash-web-and-riak-template
-    itemType: template
-    name: "Template 3: Bash Web Server and Scaling Riak Cluster"
-    description: |
-      Sample YAML building on Template 2, 
-      composing that blueprint with a Riak cluster and injecting the URL
-    item:
-      name: Bash Web Server and Riak Cluster (Brooklyn Example)
-    
-      # this example *references* the previous one, 
-      # combining it with a stock blueprint for a Riak cluster,
-      # and shows how a sensor from the latter can be injected
-      
-      services:
-      
-      # reference template 2, overriding message to point at riak 
-      - type:           2-bash-web-server-template
-        brooklyn.config:
-          my.message:   $brooklyn:formatString("connected to Riak at %s",
-                            $brooklyn:entity("riak-cluster").attributeWhenReady("main.uri"))
-        # and clear the location defined there so it is taken from this template
-        locations:      []
-                            
-      # use the off-the-shelf Riak cluster
-      - type:           org.apache.brooklyn.entity.nosql.riak.RiakCluster
-        id:             riak-cluster
-        initialSize:    3
-        # and add a policy to scale based on ops per minute
-        brooklyn.policies:
-        - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
-          brooklyn.config:
-            metric: riak.node.ops.1m.perNode
-            # more than 100 ops per second (6k/min) scales out, less than 50 scales back
-            # up to a max of 8 riak nodes here (can be changed in GUI / REST API afterwards)
-            metricLowerBound: 3000
-            metricUpperBound: 6000
-            minPoolSize: 3
-            maxPoolSize: 8
-            resizeUpStabilizationDelay: 30s
-            resizeDownStabilizationDelay: 5m
-          
-      location:
-        jclouds:aws-ec2:
-          region:       eu-central-1
-          # edit these (or delete if credentials specified in brooklyn.properties)      
-          identity:     <REPLACE>
-          credential:   <REPLACE>
-
-  - id: 4-resilient-bash-web-cluster-template
-    itemType: template
-    name: "Template 4: Resilient Load-Balanced Bash Web Cluster with Sensors"
-    description: |
-      Sample YAML to provision a cluster of the bash/python web server nodes,
-      with sensors configured, and a load balancer pointing at them,
-      and resilience policies for node replacement and scaling
-    item:
-      name: Resilient Load-Balanced Bash Web Cluster (Brooklyn Example)
-      
-      # this final example shows some of the advanced functionality:
-      # defining custom sensors, and a cluster with a "spec", 
-      # policies for resilience and scaling based on that sensor,
-      # and wiring a load balancer in front of the cluster
-      
-      # combining this with the riak cluster in the previous example
-      # is left as a suggested exercise for the user
-      
-      services:
-      
-      # define a cluster of the web nodes
-      - type:           cluster
-        name:           Cluster of Bash Web Nodes
-        id:             my-web-cluster
-        brooklyn.config:
-          initialSize:  1
-          memberSpec:
-            $brooklyn:entitySpec:
-              # template 2 is used as the spec for items in this cluster
-              # with a new message overwriting the previous,
-              # and a lot of sensors defined
-              type:           2-bash-web-server-template
-              name:           My Bash Web Server VM with Sensors
-              # and clear the location defined there so it is taken from this template
-              locations:      []
-              
-              brooklyn.config:
-                my.message:   "part of the cluster"
-              
-              brooklyn.initializers:
-              # make a simple request-count sensor, by counting the number of 200 responses in output.txt
-              - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
-                brooklyn.config:
-                  name: reqs.count
-                  targetType: int
-                  period: 5s
-                  command: "cat output.txt | grep HTTP | grep 200 | wc | awk '{print $1}'"
-              # and publish the port as a sensor so the load-balancer can pick it up
-              - type:           org.apache.brooklyn.core.sensor.StaticSensor
-                brooklyn.config:
-                  name:         app.port
-                  targetType:   int
-                  static.value: $brooklyn:config("my.app.port")
-              
-              brooklyn.enrichers:
-              # derive reqs.per_sec from reqs.count
-              - type: org.apache.brooklyn.enricher.stock.YamlTimeWeightedDeltaEnricher
-                brooklyn.config:
-                  enricher.sourceSensor: reqs.count
-                  enricher.targetSensor: reqs.per_sec
-                  enricher.delta.period: 1s
-              # and take an average over 30s for reqs.per_sec into reqs.per_sec.windowed_30s
-              - type: org.apache.brooklyn.enricher.stock.YamlRollingTimeWindowMeanEnricher
-                brooklyn.config:
-                  enricher.sourceSensor: reqs.per_sec
-                  enricher.targetSensor: reqs.per_sec.windowed_30s
-                  enricher.window.duration: 30s
-              
-              # emit failure sensor if a failure connecting to the service is sustained for 30s
-              - type: org.apache.brooklyn.policy.ha.ServiceFailureDetector
-                brooklyn.config:
-                  entityFailed.stabilizationDelay: 30s
-            
-              brooklyn.policies:
-              # restart if a failure is detected (with a max of one restart in 2m, sensor will propagate otherwise) 
-              - type: org.apache.brooklyn.policy.ha.ServiceRestarter
-                brooklyn.config:
-                  failOnRecurringFailuresInThisDuration: 2m
-        
-        # back at the cluster, create a total per-sec and some per-node average
-        brooklyn.enrichers:
-        - type: org.apache.brooklyn.enricher.stock.Aggregator
-          brooklyn.config:
-            enricher.sourceSensor: reqs.per_sec
-            enricher.targetSensor: reqs.per_sec
-            transformation: sum
-        - type: org.apache.brooklyn.enricher.stock.Aggregator
-          brooklyn.config:
-            enricher.sourceSensor: reqs.per_sec
-            enricher.targetSensor: reqs.per_sec.per_node
-            transformation: average
-        - type: org.apache.brooklyn.enricher.stock.Aggregator
-          brooklyn.config:
-            enricher.sourceSensor: reqs.per_sec.windowed_30s
-            enricher.targetSensor: reqs.per_sec.windowed_30s.per_node
-            transformation: average
-              
-        brooklyn.policies:
-        # resilience: if a per-node restart policy fails,
-        # just throw that node away and create a new one
-        - type: org.apache.brooklyn.policy.ha.ServiceReplacer
-        
-        # and scale based on reqs/sec
-        - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
-          brooklyn.config:
-            # scale based on reqs/sec (though in a real-world situation, 
-            # reqs.per_sec.windowed_30s.per_node might be a better choice) 
-            metric: reqs.per_sec.per_node
-            
-            # really low numbers, so you can trigger a scale-out just by hitting reload a lot
-            metricUpperBound: 3
-            metricLowerBound: 1
-            
-            # sustain 3 reqs/sec for 2s and it will scale out
-            resizeUpStabilizationDelay: 2s
-            # only scale down when sustained for 1m
-            resizeDownStabilizationDelay: 1m
-      
-            maxPoolSize: 10
-            
-      # and add a load-balancer pointing at the cluster
-      - type:           load-balancer
-        id:             load-bal
-        brooklyn.config:
-          # point this load balancer at the cluster, specifying port to forward to
-          loadbalancer.serverpool:  $brooklyn:entity("my-web-cluster")
-          member.sensor.portNumber: app.port
-          # disable sticky sessions to allow easy validation of balancing via browser refresh
-          nginx.sticky: false
-      
-      brooklyn.enrichers:
-      # publish a few useful info sensors and KPI's to the root of the app
-      - type: org.apache.brooklyn.enricher.stock.Propagator
-        brooklyn.config:
-          uniqueTag:    propagate-load-balancer-url
-          producer:     $brooklyn:entity("load-bal")
-          propagating:
-          - main.uri
-      - type: org.apache.brooklyn.enricher.stock.Propagator
-        brooklyn.config:
-          uniqueTag:    propagate-reqs-per-sec
-          producer:     $brooklyn:entity("my-web-cluster")
-          propagating:
-          - reqs.per_sec
-          - reqs.per_sec.windowed_30s.per_node
-      
-      location:
-        jclouds:aws-ec2:
-          # edit these (or delete if credentials specified in brooklyn.properties)      
-          identity:     <REPLACE>
-          credential:   <REPLACE>
-          
-          region:       eu-central-1
-          minRam:       2gb
+  - file:catalog/catalog.bom


[6/6] brooklyn-dist git commit: This closes #104

Posted by dr...@apache.org.
This closes #104


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/d22a71e2
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/d22a71e2
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/d22a71e2

Branch: refs/heads/master
Commit: d22a71e2c2b0b5e750ee74b8d01292ca56a672f8
Parents: ff34316 939dd79
Author: Duncan Godwin <dr...@googlemail.com>
Authored: Wed Sep 13 14:52:01 2017 +0100
Committer: Duncan Godwin <dr...@googlemail.com>
Committed: Wed Sep 13 14:52:01 2017 +0100

----------------------------------------------------------------------
 deb-packaging/deb/control/control               |   2 +-
 deb-packaging/deb/control/postinst              |   3 -
 deb-packaging/deb/control/preinst               |  10 +
 deb-packaging/pom.xml                           | 173 ++++++---
 .../main/filtered-resources/etc/brooklyn.cfg    |  28 ++
 .../src/main/resources/bin/runbrooklyn          |  39 ++
 .../src/main/resources/bin/setenv               |   7 +
 .../src/main/resources/catalog/catalog.bom      | 368 +++++++++++++++++++
 .../src/main/resources/etc/default.catalog.bom  | 362 +-----------------
 .../org.apache.brooklyn.osgilauncher.cfg        |   2 +-
 rpm-packaging/pom.xml                           | 162 +++++---
 rpm-packaging/rpm/postinstall.sh                |   3 -
 rpm-packaging/rpm/preinstall.sh                 |  10 +
 .../resources/service/systemd/brooklyn.service  |  10 +-
 .../resources/service/upstart/deb/brooklyn.conf |  13 +-
 .../resources/service/upstart/rpm/brooklyn.conf |  14 +-
 shared-packaging/src/test/yaml/Vagrantfile      |   4 +-
 .../src/test/yaml/package-apps.yaml             |  10 +-
 shared-packaging/src/test/yaml/package.bom      |  46 ++-
 19 files changed, 767 insertions(+), 499 deletions(-)
----------------------------------------------------------------------



[4/6] brooklyn-dist git commit: Disable auth by default

Posted by dr...@apache.org.
Disable auth by default


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/569f6d17
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/569f6d17
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/569f6d17

Branch: refs/heads/master
Commit: 569f6d176555f9bffcc2eee4d52086d840507f14
Parents: c640784
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Wed Sep 13 14:29:43 2017 +0100
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Wed Sep 13 14:29:43 2017 +0100

----------------------------------------------------------------------
 .../src/main/filtered-resources/etc/brooklyn.cfg          | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/569f6d17/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg b/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
index abf8550..12068d0 100644
--- a/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
+++ b/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
@@ -17,8 +17,12 @@
 #
 ################################################################################
 
-# Web login credentials
+# Disabling auth by default.
+brooklyn.webconsole.security.provider = org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider
+
+# You can enable basic auth by commenting out the line above and uncomment the last 2 lines below
 
+# Web login credentials
 # Credentials for user 'admin'
-brooklyn.webconsole.security.users=admin
-brooklyn.webconsole.security.user.admin.password=password
+#brooklyn.webconsole.security.users=admin
+#brooklyn.webconsole.security.user.admin.password=password


[3/6] brooklyn-dist git commit: Improve DEB package

Posted by dr...@apache.org.
Improve DEB package


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/c640784c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/c640784c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/c640784c

Branch: refs/heads/master
Commit: c640784c6efd60afc494b776fe2a00a8c06b02a7
Parents: 4118fc4
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Fri Sep 8 15:47:06 2017 +0100
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Mon Sep 11 10:19:33 2017 +0100

----------------------------------------------------------------------
 deb-packaging/deb/control/control               |   2 +-
 deb-packaging/deb/control/postinst              |   3 -
 deb-packaging/deb/control/preinst               |  10 ++
 deb-packaging/pom.xml                           | 173 ++++++++++++++-----
 .../resources/service/upstart/deb/brooklyn.conf |  13 +-
 shared-packaging/src/test/yaml/Vagrantfile      |   4 +-
 .../src/test/yaml/package-apps.yaml             |   6 +-
 shared-packaging/src/test/yaml/package.bom      |  12 +-
 8 files changed, 159 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/deb-packaging/deb/control/control
----------------------------------------------------------------------
diff --git a/deb-packaging/deb/control/control b/deb-packaging/deb/control/control
index a1283d4..a3b6e26 100644
--- a/deb-packaging/deb/control/control
+++ b/deb-packaging/deb/control/control
@@ -19,6 +19,6 @@ Version: [[version]]
 Section: misc
 Priority: optional
 Architecture: all
-Depends: default-jre-headless (>= 1.7)
+Depends: java8-runtime
 Maintainer: Aleksandr Vasilev <al...@cloudsoftcorp.com>
 Description: Apache Brooklyn is a framework for modeling, monitoring, and managing applications through autonomic blueprints.

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/deb-packaging/deb/control/postinst
----------------------------------------------------------------------
diff --git a/deb-packaging/deb/control/postinst b/deb-packaging/deb/control/postinst
index 20ddb29..fd786d6 100644
--- a/deb-packaging/deb/control/postinst
+++ b/deb-packaging/deb/control/postinst
@@ -18,7 +18,4 @@
 
 if which systemctl > /dev/null 2>&1; then
     systemctl daemon-reload
-    systemctl start brooklyn.service
-elif which initctl > /dev/null 2>&1; then
-    initctl start brooklyn
 fi

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/deb-packaging/deb/control/preinst
----------------------------------------------------------------------
diff --git a/deb-packaging/deb/control/preinst b/deb-packaging/deb/control/preinst
index 1c613da..4215068 100644
--- a/deb-packaging/deb/control/preinst
+++ b/deb-packaging/deb/control/preinst
@@ -17,3 +17,13 @@
 # under the License.
 /usr/bin/getent group brooklyn || /usr/sbin/groupadd -r brooklyn
 /usr/bin/getent passwd brooklyn || /usr/sbin/useradd -r -g brooklyn -d /opt/brooklyn -s /bin/false brooklyn
+# Remove the symbolic link "/opt/brooklyn" if exists (means that we are upgrading brooklyn)
+BROOKLYN_ROOT=/opt/brooklyn
+if [[ -L $BROOKLYN_ROOT && -d $BROOKLYN_ROOT ]]; then
+  rm -f $BROOKLYN_ROOT
+fi
+# Remove the symbolic link "/var/log/brooklyn" if exists (means that we are upgrading brooklyn)
+BROOKLYN_LOG=/var/log/brooklyn
+if [[ -L $BROOKLYN_LOG && -d $BROOKLYN_LOG ]]; then
+  rm -f $BROOKLYN_LOG
+fi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/deb-packaging/pom.xml
----------------------------------------------------------------------
diff --git a/deb-packaging/pom.xml b/deb-packaging/pom.xml
index a6e5611..27a9af9 100644
--- a/deb-packaging/pom.xml
+++ b/deb-packaging/pom.xml
@@ -26,6 +26,14 @@
         Brooklyn DEB Package for Debian and Ubuntu operating systems
     </description>
 
+    <properties>
+        <brooklyn.directory.permission.default>740</brooklyn.directory.permission.default>
+        <brooklyn.directory.permission.root>740</brooklyn.directory.permission.root>
+        <brooklyn.file.permission.default>740</brooklyn.file.permission.default>
+        <brooklyn.file.permission.bin>740</brooklyn.file.permission.bin>
+        <brooklyn.file.permission.global>664</brooklyn.file.permission.global>
+    </properties>
+
     <parent>
         <groupId>org.apache.brooklyn</groupId>
         <artifactId>brooklyn-dist-root</artifactId>
@@ -36,8 +44,9 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-dist</artifactId>
+            <artifactId>apache-brooklyn</artifactId>
             <version>${project.version}</version>
+            <type>zip</type>
         </dependency>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
@@ -58,23 +67,22 @@
                             <goal>unpack</goal>
                         </goals>
                         <configuration>
-                          <artifactItems>
-                            <artifactItem>
-                              <groupId>org.apache.brooklyn</groupId>
-                              <artifactId>brooklyn-dist</artifactId>
-                              <version>${project.version}</version>
-                              <classifier>dist</classifier>
-                              <type>tar.gz</type>
-                              <outputDirectory>${project.build.directory}/deps</outputDirectory>
-                            </artifactItem>
-                            <artifactItem>
-                              <groupId>org.apache.brooklyn</groupId>
-                              <artifactId>shared-packaging</artifactId>
-                              <version>${project.version}</version>
-                              <type>jar</type>
-                              <outputDirectory>${project.build.directory}/deps/shared-packaging</outputDirectory>
-                            </artifactItem>
-                          </artifactItems>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.brooklyn</groupId>
+                                    <artifactId>apache-brooklyn</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>zip</type>
+                                    <outputDirectory>${project.build.directory}/deps</outputDirectory>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.brooklyn</groupId>
+                                    <artifactId>shared-packaging</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>jar</type>
+                                    <outputDirectory>${project.build.directory}/deps/shared-packaging</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
                         </configuration>
                     </execution>
                 </executions>
@@ -92,86 +100,159 @@
                         <configuration>
                             <verbose>false</verbose>
                             <skipPOMs>false</skipPOMs>
-                            <deb>${project.build.directory}/apache-brooklyn_${project.version}_all.deb</deb>
+                            <!-- Try to follow the deb package naming convention, restricted by the maven artifact naming -->
+                            <classifier>all</classifier>
+                            <deb>${project.build.directory}/apache-brooklyn-${project.version}-all.deb</deb>
                             <controlDir>${basedir}/deb/control</controlDir>
                             <dataSet>
                                 <data>
-                                    <src>${project.build.directory}/deps/brooklyn-dist-${project.version}</src>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/bin</src>
                                     <type>directory</type>
                                     <mapper>
                                         <type>perm</type>
-                                        <prefix>/opt/brooklyn</prefix>
+                                        <prefix>/opt/brooklyn-${project.version}/bin</prefix>
                                         <user>brooklyn</user>
                                         <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.bin}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
-                                    <src>${project.build.directory}/deps/shared-packaging/service/upstart/deb/brooklyn.conf</src>
-                                    <type>file</type>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/catalog</src>
+                                    <type>directory</type>
                                     <mapper>
                                         <type>perm</type>
-                                        <prefix>/etc/init</prefix>
-                                        <filemode>644</filemode>
+                                        <prefix>/opt/brooklyn-${project.version}/catalog</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
-                                    <!-- TODO Probably should live in /usr/lib/systemd/system with a symlink in the following folder -->
-                                    <src>${project.build.directory}/deps/shared-packaging/service/systemd/brooklyn.service</src>
-                                    <type>file</type>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/data</src>
+                                    <type>directory</type>
                                     <mapper>
                                         <type>perm</type>
-                                        <prefix>/etc/systemd/system/multi-user.target.wants</prefix>
-                                        <filemode>644</filemode>
+                                        <prefix>/opt/brooklyn-${project.version}/data</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
+                                    </mapper>
+                                </data>
+                                <data>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/deploy</src>
+                                    <type>directory</type>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/opt/brooklyn-${project.version}/deploy</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
+                                    </mapper>
+                                </data>
+                                <data>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/etc</src>
+                                    <type>directory</type>
+                                    <conffile>true</conffile>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/etc/brooklyn</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
+                                    </mapper>
+                                </data>
+                                <data>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/lib</src>
+                                    <type>directory</type>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/opt/brooklyn-${project.version}/lib</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
+                                    </mapper>
+                                </data>
+                                <data>
+                                    <src>${project.build.directory}/deps/apache-brooklyn-${project.version}/system</src>
+                                    <type>directory</type>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/opt/brooklyn-${project.version}/system</prefix>
+                                        <user>brooklyn</user>
+                                        <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
                                     <type>template</type>
                                     <paths>
-                                        <path>etc/brooklyn</path>
-                                        <path>var/lib/brooklyn</path>
+                                        <path>/opt/brooklyn-${project.version}/data/log</path>
                                     </paths>
                                     <mapper>
                                         <type>perm</type>
                                         <user>brooklyn</user>
                                         <group>brooklyn</group>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
                                     <type>template</type>
                                     <paths>
-                                        <path>var/log/brooklyn</path>
+                                        <path>/var/lib/brooklyn</path>
                                     </paths>
                                     <mapper>
                                         <type>perm</type>
                                         <user>brooklyn</user>
                                         <group>brooklyn</group>
-                                        <filemode>700</filemode>
+                                        <filemode>${brooklyn.file.permission.default}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
-                                    <src>${project.build.directory}/deps/shared-packaging/conf/brooklyn.conf</src>
+                                    <src>${project.build.directory}/deps/shared-packaging/service/upstart/deb/brooklyn.conf</src>
                                     <type>file</type>
-                                    <conffile>true</conffile>
                                     <mapper>
                                         <type>perm</type>
-                                        <prefix>/etc/brooklyn</prefix>
-                                        <user>brooklyn</user>
-                                        <group>brooklyn</group>
-                                        <filemode>600</filemode>
+                                        <prefix>/etc/init</prefix>
+                                        <filemode>${brooklyn.file.permission.global}</filemode>
                                     </mapper>
                                 </data>
                                 <data>
-                                    <src>${project.build.directory}/deps/shared-packaging/conf/logback.xml</src>
+                                    <src>${project.build.directory}/deps/shared-packaging/service/systemd/brooklyn.service</src>
                                     <type>file</type>
-                                    <conffile>true</conffile>
                                     <mapper>
                                         <type>perm</type>
-                                        <prefix>/etc/brooklyn</prefix>
-                                        <user>brooklyn</user>
-                                        <group>brooklyn</group>
-                                        <filemode>644</filemode>
+                                        <prefix>/lib/systemd/system</prefix>
+                                        <filemode>${brooklyn.file.permission.global}</filemode>
+                                    </mapper>
+                                </data>
+                                <data>
+                                    <!-- TODO Probably should live in /usr/lib/systemd/system with a symlink in the following folder -->
+                                    <src>${project.build.directory}/deps/shared-packaging/service/systemd/brooklyn.service</src>
+                                    <type>file</type>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/etc/systemd/system/multi-user.target.wants</prefix>
+                                        <filemode>${brooklyn.file.permission.global}</filemode>
                                     </mapper>
                                 </data>
+                                <data>
+                                    <type>link</type>
+                                    <linkName>/opt/brooklyn</linkName>
+                                    <linkTarget>/opt/brooklyn-${project.version}</linkTarget>
+                                    <symlink>true</symlink>
+                                </data>
+                                <data>
+                                    <type>link</type>
+                                    <linkName>/opt/brooklyn-${project.version}/etc</linkName>
+                                    <linkTarget>/etc/brooklyn</linkTarget>
+                                    <symlink>true</symlink>
+                                </data>
+                                <data>
+                                    <type>link</type>
+                                    <linkName>/var/log/brooklyn</linkName>
+                                    <linkTarget>/opt/brooklyn-${project.version}/data/log</linkTarget>
+                                    <symlink>true</symlink>
+                                </data>
                             </dataSet>
                         </configuration>
                     </execution>

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf b/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
index 931fffd..c62a98e 100644
--- a/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
+++ b/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
@@ -22,6 +22,7 @@ start on started networking
 stop on runlevel [016]
 respawn
 respawn limit 5 10
+umask 0066
 
 setuid brooklyn
 setgid brooklyn
@@ -33,11 +34,13 @@ pre-start script
 end script
 
 script
-    BROOKLYN_HOME="/opt/brooklyn/"
-    JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Dlogback.configurationFile=/etc/brooklyn/logback.xml -Xms256m -Xmx1g"
-    CLASSPATH="/opt/brooklyn/conf:/opt/brooklyn/lib/patch/*:/opt/brooklyn/lib/brooklyn/*:/opt/brooklyn/lib/dropins/*"
-    export BROOKLYN_HOME
-    exec java ${JAVA_OPTS} -cp "${CLASSPATH}" org.apache.brooklyn.cli.Main launch --noGlobalBrooklynProperties --localBrooklynProperties /etc/brooklyn/brooklyn.conf --persist auto
+    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+    KARAF_HOME="/opt/brooklyn/"
+    KARAF_ETC="/etc/brooklyn/"
+    KARAF_REDIRECT=/dev/null
+    BROOKLYN_PERSISTENCE_DIR="/var/lib/brooklyn"
+    export EXTRA_JAVA_OPTS KARAF_REDIRECT KARAF_HOME KARAF_ETC BROOKLYN_PERSISTENCE_DIR
+    exec /opt/brooklyn/bin/karaf server  >> "$KARAF_REDIRECT" 2>&1
 end script
 
 pre-stop script

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/shared-packaging/src/test/yaml/Vagrantfile
----------------------------------------------------------------------
diff --git a/shared-packaging/src/test/yaml/Vagrantfile b/shared-packaging/src/test/yaml/Vagrantfile
index 9855aff..3e561bd 100644
--- a/shared-packaging/src/test/yaml/Vagrantfile
+++ b/shared-packaging/src/test/yaml/Vagrantfile
@@ -33,8 +33,10 @@ Vagrant.configure(2) do |config|
   config.vm.provision "shell", name:"set key permissions", privileged:false, inline: "chmod 400 ~/.ssh/authorized_keys"
 
   config.vm.define "apt-systemd" do |config|
-    config.vm.box = "ubuntu/wily64"
+    config.vm.box = "ubuntu/xenial64"
     config.vm.network "private_network", ip: "172.28.128.3"
+    config.ssh.insert_key = true
+    config.ssh.forward_agent = true
   end
   config.vm.define "apt-upstart" do |config|
     config.vm.box = "ubuntu/trusty64"

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/shared-packaging/src/test/yaml/package-apps.yaml
----------------------------------------------------------------------
diff --git a/shared-packaging/src/test/yaml/package-apps.yaml b/shared-packaging/src/test/yaml/package-apps.yaml
index bda0c51..0900dd7 100644
--- a/shared-packaging/src/test/yaml/package-apps.yaml
+++ b/shared-packaging/src/test/yaml/package-apps.yaml
@@ -23,9 +23,9 @@ services:
     byon:
       hosts: ["172.28.128.3"]
       # privateKeyFile: ~/.ssh/<private key>
-      user: vagrant
+      user: ubuntu
   brooklyn.config:
-    package.file:  ~/.m2/repository/org/apache/brooklyn/deb-packaging/0.12.0-SNAPSHOT/deb-packaging-0.12.0-SNAPSHOT.deb # BROOKLYN_VERSION
+    package.file:  ~/.m2/repository/org/apache/brooklyn/deb-packaging/0.12.0-SNAPSHOT/deb-packaging-0.12.0-SNAPSHOT-all.deb # BROOKLYN_VERSION
 
 ---
 
@@ -38,7 +38,7 @@ services:
       # privateKeyFile: ~/.ssh/<private key>
       user: vagrant
   brooklyn.config:
-    package.file: ~/.m2/repository/org/apache/brooklyn/deb-packaging/0.12.0-SNAPSHOT/deb-packaging-0.12.0-SNAPSHOT.deb # BROOKLYN_VERSION
+    package.file: ~/.m2/repository/org/apache/brooklyn/deb-packaging/0.12.0-SNAPSHOT/deb-packaging-0.12.0-SNAPSHOT-all.deb # BROOKLYN_VERSION
 
 ---
 

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/c640784c/shared-packaging/src/test/yaml/package.bom
----------------------------------------------------------------------
diff --git a/shared-packaging/src/test/yaml/package.bom b/shared-packaging/src/test/yaml/package.bom
index bc1780d..ba5615a 100644
--- a/shared-packaging/src/test/yaml/package.bom
+++ b/shared-packaging/src/test/yaml/package.bom
@@ -53,6 +53,7 @@ brooklyn.catalog:
           sudo apt-get update
           sudo apt-get install -y default-jre-headless
           sudo dpkg -i brooklyn-package.deb
+          sudo systemctl start brooklyn
 
   - id: apt-upstart-brooklyn
     item:
@@ -65,6 +66,7 @@ brooklyn.catalog:
           sudo apt-get update
           sudo apt-get install -y default-jre-headless
           sudo dpkg -i brooklyn-package.deb
+          sudo initctl start brooklyn
 
   - id: yum-systemd-brooklyn
     item:
@@ -166,17 +168,17 @@ brooklyn.catalog:
       name: Check paths permissions
       command: |
         BROOKLYN_DIRECTORIES="/opt/brooklyn/ /etc/brooklyn/ /var/lib/brooklyn/ /var/log/brooklyn/"
-        [ "$(sudo stat -c "%A %U %G" /opt/brooklyn)" = "lrwxrwxrwx brooklyn brooklyn" ]
+        [ "$(sudo stat -c "%A" /opt/brooklyn)" = "lrwxrwxrwx" ]
         [ "$(sudo stat -c "%A %U %G" /etc/init)" = "drwxr-xr-x root root" ]
         [ "$(sudo stat -c "%A %U %G" /lib/systemd/system/)" = "drwxr-xr-x root root" ]
         [ "$(sudo stat -c "%A %U %G" /etc/init/brooklyn.conf)" = "-rw-rw-r-- root root" ]
         [ "$(sudo stat -c "%A %U %G" /lib/systemd/system/brooklyn.service)" = "-rw-rw-r-- root root" ]
         if hash systemctl ; then
-          [ "$(sudo stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants/brooklyn.service)" = "-rwxr----- root root" ]
+          [ "$(sudo stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants/brooklyn.service)" = "-rw-rw-r-- root root" ]
         fi
-        ! sudo ls -d /opt/brooklyn-* | xargs stat -c "%F %a %U %G" | grep -v -E "^directory\s740\sbrooklyn\sbrooklyn$"
-        ! sudo find ${BROOKLYN_DIRECTORIES} -type f | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,4,6][0]\sbrooklyn\sbrooklyn"
-        ! sudo find ${BROOKLYN_DIRECTORIES} -type d | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,1,4][0-1]\sbrooklyn\sbrooklyn"
+        ! sudo ls -d /opt/brooklyn-* | xargs stat -c "%F %a %U %G" | grep -v -E "^directory\s[7][4,5][0,5]\sbrooklyn\sbrooklyn$"
+        ! sudo find ${BROOKLYN_DIRECTORIES} -type f | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,4,6][0]\sbrooklyn\s(brooklyn|wheel)"
+        ! sudo find ${BROOKLYN_DIRECTORIES} -type d | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,1,4,5][0,1,5]\sbrooklyn\s(brooklyn|wheel)"
       assertStatus:
         equals: 0
   - id: test-log-files-exist


[2/6] brooklyn-dist git commit: Improve RPM package

Posted by dr...@apache.org.
Improve RPM package


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/4118fc4f
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/4118fc4f
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/4118fc4f

Branch: refs/heads/master
Commit: 4118fc4f936d7fa440d5961880af2465afa89928
Parents: 1eb9be8
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Wed Sep 6 14:59:22 2017 +0100
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Fri Sep 8 17:22:19 2017 +0100

----------------------------------------------------------------------
 .../main/filtered-resources/etc/brooklyn.cfg    |  24 +++
 .../src/main/resources/bin/runbrooklyn          |  39 +++++
 .../src/main/resources/bin/setenv               |   7 +
 .../org.apache.brooklyn.osgilauncher.cfg        |   2 +-
 rpm-packaging/pom.xml                           | 162 ++++++++++++++-----
 rpm-packaging/rpm/postinstall.sh                |   3 -
 rpm-packaging/rpm/preinstall.sh                 |  10 ++
 .../resources/service/systemd/brooklyn.service  |  10 +-
 .../resources/service/upstart/rpm/brooklyn.conf |  14 +-
 .../src/test/yaml/package-apps.yaml             |   4 +-
 shared-packaging/src/test/yaml/package.bom      |  44 ++---
 11 files changed, 240 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg b/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
new file mode 100644
index 0000000..abf8550
--- /dev/null
+++ b/karaf/apache-brooklyn/src/main/filtered-resources/etc/brooklyn.cfg
@@ -0,0 +1,24 @@
+################################################################################
+#
+#    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.
+#
+################################################################################
+
+# Web login credentials
+
+# Credentials for user 'admin'
+brooklyn.webconsole.security.users=admin
+brooklyn.webconsole.security.user.admin.password=password

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/karaf/apache-brooklyn/src/main/resources/bin/runbrooklyn
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/resources/bin/runbrooklyn b/karaf/apache-brooklyn/src/main/resources/bin/runbrooklyn
new file mode 100644
index 0000000..59c9554
--- /dev/null
+++ b/karaf/apache-brooklyn/src/main/resources/bin/runbrooklyn
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# 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.
+
+# This script is a convenience wrapper for use to avoid problems on Centos 6
+# Upstart is too old on CentOS 6, at least v1.4 required to use setuid, setgid.
+# This script does the setuid and handles termination via signals.
+
+trap terminate_all SIGTERM
+trap kill_all SIGKILL
+
+function terminate_all () {
+  pkill -SIGTERM -g ${PGROUP}
+  kill -s SIGTERM ${KARAF}
+}
+function kill_all () {
+  pkill -SIGKILL -g ${PGROUP}
+  kill -s SIGKILL ${KARAF}
+}
+
+su -c "/opt/brooklyn/bin/karaf server  >> /dev/null 2>&1" brooklyn & KARAF=$!
+sleep 1 # gives time for process structure to be established
+PGROUP=$(pgrep -P $KARAF)
+wait

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/karaf/apache-brooklyn/src/main/resources/bin/setenv
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/resources/bin/setenv b/karaf/apache-brooklyn/src/main/resources/bin/setenv
index 9a109fd..88cbc6a 100644
--- a/karaf/apache-brooklyn/src/main/resources/bin/setenv
+++ b/karaf/apache-brooklyn/src/main/resources/bin/setenv
@@ -75,6 +75,10 @@ if [ "x$JAVA" = "x" ]; then
     fi
 fi
 
+if [ -z "${BROOKLYN_PERSISTENCE_DIR}" ] ; then
+    export BROOKLYN_PERSISTENCE_DIR="~/.brooklyn/brooklyn-persisted-state"
+fi
+
 # force resolution of localhost to be loopback
 export EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 ${EXTRA_JAVA_OPTS}"
 
@@ -83,3 +87,6 @@ export EXTRA_JAVA_OPTS="-XX:SoftRefLRUPolicyMSPerMB=1 ${EXTRA_JAVA_OPTS}"
 
 # Set the TLS protocol versions
 export EXTRA_JAVA_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2 ${EXTRA_JAVA_OPTS}"
+
+# Set the persistence directory
+export EXTRA_JAVA_OPTS="-Dbrooklyn.persistence.dir=${BROOKLYN_PERSISTENCE_DIR} ${EXTRA_JAVA_OPTS}"

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/karaf/config/src/main/resources/org.apache.brooklyn.osgilauncher.cfg
----------------------------------------------------------------------
diff --git a/karaf/config/src/main/resources/org.apache.brooklyn.osgilauncher.cfg b/karaf/config/src/main/resources/org.apache.brooklyn.osgilauncher.cfg
index 84b750c..6f80460 100644
--- a/karaf/config/src/main/resources/org.apache.brooklyn.osgilauncher.cfg
+++ b/karaf/config/src/main/resources/org.apache.brooklyn.osgilauncher.cfg
@@ -58,7 +58,7 @@ default.catalog.location=${karaf.etc}/default.catalog.bom
 #persistMode=AUTO
 
 # The directory to read/write persisted state (or container name if using an object store)
-#persistenceDir=
+persistenceDir=${brooklyn.persistence.dir}
 
 # The location spec for an object store to read/write persisted state
 #persistenceLocation=

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/rpm-packaging/pom.xml
----------------------------------------------------------------------
diff --git a/rpm-packaging/pom.xml b/rpm-packaging/pom.xml
index b2b7075..b816555 100644
--- a/rpm-packaging/pom.xml
+++ b/rpm-packaging/pom.xml
@@ -26,6 +26,14 @@
         Brooklyn RPM Package for Centos 7 and RHEL 7 operating systems
     </description>
 
+    <properties>
+        <brooklyn.directory.permission.default>740</brooklyn.directory.permission.default>
+        <brooklyn.directory.permission.root>740</brooklyn.directory.permission.root>
+        <brooklyn.file.permission.default>740</brooklyn.file.permission.default>
+        <brooklyn.file.permission.bin>740</brooklyn.file.permission.bin>
+        <brooklyn.file.permission.global>664</brooklyn.file.permission.global>
+    </properties>
+
     <parent>
         <groupId>org.apache.brooklyn</groupId>
         <artifactId>brooklyn-dist-root</artifactId>
@@ -36,8 +44,9 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-dist</artifactId>
+            <artifactId>apache-brooklyn</artifactId>
             <version>${project.version}</version>
+            <type>zip</type>
         </dependency>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
@@ -58,23 +67,22 @@
                             <goal>unpack</goal>
                         </goals>
                         <configuration>
-                          <artifactItems>
-                            <artifactItem>
-                              <groupId>org.apache.brooklyn</groupId>
-                              <artifactId>brooklyn-dist</artifactId>
-                              <version>${project.version}</version>
-                              <classifier>dist</classifier>
-                              <type>tar.gz</type>
-                              <outputDirectory>${project.build.directory}/deps</outputDirectory>
-                            </artifactItem>
-                            <artifactItem>
-                              <groupId>org.apache.brooklyn</groupId>
-                              <artifactId>shared-packaging</artifactId>
-                              <version>${project.version}</version>
-                              <type>jar</type>
-                              <outputDirectory>${project.build.directory}/deps/shared-packaging</outputDirectory>
-                            </artifactItem>
-                          </artifactItems>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.brooklyn</groupId>
+                                    <artifactId>apache-brooklyn</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>zip</type>
+                                    <outputDirectory>${project.build.directory}/deps</outputDirectory>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.brooklyn</groupId>
+                                    <artifactId>shared-packaging</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>jar</type>
+                                    <outputDirectory>${project.build.directory}/deps/shared-packaging</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
                         </configuration>
                     </execution>
                 </executions>
@@ -97,66 +105,90 @@
                     <group>Applications/Internet</group>
                     <changelogFile><!--TODO--></changelogFile>
                     <needarch>noarch</needarch>
+                    <classifier>noarch</classifier>
                     <targetOS>Linux</targetOS>
                     <requires>
-                        <require>java</require>
+                        <require>java-1.8.0</require>
                     </requires>
                     <defineStatements>
                         <defineStatement>_binaries_in_noarch_packages_terminate_build 0</defineStatement>
                     </defineStatements>
-                    <defaultDirmode>755</defaultDirmode>
-                    <defaultFilemode>644</defaultFilemode>
+                    <defaultDirmode>${brooklyn.directory.permission.default}</defaultDirmode>
+                    <defaultFilemode>${brooklyn.file.permission.default}</defaultFilemode>
                     <defaultGroupname>brooklyn</defaultGroupname>
                     <defaultUsername>brooklyn</defaultUsername>
                     <mappings>
                         <mapping>
-                            <directory>/etc/brooklyn</directory>
-                            <configuration>true</configuration>
+                            <directory>/opt/brooklyn-${project.version}</directory>
                         </mapping>
                         <mapping>
-                            <directory>/etc/brooklyn</directory>
-                            <configuration>true</configuration>
-                            <filemode>600</filemode>
-                            <username>brooklyn</username>
-                            <groupname>brooklyn</groupname>
+                            <directory>/opt/brooklyn-${project.version}/bin</directory>
+                            <filemode>${brooklyn.file.permission.bin}</filemode>
                             <sources>
                                 <source>
-                                    <location>${project.build.directory}/deps/shared-packaging/conf/brooklyn.conf</location>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/bin</location>
                                 </source>
                             </sources>
                         </mapping>
                         <mapping>
-                            <directory>/etc/brooklyn</directory>
-                            <configuration>true</configuration>
+                            <directory>/opt/brooklyn-${project.version}/catalog</directory>
                             <sources>
                                 <source>
-                                    <location>${project.build.directory}/deps/shared-packaging/conf/logback.xml</location>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/catalog</location>
                                 </source>
                             </sources>
                         </mapping>
                         <mapping>
-                            <directory>/opt/brooklyn</directory>
+                            <directory>/opt/brooklyn-${project.version}/data</directory>
+                            <directoryIncluded>true</directoryIncluded>
+                            <recurseDirectories>true</recurseDirectories>
                             <sources>
                                 <source>
-                                    <location>${project.build.directory}/deps/brooklyn-dist-${project.version}</location>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/data</location>
                                 </source>
                             </sources>
                         </mapping>
                         <mapping>
-                            <directory>/var/lib/brooklyn</directory>
-                            <configuration>true</configuration>
+                            <directory>/opt/brooklyn-${project.version}/data/log</directory>
                         </mapping>
                         <mapping>
-                            <directory>/var/log/brooklyn</directory>
-                            <configuration>true</configuration>
-                            <filemode>700</filemode>
-                            <username>brooklyn</username>
-                            <groupname>brooklyn</groupname>
+                            <directory>/opt/brooklyn-${project.version}/deploy</directory>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/deploy</location>
+                                </source>
+                            </sources>
                         </mapping>
                         <mapping>
-                            <directory>/etc/systemd/system/multi-user.target.wants</directory>
+                            <directory>/etc/brooklyn</directory>
+                            <configuration>noreplace</configuration>
+                            <filemode>${brooklyn.file.permission.default}</filemode>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/etc</location>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/opt/brooklyn-${project.version}/lib</directory>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/lib</location>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/opt/brooklyn-${project.version}/system</directory>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/deps/apache-brooklyn-${project.version}/system</location>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/lib/systemd/system</directory>
                             <directoryIncluded>false</directoryIncluded>
-                            <filemode>644</filemode>
+                            <filemode>${brooklyn.file.permission.global}</filemode>
                             <username>root</username>
                             <groupname>root</groupname>
                             <sources>
@@ -168,7 +200,7 @@
                         <mapping>
                             <directory>/etc/init</directory>
                             <directoryIncluded>false</directoryIncluded>
-                            <filemode>644</filemode>
+                            <filemode>${brooklyn.file.permission.global}</filemode>
                             <username>root</username>
                             <groupname>root</groupname>
                             <sources>
@@ -177,6 +209,48 @@
                                 </source>
                             </sources>
                         </mapping>
+                        <mapping>
+                            <directory>/etc/systemd/system/multi-user.target.wants</directory>
+                            <directoryIncluded>false</directoryIncluded>
+                            <filemode>${brooklyn.file.permission.global}</filemode>
+                            <username>root</username>
+                            <groupname>root</groupname>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/deps/shared-packaging/service/systemd</location>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/var/lib/brooklyn</directory>
+                            <filemode>${brooklyn.file.permission.default}</filemode>
+                        </mapping>
+                        <mapping>
+                            <directory>/opt/brooklyn</directory>
+                            <sources>
+                                <softlinkSource>
+                                    <location>/opt/brooklyn-${project.version}</location>
+                                </softlinkSource>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/var/log/brooklyn</directory>
+                            <sources>
+                                <softlinkSource>
+                                    <location>/opt/brooklyn-${project.version}/data/log</location>
+                                </softlinkSource>
+                            </sources>
+                        </mapping>
+                        <!-- There is a bug in karaf 4.1.2 that ignores the KARAF_ETC envvar. The workaround is to softlink to the etc folder -->
+                        <!-- Until it is resolved: https://issues.apache.org/jira/browse/KARAF-5352 -->
+                        <mapping>
+                            <directory>/opt/brooklyn-${project.version}/etc</directory>
+                            <sources>
+                                <softlinkSource>
+                                    <location>/etc/brooklyn</location>
+                                </softlinkSource>
+                            </sources>
+                        </mapping>
                     </mappings>
                     <preinstallScriptlet>
                         <scriptFile>${basedir}/rpm/preinstall.sh</scriptFile>

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/rpm-packaging/rpm/postinstall.sh
----------------------------------------------------------------------
diff --git a/rpm-packaging/rpm/postinstall.sh b/rpm-packaging/rpm/postinstall.sh
index 4782a23..13abadd 100644
--- a/rpm-packaging/rpm/postinstall.sh
+++ b/rpm-packaging/rpm/postinstall.sh
@@ -19,7 +19,4 @@
 
 if which systemctl >> /dev/null 2>&1; then
     systemctl daemon-reload
-    systemctl start brooklyn.service
-else
-    initctl start brooklyn
 fi

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/rpm-packaging/rpm/preinstall.sh
----------------------------------------------------------------------
diff --git a/rpm-packaging/rpm/preinstall.sh b/rpm-packaging/rpm/preinstall.sh
index 666327f..7da5acf 100644
--- a/rpm-packaging/rpm/preinstall.sh
+++ b/rpm-packaging/rpm/preinstall.sh
@@ -19,3 +19,13 @@
 
 getent group brooklyn || groupadd -r brooklyn
 getent passwd brooklyn || useradd -r -g brooklyn -d /opt/brooklyn -s /sbin/nologin brooklyn
+# Remove the symbolic link "/opt/brooklyn" if exists (means that we are upgrading brooklyn)
+BROOKLYN_ROOT=/opt/brooklyn
+if [[ -L $BROOKLYN_ROOT && -d $BROOKLYN_ROOT ]]; then
+    rm -f $BROOKLYN_ROOT
+fi
+# Remove the symbolic link "/var/log/brooklyn" if exists (means that we are upgrading brooklyn)
+BROOKLYN_LOG=/var/log/brooklyn
+if [[ -L $BROOKLYN_LOG && -d $BROOKLYN_LOG ]]; then
+    rm -f $BROOKLYN_LOG
+fi

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/shared-packaging/src/main/resources/service/systemd/brooklyn.service
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/systemd/brooklyn.service b/shared-packaging/src/main/resources/service/systemd/brooklyn.service
index 52dd3b6..ef861bd 100644
--- a/shared-packaging/src/main/resources/service/systemd/brooklyn.service
+++ b/shared-packaging/src/main/resources/service/systemd/brooklyn.service
@@ -22,12 +22,16 @@ Documentation=https://brooklyn.apache.org/documentation/index.html
 [Service]
 Type=simple
 WorkingDirectory=/opt/brooklyn/
-Environment="JAVA_OPTS=-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Dlogback.configurationFile=/etc/brooklyn/logback.xml -Xms256m -Xmx1g"
-Environment="CLASSPATH=/opt/brooklyn/conf:/opt/brooklyn/lib/patch/*:/opt/brooklyn/lib/brooklyn/*:/opt/brooklyn/lib/dropins/*"
-ExecStart=/usr/bin/java $JAVA_OPTS -cp "$CLASSPATH" org.apache.brooklyn.cli.Main launch --noGlobalBrooklynProperties --localBrooklynProperties /etc/brooklyn/brooklyn.conf --persist auto
+Environment="EXTRA_JAVA_OPTS=-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+Environment="KARAF_HOME=/opt/brooklyn"
+Environment="KARAF_ETC=/etc/brooklyn"
+Environment="KARAF_REDIRECT=/dev/null"
+Environment="BROOKLYN_PERSISTENCE_DIR=/var/lib/brooklyn"
+ExecStart=/opt/brooklyn/bin/karaf server  >> "$KARAF_REDIRECT" 2>&1
 Restart=always
 User=brooklyn
 Group=brooklyn
+UMask=0066
 
 [Install]
 WantedBy=multi-user.target

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf b/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
index 804e0cd..1af0674 100644
--- a/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
+++ b/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
@@ -22,6 +22,7 @@ start on runlevel [23]
 stop on runlevel [016]
 respawn
 respawn limit 5 10
+umask 0066
 
 console output
 
@@ -30,13 +31,14 @@ pre-start script
 end script
 
 script
-    BROOKLYN_HOME="/opt/brooklyn/"
-    JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Dlogback.configurationFile=/etc/brooklyn/logback.xml -Xms256m -Xmx1g"
-    CLASSPATH="/opt/brooklyn/conf:/opt/brooklyn/lib/patch/*:/opt/brooklyn/lib/brooklyn/*:/opt/brooklyn/lib/dropins/*"
-    export BROOKLYN_HOME
-    # Upstart is too old on CentOS 6, at least v1.4 required to use setuid, setgid.
+    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+    KARAF_HOME="/opt/brooklyn/"
+    KARAF_ETC="/etc/brooklyn/"
+    KARAF_REDIRECT=/dev/null
+    BROOKLYN_PERSISTENCE_DIR="/var/lib/brooklyn"
+    export EXTRA_JAVA_OPTS KARAF_REDIRECT KARAF_HOME KARAF_ETC BROOKLYN_PERSISTENCE_DIR
     chsh -s /bin/bash brooklyn
-    exec su -c "java ${JAVA_OPTS} -cp $CLASSPATH org.apache.brooklyn.cli.Main launch --noGlobalBrooklynProperties --localBrooklynProperties /etc/brooklyn/brooklyn.conf --persist auto" brooklyn
+    exec /opt/brooklyn/bin/runbrooklyn  >> "$KARAF_REDIRECT" 2>&1
 end script
 
 pre-stop script

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/shared-packaging/src/test/yaml/package-apps.yaml
----------------------------------------------------------------------
diff --git a/shared-packaging/src/test/yaml/package-apps.yaml b/shared-packaging/src/test/yaml/package-apps.yaml
index de4420c..bda0c51 100644
--- a/shared-packaging/src/test/yaml/package-apps.yaml
+++ b/shared-packaging/src/test/yaml/package-apps.yaml
@@ -51,7 +51,7 @@ services:
       # privateKeyFile: ~/.ssh/<private key>
       user: vagrant
   brooklyn.config:
-    package.file: ~/.m2/repository/org/apache/brooklyn/rpm-packaging/0.12.0-SNAPSHOT/rpm-packaging-0.12.0-SNAPSHOT.rpm # BROOKLYN_VERSION
+    package.file: ~/.m2/repository/org/apache/brooklyn/rpm-packaging/0.12.0-SNAPSHOT/rpm-packaging-0.12.0-SNAPSHOT-noarch.rpm # BROOKLYN_VERSION
 
 ---
 
@@ -64,6 +64,6 @@ services:
       # privateKeyFile: ~/.ssh/<private key>
       user: vagrant
   brooklyn.config:
-    package.file: ~/.m2/repository/org/apache/brooklyn/rpm-packaging/0.12.0-SNAPSHOT/rpm-packaging-0.12.0-SNAPSHOT.rpm # BROOKLYN_VERSION
+    package.file: ~/.m2/repository/org/apache/brooklyn/rpm-packaging/0.12.0-SNAPSHOT/rpm-packaging-0.12.0-SNAPSHOT-noarch.rpm # BROOKLYN_VERSION
 
 

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/4118fc4f/shared-packaging/src/test/yaml/package.bom
----------------------------------------------------------------------
diff --git a/shared-packaging/src/test/yaml/package.bom b/shared-packaging/src/test/yaml/package.bom
index c17cb2c..bc1780d 100644
--- a/shared-packaging/src/test/yaml/package.bom
+++ b/shared-packaging/src/test/yaml/package.bom
@@ -79,8 +79,8 @@ brooklyn.catalog:
             sudo iptables -I INPUT -p tcp -m tcp --dport 8081 -j ACCEPT
             sudo service iptables save
           fi
-          sudo yum -y install java-1.7.0-openjdk.x86_64
           sudo yum -y install brooklyn-package.rpm
+          sudo systemctl start brooklyn
 
   - id: yum-upstart-brooklyn
     item:
@@ -95,9 +95,8 @@ brooklyn.catalog:
             sudo iptables -I INPUT -p tcp -m tcp --dport 8081 -j ACCEPT
             sudo service iptables save
           fi
-          sudo yum -y install java-1.7.0-openjdk.x86_64
           sudo yum -y install brooklyn-package.rpm
-
+          sudo initctl start brooklyn
 
 ### Tests ###
   - id: test-is-up
@@ -119,7 +118,7 @@ brooklyn.catalog:
       type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
       name: Check process has started
       # The brackets prevent grep from matching its own process
-      command: ps ax | grep "[o]rg.apache.brooklyn.cli.Main"
+      command: ps ax | grep "[/]opt/brooklyn/bin/karaf"
       assertStatus:
         equals: 0
       assertOut:
@@ -131,7 +130,7 @@ brooklyn.catalog:
       type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
       name: Check process is not started
       # The brackets prevent grep from matching its own process
-      command: ps ax | grep "[o]rg.apache.brooklyn.cli.Main"
+      command: ps ax | grep "[/]opt/brooklyn/bin/karaf"
       assertStatus:
         equals: 1
       assertOut:
@@ -143,7 +142,7 @@ brooklyn.catalog:
       type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
       name: Check user the process is running under
       # The brackets prevent grep from matching its own process
-      command: ps -fu brooklyn | grep "[o]rg.apache.brooklyn.cli.Main"
+      command: ps -fu brooklyn | grep "[/]opt/brooklyn/bin/karaf"
       assertStatus:
         equals: 0
       assertOut:
@@ -166,24 +165,25 @@ brooklyn.catalog:
       type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
       name: Check paths permissions
       command: |
-        [ "$(stat -c "%A %U %G" /opt/brooklyn)" = "drwxr-xr-x brooklyn brooklyn" ] && \
-        [ "$(stat -c "%A %U %G" /var/lib/brooklyn)" = "drwxr-xr-x brooklyn brooklyn" ] && \
-        [ "$(stat -c "%A %U %G" /var/log/brooklyn)" = "drwx------ brooklyn brooklyn" ] && \
-        [ "$(stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants)" = "drwxr-xr-x root root" ] && \
-        [ "$(sudo stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants/brooklyn.service)" = "-rw-r--r-- root root" ] && \
-        [ "$(stat -c "%A %U %G" /etc/init)" = "drwxr-xr-x root root" ] && \
-        [ "$(stat -c "%A %U %G" /etc/init/brooklyn.conf)" = "-rw-r--r-- root root" ] && \
-        [ "$(stat -c "%A %U %G" /etc/brooklyn)" = "drwxr-xr-x brooklyn brooklyn" ] && \
-        [ "$(sudo stat -c "%A %U %G" /etc/brooklyn/brooklyn.conf)" = "-rw------- brooklyn brooklyn" ] && \
-        [ "$(stat -c "%A %U %G" /etc/brooklyn/logback.xml)" = "-rw-r--r-- brooklyn brooklyn" ] && \
-        ! find /opt/brooklyn | xargs stat -c "%A %U %G" | grep -v "drwxr-xr-x brooklyn brooklyn\|-rw-r--r-- brooklyn brooklyn"
+        BROOKLYN_DIRECTORIES="/opt/brooklyn/ /etc/brooklyn/ /var/lib/brooklyn/ /var/log/brooklyn/"
+        [ "$(sudo stat -c "%A %U %G" /opt/brooklyn)" = "lrwxrwxrwx brooklyn brooklyn" ]
+        [ "$(sudo stat -c "%A %U %G" /etc/init)" = "drwxr-xr-x root root" ]
+        [ "$(sudo stat -c "%A %U %G" /lib/systemd/system/)" = "drwxr-xr-x root root" ]
+        [ "$(sudo stat -c "%A %U %G" /etc/init/brooklyn.conf)" = "-rw-rw-r-- root root" ]
+        [ "$(sudo stat -c "%A %U %G" /lib/systemd/system/brooklyn.service)" = "-rw-rw-r-- root root" ]
+        if hash systemctl ; then
+          [ "$(sudo stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants/brooklyn.service)" = "-rwxr----- root root" ]
+        fi
+        ! sudo ls -d /opt/brooklyn-* | xargs stat -c "%F %a %U %G" | grep -v -E "^directory\s740\sbrooklyn\sbrooklyn$"
+        ! sudo find ${BROOKLYN_DIRECTORIES} -type f | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,4,6][0]\sbrooklyn\sbrooklyn"
+        ! sudo find ${BROOKLYN_DIRECTORIES} -type d | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,1,4][0-1]\sbrooklyn\sbrooklyn"
       assertStatus:
         equals: 0
   - id: test-log-files-exist
     item:
       type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
       name: Check log files created at expected location
-      command: sudo ls /var/log/brooklyn/brooklyn.{debug,info}.log | wc -l
+      command: sudo ls /opt/brooklyn/data/log/brooklyn.{debug,info}.log | wc -l
       assertOut:
         equals: "2"
   - id: test-healthy
@@ -228,8 +228,8 @@ brooklyn.catalog:
   - id: packaging-asserts
     item:
       type: org.apache.brooklyn.test.framework.TestCase
-      targetId: brooklyn
       brooklyn.config:
+        targetId: brooklyn
         timeout: 1m
       brooklyn.children:
       - type: test-is-up
@@ -262,8 +262,12 @@ brooklyn.catalog:
         name: 13. Restart machine
       - type: test-is-not-up
         name: 14. Check not running while restarting
+      - type: test-is-up
+        name: 15. Wait for machine to fully restart
+        brooklyn.config:
+          timeout: 10m
       - type: test-healthy
-        name: 15. Check healthy
+        name: 16. Check healthy
 ### Combined tests with target entity - system specific ###
   - id: test-yum-upstart-brooklyn
     item:


[5/6] brooklyn-dist git commit: Increase -Xmx to 2G

Posted by dr...@apache.org.
Increase -Xmx to 2G


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/939dd79b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/939dd79b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/939dd79b

Branch: refs/heads/master
Commit: 939dd79b6a2d0a77489552d67f27fb6ef41f6543
Parents: 569f6d1
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Wed Sep 13 14:30:04 2017 +0100
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Wed Sep 13 14:30:04 2017 +0100

----------------------------------------------------------------------
 .../src/main/resources/service/systemd/brooklyn.service            | 2 +-
 .../src/main/resources/service/upstart/deb/brooklyn.conf           | 2 +-
 .../src/main/resources/service/upstart/rpm/brooklyn.conf           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/939dd79b/shared-packaging/src/main/resources/service/systemd/brooklyn.service
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/systemd/brooklyn.service b/shared-packaging/src/main/resources/service/systemd/brooklyn.service
index ef861bd..d6510c7 100644
--- a/shared-packaging/src/main/resources/service/systemd/brooklyn.service
+++ b/shared-packaging/src/main/resources/service/systemd/brooklyn.service
@@ -22,7 +22,7 @@ Documentation=https://brooklyn.apache.org/documentation/index.html
 [Service]
 Type=simple
 WorkingDirectory=/opt/brooklyn/
-Environment="EXTRA_JAVA_OPTS=-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+Environment="EXTRA_JAVA_OPTS=-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx2g"
 Environment="KARAF_HOME=/opt/brooklyn"
 Environment="KARAF_ETC=/etc/brooklyn"
 Environment="KARAF_REDIRECT=/dev/null"

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/939dd79b/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf b/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
index c62a98e..6d9f356 100644
--- a/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
+++ b/shared-packaging/src/main/resources/service/upstart/deb/brooklyn.conf
@@ -34,7 +34,7 @@ pre-start script
 end script
 
 script
-    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx2g"
     KARAF_HOME="/opt/brooklyn/"
     KARAF_ETC="/etc/brooklyn/"
     KARAF_REDIRECT=/dev/null

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/939dd79b/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
----------------------------------------------------------------------
diff --git a/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf b/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
index 1af0674..fe1513b 100644
--- a/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
+++ b/shared-packaging/src/main/resources/service/upstart/rpm/brooklyn.conf
@@ -31,7 +31,7 @@ pre-start script
 end script
 
 script
-    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx1g"
+    EXTRA_JAVA_OPTS="-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx2g"
     KARAF_HOME="/opt/brooklyn/"
     KARAF_ETC="/etc/brooklyn/"
     KARAF_REDIRECT=/dev/null