Adding initial barbican client and model
Creating a barebones structure for barbican tests. Change-Id: I57966ffd3d250e5bea13648cc0d8164a404473cc
This commit is contained in:
15
cloudcafe/cloudkeep/__init__.py
Normal file
15
cloudcafe/cloudkeep/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
15
cloudcafe/cloudkeep/barbican/__init__.py
Normal file
15
cloudcafe/cloudkeep/barbican/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
36
cloudcafe/cloudkeep/barbican/client.py
Normal file
36
cloudcafe/cloudkeep/barbican/client.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from cafe.engine.clients.rest import AutoMarshallingRestClient
|
||||
from cloudcafe.cloudkeep.barbican.models.version import Version
|
||||
|
||||
|
||||
class VersionClient(AutoMarshallingRestClient):
|
||||
def __init__(self, url, serialize_format=None, deserialize_format=None):
|
||||
"""
|
||||
@param url: Base URL of meniscus api
|
||||
@type url: String
|
||||
"""
|
||||
super(VersionClient, self).__init__(serialize_format,
|
||||
deserialize_format)
|
||||
self.url = url
|
||||
|
||||
def get_version(self):
|
||||
"""
|
||||
@summary: Retrieves the version information from the API
|
||||
"""
|
||||
resp = self.request('GET', self.url, response_entity_type=Version)
|
||||
return resp
|
||||
15
cloudcafe/cloudkeep/barbican/models/__init__.py
Normal file
15
cloudcafe/cloudkeep/barbican/models/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
43
cloudcafe/cloudkeep/barbican/models/version.py
Normal file
43
cloudcafe/cloudkeep/barbican/models/version.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import json
|
||||
from cafe.engine.models.base import AutoMarshallingModel
|
||||
|
||||
|
||||
class Version(AutoMarshallingModel):
|
||||
def __init__(self, version, build):
|
||||
super(Version, self).__init__()
|
||||
self.v1 = version
|
||||
self.build = build
|
||||
|
||||
@classmethod
|
||||
def _json_to_obj(cls, serialized_str):
|
||||
"""Returns an instance of a Version based on the json serialized_str
|
||||
passed in."""
|
||||
result = None
|
||||
json_obj = json.loads(serialized_str)
|
||||
if json_obj is not None:
|
||||
result = cls._dict_to_obj(json_obj)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def _dict_to_obj(cls, json_dict):
|
||||
kwargs = {
|
||||
'version': json_dict.get('v1'),
|
||||
'build': json_dict.get('build')
|
||||
}
|
||||
return Version(**kwargs)
|
||||
41
cloudcafe/cloudkeep/config.py
Normal file
41
cloudcafe/cloudkeep/config.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from cloudcafe.common.models.configuration import ConfigSectionInterface
|
||||
|
||||
|
||||
class MarshallingConfig(ConfigSectionInterface):
|
||||
SECTION_NAME = 'marshalling'
|
||||
|
||||
@property
|
||||
def serializer(self):
|
||||
return self.get("serialize_format")
|
||||
|
||||
@property
|
||||
def deserializer(self):
|
||||
return self.get("deserialize_format")
|
||||
|
||||
|
||||
class CloudKeepConfig(ConfigSectionInterface):
|
||||
SECTION_NAME = 'cloudkeep'
|
||||
|
||||
@property
|
||||
def base_url(self):
|
||||
return self.get("base_url")
|
||||
|
||||
@property
|
||||
def api_version(self):
|
||||
return self.get("api_version")
|
||||
19
configs/cloudkeep/reference.config
Normal file
19
configs/cloudkeep/reference.config
Normal file
@@ -0,0 +1,19 @@
|
||||
# ======================================================
|
||||
# reference.config
|
||||
# ------------------------------------------------------
|
||||
# This configuration is specifically a reference
|
||||
# implementation for a configuration file.
|
||||
# You must create a proper configuration file and supply
|
||||
# the correct values for your Environment(s)
|
||||
#
|
||||
# For multiple environments it is suggested that you
|
||||
# generate specific configurations and name the files
|
||||
# <ENVIRONMENT>.<FORMAT>.config
|
||||
# ======================================================
|
||||
[marshalling]
|
||||
serialize_format=json
|
||||
deserialize_format=json
|
||||
|
||||
[cloudkeep]
|
||||
base_url=http://localhost:8080
|
||||
api_version=v1
|
||||
Reference in New Issue
Block a user