summaryrefslogtreecommitdiff
path: root/src/leap/base/providers.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-23 23:27:13 +0900
committerkali <kali@leap.se>2012-08-23 23:27:13 +0900
commit48dc15ac80cbba0123c6b14ad3afc6eddabf410a (patch)
tree7654f85b65ceed8728bef16e7aff220a7c7391a7 /src/leap/base/providers.py
parent7e6ab299a8017e1ff3a63d577541ea4e6c462b44 (diff)
basic provider-definition and provider spec classes
tests green for load/dump operations on config. defaults on config spec for LeapServiceProvider should be outputting a minimal working config for bootstrapping the connection. we should be using this config mechanism for other config operations; but probably we should specify a local_editable flag for those configs that are only changed by server.
Diffstat (limited to 'src/leap/base/providers.py')
-rw-r--r--src/leap/base/providers.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/leap/base/providers.py b/src/leap/base/providers.py
new file mode 100644
index 00000000..6fc050a0
--- /dev/null
+++ b/src/leap/base/providers.py
@@ -0,0 +1,91 @@
+import configuration
+
+from leap.base.config import JSONLeapConfig
+
+##########################################################
+# hacking in progress:
+
+# Specs are instances of configuration.Configuration class
+# and have to carry an options attr.
+#
+# Configs have:
+# - slug
+# - definition
+
+# TODO:
+# - have a good type cast repertory
+# - raise validation errors?
+##########################################################
+
+
+class LeapProviderSpec(configuration.Configuration):
+ options = {
+ 'serial': {
+ 'type': int,
+ 'default': 1,
+ 'required': True,
+ },
+ 'version': {
+ 'type': unicode,
+ 'default': '0.1.0'
+ #'required': True
+ },
+ 'domain': {
+ 'type': unicode, # XXX define uri type
+ 'default': 'testprovider.example.org'
+ #'required': True,
+ },
+ 'display_name': {
+ 'type': unicode, # XXX multilingual object?
+ 'default': 'test provider'
+ #'required': True
+ },
+ 'description': {
+ 'default': 'test provider'
+ },
+ 'enrollment_policy': {
+ 'type': unicode, # oneof ??
+ 'default': 'open'
+ },
+ 'services': {
+ 'type': list, # oneof ??
+ 'default': ['eip']
+ },
+ 'api_version': {
+ 'type': unicode,
+ 'default': '0.1.0' # version regexp
+ },
+ 'api_uri': {
+ 'type': unicode # uri
+ },
+ 'public_key': {
+ 'type': unicode # fingerprint
+ },
+ 'ca_cert': {
+ 'type': unicode
+ },
+ 'ca_cert_uri': {
+ 'type': unicode
+ },
+ }
+
+
+class LeapProviderDefinition(JSONLeapConfig):
+ slug = 'definition.json'
+ spec = LeapProviderSpec
+
+
+class LeapProvider(object):
+ # XXX ???
+ # do we need this?
+ # can we hook here the network fetching stuff?
+ # maybe (bstorming a little bit):
+
+ # config = LeapProviderDefinition
+ # fetcher = foo.FetcherClass
+ pass
+
+
+class LeapProviderSet(object):
+ def __init__(self):
+ self.count = 0