Пример #1
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     portGrp = PortGroup()
     portGrp.set_id('portGrp-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.port_group_save(get_admin_context(), portGrp)
     epoch_after = utils.get_current_epoch_ms()
     portGrp_queried = api.port_group_get_by_ids(
         get_admin_context(), [portGrp.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, portGrp_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     portGrp_modified = portGrp_queried
     test_utils.unset_timestamp_fields(portGrp_modified)
     portGrp_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     api.port_group_save(get_admin_context(), portGrp_modified)
     epoch_after = utils.get_current_epoch_ms()
     portGrp_queried = api.port_group_get_by_ids(
         get_admin_context(), [portGrp.get_id()])[0]
     self.assert_(portGrp_modified.get_createEpoch(
     ) == portGrp_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before,
         epoch_after,
         portGrp_queried.get_lastModifiedEpoch()))
Пример #2
0
 def _create_port_group(self, pg_id):
     portGroup = PortGroup()
     portGroup.set_id(pg_id)
     portGroup.set_name(pg_id)
     portGroup.set_resourceManagerId('rmId')
     portGroup.set_type('portgroup_type')
     return portGroup
Пример #3
0
    def test_port_group_delete(self):
        portgroup = PortGroup()
        portgroup.id = 'PG1'
        portgroup.name = 'test'
        portgroup.note = 'note'
        from decimal import Decimal
        portgroup.value = Decimal('123.00')
        portgroup.units = 'uni'
        portgroup.resourceManagerId = 'rm1'
        portgroup.type = 'port'
        portgroup.virtualSwitchId = 'VS1'
        portgroup.vmHostId = 'VM1'
        api.port_group_save(get_admin_context(), portgroup)

        pgs = api.port_group_get_by_ids(get_admin_context(),
                                        [portgroup.id])
        self.assertFalse(len(pgs) == 0, 'Portgroup could not be saved')

        api.port_group_delete_by_ids(get_admin_context(),
                                     [portgroup.id])
        portgroups = api.port_group_get_by_ids(get_admin_context(),
                                               [portgroup.id])

        self.assertTrue(portgroups is None or len(portgroups) == 0,
                        'port group not deleted')
Пример #4
0
 def test_PortGroup_Reconfigured_Event(self):
     cachedHost = VmHost()
     cachedHost.id = self.libvirtNetwork.compute_id
     vswitch = VirtualSwitch()
     vswitch.set_id("11")
     vswitch.set_name("vs1")
     portGroup = PortGroup()
     portGroup.set_id("PortGroup_" + vswitch.get_id())
     portGroup.set_name(vswitch.get_name())
     portGroup.set_virtualSwitchId(vswitch.get_id())
     vswitch.set_portGroups([portGroup])
     cachedHost.set_virtualSwitches([vswitch])
     cachedHost.set_portGroups([portGroup])
     vmhost = copy.deepcopy(cachedHost)
     vmhost.get_portGroups()[0].set_name("vs11")
     vmhost.get_virtualSwitches()[0].set_name("vs11")
     vmhost.get_virtualSwitches()[0].get_portGroups()[0].set_name("vs11")
     self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
     self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
     msg = test_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg['priority'], notifier_api.INFO)
     event_type = event_metadata.get_EventMetaData(
         event_metadata.EVENT_TYPE_PORTGROUP_RECONFIGURED)
     self.assertEquals(msg['event_type'],
                       event_type.get_event_fully_qal_name())
     payload = msg['payload']
     self.assertEquals(payload['entity_type'], 'PortGroup')
     self.assertEquals(payload['entity_id'], portGroup.get_id())
Пример #5
0
 def _create_port_group(self, pg_id):
     portGroup = PortGroup()
     portGroup.set_id(pg_id)
     portGroup.set_name(pg_id)
     portGroup.set_resourceManagerId('rmId')
     portGroup.set_type('portgroup_type')
     return portGroup
 def test_portGroup_deleted_event(self):
     cachedHost = VmHost()
     cachedHost.id = self.libvirtNetwork.compute_id
     vswitch = VirtualSwitch()
     vswitch.set_id("11")
     vswitch.set_name("vs1")
     portGroup = PortGroup()
     portGroup.set_id("PortGroup_" + vswitch.get_id())
     portGroup.set_name(vswitch.get_name())
     portGroup.set_virtualSwitchId(vswitch.get_id())
     vswitch.set_portGroups([portGroup])
     cachedHost.set_virtualSwitches([vswitch])
     cachedHost.set_portGroups([portGroup])
     vmhost = copy.deepcopy(cachedHost)
     vmhost.get_portGroups().pop()
     vmhost.get_virtualSwitches().pop()
     self.assertEquals(vmhost.get_virtualSwitches(), [])
     self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
     self.assertEquals(len(test_notifier.NOTIFICATIONS), 2)
     msg = test_notifier.NOTIFICATIONS[1]
     self.assertEquals(msg["priority"], notifier_api.INFO)
     event_type = event_metadata.get_EventMetaData(event_metadata.EVENT_TYPE_PORTGROUP_DELETED)
     self.assertEquals(msg["event_type"], event_type.get_event_fully_qal_name())
     payload = msg["payload"]
     self.assertEquals(payload["entity_type"], "PortGroup")
     self.assertEquals(payload["entity_id"], portGroup.get_id())
Пример #7
0
 def test_PortGroup_Reconfigured_Event(self):
     cachedHost = VmHost()
     cachedHost.id = self.libvirtNetwork.compute_id
     vswitch = VirtualSwitch()
     vswitch.set_id("11")
     vswitch.set_name("vs1")
     portGroup = PortGroup()
     portGroup.set_id("PortGroup_" + vswitch.get_id())
     portGroup.set_name(vswitch.get_name())
     portGroup.set_virtualSwitchId(vswitch.get_id())
     vswitch.set_portGroups([portGroup])
     cachedHost.set_virtualSwitches([vswitch])
     cachedHost.set_portGroups([portGroup])
     vmhost = copy.deepcopy(cachedHost)
     vmhost.get_portGroups()[0].set_name("vs11")
     vmhost.get_virtualSwitches()[0].set_name("vs11")
     vmhost.get_virtualSwitches()[0].get_portGroups()[0].set_name("vs11")
     self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
     self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
     msg = test_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg['priority'], notifier_api.INFO)
     event_type = event_metadata.get_EventMetaData(
         event_metadata.EVENT_TYPE_PORTGROUP_RECONFIGURED)
     self.assertEquals(msg['event_type'],
                       event_type.get_event_fully_qal_name())
     payload = msg['payload']
     self.assertEquals(payload['entity_type'], 'PortGroup')
     self.assertEquals(payload['entity_id'], portGroup.get_id())
