Convert file endlines to Unix (LF)
[pti/o2.git] / tests / integration-ocloud / test_clientdriver_stx_sa.py
index b2bd8c8..57598a9 100644 (file)
-# 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
-# import sys\r
-# import logging\r
-import pytest\r
-\r
-from o2common.config import config\r
-from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp\r
-from cgtsclient.client import get_client\r
-\r
-\r
-@pytest.fixture\r
-def real_stx_aio_client():\r
-    os_client_args = config.get_stx_access_info()\r
-    config_client = get_client(**os_client_args)\r
-    yield config_client\r
-\r
-# pytestmark = pytest.mark.usefixtures("mappers")\r
-\r
-\r
-def test_get_instanceinfo(real_stx_aio_client):\r
-    # logger = logging.getLogger(__name__)\r
-    stxclientimp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxclientimp is not None\r
-    systeminfo = stxclientimp.getInstanceInfo()\r
-    assert systeminfo is not None\r
-    assert systeminfo.id is not None\r
-    assert systeminfo.name is not None\r
-    assert systeminfo.content is not None\r
-\r
-\r
-def test_get_pserverlist(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hosts = stxSaClientImp.getPserverList()\r
-    assert hosts is not None\r
-    assert len(hosts) > 0\r
-\r
-\r
-def test_get_pserver(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hosts = stxSaClientImp.getPserverList()\r
-    assert hosts is not None\r
-    assert len(hosts) > 0\r
-    host1 = hosts[0]\r
-    host2 = stxSaClientImp.getPserver(host1.id)\r
-    assert host1 != host2\r
-    assert host1.id == host2.id\r
-\r
-\r
-def test_get_k8s_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    k8slist = stxSaClientImp.getK8sList()\r
-    assert k8slist is not None\r
-    assert len(k8slist) > 0\r
-    k8s1 = k8slist[0]\r
-    k8s2 = stxSaClientImp.getK8sDetail(k8s1.name)\r
-    assert k8s1 != k8s2\r
-    assert k8s1.name == k8s2.name\r
-    assert k8s1.id == k8s2.id\r
-\r
-\r
-def test_get_cpu_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hostlist = stxSaClientImp.getPserverList()\r
-    assert len(hostlist) > 0\r
-\r
-    cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)\r
-    assert len(cpulist) > 0\r
-    cpu1 = cpulist[0]\r
-    cpu2 = stxSaClientImp.getCpu(cpu1.id)\r
-    assert cpu1 != cpu2\r
-    assert cpu1.id == cpu2.id\r
-\r
-\r
-def test_get_mem_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hostlist = stxSaClientImp.getPserverList()\r
-    assert len(hostlist) > 0\r
-\r
-    memlist = stxSaClientImp.getMemList(hostid=hostlist[0].id)\r
-    assert len(memlist) > 0\r
-    mem1 = memlist[0]\r
-    mem2 = stxSaClientImp.getMem(mem1.id)\r
-    assert mem1 != mem2\r
-    assert mem1.id == mem2.id\r
-\r
-\r
-def test_get_eth_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hostlist = stxSaClientImp.getPserverList()\r
-    assert len(hostlist) > 0\r
-\r
-    ethlist = stxSaClientImp.getEthernetList(hostid=hostlist[0].id)\r
-    assert len(ethlist) > 0\r
-    eth1 = ethlist[0]\r
-    eth2 = stxSaClientImp.getEthernet(eth1.id)\r
-    assert eth1 != eth2\r
-    assert eth1.id == eth2.id\r
-\r
-\r
-def test_get_if_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hostlist = stxSaClientImp.getPserverList()\r
-    assert len(hostlist) > 0\r
-\r
-    iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)\r
-    assert len(iflist) > 0\r
-    if1 = iflist[0]\r
-    if2 = stxSaClientImp.getIf(if1.id)\r
-    assert if1 != if2\r
-    assert if1.id == if2.id\r
-\r
-\r
-def test_get_if_port_list(real_stx_aio_client):\r
-    stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
-    assert stxSaClientImp is not None\r
-    hostlist = stxSaClientImp.getPserverList()\r
-    assert len(hostlist) > 0\r
-\r
-    iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)\r
-    assert len(iflist) > 0\r
-\r
-    portlist = stxSaClientImp.getPortList(interfaceid=iflist[0].id)\r
-    assert len(portlist) > 0\r
-    port1 = portlist[0]\r
-    port2 = stxSaClientImp.getPort(port1.id)\r
-    assert port1 != port2\r
-    assert port1.id == port2.id\r
+# 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.
+
+# import sys
+# import logging
+import pytest
+
+from o2common.config import config
+from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp
+from cgtsclient.client import get_client
+
+
+@pytest.fixture
+def real_stx_aio_client():
+    os_client_args = config.get_stx_access_info()
+    config_client = get_client(**os_client_args)
+    yield config_client
+
+# pytestmark = pytest.mark.usefixtures("mappers")
+
+
+def test_get_instanceinfo(real_stx_aio_client):
+    # logger = logging.getLogger(__name__)
+    stxclientimp = StxSaClientImp(real_stx_aio_client)
+    assert stxclientimp is not None
+    systeminfo = stxclientimp.getInstanceInfo()
+    assert systeminfo is not None
+    assert systeminfo.id is not None
+    assert systeminfo.name is not None
+    assert systeminfo.content is not None
+
+
+def test_get_pserverlist(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hosts = stxSaClientImp.getPserverList()
+    assert hosts is not None
+    assert len(hosts) > 0
+
+
+def test_get_pserver(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hosts = stxSaClientImp.getPserverList()
+    assert hosts is not None
+    assert len(hosts) > 0
+    host1 = hosts[0]
+    host2 = stxSaClientImp.getPserver(host1.id)
+    assert host1 != host2
+    assert host1.id == host2.id
+
+
+def test_get_k8s_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    k8slist = stxSaClientImp.getK8sList()
+    assert k8slist is not None
+    assert len(k8slist) > 0
+    k8s1 = k8slist[0]
+    k8s2 = stxSaClientImp.getK8sDetail(k8s1.name)
+    assert k8s1 != k8s2
+    assert k8s1.name == k8s2.name
+    assert k8s1.id == k8s2.id
+
+
+def test_get_cpu_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hostlist = stxSaClientImp.getPserverList()
+    assert len(hostlist) > 0
+
+    cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)
+    assert len(cpulist) > 0
+    cpu1 = cpulist[0]
+    cpu2 = stxSaClientImp.getCpu(cpu1.id)
+    assert cpu1 != cpu2
+    assert cpu1.id == cpu2.id
+
+
+def test_get_mem_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hostlist = stxSaClientImp.getPserverList()
+    assert len(hostlist) > 0
+
+    memlist = stxSaClientImp.getMemList(hostid=hostlist[0].id)
+    assert len(memlist) > 0
+    mem1 = memlist[0]
+    mem2 = stxSaClientImp.getMem(mem1.id)
+    assert mem1 != mem2
+    assert mem1.id == mem2.id
+
+
+def test_get_eth_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hostlist = stxSaClientImp.getPserverList()
+    assert len(hostlist) > 0
+
+    ethlist = stxSaClientImp.getEthernetList(hostid=hostlist[0].id)
+    assert len(ethlist) > 0
+    eth1 = ethlist[0]
+    eth2 = stxSaClientImp.getEthernet(eth1.id)
+    assert eth1 != eth2
+    assert eth1.id == eth2.id
+
+
+def test_get_if_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hostlist = stxSaClientImp.getPserverList()
+    assert len(hostlist) > 0
+
+    iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)
+    assert len(iflist) > 0
+    if1 = iflist[0]
+    if2 = stxSaClientImp.getIf(if1.id)
+    assert if1 != if2
+    assert if1.id == if2.id
+
+
+def test_get_if_port_list(real_stx_aio_client):
+    stxSaClientImp = StxSaClientImp(real_stx_aio_client)
+    assert stxSaClientImp is not None
+    hostlist = stxSaClientImp.getPserverList()
+    assert len(hostlist) > 0
+
+    iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)
+    assert len(iflist) > 0
+
+    portlist = stxSaClientImp.getPortList(interfaceid=iflist[0].id)
+    assert len(portlist) > 0
+    port1 = portlist[0]
+    port2 = stxSaClientImp.getPort(port1.id)
+    assert port1 != port2
+    assert port1.id == port2.id