refactored
This commit is contained in:
@@ -28,7 +28,7 @@ sample_app entry point is defined in setup.py:
|
||||
|
||||
entry_points='''
|
||||
[paste.app_factory]
|
||||
sample_app = api:main
|
||||
sample_app = occi_os_api:main
|
||||
''',
|
||||
|
||||
which point to this function call (<module name>:function).
|
||||
@@ -37,7 +37,7 @@ which point to this function call (<module name>:function).
|
||||
# W0613:unused args
|
||||
# pylint: disable=W0613
|
||||
|
||||
from api import wsgi
|
||||
from occi_os_api import wsgi
|
||||
|
||||
|
||||
#noinspection PyUnusedLocal
|
||||
@@ -24,10 +24,9 @@ The compute resource backend for OpenStack.
|
||||
|
||||
import logging
|
||||
|
||||
from api.extensions import templates
|
||||
from occi_os_api.extensions import templates
|
||||
|
||||
from nova_glue import vm
|
||||
from nova_glue import storage
|
||||
from occi_os_api.nova_glue import vm, storage
|
||||
|
||||
from occi.backend import KindBackend, ActionBackend
|
||||
from occi.extensions import infrastructure
|
||||
@@ -30,7 +30,7 @@ Network resource backend.
|
||||
# implement actions
|
||||
# implement updates
|
||||
|
||||
# Also see nova/api/openstack/compute/contrib/networks.py
|
||||
# Also see nova/occi_os_api/openstack/compute/contrib/networks.py
|
||||
|
||||
from occi import backend
|
||||
|
||||
@@ -86,7 +86,6 @@ class NetworkInterfaceBackend(backend.KindBackend):
|
||||
"""
|
||||
As nova does not support creation of L2 networks we don't.
|
||||
"""
|
||||
# implement with Quantum
|
||||
# TODO: add floating ip support
|
||||
raise AttributeError('Currenlty not supported.')
|
||||
|
||||
@@ -94,12 +93,4 @@ class NetworkInterfaceBackend(backend.KindBackend):
|
||||
"""
|
||||
Allows for the update of network links.
|
||||
"""
|
||||
#L8R: here we associate a security group
|
||||
#L8R: here we could possibly assign a static (floating) ip - request
|
||||
# must include a ipnetworkinterface mixin
|
||||
# make sure the link has an IP mixin
|
||||
# get a reference to the compute instance
|
||||
# get the security group
|
||||
# associate the security group with the compute instance
|
||||
|
||||
raise AttributeError('Currently not supported.')
|
||||
@@ -25,9 +25,10 @@ import random
|
||||
from occi import backend
|
||||
from occi import exceptions
|
||||
|
||||
from api.extensions import os_addon
|
||||
from occi_os_api.extensions import os_addon
|
||||
|
||||
from nova_glue import vm, security
|
||||
from occi_os_api.nova_glue import vm
|
||||
from occi_os_api.nova_glue import security
|
||||
|
||||
class OsComputeActionBackend(backend.ActionBackend):
|
||||
"""
|
||||
@@ -26,7 +26,7 @@ import uuid
|
||||
from occi import backend
|
||||
from occi import exceptions
|
||||
from occi.extensions import infrastructure
|
||||
from nova_glue import storage, vm
|
||||
from occi_os_api.nova_glue import storage, vm
|
||||
|
||||
|
||||
class StorageBackend(backend.KindBackend, backend.ActionBackend):
|
||||
@@ -224,6 +224,15 @@ class StorageLinkBackend(backend.KindBackend):
|
||||
link.attributes['occi.storagelink.mountpoint'] = ''
|
||||
link.attributes['occi.storagelink.state'] = 'active'
|
||||
|
||||
def retrieve(self, entity, extras):
|
||||
"""
|
||||
Get most up to date attribute informations.
|
||||
"""
|
||||
# occi.storagelink.deviceid
|
||||
# occi.storagelink.mountpoint
|
||||
# occi.storagelink.state
|
||||
pass
|
||||
|
||||
def delete(self, link, extras):
|
||||
"""
|
||||
Unlinks the the compute from the storage resource.
|
||||
@@ -25,14 +25,14 @@ from nova import network
|
||||
from nova import exception
|
||||
from nova import compute
|
||||
from nova.compute import utils
|
||||
from nova_glue import vm
|
||||
from occi_os_api.nova_glue import vm
|
||||
|
||||
# Connect to nova :-)
|
||||
|
||||
NETWORK_API = network.API()
|
||||
COMPUTE_API = compute.API()
|
||||
|
||||
LOG = logging.getLogger('nova.api.wsgi.occi.nova_glue.net')
|
||||
LOG = logging.getLogger('nova.occi_os_api.wsgi.occi.nova_glue.net')
|
||||
|
||||
|
||||
def get_adapter_info(uid, context):
|
||||
@@ -46,11 +46,23 @@ def get_adapter_info(uid, context):
|
||||
|
||||
result = {'public':[], 'admin':[]}
|
||||
net_info = NETWORK_API.get_instance_nw_info(context, vm_instance)[0]
|
||||
gw = net_info['network']['subnets'][0]['gateway']['address']
|
||||
mac = net_info['address']
|
||||
|
||||
tmp = net_info['network']['subnets'][0]['ips'][0]
|
||||
for item in tmp['floating_ips']:
|
||||
result['public'].append({'ip': item['address']})
|
||||
result['admin'].append({'ip': tmp['address']})
|
||||
result['public'].append({'interface':'eth0',
|
||||
'mac':'aa:bb:cc:dd:ee:ff',
|
||||
'state': 'active',
|
||||
'address': item['address'],
|
||||
'gateway': '0.0.0.0',
|
||||
'allocation': 'static'})
|
||||
result['admin'].append({'interface':'eth0',
|
||||
'mac': mac,
|
||||
'state': 'active',
|
||||
'address': tmp['address'],
|
||||
'gateway': gw,
|
||||
'allocation': 'static'})
|
||||
|
||||
return result
|
||||
|
||||
@@ -28,7 +28,7 @@ from nova.image import glance
|
||||
from occi import exceptions
|
||||
|
||||
# Connection to the nova APIs
|
||||
from nova_glue import vm
|
||||
from occi_os_api.nova_glue import vm
|
||||
|
||||
VOLUME_API = volume.API()
|
||||
|
||||
@@ -33,8 +33,8 @@ from nova.flags import FLAGS
|
||||
from occi import exceptions
|
||||
from occi.extensions import infrastructure
|
||||
|
||||
from api.extensions import templates
|
||||
from api.extensions import os_addon
|
||||
from occi_os_api.extensions import templates
|
||||
from occi_os_api.extensions import os_addon
|
||||
|
||||
import logging
|
||||
|
||||
@@ -23,15 +23,12 @@ OCCI registry
|
||||
#R0201:method could be func.E1002:old style obj
|
||||
#pylint: disable=R0201,E1002
|
||||
import uuid
|
||||
from nova import flags
|
||||
from nova.compute import utils
|
||||
from nova.openstack import common
|
||||
|
||||
from occi import registry as occi_registry, exceptions
|
||||
from occi import registry as occi_registry
|
||||
from occi import core_model
|
||||
from occi.extensions import infrastructure
|
||||
|
||||
from nova_glue import vm, storage, net
|
||||
from occi_os_api.nova_glue import vm, storage, net
|
||||
|
||||
class OCCIRegistry(occi_registry.NonePersistentRegistry):
|
||||
"""
|
||||
@@ -234,12 +231,13 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
|
||||
|
||||
# 3. network links & get links from cache!
|
||||
net_links = net.get_adapter_info(identifier, context)
|
||||
print net_links
|
||||
for item in net_links['public']:
|
||||
link = self._construct_network_link(entity, self.pub_net, extras)
|
||||
link = self._construct_network_link(item, entity, self.pub_net,
|
||||
extras)
|
||||
result.append(link)
|
||||
for item in net_links['admin']:
|
||||
link = self._construct_network_link(entity, self.adm_net, extras)
|
||||
link = self._construct_network_link(item, entity, self.adm_net,
|
||||
extras)
|
||||
result.append(link)
|
||||
|
||||
# core.id and cache it!
|
||||
@@ -316,7 +314,7 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
|
||||
self.cache[(self.adm_net.identifier, None)] = self.adm_net
|
||||
self.cache[(self.pub_net.identifier, None)] = self.pub_net
|
||||
|
||||
def _construct_network_link(self, source, target, extras):
|
||||
def _construct_network_link(self, net_desc, source, target, extras):
|
||||
"""
|
||||
Construct a network link and add to cache!
|
||||
"""
|
||||
@@ -324,6 +322,14 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
|
||||
str(uuid.uuid4()),
|
||||
infrastructure.NETWORKINTERFACE,
|
||||
[infrastructure.IPNETWORKINTERFACE], source, target)
|
||||
link.attributes = {
|
||||
'occi.networkinterface.interface': net_desc['interface'],
|
||||
'occi.networkinterface.mac': net_desc['mac'],
|
||||
'occi.networkinterface.state': net_desc['state'],
|
||||
'occi.networkinterface.address': net_desc['address'],
|
||||
'occi.networkinterface.gateway': net_desc['gateway'],
|
||||
'occi.networkinterface.allocation': net_desc['allocation']
|
||||
}
|
||||
link.extras = self.get_extras(extras)
|
||||
source.links.append(link)
|
||||
self.cache[(link.identifier, extras['nova_ctx'].user_id)] = link
|
||||
@@ -34,12 +34,12 @@ from nova.compute import instance_types
|
||||
from nova.network import api
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
from api import registry
|
||||
from api.backends import compute
|
||||
from api.backends import network
|
||||
from api.backends import storage
|
||||
from api.extensions import templates
|
||||
from api.extensions import os_addon
|
||||
from occi_os_api import registry
|
||||
from occi_os_api.backends import compute
|
||||
from occi_os_api.backends import network
|
||||
from occi_os_api.backends import storage
|
||||
from occi_os_api.extensions import templates
|
||||
from occi_os_api.extensions import os_addon
|
||||
|
||||
from occi import backend
|
||||
from occi import core_model
|
||||
6
setup.py
6
setup.py
@@ -45,14 +45,14 @@ setup(
|
||||
url='http://intel.com',
|
||||
license='Apache License, Version 2.0',
|
||||
include_package_data=True,
|
||||
packages=['api','api.compute','api.network','api.storage',
|
||||
'api.extensions', 'nova_glue'],
|
||||
packages=['occi_os_api','occi_os_api.backends','occi_os_api.extensions',
|
||||
'occi_os_api.nova_glue'],
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
'setuptools',
|
||||
],
|
||||
entry_points='''
|
||||
[paste.app_factory]
|
||||
occi_app = api:main
|
||||
occi_app = occi_os_api:main
|
||||
''',
|
||||
)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# 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.
|
||||
"""
|
||||
Will test the registry..
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class RegistryTest(unittest.TestCase):
|
||||
"""
|
||||
Do a simple set of test.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Prepare the test.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Will test the OS api against a local running instance.
|
||||
Will test the OS occi_os_api against a local running instance.
|
||||
"""
|
||||
|
||||
#pylint: disable=W0102,C0103,R0904
|
||||
|
||||
Reference in New Issue
Block a user