Пример #8
0
    def test_port_group_get_all(self):

        portgroup = PortGroup()

        portgroup.id = 'PG1'
        portgroup.name = 'test'
        portgroup.note = 'note'
        cost = Cost()
        cost.value = Decimal('123.00')
        cost.units = 'INR'
        portgroup.cost = cost
        portgroup.resourceManagerId = 'rm1'
        portgroup.type = 'port'
        portgroup.virtualSwitchId = 'VS1'
        portgroup.vmHostId = 'VM1'
        api.port_group_save(get_admin_context(), portgroup)
        pgs = api.port_group_get_all(get_admin_context())
        indexOfThePG = -1
        for pg in pgs:
            if pg.id == portgroup.id:
                indexOfThePG = pgs.index(pg)
                break

        self.assertTrue(
            portgroup.id == pgs[indexOfThePG].id, 'Portgroup id is invalid')
        self.assertTrue(portgroup.name == pgs[indexOfThePG].name,
                        ' PortGroup name is invalid')
        self.assertTrue(portgroup.note == pgs[indexOfThePG].note,
                        'PortGroup Note is invalid')
        self.assertTrue(portgroup.cost.value == pgs[indexOfThePG]
                        .cost.value, 'PortGroup Value is invalid')
        self.assertTrue(portgroup.cost.units == pgs[indexOfThePG]
                        .cost.units, 'PortGroup Units is invalid')
        self.assertTrue(
            portgroup.resourceManagerId == pgs[indexOfThePG].resourceManagerId,
            'PortGroup resourceManagerId is invalid')
        self.assertTrue(portgroup.get_type(
        ) == pgs[indexOfThePG].get_type(), 'PortGroup type is invalid')
        self.assertTrue(
            portgroup.virtualSwitchId == pgs[indexOfThePG].virtualSwitchId,
            'PortGroup virtualSwitchId is invalid')
        self.assertTrue(portgroup.vmHostId == pgs[indexOfThePG]
                        .vmHostId, 'PortGroup vmHostId is invalid')

        self.assertFalse(pgs is None,
                         'port groups all returned a none list')
        self.assertTrue(len(pgs) == 1,
                        'port groups all returned valid number of list')
    def test_virtual_switch_delete(self):
        virtualswitch = VirtualSwitch()
        virtualswitch.id = "VS1"
        virtualswitch.switchType = "switch"

        portGroup = PortGroup()
        portGroup.set_id("pg-01")
        portGroup.set_name("pg-01")
        portGroup.set_resourceManagerId("rmId")
        portGroup.set_type("portgroup_type")
        virtualswitch.add_portGroups(portGroup)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        # virtualswitchs = api.virtual_switch_get_by_ids([virtualswitch.id])

        api.virtual_switch_delete_by_ids(self.admin_context, [virtualswitch.id])
        virtualswitchs = api.virtual_switch_get_by_ids(self.admin_context, [virtualswitch.id])
        self.assertTrue(virtualswitchs is None or len(virtualswitchs) == 0, "switch not deleted")
