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
|
||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
|
.idea/*
|
||||||
|
@@ -39,6 +39,9 @@ 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/:
|
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',
|
cfg.IntOpt('occiapi_listen_port',
|
||||||
default=8787,
|
default=8787,
|
||||||
help='the port for external test apps'),
|
help='the port for external test apps'),
|
||||||
|
@@ -28,7 +28,7 @@ sample_app entry point is defined in setup.py:
|
|||||||
|
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[paste.app_factory]
|
[paste.app_factory]
|
||||||
sam#ple_app = api:main
|
sample_app = api:main
|
||||||
""",
|
""",
|
||||||
|
|
||||||
which point to this function call (<module name>:function).
|
which point to this function call (<module name>:function).
|
||||||
|
@@ -36,7 +36,6 @@ from nova import image
|
|||||||
from nova import utils
|
from nova import utils
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
from nova.network import api as net_api
|
from nova.network import api as net_api
|
||||||
from nova.rpc import common as rpc_common
|
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
from nova.openstack.common import importutils
|
||||||
|
|
||||||
from occi import backend
|
from occi import backend
|
||||||
from occi import core_model
|
from occi import core_model
|
||||||
@@ -25,7 +26,6 @@ from nova import compute
|
|||||||
from nova import db
|
from nova import db
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
from nova import utils
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(dizz): Remove SSH Console and VNC Console once URI support is added to
|
# 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):
|
def __init__(self):
|
||||||
super(SecurityGroupBackend, self).__init__()
|
super(SecurityGroupBackend, self).__init__()
|
||||||
self.compute_api = compute.API()
|
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):
|
def init_sec_group(self, category, extras):
|
||||||
"""
|
"""
|
||||||
@@ -141,7 +141,8 @@ class SecurityGroupBackend(backend.UserDefinedMixinBackend):
|
|||||||
group_description = (category.title.strip()
|
group_description = (category.title.strip()
|
||||||
if category.title else group_name)
|
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):
|
if db.security_group_exists(context, context.project_id, group_name):
|
||||||
raise exc.HTTPBadRequest(
|
raise exc.HTTPBadRequest(
|
||||||
explanation=_('Security group %s already exists') % group_name)
|
explanation=_('Security group %s already exists') % group_name)
|
||||||
@@ -187,7 +188,7 @@ class SecurityRuleBackend(backend.KindBackend):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SecurityRuleBackend, self).__init__()
|
super(SecurityRuleBackend, self).__init__()
|
||||||
self.compute_api = compute.API()
|
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):
|
def create(self, entity, extras):
|
||||||
"""
|
"""
|
||||||
@@ -242,7 +243,9 @@ class SecurityRuleBackend(backend.KindBackend):
|
|||||||
cidr = entity.attributes['occi.network.security.range'].strip()
|
cidr = entity.attributes['occi.network.security.range'].strip()
|
||||||
if len(cidr) <= 0:
|
if len(cidr) <= 0:
|
||||||
cidr = '0.0.0.0/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
|
sg_rule['cidr'] = cidr
|
||||||
else:
|
else:
|
||||||
raise exc.HTTPBadRequest()
|
raise exc.HTTPBadRequest()
|
||||||
@@ -314,7 +317,8 @@ class SecurityRuleBackend(backend.KindBackend):
|
|||||||
"""
|
"""
|
||||||
msg = _('Deleting a network security rule')
|
msg = _('Deleting a network security rule')
|
||||||
LOG.info(msg)
|
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:
|
try:
|
||||||
rule = db.security_group_rule_get(extras['nova_ctx'],
|
rule = db.security_group_rule_get(extras['nova_ctx'],
|
||||||
int(entity.attributes['occi.core.id']))
|
int(entity.attributes['occi.core.id']))
|
||||||
@@ -322,7 +326,8 @@ class SecurityRuleBackend(backend.KindBackend):
|
|||||||
raise exc.HTTPNotFound()
|
raise exc.HTTPNotFound()
|
||||||
|
|
||||||
group_id = rule['parent_group_id']
|
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)
|
security_group = db.security_group_get(extras['nova_ctx'], group_id)
|
||||||
|
|
||||||
db.security_group_rule_destroy(extras['nova_ctx'], rule['id'])
|
db.security_group_rule_destroy(extras['nova_ctx'], rule['id'])
|
||||||
|
@@ -255,6 +255,17 @@ class OsComputeActionBackend(backend.ActionBackend):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
exc.HTTPBadRequest(explanation=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:
|
if 'org.openstack.network.floating.pool' not in attributes:
|
||||||
pool = None
|
pool = None
|
||||||
else:
|
else:
|
||||||
@@ -262,13 +273,39 @@ class OsComputeActionBackend(backend.ActionBackend):
|
|||||||
|
|
||||||
address = self.network_api.allocate_floating_ip(context, pool)
|
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
|
# once the address is allocated we need to reflect that fact
|
||||||
# on the resource holding it.
|
# on the resource holding it.
|
||||||
entity.mixins.append(OS_FLOATING_IP_EXT)
|
entity.mixins.append(OS_FLOATING_IP_EXT)
|
||||||
entity.attributes['org.openstack.network.floating.ip'] = address
|
entity.attributes['org.openstack.network.floating.ip'] = address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _os_deallocate_floating_ip(self, entity, context):
|
def _os_deallocate_floating_ip(self, entity, context):
|
||||||
"""
|
"""
|
||||||
This deallocates a floating ip from the compute resource.
|
This deallocates a floating ip from the compute resource.
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
from occi import registry
|
from occi import registry
|
||||||
|
|
||||||
from nova.api.occi.extensions import occi_future
|
from api.extensions import occi_future
|
||||||
|
|
||||||
|
|
||||||
class OCCIRegistry(registry.NonePersistentRegistry):
|
class OCCIRegistry(registry.NonePersistentRegistry):
|
||||||
|
Reference in New Issue
Block a user