Add OpenStack OS Template
This commit is contained in:
parent
8822994381
commit
3db3cb91a3
21
ooi/openstack/__init__.py
Normal file
21
ooi/openstack/__init__.py
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Spanish National Research Council
|
||||
#
|
||||
# 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 pbr.version
|
||||
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'ooi').version_string()
|
23
ooi/openstack/helpers.py
Normal file
23
ooi/openstack/helpers.py
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Spanish National Research Council
|
||||
#
|
||||
# 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 ooi.occi import helpers
|
||||
|
||||
_PREFIX = "http://schemas.openstack.org/"
|
||||
|
||||
|
||||
def build_scheme(category):
|
||||
return helpers.build_scheme(category, prefix=_PREFIX)
|
28
ooi/openstack/templates.py
Normal file
28
ooi/openstack/templates.py
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Spanish National Research Council
|
||||
#
|
||||
# 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 ooi.occi.core import mixin
|
||||
from ooi.occi.infrastructure import templates
|
||||
from ooi.openstack import helpers
|
||||
|
||||
|
||||
class OpenStackOSTemplate(mixin.Mixin):
|
||||
def __init__(self, uuid, name):
|
||||
super(OpenStackOSTemplate, self).__init__(
|
||||
helpers.build_scheme("template/os"),
|
||||
uuid,
|
||||
name,
|
||||
related=[templates.os_tpl])
|
35
ooi/tests/test_openstack.py
Normal file
35
ooi/tests/test_openstack.py
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Spanish National Research Council
|
||||
#
|
||||
# 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 uuid
|
||||
|
||||
from ooi.occi.infrastructure import templates as occi_templates
|
||||
from ooi.openstack import helpers
|
||||
from ooi.openstack import templates
|
||||
from ooi.tests import base
|
||||
|
||||
|
||||
class TestOpenStackOSTemplate(base.TestCase):
|
||||
def test_os_template(self):
|
||||
id = uuid.uuid4().hex
|
||||
title = "Frobble Image"
|
||||
|
||||
tpl = templates.OpenStackOSTemplate(id,
|
||||
title)
|
||||
self.assertEqual(id, tpl.term)
|
||||
self.assertEqual(title, tpl.title)
|
||||
self.assertTrue(tpl.scheme.startswith(helpers._PREFIX))
|
||||
self.assertIn(occi_templates.os_tpl, tpl.related)
|
Loading…
Reference in New Issue
Block a user