Fixing up the instance creation issues

* update gitignore with log file from tests
* update the tenant id on the client
* change database to instance module
* added some logging in the api calls
* configuration of nova client values
This commit is contained in:
Craig Vyvial 2012-03-16 01:19:00 -05:00
parent 6a8fc860bf
commit 380b710665
12 changed files with 68 additions and 23 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ reddwarf/vcsversion.py
.coverage
covhtml/
.DS_Store
host-syslog.log

View File

@ -37,10 +37,6 @@ REDDWARF_TENANT=reddwarf
echo $REDDWARF_TENANT
REDDWARF_USER=$(mysql keystone -e "select id from user where name='reddwarf';" | awk 'NR==2')
echo $REDDWARF_USER
REDDWARF_ROLE=$(mysql keystone -e "select id from role where name='reddwarf';" | awk 'NR==2')
echo $REDDWARF_ROLE
# These all need to be set tenant did not work with the id but the name did match in the auth shim.
REDDWARF_TOKEN=$(curl -d '{"auth":{"passwordCredentials":{"username": "reddwarf", "password": "REDDWARF-PASS"},"tenantName":"reddwarf"}}' -H "Content-type: application/json" http://localhost:35357/v2.0/tokens | python -mjson.tool | grep id | tr -s ' ' | cut -d ' ' -f 3 | sed s/\"/''/g | awk 'NR==2' | cut -d ',' -f 1)
echo $REDDWARF_TOKEN

View File

@ -0,0 +1,33 @@
#!/bin/bash
function reddwarf_auth {
REDDWARF_TENANT=`keystone --endpoint http://localhost:35357/v2.0 --token be19c524ddc92109a224 tenant-list| grep reddwarf | cut -d ' ' -f 2`
REDDWARF_USER=`keystone --endpoint http://localhost:35357/v2.0 --token be19c524ddc92109a224 user-list| grep reddwarf | cut -d ' ' -f 2`
REDDWARF_TOKEN=$(curl -d '{"auth":{"passwordCredentials":{"username": "reddwarf", "password": "REDDWARF-PASS"},"tenantName":"reddwarf"}}' -H "Content-type: application/json" http://localhost:35357/v2.0/tokens | python -mjson.tool | grep id | tr -s ' ' | cut -d ' ' -f 3 | sed s/\"/''/g | awk 'NR==2' | cut -d ',' -f 1)
export REDDWARF_TENANT
export REDDWARF_USER
export REDDWARF_TOKEN
echo "REDDWARF_TENANT = $REDDWARF_TENANT"
echo "REDDWARF_USER = $REDDWARF_USER"
echo "REDDWARF_TOKEN = $REDDWARF_TOKEN"
}
function create_instance {
FLAVOR_ID=$1
curl -H"Content-type:application/json" -H"X-Auth-Token:$REDDWARF_TOKEN" http://0.0.0.0:8779/v0.1/$REDDWARF_TENANT/instances -d '{"instance": {"databases": [{"character_set": "utf8", "collate": "utf8_general_ci", "name": "sampledb"}, {"name": "nextround"}], "flavorRef": "http://0.0.0.0:8779/v0.1/$REDDWARF_TENANT/flavors/1", "name": "json_rack_instance"}}' | python -mjson.tool
}
function list_instances {
curl -H"X-Auth-Token:$REDDWARF_TOKEN" http://0.0.0.0:8779/v0.1/$REDDWARF_TENANT/instances | python -mjson.tool
}
function delete_instance {
INSTANCE_ID=$1
curl -H"X-Auth-Token:$REDDWARF_TOKEN" -H"ACCEPT:application/json" http://0.0.0.0:8779/v0.1/$REDDWARF_TENANT/instances/$INSTANCE_ID -X DELETE | python -mjson.tool
}
function show_instance {
INSTANCE_ID=$1
curl -H"X-Auth-Token:$REDDWARF_TOKEN" -H"ACCEPT:application/json" http://0.0.0.0:8779/v0.1/$REDDWARF_TENANT/instances/$INSTANCE_ID | python -mjson.tool
}

View File

@ -45,6 +45,10 @@ reddwarf_proxy_admin_pass = 3de4922d8b6ac5a1aad9
reddwarf_proxy_admin_tenant_name = admin
reddwarf_auth_url = http://0.0.0.0:5000/v2.0
nova_region_name = RegionOne
nova_service_type = compute
nova_service_name = Compute Service
# ============ notifer queue kombu connection options ========================
notifier_queue_hostname = localhost
@ -85,7 +89,7 @@ admin_token = be19c524ddc92109a224
paste.filter_factory = reddwarf.common.auth:AuthorizationMiddleware.factory
[app:reddwarfapp]
paste.app_factory = reddwarf.database.service:app_factory
paste.app_factory = reddwarf.instance.service:app_factory
#Add this filter to log request and response for debugging
[filter:debug]

View File

@ -21,7 +21,7 @@ from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy.orm import sessionmaker
from reddwarf import database
from reddwarf import instance
from reddwarf.common import config
from reddwarf.db.sqlalchemy import mappers
@ -40,7 +40,7 @@ def configure_db(options, models_mapper=None):
if models_mapper:
models_mapper.map(_ENGINE)
else:
mappers.map(_ENGINE, database.models.persisted_models())
mappers.map(_ENGINE, instance.models.persisted_models())
def configure_sqlalchemy_log(options):

View File

@ -87,14 +87,18 @@ class RemoteModelBase(ModelBase):
'admin')
PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
'http://0.0.0.0:5000/v2.0')
REGION_NAME = CONFIG.get('nova_region_name', 'RegionOne')
SERVICE_TYPE = CONFIG.get('nova_service_type', 'compute')
SERVICE_NAME = CONFIG.get('nova_service_name', 'Compute Service')
#TODO(cp16net) need to fix this proxy_tenant_id
client = Client(PROXY_ADMIN_USER, PROXY_ADMIN_PASS,
PROXY_ADMIN_TENANT_NAME, PROXY_AUTH_URL,
proxy_tenant_id=context.tenant,
proxy_tenant_id='reddwarf',
proxy_token=context.auth_tok,
region_name='RegionOne',
service_type='compute',
service_name="'Compute Service'")
region_name=REGION_NAME,
service_type=SERVICE_TYPE,
service_name=SERVICE_NAME)
client.authenticate()
return client

