summaryrefslogtreecommitdiffstats
path: root/Testcases/vnc_api/common
diff options
context:
space:
mode:
Diffstat (limited to 'Testcases/vnc_api/common')
-rw-r--r--Testcases/vnc_api/common/__init__.py50
-rw-r--r--Testcases/vnc_api/common/__init__.pycbin0 -> 2573 bytes
-rw-r--r--Testcases/vnc_api/common/exceptions.py133
-rw-r--r--Testcases/vnc_api/common/exceptions.pycbin0 -> 6605 bytes
-rw-r--r--Testcases/vnc_api/common/rest.py41
-rw-r--r--Testcases/vnc_api/common/rest.pycbin0 -> 1373 bytes
6 files changed, 224 insertions, 0 deletions
diff --git a/Testcases/vnc_api/common/__init__.py b/Testcases/vnc_api/common/__init__.py
new file mode 100644
index 0000000..feaf215
--- /dev/null
+++ b/Testcases/vnc_api/common/__init__.py
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
+#
+
+import sys
+import re
+
+IP_FABRIC_VN_FQ_NAME = ['default-domain', 'default-project', 'ip-fabric']
+IP_FABRIC_RI_FQ_NAME = IP_FABRIC_VN_FQ_NAME + ['__default__']
+LINK_LOCAL_VN_FQ_NAME = ['default-domain', 'default-project', '__link_local__']
+LINK_LOCAL_RI_FQ_NAME = LINK_LOCAL_VN_FQ_NAME + ['__link_local__']
+SG_NO_RULE_NAME = "__no_rule__"
+SG_NO_RULE_FQ_NAME = ['default-domain', 'default-project', SG_NO_RULE_NAME]
+
+BGP_RTGT_MIN_ID = 8000000
+SGID_MIN_ALLOC = 8000000
+
+def obj_to_json(obj):
+ return dict((k, v) for k, v in obj.__dict__.iteritems())
+#end obj_to_json
+
+def json_to_obj(obj):
+ pass
+#end json_to_obj
+
+def ignore_exceptions(func):
+ def wrapper(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except Exception as e:
+ return None
+ return wrapper
+# end ignore_exceptions
+
+_illegal_unichrs = [(0x00, 0x08), (0x0B, 0x0C), (0x0E, 0x1F),
+ (0x7F, 0x84), (0x86, 0x9F),
+ (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF)]
+if sys.maxunicode >= 0x10000: # not narrow build
+ _illegal_unichrs.extend([(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF),
+ (0x3FFFE, 0x3FFFF), (0x4FFFE, 0x4FFFF),
+ (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
+ (0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF),
+ (0x9FFFE, 0x9FFFF), (0xAFFFE, 0xAFFFF),
+ (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
+ (0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF),
+ (0xFFFFE, 0xFFFFF), (0x10FFFE, 0x10FFFF)])
+
+_illegal_ranges = ["%s-%s" % (unichr(low), unichr(high))
+ for (low, high) in _illegal_unichrs]
+illegal_xml_chars_RE = re.compile(u'[%s]' % u''.join(_illegal_ranges))
diff --git a/Testcases/vnc_api/common/__init__.pyc b/Testcases/vnc_api/common/__init__.pyc
new file mode 100644
index 0000000..a485c8c
--- /dev/null
+++ b/Testcases/vnc_api/common/__init__.pyc
Binary files differ
diff --git a/Testcases/vnc_api/common/exceptions.py b/Testcases/vnc_api/common/exceptions.py
new file mode 100644
index 0000000..d9723a4
--- /dev/null
+++ b/Testcases/vnc_api/common/exceptions.py
@@ -0,0 +1,133 @@
+#
+# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
+#
+# Base class of all exceptions in VNC
+
+
+class VncError(Exception):
+ pass
+# end class VncError
+
+class ServiceUnavailableError(VncError):
+ def __init__(self, code):
+ self._reason_code = code
+ # end __init__
+
+ def __str__(self):
+ return 'Service unavailable time out due to: %s' % (str(self._reason_code))
+ # end __str__
+# end class ServiceUnavailableError
+
+class TimeOutError(VncError):
+ def __init__(self, code):
+ self._reason_code = code
+ # end __init__
+
+ def __str__(self):
+ return 'Timed out due to: %s' % (str(self._reason_code))
+ # end __str__
+# end class TimeOutError
+
+
+class BadRequest(Exception):
+ def __init__(self, status_code, content):
+ self.status_code = status_code
+ self.content = content
+ # end __init__
+
+ def __str__(self):
+ return 'HTTP Status: %s Content: %s' % (self.status_code, self.content)
+ # end __str__
+# end class BadRequest
+
+
+class NoIdError(VncError):
+
+ def __init__(self, unknown_id):
+ self._unknown_id = unknown_id
+ # end __init__
+
+ def __str__(self):
+ return 'Unknown id: %s' % (self._unknown_id)
+ # end __str__
+# end class NoIdError
+
+
+class MaxRabbitPendingError(VncError):
+
+ def __init__(self, npending):
+ self._npending = npending
+ # end __init__
+
+ def __str__(self):
+ return 'Too many pending updates to RabbitMQ: %s' % (self._npending)
+ # end __str__
+# end class MaxRabbitPendingError
+
+class ResourceExistsError(VncError):
+ def __init__(self, eexists_fq_name, eexists_id):
+ self._eexists_fq_name = eexists_fq_name
+ self._eexists_id = eexists_id
+ # end __init__
+
+ def __str__(self):
+ return 'FQ Name: %s exists already with ID: %s' \
+ % (self._eexists_fq_name, self._eexists_id)
+ # end __str__
+# end class ResourceExistsError
+
+class ResourceTypeUnknownError(VncError):
+ def __init__(self, obj_type):
+ self._unknown_type = obj_type
+ # end __init__
+
+ def __str__(self):
+ return 'Unknown object type: %s' %(self._unknown_type)
+ # end __str__
+# end class ResourceTypeUnknownError
+
+class PermissionDenied(VncError):
+ pass
+# end class PermissionDenied
+
+
+class RefsExistError(VncError):
+ pass
+# end class RefsExistError
+
+
+class ResourceExhaustionError(VncError):
+ pass
+# end class ResourceExhaustionError
+
+
+class NoUserAgentKey(VncError):
+ pass
+# end class NoUserAgentKey
+
+
+class UnknownAuthMethod(VncError):
+ pass
+# end class UnknownAuthMethod
+
+
+class HttpError(VncError):
+
+ def __init__(self, status_code, content):
+ self.status_code = status_code
+ self.content = content
+ # end __init__
+
+ def __str__(self):
+ return 'HTTP Status: %s Content: %s' % (self.status_code, self.content)
+ # end __str__
+# end class HttpError
+
+
+class AmbiguousParentError(VncError):
+ pass
+
+
+class InvalidSessionID(VncError):
+ pass
+# end InvalidSessionID
diff --git a/Testcases/vnc_api/common/exceptions.pyc b/Testcases/vnc_api/common/exceptions.pyc
new file mode 100644
index 0000000..972c8fb
--- /dev/null
+++ b/Testcases/vnc_api/common/exceptions.pyc
Binary files differ
diff --git a/Testcases/vnc_api/common/rest.py b/Testcases/vnc_api/common/rest.py
new file mode 100644
index 0000000..7287f8d
--- /dev/null
+++ b/Testcases/vnc_api/common/rest.py
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
+#
+OP_POST = 1
+OP_GET = 2
+OP_PUT = 3
+OP_DELETE = 4
+
+
+def hdr_client_tenant():
+ return 'X-Tenant-Name'
+# end hdr_tenant_client
+
+# TODO transform from client value
+
+
+def hdr_server_tenant():
+ return 'HTTP_X_TENANT_NAME'
+# end hdr_tenant_server
+
+
+class LinkObject(object):
+
+ def __init__(self, rel, base_url, uri, name):
+ self.rel = rel
+ self.base_url = base_url
+ self.uri = uri
+ self.name = name
+ # end __init__
+
+ def to_dict(self, with_url=None):
+ if not with_url:
+ url = self.base_url
+ else:
+ url = with_url
+ return {'rel': self.rel,
+ 'href': url + self.uri,
+ 'name': self.name}
+ # end to_dict
+
+# end class LinkObject
diff --git a/Testcases/vnc_api/common/rest.pyc b/Testcases/vnc_api/common/rest.pyc
new file mode 100644
index 0000000..ed5532d
--- /dev/null
+++ b/Testcases/vnc_api/common/rest.pyc
Binary files differ