def get_flavor_os_metadata( flavor_id, os_id, user=None, session=None, **kwargs ): """Get metadata by flavor and os.""" flavor = adapter_holder_api.get_flavor( flavor_id, user=user, session=session ) adapter_id = flavor['adapter_id'] adapter = adapter_holder_api.get_adapter( adapter_id, user=user, session=session ) os_ids = [os['id'] for os in adapter['supported_oses']] if os_id not in os_ids: raise exception.InvalidParameter( 'os %s is not in the supported os list of adapter %s' % ( os_id, adapter_id ) ) metadatas = {} metadatas['os_config'] = _get_os_metadata( session, os_id ) metadatas['package_config'] = _get_flavor_metadata( session, flavor_id ) return metadatas
def test_get_flavor(self): """Test get a flavor.""" flavor = adapter.get_flavor(self.flavor_id, user=self.user_object) expected = { 'display_name': 'Multi-node Cluster with HA', 'id': 'openstack_icehouse:HA-multinodes', 'template': 'ha_multinodes.tmpl', 'name': 'HA-multinodes' } self.assertTrue( all(item in flavor.items() for item in expected.items()))
def test_get_flavor(self): """Test get a flavor.""" flavor = adapter.get_flavor( self.flavor_id, user=self.user_object ) expected = { 'display_name': 'Multi-node Cluster with HA', 'id': 'openstack_icehouse:HA-multinodes', 'template': 'ha_multinodes.tmpl', 'name': 'HA-multinodes' } self.assertTrue( all(item in flavor.items() for item in expected.items()) )
def get_flavor_os_metadata(flavor_id, os_id, user=None, session=None, **kwargs): """Get metadata by flavor and os.""" flavor = adapter_holder_api.get_flavor(flavor_id, user=user, session=session) adapter_id = flavor['adapter_id'] adapter = adapter_holder_api.get_adapter(adapter_id, user=user, session=session) os_ids = [os['id'] for os in adapter['supported_oses']] if os_id not in os_ids: raise exception.InvalidParameter( 'os %s is not in the supported os list of adapter %s' % (os_id, adapter_id)) metadatas = {} metadatas['os_config'] = _get_os_metadata(session, os_id) metadatas['package_config'] = _get_flavor_metadata(session, flavor_id) return metadatas