From 68e3298d5cefed53c7a92f2733a514ddc30553f1 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Wed, 16 Sep 2015 14:14:30 +0200 Subject: [PATCH] First stage of porting --- examples/riak/riaks.py | 46 ++++++++++++++-------- resources/haproxy_config/meta.yaml | 31 ++++++++------- resources/haproxy_service_config/meta.yaml | 14 ++++--- solar/solar/core/validation.py | 3 ++ 4 files changed, 57 insertions(+), 37 deletions(-) diff --git a/examples/riak/riaks.py b/examples/riak/riaks.py index 30282c9b..53dbb24f 100644 --- a/examples/riak/riaks.py +++ b/examples/riak/riaks.py @@ -144,33 +144,45 @@ def setup_haproxies(): for single_hpsc in hpsc_http: for riak in riaks: - signals.connect(riak, single_hpsc, {'riak_hostname': 'servers', - 'riak_port_http': 'ports'}) + # signals.connect(riak, single_hpsc, {'riak_hostname': 'servers', + # 'riak_port_http': 'ports'}) + signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server', + 'riak_port_http': 'backends:port'}) for single_hpsc in hpsc_pb: for riak in riaks: - signals.connect(riak, single_hpsc, {'riak_hostname': 'servers', - 'riak_port_pb': 'ports'}) + # signals.connect(riak, single_hpsc, {'riak_hostname': 'servers', + # 'riak_port_pb': 'ports'}) + signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server', + 'riak_port_pb': 'backends:port'}) # haproxy config to haproxy service for single_hpc, single_hpsc in zip(hpc, hpsc_http): - signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols', - 'listen_port': 'listen_ports', - 'name': 'configs_names', - 'servers': 'configs', - 'ports': 'configs_ports'}) + # signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols', + # 'listen_port': 'listen_ports', + # 'name': 'configs_names', + # 'servers': 'configs', + # 'ports': 'configs_ports'}) + signals.connect(single_hpsc, single_hpc, {"backends": "config:backends", + "listen_port": "config:listen_port", + "protocol": "config:protocol", + "name": "config:name"}) for single_hpc, single_hpsc in zip(hpc, hpsc_pb): - signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols', - 'listen_port': 'listen_ports', - 'name': 'configs_names', - 'servers': 'configs', - 'ports': 'configs_ports'}) + # signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols', + # 'listen_port': 'listen_ports', + # 'name': 'configs_names', + # 'servers': 'configs', + # 'ports': 'configs_ports'}) + signals.connect(single_hpsc, single_hpc, {"backends": "config:backends", + "listen_port": "config:listen_port", + "protocol": "config:protocol", + "name": "config:name"}) - for single_hps, single_hpc in zip(hps, hpc): - signals.connect(single_hpc, single_hps, {'listen_ports': 'ports'}, - events=False) + # for single_hps, single_hpc in zip(hps, hpc): + # signals.connect(single_hpc, single_hps, {'listen_ports': 'ports'}, + # events=False) # assign haproxy services to each node diff --git a/resources/haproxy_config/meta.yaml b/resources/haproxy_config/meta.yaml index af5858e6..22636166 100644 --- a/resources/haproxy_config/meta.yaml +++ b/resources/haproxy_config/meta.yaml @@ -8,20 +8,23 @@ input: config_dir: schema: {src: str!, dst: str!} value: {src: /etc/solar/haproxy, dst: /etc/haproxy} - listen_ports: - schema: [int] - value: [] - configs: - schema: [[str]] - value: [] - configs_names: - schema: [str] - value: [] - configs_ports: - schema: [[int]] - value: [] - configs_protocols: - schema: [str] + # listen_ports: + # schema: [int] + # value: [] + # configs: + # schema: [[str]] + # value: [] + # configs_names: + # schema: [str] + # value: [] + # configs_ports: + # schema: [[int]] + # value: [] + # configs_protocols: + # schema: [str] + # value: [] + config: + schema: [{backends: [{server: str!, port: int!}], listen_port: int!, protocol: str!, name: str!}] value: [] ssh_user: schema: str! diff --git a/resources/haproxy_service_config/meta.yaml b/resources/haproxy_service_config/meta.yaml index 88c71742..c6dd6890 100644 --- a/resources/haproxy_service_config/meta.yaml +++ b/resources/haproxy_service_config/meta.yaml @@ -5,17 +5,19 @@ input: name: schema: str! value: general_haproxy + backends: + schema: [{server: str!, port: int!}] listen_port: schema: int! value: 9999 protocol: schema: str! value: http - ports: - schema: [int] - value: [] - servers: - schema: [str] - value: [] + # ports: + # schema: [int] + # value: [] + # servers: + # schema: [str] + # value: [] tags: [resources/haproxy, resource/haproxy_general_config] diff --git a/solar/solar/core/validation.py b/solar/solar/core/validation.py index 91f6c565..726ed3a1 100644 --- a/solar/solar/core/validation.py +++ b/solar/solar/core/validation.py @@ -98,6 +98,9 @@ def _construct_jsonschema(schema, definition_base=''): if schema == 'bool!': return {'type': 'boolean'}, {} + print repr(schema) + print locals() + if isinstance(schema, list): items, definitions = _construct_jsonschema(schema[0], definition_base=definition_base)