def delete_chain_bypass_rule(rule_id): """ Delete a Chain """ session = get_session() with session.begin(): session.query(ChainBypassRules).filter(ChainBypassRules.id == rule_id).delete() session.flush()
def delete_chain_sel_rule(rule_id): """ Delete a Chain Selection rule """ session = get_session() with session.begin(): session.query(ChainSelectionRules).filter(ChainSelectionRules.id == rule_id).delete() session.flush()
def delete_chain_set(chain_set_id): """ Delete a Chain Set """ session = get_session() with session.begin(): session.query(ChainSet).filter(ChainSet.id == chain_set_id).delete() session.flush()
def delete_chain_network_map(chain_network_id): """ Delete a Chain Network Map """ session = get_session() with session.begin(): session.query(ChainNetworkMaps).filter(ChainNetworkMaps.id == chain_network_id).delete() session.flush()
def delete_chain_service_instance(service_instance_id): """ Delete a Chain Service Instance """ session = get_session() with session.begin(): if service_instance_id is not None: session.query(ChainServiceInstances).\ filter(ChainServiceInstances.id == service_instance_id).delete() session.flush()
def update_chain_set_zone(self, chain_set_zone): """ Update an Chain Set. """ session = get_session() with session.begin(): zone_row = session.merge(ChainSetZone(id=chain_set_zone.id)) zone_row.update(chain_set_zone.as_dict()) session.flush() return self._row_to_chain_set_zone(zone_row)
def update_chain_sel_rule(self, chain_sel_rule): """ Update an Chain Selection Rule. """ session = get_session() with session.begin(): rule_row = session.merge(ChainSelectionRules(id=chain_sel_rule.id)) rule_row.update(chain_sel_rule.as_dict()) session.flush() return self._row_to_chain_sel_rule(rule_row)
def update_chain_set(self, chain_set): """ Update an Chain Set. """ session = get_session() with session.begin(): chain_set_row = session.merge(ChainSet(id=chain_set.id)) chain_set_row.update(chain_set.as_dict()) session.flush() return self._row_to_chain_set(chain_set_row)
def update_chain_service_instance(self, service_instance): """ Update an Chain Service Instance. """ session = get_session() with session.begin(): service_row = session.merge(ChainServiceInstances(id=service_instance.id)) service_row.update(service_instance.as_dict()) session.flush() return self._row_to_chain_service_instance(service_row)
def update_service(self, service): """ Update an Network Service. """ session = get_session() with session.begin(): service_row = session.merge(Services(id=service.id)) service_row.update(service.as_dict()) session.flush() return self._row_to_service(service_row)
def update_chain_network_map(self, chain_nw_map): """ Update an Chain Network Map. """ session = get_session() with session.begin(): chain_nw_row = session.merge(ChainNetworkMaps(id=chain_nw_map.id)) chain_nw_row.update(chain_nw_map.as_dict()) session.flush() return self._row_to_chain_nw_map(chain_nw_row)
def delete_service(service_id=None, name=None): """ Delete a Network Service """ session = get_session() with session.begin(): if service_id is not None: session.query(Services).\ filter(Services.id == service_id).delete() elif name is not None: session.query(Services).\ filter(Services.name == name).delete() session.flush()
def create_chain_service_instance(self, service_instance): """ Insert Chain Service Instance record into database :return: Chain Service Instance data if the insertion is successful revoke transaction and raise exception """ session = get_session() with session.begin(): service_instance_row = ChainServiceInstances(id=service_instance.id) service_instance_row.update(service_instance.as_dict()) session.add(service_instance_row) session.flush() return self._row_to_chain_service_instance(service_instance_row)
def create_chain_sel_rule(self, chain_sel_rule): """ Insert Chain Selection Rule record into database :return: Chain Selection Rule if the insertion is successful revoke transaction and raise exception """ session = get_session() with session.begin(): rule_row = ChainSelectionRules(id=chain_sel_rule.id) rule_row.update(chain_sel_rule.as_dict()) session.add(rule_row) session.flush() return self._row_to_chain_sel_rule(rule_row)
def create_chain_set_zone(self, chain_set_zone): """ Insert Chain Set Zone record into database :return: Chain data if the insertion is successful revoke transaction and raise exception """ session = get_session() with session.begin(): chain_set_zone_row = ChainSetZone(id=chain_set_zone.id) chain_set_zone_row.update(chain_set_zone.as_dict()) session.add(chain_set_zone_row) session.flush() return self._row_to_chain_set_zone(chain_set_zone_row)
def create_chain_network_map(self, chain_nw_map): """ Insert Chain Network Map record into database :return: Chain data if the insertion is successful revoke transaction and raise exception """ session = get_session() with session.begin(): chain_nw_row = ChainNetworkMaps(id=chain_nw_map.id) chain_nw_row.update(chain_nw_map.as_dict()) session.add(chain_nw_row) session.flush() return self._row_to_chain_nw_map(chain_nw_row)
def get_services(self, service_id=None, name=None, pagination=None): """ Yields a lists of Network services that match filters :param name: Optional name to return one network service. :param service_id: Optional service_id to return one Network Service. :param pagination: Optional pagination query. """ session = get_session() if pagination: raise NotImplementedError(_('Pagination not implemented')) query = session.query(Services) if name is not None: query = query.filter(Services.name == name) if service_id is not None: query = query.filter(Services.id == service_id) return (self._row_to_service(x) for x in query.all())
def get_chain_network_maps(self, chain_network_id=None, name=None, pagination=None): """ Yields a lists of Chain Network Maps that match filters :param name: Optional name to return one chain. :param chain_network_id: Optional chain_set_id to return one chain Set. :param pagination: Optional pagination query. """ session = get_session() if pagination: raise NotImplementedError(_('Pagination not implemented')) query = session.query(ChainNetworkMaps) if name is not None: query = query.filter(ChainNetworkMaps.name == name) if chain_network_id is not None: query = query.filter(ChainNetworkMaps.id == chain_network_id) return (self._row_to_chain_nw_map(x) for x in query.all())
def get_chain_services(self, chain_id=None, chain_service_id=None, service_id=None, pagination=None): """ Yields a lists of Chain services that match filters :param chain_id: Optional chain_id to return one Chain Service. :param chain_service_id: Optional service_id to return one Chain Service. :param pagination: Optional pagination query. """ session = get_session() if pagination: raise NotImplementedError(_('Pagination not implemented')) query = session.query(ChainServices) if chain_id is not None: query = query.filter(ChainServices.chain_id == chain_id) if service_id is not None: query = query.filter(ChainServices.service_id == service_id) if chain_service_id is not None: query = query.filter(ChainServices.id == chain_service_id) return (self._row_to_chain_service(x) for x in query.all())
def get_chain_set_zones(self, chain_set_zone_id=None, name=None, chain_set_id=None, pagination=None): """ Yields a lists of Chain Set zones that match filters :param name: Optional name to return one chain set zone name. :param chain_set_zone_id: Optional Chain set zone id :param chain_set_id: Optional chain_set_id to return one chain Set. :param pagination: Optional pagination query. """ session = get_session() if pagination: raise NotImplementedError(_('Pagination not implemented')) query = session.query(ChainSetZone) query.filter(ChainSetZone.chain_set_id == chain_set_id) if name is not None: query = query.filter(ChainSetZone.name == name) if chain_set_zone_id is not None: query = query.filter(ChainSetZone.id == chain_set_zone_id) return (self._row_to_chain_set_zone(x) for x in query.all())
def get_chain_sel_rules(self, chain_set_id=None, rule_id=None, name=None, pagination=None): """ Yields a lists of Chain Selection rules that match filters :param name: Optional name to return one chain. :param chain_set_id: Optional chain_id to return rules in one chain. :param rule_id: Optional rule_id to return one rule :param pagination: Optional pagination query. """ session = get_session() if pagination: raise NotImplementedError(_('Pagination not implemented')) query = session.query(ChainSelectionRules) if chain_set_id is not None: query = query.filter(ChainSelectionRules.chain_set_id == chain_set_id) if name is not None: query = query.filter(ChainSelectionRules.name == name) if rule_id is not None: query = query.filter(ChainSelectionRules.id == rule_id) return (self._row_to_chain_sel_rule(x) for x in query.all())
def before(self, state): state.request.storage_session = storage.get_session()