Пример #10
0
    def test_virtual_switch_delete(self):
        virtualswitch = VirtualSwitch()
        virtualswitch.id = 'VS1'
        virtualswitch.switchType = 'switch'

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        virtualswitch.add_portGroups(portGroup)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        #virtualswitchs = api.virtual_switch_get_by_ids([virtualswitch.id])

        api.virtual_switch_delete_by_ids(self.admin_context,
                                         [virtualswitch.id])
        virtualswitchs = \
            api.virtual_switch_get_by_ids(self.admin_context,
                                          [virtualswitch.id])
        self.assertTrue(virtualswitchs is None or len(virtualswitchs) == 0,
                        'switch not deleted')
    def test_virtual_switch_delete(self):
        virtualswitch = VirtualSwitch()
        virtualswitch.id = 'VS1'
        virtualswitch.switchType = 'switch'

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        virtualswitch.add_portGroups(portGroup)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        #virtualswitchs = api.virtual_switch_get_by_ids([virtualswitch.id])

        api.virtual_switch_delete_by_ids(self.admin_context,
                                         [virtualswitch.id])
        virtualswitchs = \
            api.virtual_switch_get_by_ids(self.admin_context,
                                          [virtualswitch.id])
        self.assertTrue(virtualswitchs is None or len(virtualswitchs)
                        == 0, 'switch not deleted')
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     virSw1 = VirtualSwitch()
     virSw1.set_id("VS1_VH1")
     portGrp1 = PortGroup()
     portGrp1.set_id("PG1_VH1")
     virSw1.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virSw1)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_createEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     virsw_modified.set_name("changed_name")
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(virsw_modified.get_portGroups()[0].get_createEpoch() == pg.get_createEpoch())
         self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding portgroup to switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     portGrp2 = PortGroup()
     portGrp2.set_id("PG2_VH1")
     virsw_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         if pg.get_id() == portGrp2.get_id():
             self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
         else:
             self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
 def test_virtual_switch_save_with_subnet(self):
     # Save virtual switch with a port group
     vSwitch = VirtualSwitch()
     vSwitch.set_id("vSwitch-11")
     vSwitch.set_name("vSwitch-11")
     vSwitch.set_resourceManagerId("rmId")
     vSwitch.set_switchType("vSwitch")
     cost1 = Cost()
     cost1.set_value(100)
     cost1.set_units("USD")
     vSwitch.set_cost(cost1)
     portGroup = PortGroup()
     portGroup.set_id("pg-01")
     portGroup.set_name("pg-01")
     portGroup.set_resourceManagerId("rmId")
     portGroup.set_type("portgroup_type")
     portGroup.set_cost(cost1)
     vSwitch.add_portGroups(portGroup)
     api.virtual_switch_save(self.admin_context, vSwitch)
     # Update after adding a port group and subnet
     vSwitch = api.virtual_switch_get_by_ids(self.admin_context, [vSwitch.id])[0]
     portGroup2 = PortGroup()
     portGroup2.set_id("pg-02")
     portGroup2.set_name("pg-02")
     portGroup2.set_resourceManagerId("rmId")
     portGroup2.set_type("portgroup_type")
     vSwitch.add_portGroups(portGroup2)
     subnet = Subnet()
     subnet.set_id("subnet-02")
     subnet.set_name("subnet-02")
     subnet.set_networkAddress("1.1.1.1")
     api.subnet_save(self.admin_context, subnet)
     vSwitch.add_subnetIds(subnet.id)
     vSwitch.add_networkInterfaces("1")
     api.virtual_switch_save(self.admin_context, vSwitch)
     virtualswitches = api.virtual_switch_get_by_ids(self.admin_context, [vSwitch.id])
     # Assert the values
     self.assertTrue(len(virtualswitches) == 1, "Unexpected number of Virtual Switch returned")
     self.assertTrue(virtualswitches[0].get_id() == "vSwitch-11", "Virtual Switch id mismatch")
     self.assertTrue(virtualswitches[0].get_name() == "vSwitch-11", "Virtual Switch name mismatch")
     self.assertTrue(
         virtualswitches[0].get_resourceManagerId() == "rmId", "Virtual Switch Resource Manager id mismatch"
     )
     self.assertTrue(virtualswitches[0].get_switchType() == "vSwitch", "Virtual Switch type mismatch")
     cost1 = virtualswitches[0].get_cost()
     self.assertTrue(cost1.get_value() == 100, "VSwitch Cost Value mismatch")
     self.assertTrue(cost1.get_units() == "USD", "VSwitch Cost units mismatch")
     portGroups = virtualswitches[0].get_portGroups()
     self.assertTrue(len(portGroups) == 2, "All the portgroups have not been saved")
     self.assertTrue(portGroups[0].get_id() == "pg-01", "VSwitch Port Group id mismatch")
     self.assertTrue(portGroups[0].get_name() == "pg-01", "VSwitch Port Group Name mismatch")
     self.assertTrue(
         portGroups[0].get_resourceManagerId() == "rmId", "VSwitch portgroup Resource Manager id mismatch"
     )
     self.assertTrue(portGroups[0].get_type() == "portgroup_type", "VSwitch port group type mismatched")
     cost2 = portGroups[0].get_cost()
     self.assertTrue(cost2.get_value() == 100, "PortGroup Cost Value mismatch")
     self.assertTrue(cost2.get_units() == "USD", "PortGroup Cost units mismatch")
     self.assertTrue(portGroups[1].get_id() == "pg-02", "VSwitch Port Group id mismatch")
     self.assertTrue(portGroups[1].get_name() == "pg-02", "VSwitch Port Group Name mismatch")
     self.assertTrue(
         portGroups[1].get_resourceManagerId() == "rmId", "VSwitch portgroup Resource Manager id mismatch"
     )
     self.assertTrue(portGroups[1].get_type() == "portgroup_type", "VSwitch port group type mismatched")
     subnetId = virtualswitches[0].get_subnetIds()
     self.assertTrue(subnetId[0] == "subnet-02", "Virtual Switch subnet id mismatch")
     self.assertTrue(
         virtualswitches[0].get_networkInterfaces()[0] == "1", "Virtual Switch network INterfaces mismatch"
     )
