Commit bcd98f53 authored by Marco Mariani's avatar Marco Mariani

correctly assign slave instances

parent 4fe6b083
......@@ -123,20 +123,30 @@ class Recipe(object):
isSlave = options.get('slave', '').lower() in \
librecipe.GenericBaseRecipe.TRUE_VALUES
self.instance = instance = request(software_url, software_type,
self.instance = request(software_url, software_type,
name, partition_parameter_kw=partition_parameter_kw,
filter_kw=filter_kw, shared=isSlave)
self._raise_resource_not_ready = None
try:
# XXX what is the right way to get a global id?
options['instance_guid'] = self.instance.getId()
except slapmodule.ResourceNotReady as exc:
self._raise_resource_not_ready = exc
for param in return_parameters:
try:
options['connection-%s' % param] = str(
instance.getConnectionParameter(param))
self.instance.getConnectionParameter(param))
except (slapmodule.NotFoundError, slapmodule.ServerError):
options['connection-%s' % param] = ''
if self.failed is None:
self.failed = param
def install(self):
if self._raise_resource_not_ready:
raise slapmodule.ResourceNotReady(self._resource_not_ready)
if self.failed is not None:
# Check instance status to know if instance has been deployed
try:
......
......@@ -94,7 +94,7 @@ context = key templateapache template-apache-php:output
import-list = file parts template-parts:destination
file replicated template-replicated:destination
md5sum = 03aafcba5c626a4a1bd180d71007be1e
md5sum = d96890f5cde5a6db3a71926002000082
mode = 0644
......
......@@ -121,6 +121,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull
config-frequency = 30 * * * *
slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-2]
<= request-pbs-common
......@@ -134,6 +136,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull
config-frequency = 30 * * * *
slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-backup-1]
......@@ -146,6 +150,8 @@ config-type = push
config-server-key = ${request-apache-backup-1:connection-ssh-public-key}
config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-1:config-notification-id}
slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-backup-2]
<= request-pbs-common
......@@ -157,6 +163,8 @@ config-type = push
config-server-key = ${request-apache-backup-2:connection-ssh-public-key}
config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-2:config-notification-id}
slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[directory]
......
......@@ -51,7 +51,7 @@ mode = 0644
[template-replicated]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/template-replicated.cfg
md5sum = 61780842ccda1600a102456b0da69ac9
md5sum = 140beeb9193e0580e42a6004b9e3821f
mode = 0644
destination = ${buildout:directory}/template-replicated.cfg
......
......@@ -135,6 +135,8 @@ config-notify = ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-pull
config-title = Pulling from {{namebase}}
slave = true
sla = instance_guid
sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
[request-pull-backup-server-{{namebase}}-backup-{{id}}]
<= request-pbs-common
......@@ -149,6 +151,8 @@ config-notify = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-noti
config-notification-id = ${request-{{namebase}}-pseudo-replicating-{{id}}:pbs-notification-id}
config-title = Pushing to {{namebase}} backup {{id}}
slave = true
sla = instance_guid
sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
{% endfor %}
{% endmacro %}
\ No newline at end of file
{% endmacro %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment