- uow: unit_of_work.SqlAlchemyUnitOfWork):\r
- with uow:\r
- # res = uow.session.execute(\r
- # """\r
- # SELECT "resourcePoolId", "oCloudId", "location", "name"\r
- # FROM resourcepool\r
- # WHERE "resourcePoolId" = :resourcePoolId\r
- # """,\r
- # dict(resourcePoolId=resourcePoolId),\r
- # )\r
- res = uow.session.execute(select(resourcepool).where(\r
- resourcepool.c.resourcePoolId == resourcePoolId))\r
- first = res.first()\r
- return None if first is None else dict(first)\r
-\r
-\r
-def resources(resourcePoolId: str, uow: unit_of_work.SqlAlchemyUnitOfWork):\r
- with uow:\r
- # res = uow.session.execute(\r
- # """\r
- # SELECT "resourceId", "parentId", "resourceTypeId",\r
- # "resourcePoolId", "oCloudId"\r
- # FROM resource\r
- # WHERE "resourcePoolId" = :resourcePoolId\r
- # """,\r
- # dict(resourcePoolId=resourcePoolId),\r
- # )\r
- res = uow.session.execute(select(resource).where(\r
- resource.c.resourcePoolId == resourcePoolId))\r
- return [dict(r) for r in res]\r
-\r
-\r
-def resource_one(resourceId: str, uow: unit_of_work.SqlAlchemyUnitOfWork):\r
- with uow:\r
- # res = uow.session.execute(\r
- # """\r
- # SELECT "resourceId", "parentId", "resourceTypeId",\r
- # "resourcePoolId", "oCloudId"\r
- # FROM resource\r
- # WHERE "resourceId" = :resourceId\r
- # """,\r
- # # AND "resourcePoolId" = :resourcePoolId\r
- # # dict(resourcePoolId=resourcePoolId,\r
- # dict(resourceId=resourceId),\r
- # )\r
- res = uow.session.execute(select(resource).where(\r
- resource.c.resourceId == resourceId))\r
- first = res.first()\r
- return None if first is None else dict(first)\r
-\r
-\r
-def deployment_managers(uow: unit_of_work.SqlAlchemyUnitOfWork):\r
- with uow:\r
- # res = uow.session.execute(\r
- # """\r
- # SELECT "deploymentManagerId", "oCloudId",\r
- # "deploymentManagementServiceEndpoint", "name"\r
- # FROM deploymentmanager\r
- # """,\r
- # )\r
- res = uow.session.execute(select(deploymentmanager))\r
- return [dict(r) for r in res]\r
+ uow: unit_of_work.AbstractUnitOfWork):\r
+ with uow:\r
+ first = uow.resource_pools.get(resourcePoolId)\r
+ return first.serialize() if first is not None else None\r
+\r
+\r
+def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork):\r
+ with uow:\r
+ li = uow.resources.list(resourcePoolId)\r
+ return [r.serialize() for r in li]\r
+\r
+\r
+def resource_one(resourceId: str, uow: unit_of_work.AbstractUnitOfWork):\r
+ with uow:\r
+ first = uow.resources.get(resourceId)\r
+ return first.serialize() if first is not None else None\r
+\r
+\r
+def deployment_managers(uow: unit_of_work.AbstractUnitOfWork):\r
+ with uow:\r
+ li = uow.deployment_managers.list()\r
+ return [r.serialize() for r in li]\r