Пример #14
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     vmhost = VmHost()
     vmhost.set_id('VH1')
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     vmhost.add_virtualSwitches(virSw1)
     vmhost.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_createEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, virSw.get_createEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     vmhost_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch(
     ) == vmhost_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding switch and portgroup to host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     virSw2 = VirtualSwitch()
     virSw2.set_id('VS2_VH1')
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virSw2.add_portGroups(portGrp2)
     vmhost_modified.add_virtualSwitches(virSw2)
     vmhost_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch(
     ) == vmhost_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         if virSw.get_id() == virSw2.get_id():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, virSw.get_createEpoch()))
         else:
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             if pg.get_id() == portGrp2.get_id():
                 self.assert_(test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_createEpoch()))
             else:
                 self.assert_(test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for deletedEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_delete_by_ids(
         self.admin_context, [vmhost_queried.get_id()])
     epoch_after = utils.get_current_epoch_ms()
     deleted_host = healthnmon_db_api.vm_host_get_all_by_filters(
         self.admin_context,
         {"id": vmhost_queried.get_id()}, None, None)[0]
     self.assertTrue(deleted_host.get_deleted())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, deleted_host.get_deletedEpoch()))
     deleted_switches = healthnmon_db_api.\
         virtual_switch_get_all_by_filters(self.admin_context,
                                           {"id": (virSw1.get_id(),
                                                   virSw2.get_id())},
                                           None, None)
     for deleted_switch in deleted_switches:
         self.assertTrue(deleted_switch.get_deleted())
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, deleted_switch.get_deletedEpoch()))
         for deleted_portgrp in deleted_switch.get_portGroups():
             self.assertTrue(deleted_portgrp.get_deleted())
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after,
                 deleted_portgrp.get_deletedEpoch()))
