Revision as of 16:28, 16 September 2013 by Sushilkm (Extending Flavor API to create and delete Flavors from trove)
Extending Flavor API to create and delete Flavors from trove
== Requirements ==
- Management API to add/delete flavors from trove.
- Categorization for service_type for a flavor created from trove.(This categorization would be used to validate the guest vm creation and resize activities to related flavors, mapped for service.)
== Implementation ==
- In Troveclient's management.py a new class MgmtFlavors has been added with two methods for creation and deletion of flavors using the API "/mgmt/flavors" in trove.
- In Trove, new controller MgmtFlavorController has been added in trove.extensions.mgmt.flavors.service.py and is registered in trove.extensions.routes.mgmt.py
- This controller has two public methods create and delete which could be called under admin context only.
- Create method in controller also does a json-schema validation using the new schema added in trove.common.apischema.py
- Controller methods in turn calls their counter-parts from trove.flavor.models.py
- New class FlavorManage with 3 methods(create, delete, load_flavor) have been implemented in trove.flavor.models.py.
- Class FlavorView in trove.flavor.views.py has been edited to show service for the flavors.
- To keep the service_type classification, table service_flavors is created using trove.db.sqlalchemy.migrate_repo.versions.016_service_flavor.py and mapped in db.sqlalchemy.mappers.py as service_flavor.
- service_flavors table is created with three columns(id, service_type, flavor_id).
- New model ServiceFlavor has been created in trove.flavor.models.py to work with table service_flavors and is registered in trove.db.sqlalchemy.session.py
- Create method in trove.flavor.models.py creates the flavor using nova client and creates a record in service_flavors table. Delete method deletes the flavor from nova and removes entry from trove database. Load_flavor has been written to fetch the flavor details using nova client.
- Integration tests have been updated in trove.tests.api.flavors.py and unit-tests have been written as tests.unittests.mgmt.flavors.test_flavors_controller.py and tests.unittests.mgmt.flavors. test_flavors_models.py
- Fake implementation for nova flavor create and delete have been written in trove.tests.fakes.nova.py to support fake calls during unit-tests.