Exemple #1
0
 def test_model_host(self):
     key = "host1"
     name = "hostname1"
     host = model.Host(name, key)
     self.assertFalse(host.uuid is None, "Host uuid is none")
     self.assertEqual(host.key, key, "Host key does not match")
     self.assertEqual(host.name, name, "Host name does not match")
     self.assertTrue(str(host) is not None)
Exemple #2
0
 def create_port(self, network, net_id, port, virtual_nic):
     device_id = port.vm_id
     cluster_mor, cluster_path, switch = self._find_cluster_switch_for_vm(
         device_id)
     host_mors = self.is_valid_switch(cluster_mor, switch)
     if not host_mors:
         LOG.error(_LE("Invalid Switch: %(sw)s for cluster: %(cp)s."),
                   {'sw': switch, 'cp': cluster_path})
         raise error.VcenterConfigurationError("Invalid Switch: %s for "
                                               "cluster: %s." %
                                               (switch, cluster_path))
     hosts = []
     for host_mor in host_mors:
         hosts.append(model.Host(key=host_mor.value))
     vswitch = model.VirtualSwitch(switch, hosts=hosts)
     self.create_network(network, net_id, vswitch)