Пример #15
0
 def test_virtual_switch_save_with_subnet(self):
     # Save virtual switch with a port group
     vSwitch = VirtualSwitch()
     vSwitch.set_id('vSwitch-11')
     vSwitch.set_name('vSwitch-11')
     vSwitch.set_resourceManagerId('rmId')
     vSwitch.set_switchType('vSwitch')
     cost1 = Cost()
     cost1.set_value(100)
     cost1.set_units('USD')
     vSwitch.set_cost(cost1)
     portGroup = PortGroup()
     portGroup.set_id('pg-01')
     portGroup.set_name('pg-01')
     portGroup.set_resourceManagerId('rmId')
     portGroup.set_type('portgroup_type')
     portGroup.set_cost(cost1)
     vSwitch.add_portGroups(portGroup)
     api.virtual_switch_save(self.admin_context, vSwitch)
     # Update after adding a port group and subnet
     vSwitch = api.virtual_switch_get_by_ids(self.admin_context,
                                             [vSwitch.id])[0]
     portGroup2 = PortGroup()
     portGroup2.set_id('pg-02')
     portGroup2.set_name('pg-02')
     portGroup2.set_resourceManagerId('rmId')
     portGroup2.set_type('portgroup_type')
     vSwitch.add_portGroups(portGroup2)
     subnet = Subnet()
     subnet.set_id('subnet-02')
     subnet.set_name('subnet-02')
     subnet.set_networkAddress('1.1.1.1')
     api.subnet_save(self.admin_context, subnet)
     vSwitch.add_subnetIds(subnet.id)
     vSwitch.add_networkInterfaces('1')
     api.virtual_switch_save(self.admin_context, vSwitch)
     virtualswitches = \
         api.virtual_switch_get_by_ids(self.admin_context,
                                       [vSwitch.id])
     # Assert the values
     self.assertTrue(
         len(virtualswitches) == 1,
         'Unexpected number of Virtual Switch returned')
     self.assertTrue(virtualswitches[0].get_id() == 'vSwitch-11',
                     'Virtual Switch id mismatch')
     self.assertTrue(virtualswitches[0].get_name() == 'vSwitch-11',
                     'Virtual Switch name mismatch')
     self.assertTrue(virtualswitches[0].get_resourceManagerId() == 'rmId',
                     'Virtual Switch Resource Manager id mismatch')
     self.assertTrue(virtualswitches[0].get_switchType() == 'vSwitch',
                     'Virtual Switch type mismatch')
     cost1 = virtualswitches[0].get_cost()
     self.assertTrue(cost1.get_value() == 100,
                     'VSwitch Cost Value mismatch')
     self.assertTrue(cost1.get_units() == 'USD',
                     'VSwitch Cost units mismatch')
     portGroups = virtualswitches[0].get_portGroups()
     self.assertTrue(
         len(portGroups) == 2, 'All the portgroups have not been saved')
     self.assertTrue(portGroups[0].get_id() == 'pg-01',
                     'VSwitch Port Group id mismatch')
     self.assertTrue(portGroups[0].get_name() == 'pg-01',
                     'VSwitch Port Group Name mismatch')
     self.assertTrue(portGroups[0].get_resourceManagerId() == 'rmId',
                     'VSwitch portgroup Resource Manager id mismatch')
     self.assertTrue(portGroups[0].get_type() == 'portgroup_type',
                     'VSwitch port group type mismatched')
     cost2 = portGroups[0].get_cost()
     self.assertTrue(cost2.get_value() == 100,
                     'PortGroup Cost Value mismatch')
     self.assertTrue(cost2.get_units() == 'USD',
                     'PortGroup Cost units mismatch')
     self.assertTrue(portGroups[1].get_id() == 'pg-02',
                     'VSwitch Port Group id mismatch')
     self.assertTrue(portGroups[1].get_name() == 'pg-02',
                     'VSwitch Port Group Name mismatch')
     self.assertTrue(portGroups[1].get_resourceManagerId() == 'rmId',
                     'VSwitch portgroup Resource Manager id mismatch')
     self.assertTrue(portGroups[1].get_type() == 'portgroup_type',
                     'VSwitch port group type mismatched')
     subnetId = virtualswitches[0].get_subnetIds()
     self.assertTrue(subnetId[0] == 'subnet-02',
                     'Virtual Switch subnet id mismatch')
     self.assertTrue(virtualswitches[0].get_networkInterfaces()[0] == '1',
                     'Virtual Switch network INterfaces mismatch')
