コード例 #1
0
 def __init__(self):
     super(VMWareNodes, self).__init__()
     self.cluster_name = config.ENV_DATA.get("cluster_name")
     self.server = config.ENV_DATA['vsphere_server']
     self.user = config.ENV_DATA['vsphere_user']
     self.password = config.ENV_DATA['vsphere_password']
     self.cluster = config.ENV_DATA['vsphere_cluster']
     self.datacenter = config.ENV_DATA['vsphere_datacenter']
     self.vsphere = vsphere.VSPHERE(self.server, self.user, self.password)
コード例 #2
0
ファイル: bootstrap.py プロジェクト: xenolinux/ocs-ci
def get_node_data_vsphere():
    """
    Retrieve bootstrap public IP and master node private IPs running in vsphere

    Raises:
        NodeNotFoundError: If we are unable to find the bootstrap node or IP

    Returns:
        dict: bootstrap and master node IP data

    """
    server = config.ENV_DATA['vsphere_server']
    user = config.ENV_DATA['vsphere_user']
    password = config.ENV_DATA['vsphere_password']
    cluster = config.ENV_DATA['vsphere_cluster']
    datacenter = config.ENV_DATA['vsphere_datacenter']
    pool = config.ENV_DATA['cluster_name']
    _vsphere = vsphere.VSPHERE(server, user, password)
    bootstrap_name = "bootstrap-0"
    master_pattern = "control-plane"
    data = dict()
    try:
        bootstrap_vm = _vsphere.get_vm_in_pool_by_name(
            bootstrap_name, datacenter, cluster, pool
        )
        bootstrap_ip = _vsphere.get_vms_ips([bootstrap_vm])[0]
        logger.info(
            "Found bootstrap node %s with IP %s", bootstrap_name, bootstrap_ip
        )
        data['bootstrap_ip'] = bootstrap_ip
    except IndexError:
        raise NodeNotFoundError(
            f"Unable to find bootstrap node with name {bootstrap_name}"
        )
    master_ips = list()
    for i in range(config.ENV_DATA['master_replicas']):
        master_name = f"{master_pattern}-{i}"
        master_node = _vsphere.get_vm_in_pool_by_name(
            master_name, datacenter, cluster, pool
        )
        master_ip = _vsphere.get_vms_ips([master_node])[0]
        if master_ip:
            logger.info(
                "Found master node %s with IP %s", master_name, master_ip
            )
            master_ips.append(master_ip)
        else:
            logger.warning("Unable to find IP for node %s", master_name)
    data['master_ips'] = master_ips
    logger.debug(data)
    return data