location_id introduced, transports resources added
This commit is contained in:
parent
6c10e08980
commit
c6df20ad7b
@ -6,12 +6,12 @@ input:
|
||||
ip:
|
||||
schema: str!
|
||||
value:
|
||||
ssh_key:
|
||||
schema: str!
|
||||
value:
|
||||
ssh_user:
|
||||
schema: str!
|
||||
value:
|
||||
# ssh_key:
|
||||
# schema: str!
|
||||
# value:
|
||||
# ssh_user:
|
||||
# schema: str!
|
||||
# value:
|
||||
name:
|
||||
schema: str
|
||||
value:
|
||||
|
14
resources/transport_ssh/meta.yaml
Normal file
14
resources/transport_ssh/meta.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
id: transport_ssh
|
||||
input:
|
||||
ssh_key:
|
||||
schema: str!
|
||||
value:
|
||||
ssh_user:
|
||||
schema: str!
|
||||
value:
|
||||
ssh_port:
|
||||
schema: int!
|
||||
value: 22
|
||||
name:
|
||||
schema: str!
|
||||
value: ssh
|
5
resources/transports/meta.yaml
Normal file
5
resources/transports/meta.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
id: transports
|
||||
input:
|
||||
transports:
|
||||
schema: [{user: str, password: str, port: int!, key: str, name: str!}]
|
||||
value: []
|
@ -18,9 +18,14 @@ from multipledispatch import dispatch
|
||||
import os
|
||||
|
||||
from solar import utils
|
||||
|
||||
from solar.core import validation
|
||||
from solar.interfaces import orm
|
||||
|
||||
from uuid import uuid4
|
||||
from hashlib import md5
|
||||
|
||||
|
||||
|
||||
def read_meta(base_path):
|
||||
base_meta_file = os.path.join(base_path, 'meta.yaml')
|
||||
@ -51,6 +56,10 @@ class Resource(object):
|
||||
self.tags = tags or []
|
||||
self.virtual_resource = virtual_resource
|
||||
|
||||
inputs = metadata.get('input', {})
|
||||
|
||||
self.auto_extend_inputs(inputs)
|
||||
|
||||
self.db_obj = orm.DBResource(**{
|
||||
'id': name,
|
||||
'name': name,
|
||||
@ -60,8 +69,10 @@ class Resource(object):
|
||||
'handler': metadata.get('handler', ''),
|
||||
'puppet_module': metadata.get('puppet_module', ''),
|
||||
'version': metadata.get('version', ''),
|
||||
'meta_inputs': metadata.get('input', {})
|
||||
'meta_inputs': inputs
|
||||
|
||||
})
|
||||
|
||||
self.db_obj.save()
|
||||
|
||||
self.create_inputs(args)
|
||||
@ -75,6 +86,10 @@ class Resource(object):
|
||||
self.tags = []
|
||||
self.virtual_resource = None
|
||||
|
||||
def auto_extend_inputs(self, inputs):
|
||||
inputs.setdefault('location_id', {'value': md5(self.name + uuid4().hex).hexdigest(),
|
||||
'schema': 'str!'})
|
||||
|
||||
@property
|
||||
def actions(self):
|
||||
ret = {
|
||||
|
@ -46,10 +46,18 @@ def guess_mapping(emitter, receiver):
|
||||
|
||||
return guessed
|
||||
|
||||
def extend_mapping_by_defaults(mapping):
|
||||
if isinstance(mapping, set):
|
||||
mapping.add('location_id')
|
||||
else:
|
||||
mapping['location_id'] = 'location_id'
|
||||
|
||||
def connect(emitter, receiver, mapping=None, events=None):
|
||||
mapping = mapping or guess_mapping(emitter, receiver)
|
||||
|
||||
extend_mapping_by_defaults(mapping)
|
||||
|
||||
|
||||
if isinstance(mapping, set):
|
||||
mapping = {src: src for src in mapping}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user