Code Review
/
pti
/
o2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add back secret with built-in user for o2 service
[pti/o2.git]
/
o2ims
/
views
/
ocloud_view.py
diff --git
a/o2ims/views/ocloud_view.py
b/o2ims/views/ocloud_view.py
index
83be178
..
ed55dda
100644
(file)
--- a/
o2ims/views/ocloud_view.py
+++ b/
o2ims/views/ocloud_view.py
@@
-20,11
+20,13
@@
from datetime import datetime
import shutil
from o2common.service import unit_of_work
import shutil
from o2common.service import unit_of_work
+from o2common.config import config
+from o2common.views.pagination_view import Pagination
+from o2ims.domain import ocloud
from o2ims.views.ocloud_dto import SubscriptionDTO
from o2ims.domain.subscription_obj import Subscription
from o2common.helper import o2logging
from o2ims.views.ocloud_dto import SubscriptionDTO
from o2ims.domain.subscription_obj import Subscription
from o2common.helper import o2logging
-from o2common.config import config
logger = o2logging.get_logger(__name__)
logger = o2logging.get_logger(__name__)
@@
-40,10
+42,12
@@
def ocloud_one(ocloudid: str, uow: unit_of_work.AbstractUnitOfWork):
return first.serialize() if first is not None else None
return first.serialize() if first is not None else None
-def resource_types(uow: unit_of_work.AbstractUnitOfWork):
+def resource_types(uow: unit_of_work.AbstractUnitOfWork, **kwargs):
+ pagination = Pagination(**kwargs)
+ filter_kwargs = pagination.get_filter()
with uow:
with uow:
- li = uow.resource_types.list
(
)
- return
[r.serialize() for r in li]
+ li = uow.resource_types.list
_with_count(**filter_kwargs
)
+ return
pagination.get_result(li)
def resource_type_one(resourceTypeId: str,
def resource_type_one(resourceTypeId: str,
@@
-53,10
+57,12
@@
def resource_type_one(resourceTypeId: str,
return first.serialize() if first is not None else None
return first.serialize() if first is not None else None
-def resource_pools(uow: unit_of_work.AbstractUnitOfWork):
+def resource_pools(uow: unit_of_work.AbstractUnitOfWork, **kwargs):
+ pagination = Pagination(**kwargs)
+ filter_kwargs = pagination.get_filter()
with uow:
with uow:
- li = uow.resource_pools.list
(
)
- return
[r.serialize() for r in li]
+ li = uow.resource_pools.list
_with_count(**filter_kwargs
)
+ return
pagination.get_result(li)
def resource_pool_one(resourcePoolId: str,
def resource_pool_one(resourcePoolId: str,
@@
-68,8
+74,9
@@
def resource_pool_one(resourcePoolId: str,
def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork,
**kwargs):
def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork,
**kwargs):
-
- filter_kwargs = {} # filter key should be the same with database name
+ pagination = Pagination(**kwargs)
+ # filter key should be the same with database name
+ filter_kwargs = pagination.get_filter()
if 'resourceTypeName' in kwargs:
resource_type_name = kwargs['resourceTypeName']
with uow:
if 'resourceTypeName' in kwargs:
resource_type_name = kwargs['resourceTypeName']
with uow:
@@
-82,14
+89,15
@@
def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork,
restype_id = '' if res_type is None else res_type.resourceTypeId
filter_kwargs['resourceTypeId'] = restype_id
restype_id = '' if res_type is None else res_type.resourceTypeId
filter_kwargs['resourceTypeId'] = restype_id
- # li = uow.resources.list(resourcePoolId)
- # return [r.serialize() for r in li if r.resourceTypeId == restype_id]
if 'parentId' in kwargs:
filter_kwargs['parentId'] = kwargs['parentId']
if 'parentId' in kwargs:
filter_kwargs['parentId'] = kwargs['parentId']
+ if 'sort' in kwargs:
+ filter_kwargs['sort'] = kwargs['sort']
with uow:
with uow:
- li = uow.resources.list(resourcePoolId, **filter_kwargs)
- return [r.serialize() for r in li]
+ ret = uow.resources.list_with_count(resourcePoolId, **filter_kwargs)
+
+ return pagination.get_result(ret)
def resource_one(resourceId: str, uow: unit_of_work.AbstractUnitOfWork):
def resource_one(resourceId: str, uow: unit_of_work.AbstractUnitOfWork):
@@
-98,10
+106,12
@@
def resource_one(resourceId: str, uow: unit_of_work.AbstractUnitOfWork):
return first.serialize() if first is not None else None
return first.serialize() if first is not None else None
-def deployment_managers(uow: unit_of_work.AbstractUnitOfWork):
+def deployment_managers(uow: unit_of_work.AbstractUnitOfWork, **kwargs):
+ pagination = Pagination(**kwargs)
+ filter_kwargs = pagination.get_filter()
with uow:
with uow:
- li = uow.deployment_managers.list
(
)
- return
[r.serialize() for r in li]
+ li = uow.deployment_managers.list
_with_count(**filter_kwargs
)
+ return
pagination.get_result(li)
def deployment_manager_one(deploymentManagerId: str,
def deployment_manager_one(deploymentManagerId: str,
@@
-119,13
+129,13
@@
def deployment_manager_one(deploymentManagerId: str,
profile_data = result.pop("profile", None)
result['profileName'] = profile
profile_data = result.pop("profile", None)
result['profileName'] = profile
- if
"default"
== profile:
+ if
ocloud.DeploymentManagerProfileDefault
== profile:
pass
pass
- elif
"sol018"
== profile:
+ elif
ocloud.DeploymentManagerProfileSOL018
== profile:
result['deploymentManagementServiceEndpoint'] = \
profile_data['cluster_api_endpoint']
result['profileData'] = profile_data
result['deploymentManagementServiceEndpoint'] = \
profile_data['cluster_api_endpoint']
result['profileData'] = profile_data
- elif
"sol018_helmcli"
== profile:
+ elif
ocloud.DeploymentManagerProfileSOL018HelmCLI
== profile:
result['deploymentManagementServiceEndpoint'] = \
profile_data['cluster_api_endpoint']
result['deploymentManagementServiceEndpoint'] = \
profile_data['cluster_api_endpoint']
@@
-176,10
+186,12
@@
def _gen_kube_config(dmId: str, kubeconfig: dict) -> dict:
return '/configs/'+kube_config_name
return '/configs/'+kube_config_name
-def subscriptions(uow: unit_of_work.AbstractUnitOfWork):
+def subscriptions(uow: unit_of_work.AbstractUnitOfWork, **kwargs):
+ pagination = Pagination(**kwargs)
+ filter_kwargs = pagination.get_filter()
with uow:
with uow:
- li = uow.subscriptions.list
(
)
- return
[r.serialize() for r in li]
+ li = uow.subscriptions.list
_with_count(**filter_kwargs
)
+ return
pagination.get_result(li)
def subscription_one(subscriptionId: str,
def subscription_one(subscriptionId: str,