merge with master
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,3 +25,4 @@ pip-log.txt
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
||||
.idea/*
|
||||
|
@@ -39,12 +39,15 @@ Make sure the API (name from above) is enabled in nova.conf:
|
||||
|
||||
Currently nova compute will start the OCCI API on a random port. If you want to have it on a predefined port you will need to edit the 'flags.py' file in <path to nova>/nova/:
|
||||
|
||||
cfg.ListOpt('enabled_apis',
|
||||
default=['occiapi', 'ec2', 'osapi_compute', 'osapi_volume', 'metadata'],
|
||||
help='a list of APIs to enable by default'),
|
||||
cfg.IntOpt('occiapi_listen_port',
|
||||
default=8787,
|
||||
help='the port for external test apps'),
|
||||
|
||||
Again the name you provide here should be identical to the name of the app you provided above (In this case 'occiapi')!
|
||||
|
||||
|
||||
### For development
|
||||
|
||||
Make sure the nova compute api is in the path for Python and if you wanna test the app run:
|
||||
|
@@ -28,7 +28,7 @@ sample_app entry point is defined in setup.py:
|
||||
|
||||
entry_points="""
|
||||
[paste.app_factory]
|
||||
sam#ple_app = api:main
|
||||
sample_app = api:main
|
||||
""",
|
||||
|
||||
which point to this function call (<module name>:function).
|
||||
|
@@ -36,7 +36,6 @@ from nova import image
|
||||
from nova import utils
|
||||
from nova import log as logging
|
||||
from nova.network import api as net_api
|
||||
from nova.rpc import common as rpc_common
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
@@ -16,6 +16,7 @@
|
||||
# under the License.
|
||||
|
||||
import random
|
||||
from nova.openstack.common import importutils
|
||||
|
||||
from occi import backend
|
||||
from occi import core_model
|
||||
@@ -25,7 +26,6 @@ from nova import compute
|
||||
from nova import db
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import utils
|
||||
|
||||
|
||||
# TODO(dizz): Remove SSH Console and VNC Console once URI support is added to
|
||||
@@ -124,7 +124,7 @@ class SecurityGroupBackend(backend.UserDefinedMixinBackend):
|
||||
def __init__(self):
|
||||
super(SecurityGroupBackend, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.sgh = utils.import_object(FLAGS.security_group_handler)
|
||||
self.sgh = importutils.import_object(FLAGS.security_group_handler)
|
||||
|
||||
def init_sec_group(self, category, extras):
|
||||
"""
|
||||
@@ -141,7 +141,8 @@ class SecurityGroupBackend(backend.UserDefinedMixinBackend):
|
||||
group_description = (category.title.strip()
|
||||
if category.title else group_name)
|
||||
|
||||
self.compute_api.ensure_default_security_group(context)
|
||||
# TODO(dizz): method seems to be gone!
|
||||
#self.compute_api.ensure_default_security_group(context)
|
||||
if db.security_group_exists(context, context.project_id, group_name):
|
||||
raise exc.HTTPBadRequest(
|
||||
explanation=_('Security group %s already exists') % group_name)
|
||||
@@ -187,7 +188,7 @@ class SecurityRuleBackend(backend.KindBackend):
|
||||
def __init__(self):
|
||||
super(SecurityRuleBackend, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.sgh = utils.import_object(FLAGS.security_group_handler)
|
||||
self.sgh = importutils.import_object(FLAGS.security_group_handler)
|
||||
|
||||
def create(self, entity, extras):
|
||||
"""
|
||||
@@ -242,7 +243,9 @@ class SecurityRuleBackend(backend.KindBackend):
|
||||
cidr = entity.attributes['occi.network.security.range'].strip()
|
||||
if len(cidr) <= 0:
|
||||
cidr = '0.0.0.0/0'
|
||||
if utils.is_valid_cidr(cidr):
|
||||
# TODO(dizz): find corresponding call in master!
|
||||
#if utils.is_valid_cidr(cidr):
|
||||
if True:
|
||||
sg_rule['cidr'] = cidr
|
||||
else:
|
||||
raise exc.HTTPBadRequest()
|
||||
@@ -314,7 +317,8 @@ class SecurityRuleBackend(backend.KindBackend):
|
||||
"""
|
||||
msg = _('Deleting a network security rule')
|
||||
LOG.info(msg)
|
||||
self.compute_api.ensure_default_security_group(extras['nova_ctx'])
|
||||
# TODO(dizz): method seems to be gone!
|
||||
# self.compute_api.ensure_default_security_group(extras['nova_ctx'])
|
||||
try:
|
||||
rule = db.security_group_rule_get(extras['nova_ctx'],
|
||||
int(entity.attributes['occi.core.id']))
|
||||
@@ -322,7 +326,8 @@ class SecurityRuleBackend(backend.KindBackend):
|
||||
raise exc.HTTPNotFound()
|
||||
|
||||
group_id = rule['parent_group_id']
|
||||
self.compute_api.ensure_default_security_group(extras['nova_ctx'])
|
||||
# TODO(dizz): method seems to be gone!
|
||||
# self.compute_api.ensure_default_security_group(extras['nova_ctx'])
|
||||
security_group = db.security_group_get(extras['nova_ctx'], group_id)
|
||||
|
||||
db.security_group_rule_destroy(extras['nova_ctx'], rule['id'])
|
||||
|
@@ -255,6 +255,17 @@ class OsComputeActionBackend(backend.ActionBackend):
|
||||
LOG.error(msg)
|
||||
exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
cached_nwinfo = compute.utils.get_nw_info_for_instance\
|
||||
(instance)
|
||||
if not cached_nwinfo:
|
||||
msg = _('No nw_info cache associated with instance')
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
fixed_ips = cached_nwinfo.fixed_ips()
|
||||
if not fixed_ips:
|
||||
msg = _('No fixed ips associated to instance')
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
if 'org.openstack.network.floating.pool' not in attributes:
|
||||
pool = None
|
||||
else:
|
||||
@@ -262,13 +273,39 @@ class OsComputeActionBackend(backend.ActionBackend):
|
||||
|
||||
address = self.network_api.allocate_floating_ip(context, pool)
|
||||
|
||||
self.compute_api.associate_floating_ip(context, instance, address)
|
||||
if len(fixed_ips) > 1:
|
||||
msg = _('multiple fixed_ips exist, using the first: %s')
|
||||
LOG.warning(msg, fixed_ips[0]['address'])
|
||||
|
||||
try:
|
||||
self.network_api.associate_floating_ip(context, instance,
|
||||
floating_address=address,
|
||||
fixed_address=fixed_ips[0]['address'])
|
||||
except exception.FloatingIpAssociated:
|
||||
msg = _('floating ip is already associated')
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
except exception.NoFloatingIpInterface:
|
||||
msg = _('l3driver call to add floating ip failed')
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
except Exception:
|
||||
msg = _('Error. Unable to associate floating ip')
|
||||
LOG.exception(msg)
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
|
||||
# once the address is allocated we need to reflect that fact
|
||||
# on the resource holding it.
|
||||
entity.mixins.append(OS_FLOATING_IP_EXT)
|
||||
entity.attributes['org.openstack.network.floating.ip'] = address
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def _os_deallocate_floating_ip(self, entity, context):
|
||||
"""
|
||||
This deallocates a floating ip from the compute resource.
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
from occi import registry
|
||||
|
||||
from nova.api.occi.extensions import occi_future
|
||||
from api.extensions import occi_future
|
||||
|
||||
|
||||
class OCCIRegistry(registry.NonePersistentRegistry):
|
||||
|
Reference in New Issue
Block a user