summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authormdietz <mdietz@openstack>2010-10-05 20:13:50 +0000
committerTarmac <>2010-10-05 20:13:50 +0000
commit90199a2acbf4499c7e218ec0c5c31620cbac0f07 (patch)
treec772cba8b7ecc295c34d3be65e3837ab89ea686a /nova/api
parentf0db8b74ec894631fe29c2a33748b797758ecf50 (diff)
parentc86462d11a6709bf9f2130056bf04712fe3db2d9 (diff)
Cleanup around the rackspace API for the ec2 to internal_id transition
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/cloud.py2
-rw-r--r--nova/api/rackspace/servers.py37
2 files changed, 13 insertions, 26 deletions
diff --git a/nova/api/cloud.py b/nova/api/cloud.py
index 345677d4f..57e94a17a 100644
--- a/nova/api/cloud.py
+++ b/nova/api/cloud.py
@@ -34,7 +34,7 @@ def reboot(instance_id, context=None):
#TODO(gundlach) not actually sure what context is used for by ec2 here
-- I think we can just remove it and use None all the time.
"""
- instance_ref = db.instance_get_by_ec2_id(None, instance_id)
+ instance_ref = db.instance_get_by_internal_id(None, instance_id)
host = instance_ref['host']
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "reboot_instance",
diff --git a/nova/api/rackspace/servers.py b/nova/api/rackspace/servers.py
index 11efd8aef..5cfb7a431 100644
--- a/nova/api/rackspace/servers.py
+++ b/nova/api/rackspace/servers.py
@@ -35,9 +35,6 @@ import nova.image.service
FLAGS = flags.FLAGS
-flags.DEFINE_string('rs_network_manager', 'nova.network.manager.FlatManager',
- 'Networking for rackspace')
-
def _instance_id_translator():
""" Helper method for initializing an id translator for Rackspace instance
ids """
@@ -131,11 +128,8 @@ class Controller(wsgi.Controller):
def show(self, req, id):
""" Returns server details by server id """
- inst_id_trans = _instance_id_translator()
- inst_id = inst_id_trans.from_rs_id(id)
-
user_id = req.environ['nova.context']['user']['id']
- inst = self.db_driver.instance_get_by_ec2_id(None, inst_id)
+ inst = self.db_driver.instance_get_by_internal_id(None, int(id))
if inst:
if inst.user_id == user_id:
return _entity_detail(inst)
@@ -143,11 +137,8 @@ class Controller(wsgi.Controller):
def delete(self, req, id):
""" Destroys a server """
- inst_id_trans = _instance_id_translator()
- inst_id = inst_id_trans.from_rs_id(id)
-
user_id = req.environ['nova.context']['user']['id']
- instance = self.db_driver.instance_get_by_ec2_id(None, inst_id)
+ instance = self.db_driver.instance_get_by_internal_id(None, int(id))
if instance and instance['user_id'] == user_id:
self.db_driver.instance_destroy(None, id)
return faults.Fault(exc.HTTPAccepted())
@@ -160,10 +151,10 @@ class Controller(wsgi.Controller):
if not env:
return faults.Fault(exc.HTTPUnprocessableEntity())
- try:
- inst = self._build_server_instance(req, env)
- except Exception, e:
- return faults.Fault(exc.HTTPUnprocessableEntity())
+ #try:
+ inst = self._build_server_instance(req, env)
+ #except Exception, e:
+ # return faults.Fault(exc.HTTPUnprocessableEntity())
rpc.cast(
FLAGS.compute_topic, {
@@ -173,8 +164,6 @@ class Controller(wsgi.Controller):
def update(self, req, id):
""" Updates the server name or password """
- inst_id_trans = _instance_id_translator()
- inst_id = inst_id_trans.from_rs_id(id)
user_id = req.environ['nova.context']['user']['id']
inst_dict = self._deserialize(req.body, req)
@@ -182,11 +171,11 @@ class Controller(wsgi.Controller):
if not inst_dict:
return faults.Fault(exc.HTTPUnprocessableEntity())
- instance = self.db_driver.instance_get_by_ec2_id(None, inst_id)
+ instance = self.db_driver.instance_get_by_internal_id(None, int(id))
if not instance or instance.user_id != user_id:
return faults.Fault(exc.HTTPNotFound())
- self.db_driver.instance_update(None, id,
+ self.db_driver.instance_update(None, int(id),
_filter_params(inst_dict['server']))
return faults.Fault(exc.HTTPNoContent())
@@ -198,7 +187,7 @@ class Controller(wsgi.Controller):
reboot_type = input_dict['reboot']['type']
except Exception:
raise faults.Fault(webob.exc.HTTPNotImplemented())
- opaque_id = _instance_id_translator().from_rs_id(id)
+ opaque_id = _instance_id_translator().from_rs_id(int(id))
cloud.reboot(opaque_id)
def _build_server_instance(self, req, env):
@@ -206,8 +195,6 @@ class Controller(wsgi.Controller):
ltime = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
inst = {}
- inst_id_trans = _instance_id_translator()
-
user_id = req.environ['nova.context']['user']['id']
flavor_id = env['server']['flavorId']
@@ -258,7 +245,7 @@ class Controller(wsgi.Controller):
inst['local_gb'] = flavor['local_gb']
ref = self.db_driver.instance_create(None, inst)
- inst['id'] = inst_id_trans.to_rs_id(ref.ec2_id)
+ inst['id'] = ref.internal_id
# TODO(dietz): this isn't explicitly necessary, but the networking
# calls depend on an object with a project_id property, and therefore
@@ -270,10 +257,10 @@ class Controller(wsgi.Controller):
#TODO(dietz) is this necessary?
inst['launch_index'] = 0
- inst['hostname'] = ref.ec2_id
+ inst['hostname'] = str(ref.internal_id)
self.db_driver.instance_update(None, inst['id'], inst)
- network_manager = utils.import_object(FLAGS.rs_network_manager)
+ network_manager = utils.import_object(FLAGS.network_manager)
address = network_manager.allocate_fixed_ip(api_context,
inst['id'])