super().__init__()\r
self.driver = driver if driver else StxSaClientImp()\r
\r
- # def list(self) -> List[ocloudModel.StxGenericModel]:\r
- # return self._list()\r
-\r
- # def get(self, id) -> ocloudModel.StxGenericModel:\r
- # return self._get(id)\r
-\r
def _get(self, id) -> ocloudModel.StxGenericModel:\r
return self.driver.getInstanceInfo()\r
\r
- def _list(self):\r
+ def _list(self, **filters):\r
return [self.driver.getInstanceInfo()]\r
\r
\r
def _get(self, id) -> ocloudModel.StxGenericModel:\r
return self.driver.getInstanceInfo()\r
\r
- def _list(self):\r
+ def _list(self, **filters):\r
return [self.driver.getInstanceInfo()]\r
\r
\r
def _get(self, name) -> ocloudModel.StxGenericModel:\r
return self.driver.getK8sDetail(name)\r
\r
- def _list(self):\r
- return self.driver.getK8sList()\r
+ def _list(self, **filters):\r
+ return self.driver.getK8sList(filters)\r
\r
\r
class StxPserverClient(BaseClient):\r
def _get(self, id) -> ocloudModel.StxGenericModel:\r
return self.driver.getPserver(id)\r
\r
- def _list(self) -> List[ocloudModel.StxGenericModel]:\r
- return self.driver.getPserverList()\r
+ def _list(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
+ return self.driver.getPserverList(filters)\r
\r
\r
class StxCpuClient(BaseClient):\r
- def __init__(self, pserver_id):\r
+ def __init__(self):\r
super().__init__()\r
- self._pserver_id = pserver_id\r
+ # self._pserver_id = pserver_id\r
self.driver = StxSaClientImp()\r
\r
def _get(self, id) -> ocloudModel.StxGenericModel:\r
return self.driver.getCpu(id)\r
\r
- def _list(self) -> List[ocloudModel.StxGenericModel]:\r
- return self.driver.getCpuList(self._pserver_id)\r
+ def _list(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
+ return self.driver.getCpuList(filters)\r
\r
# internal driver which implement client call to Stx Standalone instance\r
\r
return ocloudModel.StxGenericModel(\r
ResourceTypeEnum.OCLOUD, systems[0]) if systems else None\r
\r
- def getPserverList(self) -> List[ocloudModel.StxGenericModel]:\r
+ def getPserverList(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
+ # resourcepoolid = filters.get("resourcepoolid", None)\r
hosts = self.stxclient.ihost.list()\r
logger.debug("host 1:" + str(hosts[0].to_dict()))\r
return [ocloudModel.StxGenericModel(\r
return ocloudModel.StxGenericModel(\r
ResourceTypeEnum.PSERVER, self._hostconverter(host))\r
\r
- def getK8sList(self) -> List[ocloudModel.StxGenericModel]:\r
+ def getK8sList(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
k8sclusters = self.stxclient.kube_cluster.list()\r
logger.debug("k8sresources[0]:" + str(k8sclusters[0].to_dict()))\r
return [ocloudModel.StxGenericModel(\r
ResourceTypeEnum.DMS,\r
self._k8sconverter(k8scluster), self._k8shasher(k8scluster))\r
\r
- def getCpuList(self, hostid) -> List[ocloudModel.StxGenericModel]:\r
+ def getCpuList(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
+ hostid = filters.get("hostid", None)\r
cpulist = self.stxclient.icpu.list(hostid)\r
return [ocloudModel.StxGenericModel(\r
ResourceTypeEnum.OCLOUD,\r
import cotyledon\r
\r
from o2ims.service.watcher.worker import PollWorker\r
-from o2ims.service.watcher.base import OcloudWatcher\r
-from o2ims.service.watcher.base import DmsWatcher\r
-# from o2ims.service.client.base_client import BaseClient\r
+from o2ims.service.watcher.ocloud_watcher import OcloudWatcher\r
+from o2ims.service.watcher.ocloud_watcher import DmsWatcher\r
+from o2ims.service.watcher.resourcepool_watcher import ResourcePoolWatcher\r
from o2ims.adapter.clients.ocloud_sa_client import StxSaDmsClient\r
from o2ims.adapter.clients.ocloud_sa_client import StxSaOcloudClient\r
+from o2ims.adapter.clients.ocloud_sa_client import StxSaResourcePoolClient\r
+\r
+from o2ims.service.watcher.pserver_watcher import PServerWatcher\r
+from o2ims.adapter.clients.ocloud_sa_client import StxPserverClient\r
+\r
+from o2ims.service.watcher.pserver_cpu_watcher import PServerCpuWatcher\r
+from o2ims.adapter.clients.ocloud_sa_client import StxCpuClient\r
+\r
+from o2ims.service.watcher.base import WatcherTree\r
\r
from o2ims import bootstrap\r
# from o2ims import config\r
self.args = args\r
self.bus = bootstrap.bootstrap()\r
self.worker = PollWorker()\r
- # self.stxrepo = self.bus.uow.stxobjects\r
- # tbd: 1 client per resource pool\r
- # self.client = StxSaOcloudClient()\r
\r
def run(self):\r
try:\r
- self.worker.add_watcher(OcloudWatcher(StxSaOcloudClient(),\r
- self.bus.uow))\r
- self.worker.add_watcher(DmsWatcher(StxSaDmsClient(),\r
+ root = WatcherTree(OcloudWatcher(\r
+ StxSaOcloudClient(), self.bus.uow))\r
+ root.addchild(\r
+ DmsWatcher(StxSaDmsClient(), self.bus.uow))\r
+\r
+ child_respool = root.addchild(\r
+ ResourcePoolWatcher(StxSaResourcePoolClient(),\r
self.bus.uow))\r
+ child_pserver = child_respool.addchild(\r
+ PServerWatcher(StxPserverClient(), self.bus.uow))\r
+ child_pserver.addchild(\r
+ PServerCpuWatcher(StxCpuClient(), self.bus.uow))\r
+\r
+ self.worker.add_watcher(root)\r
+\r
self.worker.start()\r
except Exception as ex:\r
logger.warning("WorkerService Exception:" + str(ex))\r
def __init__(self):\r
pass\r
\r
- def list(self) -> List[ocloudModel.StxGenericModel]:\r
- return self._list()\r
+ def list(self, **filters) -> List[ocloudModel.StxGenericModel]:\r
+ return self._list(filters)\r
\r
def get(self, id) -> ocloudModel.StxGenericModel:\r
return self._get(id)\r
raise NotImplementedError\r
\r
@abc.abstractmethod\r
- def _list(self):\r
+ def _list(self, **filters):\r
raise NotImplementedError\r
# See the License for the specific language governing permissions and\r
# limitations under the License.\r
\r
-from o2ims.domain.resource_type import ResourceTypeEnum\r
from o2ims.service.client.base_client import BaseClient\r
from o2ims.domain.stx_object import StxGenericModel\r
from o2ims.service.unit_of_work import AbstractUnitOfWork\r
logger = logging.getLogger(__name__)\r
\r
\r
-class InvalidOcloudState(Exception):\r
- pass\r
-\r
-\r
class BaseWatcher(object):\r
- def __init__(self, client: BaseClient) -> None:\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
super().__init__()\r
self._client = client\r
+ self._uow = uow\r
\r
def targetname(self) -> str:\r
return self._targetname()\r
\r
- def probe(self):\r
- self._probe()\r
+ def probe(self, parent: object = None):\r
+ return self._probe(parent)\r
\r
- def _probe(self):\r
+ def _probe(self, parent: object = None):\r
raise NotImplementedError\r
\r
def _targetname(self):\r
raise NotImplementedError\r
\r
-\r
-class OcloudWatcher(BaseWatcher):\r
- def __init__(self, ocloud_client: BaseClient,\r
- uow: AbstractUnitOfWork) -> None:\r
- super().__init__(ocloud_client)\r
- self._uow = uow\r
-\r
- def _targetname(self):\r
- return "ocloud"\r
-\r
- def _probe(self):\r
- ocloudmodel = self._client.get(None)\r
- if ocloudmodel:\r
- self._compare_and_update(ocloudmodel)\r
-\r
- def _compare_and_update(self, ocloudmodel: StxGenericModel) -> bool:\r
- with self._uow:\r
- # localmodel = self._uow.stxobjects.get(str(ocloudmodel.id))\r
- oclouds = self._uow.stxobjects.list(ResourceTypeEnum.OCLOUD)\r
- if len(oclouds) > 1:\r
- raise InvalidOcloudState("More than 1 ocloud is found")\r
- if len(oclouds) == 0:\r
- logger.info("add ocloud:" + ocloudmodel.name\r
- + " update_at: " + str(ocloudmodel.updatetime)\r
- + " id: " + str(ocloudmodel.id)\r
- + " hash: " + str(ocloudmodel.hash))\r
- self._uow.stxobjects.add(ocloudmodel)\r
- else:\r
- localmodel = oclouds.pop()\r
- if localmodel.is_outdated(ocloudmodel):\r
- logger.info("update ocloud:" + ocloudmodel.name\r
- + " update_at: " + str(ocloudmodel.updatetime)\r
- + " id: " + str(ocloudmodel.id)\r
- + " hash: " + str(ocloudmodel.hash))\r
- localmodel.update_by(ocloudmodel)\r
- self._uow.stxobjects.update(localmodel)\r
- self._uow.commit()\r
-\r
-\r
-class DmsWatcher(BaseWatcher):\r
- def __init__(self, client: BaseClient,\r
- uow: AbstractUnitOfWork) -> None:\r
- super().__init__(client)\r
- self._uow = uow\r
-\r
- def _targetname(self):\r
- return "dms"\r
-\r
- def _probe(self):\r
- ocloudmodel = self._client.get(None)\r
- if ocloudmodel:\r
- self._compare_and_update(ocloudmodel)\r
-\r
def _compare_and_update(self, newmodel: StxGenericModel) -> bool:\r
with self._uow:\r
# localmodel = self._uow.stxobjects.get(ocloudmodel.id)\r
localmodel = self._uow.stxobjects.get(str(newmodel.id))\r
if not localmodel:\r
- logger.info("add dms:" + newmodel.name)\r
+ logger.info("add entry:" + newmodel.name)\r
self._uow.stxobjects.add(newmodel)\r
elif localmodel.is_outdated(newmodel):\r
- logger.info("update dms:" + newmodel.name)\r
+ logger.info("update entry:" + newmodel.name)\r
localmodel.update_by(newmodel)\r
- self._uow.stxobjects.update(newmodel)\r
+ self._uow.stxobjects.update(localmodel)\r
self._uow.commit()\r
\r
\r
-class ResourcePoolWatcher(BaseWatcher):\r
- def __init__(self, client: BaseClient,\r
- uow: AbstractUnitOfWork) -> None:\r
+# node to organize watchers in tree hierachy\r
+class WatcherTree(object):\r
+ def __init__(self, watcher: BaseWatcher) -> None:\r
super().__init__()\r
- self._uow = uow\r
-\r
- def _targetname(self):\r
- return "resourcepool"\r
-\r
- def _probe(self):\r
- ocloudmodel = self._client.get(None)\r
- if ocloudmodel:\r
- logger.info("detect ocloudmodel:" + ocloudmodel.name)\r
- self._compare_and_update(ocloudmodel)\r
-\r
- def _compare_and_update(self, newmodel: StxGenericModel) -> bool:\r
- with self._uow:\r
- # localmodel = self._uow.stxobjects.get(ocloudmodel.id)\r
- localmodel = self._uow.stxobjects.get(str(newmodel.id))\r
- if not localmodel:\r
- self._uow.stxobjects.add(newmodel)\r
- elif localmodel.is_outdated(newmodel):\r
- localmodel.update_by(newmodel)\r
- self._uow.stxobjects.update(newmodel)\r
- self._uow.commit()\r
-\r
-\r
-class ResourceWatcher(BaseWatcher):\r
- def __init__(self, client: BaseClient,\r
- uow: AbstractUnitOfWork) -> None:\r
- super().__init__()\r
- self._uow = uow\r
-\r
- def _targetname(self):\r
- return "resource"\r
-\r
- def _probe(self):\r
- ocloudmodel = self._client.get(None)\r
- if ocloudmodel:\r
- self._compare_and_update(ocloudmodel)\r
-\r
- def _compare_and_update(self, newmodel: StxGenericModel) -> bool:\r
- with self._uow:\r
- # localmodel = self._repo.get(ocloudmodel.id)\r
- localmodel = self._uow.stxobjects.get(str(newmodel.id))\r
- if not localmodel:\r
- self._uow.stxobjects.add(newmodel)\r
- elif localmodel.is_outdated(newmodel):\r
- localmodel.update_by(newmodel)\r
- self._uow.stxobjects.update(newmodel)\r
- self._uow.commit()\r
+ self.watcher = watcher\r
+ self.children = {}\r
+\r
+ def addchild(self, watcher: BaseWatcher) -> object:\r
+ child = WatcherTree(watcher)\r
+ self.children[watcher.targetname()] = child\r
+ return child\r
+\r
+ def removechild(self, targetname: str) -> object:\r
+ return self.children.pop(targetname)\r
+\r
+ # probe all resources by parent, depth = 0 for indefinite recursive\r
+ def probe(self, parentresource=None, depth: int = 0):\r
+ logger.debug("probe resources with watcher: "\r
+ + self.watcher.targetname())\r
+ childdepth = depth - 1 if depth > 0 else 0\r
+ resources = self.watcher.probe(parentresource)\r
+ logger.debug("probe returns " + str(len(resources)) + "resources")\r
+\r
+ if depth == 1:\r
+ # stop recursive\r
+ return\r
+\r
+ for res in resources:\r
+ for node in self.children:\r
+ node.probe(res, childdepth)\r
--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+from o2ims.domain.resource_type import ResourceTypeEnum\r
+from o2ims.service.client.base_client import BaseClient\r
+from o2ims.domain.stx_object import StxGenericModel\r
+from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.base import BaseWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class InvalidOcloudState(Exception):\r
+ pass\r
+\r
+\r
+class OcloudWatcher(BaseWatcher):\r
+ def __init__(self, ocloud_client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(ocloud_client, uow)\r
+\r
+ def _targetname(self):\r
+ return "ocloud"\r
+\r
+ def _probe(self, parent: object = None):\r
+ ocloudmodel = self._client.get(None)\r
+ if ocloudmodel:\r
+ self._compare_and_update(ocloudmodel)\r
+ return [ocloudmodel]\r
+\r
+ def _compare_and_update(self, ocloudmodel: StxGenericModel) -> bool:\r
+ with self._uow:\r
+ # localmodel = self._uow.stxobjects.get(str(ocloudmodel.id))\r
+ oclouds = self._uow.stxobjects.list(ResourceTypeEnum.OCLOUD)\r
+ if len(oclouds) > 1:\r
+ raise InvalidOcloudState("More than 1 ocloud is found")\r
+ if len(oclouds) == 0:\r
+ logger.info("add ocloud:" + ocloudmodel.name\r
+ + " update_at: " + str(ocloudmodel.updatetime)\r
+ + " id: " + str(ocloudmodel.id)\r
+ + " hash: " + str(ocloudmodel.hash))\r
+ self._uow.stxobjects.add(ocloudmodel)\r
+ else:\r
+ localmodel = oclouds.pop()\r
+ if localmodel.is_outdated(ocloudmodel):\r
+ logger.info("update ocloud:" + ocloudmodel.name\r
+ + " update_at: " + str(ocloudmodel.updatetime)\r
+ + " id: " + str(ocloudmodel.id)\r
+ + " hash: " + str(ocloudmodel.hash))\r
+ localmodel.update_by(ocloudmodel)\r
+ self._uow.stxobjects.update(localmodel)\r
+ self._uow.commit()\r
+\r
+\r
+class DmsWatcher(BaseWatcher):\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(client, uow)\r
+\r
+ def _targetname(self):\r
+ return "dms"\r
+\r
+ def _probe(self, parent: object = None):\r
+ ocloudid = parent.id if parent else None\r
+ newmodels = self._client.list(ocloudid=ocloudid)\r
+ for newmodel in newmodels:\r
+ super()._compare_and_update(newmodel)\r
+ return newmodels\r
--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+from o2ims.service.client.base_client import BaseClient\r
+from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.resource_watcher import ResourceWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class PServerCpuWatcher(ResourceWatcher):\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(client, uow)\r
+\r
+ def _targetname(self):\r
+ return "pserver_cpu"\r
+\r
+ def _probe(self, parent: object = None):\r
+ hostid = parent.id if parent else None\r
+ newmodels = self._client.list(hostid=hostid)\r
+ for newmodel in newmodels:\r
+ super()._compare_and_update(newmodel)\r
+ return newmodels\r
--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+from o2ims.service.client.base_client import BaseClient\r
+from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.resource_watcher import ResourceWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class PServerWatcher(ResourceWatcher):\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(client, uow)\r
+\r
+ def _targetname(self):\r
+ return "pserver"\r
+\r
+ def _probe(self, parent: object = None):\r
+ resourcepoolid = parent.id if parent else None\r
+ newmodels = self._client.list(resourcepoolid=resourcepoolid)\r
+ for newmodel in newmodels:\r
+ super()._compare_and_update(newmodel)\r
+ return newmodels\r
--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+from o2ims.service.client.base_client import BaseClient\r
+from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.base import BaseWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class ResourceWatcher(BaseWatcher):\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(client, uow)\r
+\r
+ def _targetname(self):\r
+ return "resource"\r
+\r
+ def _probe(self, parent: object = None):\r
+ parentid = parent.id if parent else None\r
+ newmodels = self._client.get(parentid=parentid)\r
+ for newmodel in newmodels:\r
+ super()._compare_and_update(newmodel)\r
+ return newmodels\r
--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+from o2ims.service.client.base_client import BaseClient\r
+from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.base import BaseWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class ResourcePoolWatcher(BaseWatcher):\r
+ def __init__(self, client: BaseClient,\r
+ uow: AbstractUnitOfWork) -> None:\r
+ super().__init__(client, uow)\r
+\r
+ def _targetname(self):\r
+ return "resourcepool"\r
+\r
+ def _probe(self, parent: object = None):\r
+ ocloudid = parent.id if parent else None\r
+ newmodels = self._client.list(ocloudid=ocloudid)\r
+ for newmodel in newmodels:\r
+ logger.info("detect ocloudmodel:" + newmodel.name)\r
+ super()._compare_and_update(newmodel)\r
+ return newmodels\r
\r
import time\r
import sched\r
-from o2ims.service.watcher.base import BaseWatcher\r
+from o2ims.service.watcher.base import WatcherTree\r
\r
import logging\r
logger = logging.getLogger(__name__)\r
class PollWorker(object):\r
def __init__(self, interval=10) -> None:\r
super().__init__()\r
- self.watchers = {}\r
+ self.watchers = []\r
self.schedinstance = sched.scheduler(time.time, time.sleep)\r
self.schedinterval = interval\r
self._stopped = True\r
else:\r
raise Exception("Invalid interval:" + interval)\r
\r
- def add_watcher(self, watcher: BaseWatcher):\r
- self.watchers[watcher.targetname()] = watcher\r
+ def add_watcher(self, watcher: WatcherTree):\r
+ self.watchers.append(watcher)\r
\r
def _repeat(self):\r
logger.debug("_repeat started")\r
if self._stopped:\r
return\r
- for w in self.watchers.keys():\r
+ for w in self.watchers:\r
try:\r
- logger.debug("about to probe:"+w)\r
- self.watchers[w].probe()\r
+ # logger.debug("about to probe:"+w)\r
+ w.probe(None)\r
except Exception as ex:\r
- logger.warning("Worker:" + w + " raises exception:" + str(ex))\r
+ logger.warning("Worker raises exception:" + str(ex))\r
continue\r
self.schedinstance.enter(self.schedinterval, 1, self._repeat)\r
\r
hostlist = stxSaClientImp.getPserverList()\r
assert len(hostlist) > 0\r
\r
- cpulist = stxSaClientImp.getCpuList(hostlist[0].id)\r
+ cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)\r
assert len(cpulist) > 0\r
cpu1 = cpulist[0]\r
cpu2 = stxSaClientImp.getCpu(cpu1.id)\r
from o2ims.domain import ocloud\r
from o2ims import config\r
import uuid\r
-from o2ims.service.watcher.base import BaseWatcher, OcloudWatcher\r
+from o2ims.service.watcher.base import BaseWatcher, WatcherTree\r
from o2ims.domain import stx_object as ocloudModel\r
from o2ims.adapter.ocloud_repository import OcloudRepository\r
from o2ims.domain.stx_repo import StxObjectRepository\r
from o2ims.service.watcher import worker\r
from o2ims.service.unit_of_work import AbstractUnitOfWork\r
+from o2ims.service.watcher.ocloud_watcher import OcloudWatcher\r
\r
\r
class FakeOcloudClient(BaseClient):\r
class FakeOCloudWatcher(BaseWatcher):\r
def __init__(self, client: BaseClient,\r
repo: OcloudRepository) -> None:\r
- super().__init__(client)\r
+ super().__init__(client, None)\r
self.fakeOcloudWatcherCounter = 0\r
self._client = client\r
self._repo = repo\r
def _targetname(self):\r
return "fakeocloudwatcher"\r
\r
- def _probe(self):\r
+ def _probe(self, parent: object=None):\r
+ # import pdb; pdb.set_trace()\r
self.fakeOcloudWatcherCounter += 1\r
# hacking to stop the blocking sched task\r
if self.fakeOcloudWatcherCounter > 2:\r
testedworker.stop()\r
+ return []\r
\r
\r
# fakeRepo = FakeOcloudRepo()\r
fakeClient = FakeOcloudClient()\r
fakewatcher = FakeOCloudWatcher(fakeClient, fakeuow)\r
\r
+ root = WatcherTree(fakewatcher)\r
+\r
testedworker.set_interval(1)\r
- testedworker.add_watcher(fakewatcher)\r
+ testedworker.add_watcher(root)\r
assert fakewatcher.fakeOcloudWatcherCounter == 0\r
\r
count1 = fakewatcher.fakeOcloudWatcherCounter\r