X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_view.py;fp=o2ims%2Fviews%2Focloud_view.py;h=7005b5a699bf32bef51770cc8b3cac1dd063df8a;hb=81e3575a77366f30c2049f98c48a3087db0ea992;hp=0000000000000000000000000000000000000000;hpb=8339c9a882a586578b37f44a504e21c5208611c0;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_view.py b/o2ims/views/ocloud_view.py new file mode 100644 index 0000000..7005b5a --- /dev/null +++ b/o2ims/views/ocloud_view.py @@ -0,0 +1,36 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from o2ims.service import unit_of_work + + +def ocloud_one(ocloudid: str, uow: unit_of_work.SqlAlchemyUnitOfWork): + with uow: + results = uow.session.execute( + """ + SELECT oCloudId, name FROM ocloud WHERE oCloudId = :ocloudid + """, + dict(ocloudid=ocloudid), + ) + return dict(results[0]) if len(results) > 0 else None + + +def oclouds(uow: unit_of_work.SqlAlchemyUnitOfWork): + with uow: + results = uow.session.execute( + """ + SELECT oCloudId, name FROM ocloud + """, + ) + return [dict(r) for r in results]