Пример #16
0
    def test_vm_host_delete(self):
        vmhost_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = vmhost_id
        vSwitch = VirtualSwitch()
        vSwitch.set_id('vSwitch-01')
        vSwitch.set_name('vSwitch-01')
        vSwitch.set_resourceManagerId('rmId')
        vSwitch.set_switchType('vSwitch')

        cost1 = Cost()
        cost1.set_value(100)
        cost1.set_units('USD')
        vSwitch.set_cost(cost1)

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        portGroup.set_cost(cost1)
        vSwitch.add_portGroups(portGroup)
        vmhost.add_virtualSwitches(vSwitch)
        vmhost.add_portGroups(portGroup)
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)

        vmhost2 = VmHost()
        vmhost2.set_id('VH2')
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost2)

        storage = StorageVolume()
        storage.set_id('sv-01')
        storage.set_name('storage-01')
        storage.set_resourceManagerId('rmId')
        storage.set_size(1234)
        storage.set_free(2345)
        storage.set_vmfsVolume(True)
        storage.set_shared(True)
        storage.set_assignedServerCount(1)
        storage.set_volumeType('VMFS')
        storage.set_volumeId('101')

        hostMount1 = HostMountPoint()
        hostMount1.set_path('test_path1')
        hostMount1.set_vmHostId('VH1')
        storage.add_mountPoints(hostMount1)
        hostMount2 = HostMountPoint()
        hostMount2.set_path('test_path2')
        hostMount2.set_vmHostId('VH2')
        storage.add_mountPoints(hostMount2)
        healthnmon_db_api.storage_volume_save(get_admin_context(),
                                              storage)

        vm = Vm()
        vm.set_id('vm-01')
        vm.set_name('vm-01')
        vm.set_vmHostId('VH1')
        healthnmon_db_api.vm_save(get_admin_context(), vm)

        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [vmhost_id])
        self.assertFalse(vmhosts is None,
                         'host get by id returned a none list')
        self.assertTrue(len(vmhosts) > 0,
                        'host get by id returned invalid number of list'
                        )

        healthnmon_db_api.vm_host_delete_by_ids(get_admin_context(),
                                                [vmhost_id])

        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [vmhost_id])
        self.assertTrue(vmhosts is None or len(vmhosts) == 0,
                        'host not deleted')
Пример #17
0
    def test_vm_host_save(self):
        host_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = host_id

        vSwitch = VirtualSwitch()
        vSwitch.set_id('vSwitch-01')
        vSwitch.set_name('vSwitch-01')
        vSwitch.set_resourceManagerId('rmId')
        vSwitch.set_switchType('vSwitch')

        cost1 = Cost()
        cost1.set_value(100)
        cost1.set_units('USD')
        vSwitch.set_cost(cost1)

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        portGroup.set_cost(cost1)
        vSwitch.add_portGroups(portGroup)
        vmhost.add_virtualSwitches(vSwitch)
        vmhost.add_portGroups(portGroup)
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [host_id])
        self.assertFalse(vmhosts is None,
                         'Host get by id returned a none list')
        self.assertTrue(len(vmhosts) > 0,
                        'Host get by id returned invalid number of list'
                        )
        self.assertTrue(
            len(vmhosts[0].get_virtualSwitches()) > 0,
            'Host get by virtual switch returned invalid number of list')
        self.assertTrue(
            len(vmhosts[0].get_portGroups()) > 0,
            'Host get by port group returned invalid number of list')
        self.assertTrue(vmhosts[0].id == host_id)
Пример #18
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virSw1)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         virsw_queried.get_createEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     virsw_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() ==
                  virsw_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(virsw_modified.get_portGroups()[0].get_createEpoch()
                      == pg.get_createEpoch())
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding portgroup to switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virsw_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() ==
                  virsw_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         if pg.get_id() == portGrp2.get_id():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 pg.get_createEpoch()))
         else:
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
Пример #19
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     vmhost = VmHost()
     vmhost.set_id('VH1')
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     vmhost.add_virtualSwitches(virSw1)
     vmhost.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         vmhost_queried.get_createEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             virSw.get_createEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     vmhost_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch() ==
                  vmhost_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding switch and portgroup to host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     virSw2 = VirtualSwitch()
     virSw2.set_id('VS2_VH1')
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virSw2.add_portGroups(portGrp2)
     vmhost_modified.add_virtualSwitches(virSw2)
     vmhost_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch() ==
                  vmhost_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         if virSw.get_id() == virSw2.get_id():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 virSw.get_createEpoch()))
         else:
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after,
                     virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             if pg.get_id() == portGrp2.get_id():
                 self.assert_(
                     test_utils.is_timestamp_between(
                         epoch_before, epoch_after, pg.get_createEpoch()))
             else:
                 self.assert_(
                     test_utils.is_timestamp_between(
                         epoch_before, epoch_after,
                         pg.get_lastModifiedEpoch()))
     # Check for deletedEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_delete_by_ids(self.admin_context,
                                             [vmhost_queried.get_id()])
     epoch_after = utils.get_current_epoch_ms()
     deleted_host = healthnmon_db_api.vm_host_get_all_by_filters(
         self.admin_context, {"id": vmhost_queried.get_id()}, None, None)[0]
     self.assertTrue(deleted_host.get_deleted())
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         deleted_host.get_deletedEpoch()))
     deleted_switches = healthnmon_db_api.virtual_switch_get_all_by_filters(
         self.admin_context, {"id": (virSw1.get_id(), virSw2.get_id())},
         None, None)
     for deleted_switch in deleted_switches:
         self.assertTrue(deleted_switch.get_deleted())
         self.assert_(
             test_utils.is_timestamp_between(
                 epoch_before, epoch_after,
                 deleted_switch.get_deletedEpoch()))
         for deleted_portgrp in deleted_switch.get_portGroups():
             self.assertTrue(deleted_portgrp.get_deleted())
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after,
                     deleted_portgrp.get_deletedEpoch()))
