**** CubicPower OpenStack Study ****
def get_flavor_by_network(session, net_id):
try:
binding = (session.query(meta_models_v2.NetworkFlavor).
filter_by(network_id=net_id).
one())
except exc.NoResultFound:
return None
return binding.flavor
**** CubicPower OpenStack Study ****
def add_network_flavor_binding(session, flavor, net_id):
binding = meta_models_v2.NetworkFlavor(flavor=flavor, network_id=net_id)
session.add(binding)
return binding
**** CubicPower OpenStack Study ****
def get_flavor_by_router(session, router_id):
try:
binding = (session.query(meta_models_v2.RouterFlavor).
filter_by(router_id=router_id).
one())
except exc.NoResultFound:
return None
return binding.flavor
**** CubicPower OpenStack Study ****
def add_router_flavor_binding(session, flavor, router_id):
binding = meta_models_v2.RouterFlavor(flavor=flavor, router_id=router_id)
session.add(binding)
return binding