Add naive_sync driver which will copy resource from solar location
This commit is contained in:
parent
742d699386
commit
162c0731e3
7
resources/sources/meta.yaml
Normal file
7
resources/sources/meta.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
id: sources
|
||||
handler: naive_sync
|
||||
version: 1.0.0
|
||||
input:
|
||||
sources:
|
||||
schema: [{'src': 'str!', 'dst': 'str!'}]
|
||||
value: []
|
@ -18,6 +18,7 @@ from solar.core.handlers.ansible_playbook import AnsiblePlaybook
|
||||
from solar.core.handlers.base import Empty
|
||||
from solar.core.handlers.puppet import Puppet, PuppetV2
|
||||
from solar.core.handlers.shell import Shell
|
||||
from solar.core.handlers.naive_sync import NaiveSync
|
||||
|
||||
|
||||
HANDLERS = {'ansible': AnsibleTemplate,
|
||||
@ -25,7 +26,8 @@ HANDLERS = {'ansible': AnsibleTemplate,
|
||||
'shell': Shell,
|
||||
'puppet': Puppet,
|
||||
'none': Empty,
|
||||
'puppetv2': PuppetV2}
|
||||
'puppetv2': PuppetV2,
|
||||
'naive_sync': NaiveSync}
|
||||
|
||||
|
||||
def get(handler_name):
|
||||
|
@ -90,7 +90,7 @@ class Resource(object):
|
||||
'meta_inputs': inputs,
|
||||
'tags': tags,
|
||||
'state': RESOURCE_STATE.created.name,
|
||||
'manager': metadata.get('manager')
|
||||
'manager': metadata.get('manager', '')
|
||||
})
|
||||
self.create_inputs(args)
|
||||
|
||||
@ -292,8 +292,7 @@ class Resource(object):
|
||||
|
||||
manager_path = os.path.join(
|
||||
self.db_obj.base_path, self.db_obj.manager)
|
||||
data = json.dumps(self.args)
|
||||
rst = utils.communicate([manager_path], data)
|
||||
rst = utils.communicate([manager_path], json.dumps(self.args))
|
||||
self.update(json.loads(rst))
|
||||
|
||||
def load(name):
|
||||
|
30
solar/solar/core/handlers/naive_sync.py
Normal file
30
solar/solar/core/handlers/naive_sync.py
Normal file
@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed 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.
|
||||
|
||||
from solar.core.handlers.base import BaseHandler
|
||||
|
||||
|
||||
class NaiveSync(BaseHandler):
|
||||
|
||||
def action(self, resource, action_name):
|
||||
# it is inconsistent with handlers because action_name
|
||||
# is totally useless piece of info here
|
||||
|
||||
args = resource.args
|
||||
# this src seems not intuitive to me, wo context it is impossible
|
||||
# to understand where src comes from
|
||||
for item in args['sources']:
|
||||
self.transport_sync.copy(resource, item['src'], item['dst'])
|
||||
self.transport_sync.sync_all()
|
8
templates/sources.yaml
Normal file
8
templates/sources.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
id: sources
|
||||
resources:
|
||||
- id: sources{{index}}
|
||||
from: resources/sources
|
||||
location: {{node}}
|
||||
values:
|
||||
sources:
|
||||
- {src: /tmp/sources_test, dst: /tmp/sources_test}
|
Loading…
x
Reference in New Issue
Block a user