Add OpenStack OS Template
This commit is contained in:
parent
8822994381
commit
3db3cb91a3
|
@ -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()
|
|
@ -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)
|
|
@ -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])
|
|
@ -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