Пример #20
0
    def test_vm_host_save(self):
        host_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = host_id

        vSwitch = VirtualSwitch()
        vSwitch.set_id('vSwitch-01')
        vSwitch.set_name('vSwitch-01')
        vSwitch.set_resourceManagerId('rmId')
        vSwitch.set_switchType('vSwitch')

        cost1 = Cost()
        cost1.set_value(100)
        cost1.set_units('USD')
        vSwitch.set_cost(cost1)

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        portGroup.set_cost(cost1)
        vSwitch.add_portGroups(portGroup)
        vmhost.add_virtualSwitches(vSwitch)
        vmhost.add_portGroups(portGroup)
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [host_id])
        self.assertFalse(vmhosts is None,
                         'Host get by id returned a none list')
        self.assertTrue(
            len(vmhosts) > 0, 'Host get by id returned invalid number of list')
        self.assertTrue(
            len(vmhosts[0].get_virtualSwitches()) > 0,
            'Host get by virtual switch returned invalid number of list')
        self.assertTrue(
            len(vmhosts[0].get_portGroups()) > 0,
            'Host get by port group returned invalid number of list')
        self.assertTrue(vmhosts[0].id == host_id)
Пример #21
0
    def test_vm_host_delete(self):
        vmhost_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = vmhost_id
        vSwitch = VirtualSwitch()
        vSwitch.set_id('vSwitch-01')
        vSwitch.set_name('vSwitch-01')
        vSwitch.set_resourceManagerId('rmId')
        vSwitch.set_switchType('vSwitch')

        cost1 = Cost()
        cost1.set_value(100)
        cost1.set_units('USD')
        vSwitch.set_cost(cost1)

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        portGroup.set_cost(cost1)
        vSwitch.add_portGroups(portGroup)
        vmhost.add_virtualSwitches(vSwitch)
        vmhost.add_portGroups(portGroup)
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)

        vmhost2 = VmHost()
        vmhost2.set_id('VH2')
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost2)

        storage = StorageVolume()
        storage.set_id('sv-01')
        storage.set_name('storage-01')
        storage.set_resourceManagerId('rmId')
        storage.set_size(1234)
        storage.set_free(2345)
        storage.set_vmfsVolume(True)
        storage.set_shared(True)
        storage.set_assignedServerCount(1)
        storage.set_volumeType('VMFS')
        storage.set_volumeId('101')

        hostMount1 = HostMountPoint()
        hostMount1.set_path('test_path1')
        hostMount1.set_vmHostId('VH1')
        storage.add_mountPoints(hostMount1)
        hostMount2 = HostMountPoint()
        hostMount2.set_path('test_path2')
        hostMount2.set_vmHostId('VH2')
        storage.add_mountPoints(hostMount2)
        healthnmon_db_api.storage_volume_save(get_admin_context(), storage)

        vm = Vm()
        vm.set_id('vm-01')
        vm.set_name('vm-01')
        vm.set_vmHostId('VH1')
        healthnmon_db_api.vm_save(get_admin_context(), vm)

        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [vmhost_id])
        self.assertFalse(vmhosts is None,
                         'host get by id returned a none list')
        self.assertTrue(
            len(vmhosts) > 0, 'host get by id returned invalid number of list')

        #        self.assertRaises(Exception, healthnmon_db_api.vm_host_delete_by_ids,([vmhost_id]))

        healthnmon_db_api.vm_host_delete_by_ids(get_admin_context(),
                                                [vmhost_id])

        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [vmhost_id])
        self.assertTrue(vmhosts is None or len(vmhosts) == 0,
                        'host not deleted')
 def test_virtual_switch_save_with_subnet(self):
     # Save virtual switch with a port group
     vSwitch = VirtualSwitch()
     vSwitch.set_id('vSwitch-11')
     vSwitch.set_name('vSwitch-11')
     vSwitch.set_resourceManagerId('rmId')
     vSwitch.set_switchType('vSwitch')
     cost1 = Cost()
     cost1.set_value(100)
     cost1.set_units('USD')
     vSwitch.set_cost(cost1)
     portGroup = PortGroup()
     portGroup.set_id('pg-01')
     portGroup.set_name('pg-01')
     portGroup.set_resourceManagerId('rmId')
     portGroup.set_type('portgroup_type')
     portGroup.set_cost(cost1)
     vSwitch.add_portGroups(portGroup)
     api.virtual_switch_save(self.admin_context, vSwitch)
     # Update after adding a port group and subnet
     vSwitch = api.virtual_switch_get_by_ids(self.admin_context,
                                             [vSwitch.id])[0]
     portGroup2 = PortGroup()
     portGroup2.set_id('pg-02')
     portGroup2.set_name('pg-02')
     portGroup2.set_resourceManagerId('rmId')
     portGroup2.set_type('portgroup_type')
     vSwitch.add_portGroups(portGroup2)
     subnet = Subnet()
     subnet.set_id('subnet-02')
     subnet.set_name('subnet-02')
     subnet.set_networkAddress('1.1.1.1')
     api.subnet_save(self.admin_context, subnet)
     vSwitch.add_subnetIds(subnet.id)
     vSwitch.add_networkInterfaces('1')
     api.virtual_switch_save(self.admin_context, vSwitch)
     virtualswitches = \
         api.virtual_switch_get_by_ids(self.admin_context,
                                       [vSwitch.id])
     # Assert the values
     self.assertTrue(len(virtualswitches) == 1,
                     'Unexpected number of Virtual Switch returned')
     self.assertTrue(virtualswitches[0].get_id(
     ) == 'vSwitch-11', 'Virtual Switch id mismatch')
     self.assertTrue(virtualswitches[0].get_name(
     ) == 'vSwitch-11', 'Virtual Switch name mismatch')
     self.assertTrue(virtualswitches[0].get_resourceManagerId(
     ) == 'rmId', 'Virtual Switch Resource Manager id mismatch')
     self.assertTrue(virtualswitches[0].get_switchType(
     ) == 'vSwitch', 'Virtual Switch type mismatch')
     cost1 = virtualswitches[0].get_cost()
     self.assertTrue(
         cost1.get_value() == 100, 'VSwitch Cost Value mismatch')
     self.assertTrue(
         cost1.get_units() == 'USD', 'VSwitch Cost units mismatch')
     portGroups = virtualswitches[0].get_portGroups()
     self.assertTrue(
         len(portGroups) == 2, 'All the portgroups have not been saved')
     self.assertTrue(portGroups[0].get_id(
     ) == 'pg-01', 'VSwitch Port Group id mismatch')
     self.assertTrue(portGroups[0].get_name(
     ) == 'pg-01', 'VSwitch Port Group Name mismatch')
     self.assertTrue(portGroups[0].get_resourceManagerId(
     ) == 'rmId', 'VSwitch portgroup Resource Manager id mismatch')
     self.assertTrue(portGroups[0].get_type(
     ) == 'portgroup_type', 'VSwitch port group type mismatched')
     cost2 = portGroups[0].get_cost()
     self.assertTrue(
         cost2.get_value() == 100, 'PortGroup Cost Value mismatch')
     self.assertTrue(
         cost2.get_units() == 'USD', 'PortGroup Cost units mismatch')
     self.assertTrue(portGroups[1].get_id(
     ) == 'pg-02', 'VSwitch Port Group id mismatch')
     self.assertTrue(portGroups[1].get_name(
     ) == 'pg-02', 'VSwitch Port Group Name mismatch')
     self.assertTrue(portGroups[1].get_resourceManagerId(
     ) == 'rmId', 'VSwitch portgroup Resource Manager id mismatch')
     self.assertTrue(portGroups[1].get_type(
     ) == 'portgroup_type', 'VSwitch port group type mismatched')
     subnetId = virtualswitches[0].get_subnetIds()
     self.assertTrue(
         subnetId[0] == 'subnet-02', 'Virtual Switch subnet id mismatch')
     self.assertTrue(virtualswitches[0].get_networkInterfaces(
     )[0] == '1', 'Virtual Switch network INterfaces mismatch')