Permalink
Browse files

Bosh packaging for Marketplace Gateway

Change-Id: I050eddfad8a31fb671e3e2715d6c2f1a1d232a02
  • Loading branch information...
1 parent e5fb42f commit 937d72018a1bb23110ac55df47e02a15a4920ca8 Harshawardhan Gadgil committed Sep 18, 2012
@@ -171,10 +171,19 @@ builtin_services:
<% end %>
<% end %>
-<% if properties.service_broker %>
-service_broker:
- token: <%= properties.service_broker.token %>
-<% end %>
+<%
+ service_proxy_tokens = []
+ if properties.service_broker
+ properties.service_broker.token.each { |tok| service_proxy_tokens << tok }
+ end
+
+ if properties.marketplace_gateway
+ properties.marketplace_gateway.tokens.each { |tok| service_proxy_tokens << tok }
+ end
+%>
+
+service_proxy:
+ token: <%= "['#{service_proxy_tokens.join("' , '")}']" %>
<%
if properties.cc.service_extension && properties.cc.service_extension.service_lifecycle
@@ -0,0 +1,5 @@
+check process marketplace_gateway
+ with pidfile /var/vcap/sys/run/marketplace_gateway/marketplace_gateway.pid
+ start program "/var/vcap/jobs/marketplace_gateway/bin/marketplace_gateway_ctl start"
+ stop program "/var/vcap/jobs/marketplace_gateway/bin/marketplace_gateway_ctl stop"
+ group vcap
@@ -0,0 +1,14 @@
+---
+name: marketplace_gateway
+
+templates:
+ marketplace_gateway_ctl: bin/marketplace_gateway_ctl
+ marketplace_gateway.yml.erb: config/marketplace_gateway.yml
+ appdirect.yml.erb: config/appdirect.yml
+ syslog_forwarder.conf.erb: config/syslog_forwarder.conf
+
+packages:
+ - common
+ - marketplace
+ - ruby
+ - syslog_aggregator
@@ -0,0 +1,37 @@
+---
+classname: "VCAP::Services::Marketplace::Appdirect::AppdirectMarketplace"
+
+<%
+ gateway = properties.marketplace_gateway
+ marketplace = gateway.send(gateway.marketplace.to_sym)
+%>
+
+node_timeout: <%= gateway.node_timeout || 10 %>
+
+appdirect:
+ endpoint: <%= marketplace.endpoint %>
+ key: <%= marketplace.key %>
+ secret: <%= marketplace.secret %>
+
+<%
+ if gateway.whitelist
+%>
+offering_whitelist: <%= "['#{gateway.whitelist.join("', '")}']" %>
+<%
+ end
+%>
+
+<%
+ if gateway.service_mappings
+%>
+offering_mapping:
+<%
+ gateway.service_mappings.each { |svc|
+%>
+ <%= svc.service %>:
+ name: <%= svc.name %>
+ provider: <%= svc.provider %>
+<%
+ }
+ end
+%>
@@ -0,0 +1,35 @@
+---
+cloud_controller_uri: <%= properties.cc.srv_api_uri %>
+
+<%
+ props = properties.marketplace_gateway
+ nats = "nats://#{properties.nats.user}:#{properties.nats.password}@#{properties.nats.address}:#{properties.nats.port}"
+ acls = props.acls
+%>
+
+<% if props.ip_route %>
+ip_route: <%= props.ip_route %>
+<% end %>
+
+index: <%= spec.index %>
+token: <%= props.token %>
+mbus: <%= nats %>
+pid: /var/vcap/sys/run/marketplace_gateway/marketplace_gateway.pid
+external_uri: <%= props.external_uri %>
+acls:
+ users: <%= "['#{acls.users.join("', '")}']" if acls && acls.users %>
+ wildcards: <%= "['#{acls.wildcards.join("', '")}']" if acls && acls.wildcards %>
+
+# node_timeout is required by base async gateway class. This is defined in #{marketplace}.yml
+# since this value is specific to interactions with #{marketplace}
+
+marketplace: <%= props.marketplace %>
+
+refresh_interval: <%= props.refresh_interval || 300 %>
+
+logging:
+ file: /var/vcap/sys/log/marketplace_gateway/marketplace_gateway.log
+ level: info
+ <% if properties.syslog_aggregator %>
+ syslog: vcap.marketplace_gateway
+ <% end %>
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+export PATH=/var/vcap/packages/ruby/bin:$PATH
+
+RUN_DIR=/var/vcap/sys/run/marketplace_gateway
+LOG_DIR=/var/vcap/sys/log/marketplace_gateway
+PIDFILE=$RUN_DIR/marketplace_gateway.pid
+JOB_DIR=/var/vcap/jobs/marketplace_gateway
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "Marketplace Gateway"
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+
+ <% if properties.syslog_aggregator %>
+ /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $JOB_DIR/config
+ <% end %>
+
+ echo $$ > $PIDFILE
+
+ exec /var/vcap/packages/marketplace/services/marketplace/bin/marketplace_gateway \
+ -c $JOB_DIR/config/marketplace_gateway.yml \
+ >>$LOG_DIR/marketplace_gateway.stdout.log \
+ 2>>$LOG_DIR/marketplace_gateway.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE
+
+ ;;
+
+ *)
+ echo "Usage: marketplace_gateway_ctl {start|stop}"
+
+ ;;
+
+esac
@@ -0,0 +1,25 @@
+<% if properties.syslog_aggregator %>
+$ModLoad imuxsock # local message reception (rsyslog uses a datagram socket)
+$MaxMessageSize 4k # default is 2k
+$WorkDirectory /var/vcap/sys/rsyslog/buffered # where messages should be buffered on disk
+
+# Forward vcap messages to the aggregator
+#
+$ActionResumeRetryCount -1 # Try until the server becomes available
+$ActionQueueType LinkedList # Allocate on-demand
+$ActionQueueFileName agg_backlog # Spill to disk if queue is full
+$ActionQueueMaxDiskSpace 32m # Max size for disk queue
+$ActionQueueLowWaterMark 2000 # Num messages. Assuming avg size of 512B, this is 1MiB.
+$ActionQueueHighWaterMark 8000 # Num messages. Assuming avg size of 512B, this is 4MiB. (If this is reached, messages will spill to disk until the low watermark is reached).
+$ActionQueueTimeoutEnqueue 0 # Discard messages if the queue + disk is full
+$ActionQueueSaveOnShutdown on # Save in-memory data to disk if rsyslog shuts down
+:programname, startswith, "vcap." @@<%= properties.syslog_aggregator.address %>:<%= properties.syslog_aggregator.port %>
+
+# Log vcap messages locally, too
+#$template VcapComponentLogFile, "/var/log/%programname:6:$%/%programname:6:$%.log"
+#$template VcapComponentLogFormat, "%timegenerated% %syslogseverity-text% -- %msg%\n"
+#:programname, startswith, "vcap." -?VcapComponentLogFile;VcapComponentLogFormat
+
+# Prevent them from reaching anywhere else
+:programname, startswith, "vcap." ~
+<% end %>
@@ -0,0 +1,12 @@
+# abort script on any command that exit with a non zero value
+set -e
+
+cp -a * ${BOSH_INSTALL_TARGET}
+
+(
+ cd ${BOSH_INSTALL_TARGET}/services/marketplace
+
+ bundle_cmd=/var/vcap/packages/ruby/bin/bundle
+ $bundle_cmd config build.do_sqlite3 --with-sqlite3-dir=/var/vcap/packages/sqlite
+ $bundle_cmd install --local --deployment --without=development test
+)
@@ -0,0 +1,5 @@
+# abort script on any command that exit with a non zero value
+set -e
+
+cd ${BUILD_DIR}
+pkg_utils/vendor.sh services/marketplace
@@ -0,0 +1,8 @@
+---
+name: marketplace
+dependencies:
+- ruby
+- sqlite
+files:
+- services/marketplace/**/*
+- pkg_utils/*

0 comments on commit 937d720

Please sign in to comment.