From 2d57c49be362821142936d095ef359712538f1f8 Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Mon, 12 Oct 2015 17:57:34 +0300 Subject: [PATCH 1/2] Add remote file resource which will download keys --- examples/library_ceph/ceph.py | 8 +++++++- resources/ceph_keys/meta.yaml | 3 +++ resources/remote_file/actions/run.sh | 3 +++ resources/remote_file/meta.yaml | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 resources/remote_file/actions/run.sh create mode 100644 resources/remote_file/meta.yaml diff --git a/examples/library_ceph/ceph.py b/examples/library_ceph/ceph.py index b48ade0d..b6a0e579 100644 --- a/examples/library_ceph/ceph.py +++ b/examples/library_ceph/ceph.py @@ -37,12 +37,18 @@ def deploy(): db.clear() resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 1}) first_node = next(x for x in resources if x.name.startswith('node')) - + ssh = next(x for x in resources if x.name.startswith('ssh')) library = vr.create('library1', 'resources/fuel_library', {})[0] first_node.connect(library) keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0] + remote_file = vr.create('ceph_key2', 'resources/remote_file', + {'dest': '/var/lib/astute/'})[0] first_node.connect(keys) + keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'}) + ssh.connect(remote_file, + {'ssh_key': 'remote_key', 'ssh_user': 'remote_user'}) + first_node.connect(remote_file) ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon', {'storage': STORAGE, diff --git a/resources/ceph_keys/meta.yaml b/resources/ceph_keys/meta.yaml index 4a61d4f6..43a2d25a 100644 --- a/resources/ceph_keys/meta.yaml +++ b/resources/ceph_keys/meta.yaml @@ -11,4 +11,7 @@ input: key_name: schema: str! value: ceph + path: + schema: str! + value: /var/lib/astute/ceph/ tags: [] diff --git a/resources/remote_file/actions/run.sh b/resources/remote_file/actions/run.sh new file mode 100644 index 00000000..cb2cb39e --- /dev/null +++ b/resources/remote_file/actions/run.sh @@ -0,0 +1,3 @@ +mkdir -p {{remote_path}} + +scp -i {{remote_key}} -r {{remote_user}}@{{remote_ip}}:/{{remote_path}} {{dest}} diff --git a/resources/remote_file/meta.yaml b/resources/remote_file/meta.yaml new file mode 100644 index 00000000..1b4bed9f --- /dev/null +++ b/resources/remote_file/meta.yaml @@ -0,0 +1,23 @@ +id: remote_file +handler: shell +version: 1.0.0 +input: + ip: + schema: str! + value: + remote_ip: + schema: str! + value: + remote_user: + schema: {} + value: + remote_path: + schema: str! + value: + remote_key: + schema: str! + value: + dest: + schema: str! + value: +tags: [] From 588bfe83f8cc26f0a71d34233f71497e82214207 Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Tue, 13 Oct 2015 11:44:44 +0300 Subject: [PATCH 2/2] Change remote_file to use transports --- examples/library_ceph/ceph.py | 16 +++++++++------- resources/remote_file/actions/run.sh | 11 +++++++++-- resources/remote_file/meta.yaml | 9 +++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/examples/library_ceph/ceph.py b/examples/library_ceph/ceph.py index b6a0e579..2529c335 100644 --- a/examples/library_ceph/ceph.py +++ b/examples/library_ceph/ceph.py @@ -35,20 +35,22 @@ NETWORK_METADATA = yaml.load(""" def deploy(): db.clear() - resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 1}) - first_node = next(x for x in resources if x.name.startswith('node')) - ssh = next(x for x in resources if x.name.startswith('ssh')) + resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2}) + first_node, second_node = [x for x in resources if x.name.startswith('node')] + first_transp = next(x for x in resources if x.name.startswith('transport')) + library = vr.create('library1', 'resources/fuel_library', {})[0] first_node.connect(library) keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0] + first_node.connect(keys) + remote_file = vr.create('ceph_key2', 'resources/remote_file', {'dest': '/var/lib/astute/'})[0] - first_node.connect(keys) + second_node.connect(remote_file) keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'}) - ssh.connect(remote_file, - {'ssh_key': 'remote_key', 'ssh_user': 'remote_user'}) - first_node.connect(remote_file) + first_transp.connect(remote_file, {'transports': 'remote'}) + ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon', {'storage': STORAGE, diff --git a/resources/remote_file/actions/run.sh b/resources/remote_file/actions/run.sh index cb2cb39e..212bdfb4 100644 --- a/resources/remote_file/actions/run.sh +++ b/resources/remote_file/actions/run.sh @@ -1,3 +1,10 @@ -mkdir -p {{remote_path}} +mkdir -p {{dest}} -scp -i {{remote_key}} -r {{remote_user}}@{{remote_ip}}:/{{remote_path}} {{dest}} +{% for transport in remote %} + {% if transport.name == 'ssh' %} +scp -i {{transport.key}} -r {{transport.user}}@{{remote_ip}}:/{{remote_path}} {{dest}} +exit 0 + {% endif %} +{% endfor %} +echo 'No suitable transport.' +exit 2 diff --git a/resources/remote_file/meta.yaml b/resources/remote_file/meta.yaml index 1b4bed9f..6e319bdb 100644 --- a/resources/remote_file/meta.yaml +++ b/resources/remote_file/meta.yaml @@ -5,18 +5,15 @@ input: ip: schema: str! value: + remote: + schema: {} + value: remote_ip: schema: str! value: - remote_user: - schema: {} - value: remote_path: schema: str! value: - remote_key: - schema: str! - value: dest: schema: str! value: