Fix resource.py input args so that validation is performed

This commit is contained in:
Przemyslaw Kaminski 2015-04-21 12:02:08 +02:00
parent a1f3b26a7b
commit f70a3f36f1
7 changed files with 60 additions and 19 deletions

View File

@ -58,12 +58,14 @@ resources:
model: x/resources/keystone/
args:
ip:
image: TEST
ssh_user:
ssh_key:
- name: keystone2
model: x/resources/keystone/
args:
ip:
image: TEST
ssh_user:
ssh_key:
- name: haproxy_keystone_config
@ -95,12 +97,14 @@ resources:
model: x/resources/nova/
args:
ip:
image: TEST
ssh_user:
ssh_key:
- name: nova2
model: x/resources/nova/
args:
ip:
image: TEST
ssh_user:
ssh_key:
- name: haproxy_nova_config
@ -110,13 +114,30 @@ resources:
ssh_user:
ssh_key:
#- name: haproxy-config-container
# model: x/resources/data_container/
# args:
# ip:
# image: haproxy-config
# export_volumes:
# - haproxy-config
#- name: haproxy-config
# model: x/resources/haproxy/
# args:
# ip:
# configs: {}
# ssh_user:
# ssh_key:
- name: haproxy
model: x/resources/haproxy/
model: x/resources/docker_container
args:
ip:
configs: {}
image: haproxy
ssh_user:
ssh_key:
host_binds:
- /etc/haproxy: /vagrant/haproxy-etc
volume_binds:
connections:
@ -154,13 +175,25 @@ connections:
mapping:
ip: servers
# HAProxy config container
#- emitter: node5
# receiver: haproxy-config-container
#- emitter: haproxy-config-container
# receiver: haproxy-config
#- emitter: haproxy_keystone_config
# receiver: haproxy-config
# mapping:
# servers: configs
#- emitter: haproxy_nova_config
# receiver: haproxy-config
# mapping:
# servers: configs
# HAProxy service
- emitter: node5
receiver: haproxy
- emitter: haproxy_keystone_config
receiver: haproxy
mapping:
servers: configs
- emitter: haproxy_nova_config
receiver: haproxy
mapping:
servers: configs
#- emitter: haproxy-config
# receiver: haproxy
# mapping:

View File

@ -55,13 +55,13 @@ class TestHAProxyDeployment(unittest.TestCase):
haproxy = db.get_resource('haproxy')
self.assertEqual(node5.args['ip'], haproxy.args['ip'])
self.assertItemsEqual(
haproxy.args['configs'],
{
'haproxy_keystone_config': haproxy_keystone_config.args['servers'],
'haproxy_nova_config': haproxy_nova_config.args['servers'],
}
)
#self.assertItemsEqual(
# haproxy.args['configs'],
# {
# 'haproxy_keystone_config': haproxy_keystone_config.args['servers'],
# 'haproxy_nova_config': haproxy_nova_config.args['servers'],
# }
#)
def main():

View File

@ -21,6 +21,7 @@ class Resource(object):
self.requires = metadata['input'].keys()
self._validate_args(args)
self.args = args
self.metadata['input'] = args
self.input_types = metadata.get('input-types', {})
self.changed = []
self.tags = tags or []
@ -92,7 +93,6 @@ def create(name, base_path, dest_path, args, connections={}):
meta['id'] = name
meta['version'] = '1.0.0'
meta['actions'] = {}
meta['input'] = args
meta['tags'] = []
if os.path.exists(actions_path):
@ -102,7 +102,7 @@ def create(name, base_path, dest_path, args, connections={}):
resource = Resource(name, meta, args, dest_path)
signals.assign_connections(resource, connections)
#save
# save
shutil.copytree(base_path, dest_path)
resource.save()
db.resource_add(name, resource)

View File

@ -2,5 +2,10 @@ id: container
handler: ansible
version: 1.0.0
input:
ip:
image:
host_binds:
volume_binds:
input-types:
host_binds: list
volume_binds: list

View File

@ -2,6 +2,7 @@ id: haproxy
handler: ansible
version: 1.0.0
input:
ip:
configs:
input-types:
configs: list

View File

@ -2,4 +2,5 @@ id: keystone
handler: ansible
version: 1.0.0
input:
ip:
image: garland/docker-openstack-keystone

View File

@ -2,4 +2,5 @@ id: nova
handler: ansible
version: 1.0.0
input:
ip:
image: # TODO