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')
 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"
     )
Beispiel #3
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')