summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/nova-manage10
-rw-r--r--nova/api/openstack/__init__.py5
-rw-r--r--nova/db/api.py8
-rw-r--r--nova/db/sqlalchemy/api.py9
4 files changed, 32 insertions, 0 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 7835ca551..b62687aec 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -569,6 +569,15 @@ class DbCommands(object):
print migration.db_version()
+class ZoneCommands(object):
+ """Methods for defining zones."""
+
+ def create(self, name):
+ """Create a new Zone for this deployment."""
+ ctxt = context.get_admin_context()
+ db.create_zone(ctxt, name)
+
+
class VolumeCommands(object):
"""Methods for dealing with a cloud in an odd state"""
@@ -620,6 +629,7 @@ CATEGORIES = [
('service', ServiceCommands),
('log', LogCommands),
('db', DbCommands),
+ ('zone', ZoneCommands),
('volume', VolumeCommands)]
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index c70bb39ed..025fa12a4 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -34,6 +34,7 @@ from nova.api.openstack import flavors
from nova.api.openstack import images
from nova.api.openstack import servers
from nova.api.openstack import shared_ip_groups
+from nova.api.openstack import zones
LOG = logging.getLogger('nova.api.openstack')
@@ -79,6 +80,10 @@ class APIRouter(wsgi.Router):
server_members["actions"] = "GET"
server_members['suspend'] = 'POST'
server_members['resume'] = 'POST'
+
+ mapper.resource("zone", "zones", controller=zones.Controller(),
+ collection={'detail': 'GET'},
+ member=zone_members)
mapper.resource("server", "servers", controller=servers.Controller(),
collection={'detail': 'GET'},
diff --git a/nova/db/api.py b/nova/db/api.py
index 789cb8ebb..dc35f20b2 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -980,3 +980,11 @@ def console_get_all_by_instance(context, instance_id):
def console_get(context, console_id, instance_id=None):
"""Get a specific console (possibly on a given instance)."""
return IMPL.console_get(context, console_id, instance_id)
+
+
+####################
+
+
+def create_zone(context, name):
+ """Create a new Zone entry for this deployment."""
+ return IMPL.create_zone(context, name)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 895e7eabe..ec36c481e 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -1996,3 +1996,12 @@ def console_get(context, console_id, instance_id=None):
raise exception.NotFound(_("No console with id %(console_id)s"
" %(idesc)s") % locals())
return result
+
+
+##################
+
+
+@require_admin_context
+def create_zone(context, zone):
+ session = get_session()
+ print "Creating Zone", zone