View File

@ -19,14 +19,12 @@ import logging
import routes
import webob.exc
from reddwarf import rpc
from reddwarf.common import config
from reddwarf.common import context as rd_context
from reddwarf.common import exception
from reddwarf.common import utils
from reddwarf.common import wsgi
from reddwarf.database import models
from reddwarf.database import views
from reddwarf.instance import models, views
CONFIG = config.Config
LOG = logging.getLogger(__name__)
@ -63,8 +61,16 @@ class BaseController(wsgi.Controller):
class InstanceController(BaseController):
"""Controller for instance functionality"""
def detail(self, req, tenant_id):
"""Return all instances."""
LOG.info("req : '%s'\n\n" % req)
LOG.info("Creating a database instance for tenant '%s'" % tenant_id)
return self.index(req, tenant_id)
def index(self, req, tenant_id):
"""Return all instances."""
LOG.info("req : '%s'\n\n" % req)
LOG.info("Creating a database instance for tenant '%s'" % tenant_id)
# TODO(hub-cap): turn this into middleware
context = rd_context.ReddwarfContext(
auth_tok=req.headers["X-Auth-Token"],
@ -75,6 +81,9 @@ class InstanceController(BaseController):
def show(self, req, tenant_id, id):
"""Return a single instance."""
LOG.info("req : '%s'\n\n" % req)
LOG.info("Creating a database instance for tenant '%s'" % tenant_id)
LOG.info("id : '%s'\n\n" % id)
# TODO(hub-cap): turn this into middleware
context = rd_context.ReddwarfContext(
auth_tok=req.headers["X-Auth-Token"],
@ -91,6 +100,9 @@ class InstanceController(BaseController):
def delete(self, req, tenant_id, id):
"""Delete a single instance."""
LOG.info("req : '%s'\n\n" % req)
LOG.info("Creating a database instance for tenant '%s'" % tenant_id)
LOG.info("id : '%s'\n\n" % id)
# TODO(hub-cap): turn this into middleware
context = rd_context.ReddwarfContext(
auth_tok=req.headers["X-Auth-Token"],
@ -126,6 +138,7 @@ class InstanceController(BaseController):
image_id,
body).data()
# Now wait for the response from the create to do additional work
#TODO(cp16net): need to set the return code correctly
return wsgi.Result(views.InstanceView(server).data(), 201)

View File

@ -19,7 +19,7 @@ import factory
from reddwarf.common import context
from reddwarf.common import utils
from reddwarf.database import models
from reddwarf.instance import models
class Instance(factory.Factory):

View File

@ -18,11 +18,8 @@ import mox
import novaclient
from reddwarf import tests
from reddwarf.common import exception
from reddwarf.common import utils
from reddwarf.database import models
from reddwarf.db import db_query
from reddwarf.tests import unit
from reddwarf.instance import models
from reddwarf.tests.factories import models as factory_models

View File

@ -16,15 +16,12 @@
import mox
import logging
import json
import novaclient
from reddwarf import tests
from reddwarf.common import config
from reddwarf.common import utils
from reddwarf.common import wsgi
from reddwarf.database import models
from reddwarf.database import service
from reddwarf.instance import models
from reddwarf.tests import unit