當前位置: 首頁>>代碼示例>>Python>>正文


Python NailgunClient.list_nodes方法代碼示例

本文整理匯總了Python中fuelweb_test.models.nailgun_client.NailgunClient.list_nodes方法的典型用法代碼示例。如果您正苦於以下問題:Python NailgunClient.list_nodes方法的具體用法?Python NailgunClient.list_nodes怎麽用?Python NailgunClient.list_nodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fuelweb_test.models.nailgun_client.NailgunClient的用法示例。


在下文中一共展示了NailgunClient.list_nodes方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: remove_env

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]
def remove_env(admin_node_ip, env_name, dont_wait_for_nodes=True):

    LOG.info('Removing cluster with name:{0}'.format(env_name))
    client = NailgunClient(admin_node_ip)
    cluster_id = client.get_cluster_id(env_name)
    all_nodes = []

    if cluster_id:
        cluster_nodes = client.list_cluster_nodes(cluster_id)
        if len(cluster_nodes) > 0:
            all_nodes = client.list_nodes()
        client.delete_cluster(cluster_id)
    else:
        LOG.info('Looks like cluster has not been created before.Okay')
        return "OK"

    # wait for cluster to disappear
    rerty_c = 120
    for i in range(rerty_c):
        cluster_id = client.get_cluster_id(env_name)
        LOG.info('Wait for cluster to disappear...try %s /%s' % (i, rerty_c))
        if cluster_id:
            time.sleep(10)
        else:
            break

    # fail if cluster is still around
    if cluster_id:
        return "Can't delete cluster"

    # wait for removed nodes to come back online
    if not dont_wait_for_nodes:
        for i in range(90):
            cur_nodes = client.list_nodes()
            if len(cur_nodes) < len(all_nodes):
                LOG.info('Wait for nodes to came back. Should be:{0} '
                         'Currently:{1} ...try {2}'.format(
                            len(all_nodes), len(cur_nodes), i))
                time.sleep(10)

    if len(client.list_nodes()) < len(all_nodes) and not dont_wait_for_nodes:
        return "Timeout while waiting for removed nodes ({}) to come back up".format(
            len(cluster_nodes))

    return "OK"
開發者ID:alexz-kh,項目名稱:fuel_manage_env,代碼行數:47,代碼來源:manage_env.py

示例2: remove_env

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]
def remove_env(admin_node_ip, env_name, dont_wait_for_nodes):

  client = NailgunClient(admin_node_ip)
  cluster_id = client.get_cluster_id(env_name)
  need_to_wait_for_nodes = False
  all_nodes = []

  if cluster_id:
    cluster_nodes = client.list_cluster_nodes(cluster_id)
    if len(cluster_nodes) > 0:
      need_to_wait_for_nodes = True
      all_nodes = client.list_nodes()
    client.delete_cluster(cluster_id)
  else:
    return "OK"

  # wait for cluster to disappear
  for i in range(60):
    cluster_id = client.get_cluster_id(env_name)
    if cluster_id:
      time.sleep(10)

  # fail if cluster is still around
  if cluster_id:
    return "Can't delete cluster"

  # wait for removed nodes to come back online
  if not dont_wait_for_nodes:
    for i in range(90):
      cur_nodes = client.list_nodes()
      if len(cur_nodes) < len(all_nodes):
        time.sleep(10)

  if len(cur_nodes) < len(all_nodes) and not dont_wait_for_nodes:
    return "Timeout while waiting for removed nodes ({}) to come back up".format(len(cluster_nodes))

  return "OK"
開發者ID:adidenko,項目名稱:fuel_bm_tests,代碼行數:39,代碼來源:manage_env.py

示例3: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
    @logwrap
    def get_pacemaker_config(self, controller_node_name):
        remote = self.get_ssh_for_node(controller_node_name)
        return "".join(remote.check_call("crm configure show")["stdout"])

    @logwrap
    def get_last_created_cluster(self):
        # return id of last created cluster
        clusters = self.client.list_clusters()
        if len(clusters) > 0:
            return clusters.pop()["id"]
        return None

    @logwrap
    def get_nailgun_node_roles(self, nodes_dict):
        nailgun_node_roles = []
        for node_name in nodes_dict:
            slave = self.environment.get_virtual_environment().node_by_name(node_name)
            node = self.get_nailgun_node_by_devops_node(slave)
            nailgun_node_roles.append((node, nodes_dict[node_name]))
        return nailgun_node_roles

    @logwrap
    def get_nailgun_node_by_name(self, node_name):
        return self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))

    @logwrap
    def get_nailgun_node_by_devops_node(self, devops_node):
        """Return slave node description.
        Returns dict with nailgun slave node description if node is
        registered. Otherwise return None.
        """
        mac_addresses = map(lambda interface: interface.mac_address.capitalize(), devops_node.interfaces)
        for nailgun_node in self.client.list_nodes():
            if nailgun_node["mac"].capitalize() in mac_addresses:
                nailgun_node["devops_name"] = devops_node.name
                return nailgun_node

        return None

    @logwrap
    def get_ssh_for_node(self, node_name):
        ip = self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))[
            "ip"
        ]
        return self.environment.get_ssh_to_remote(ip)

    @logwrap
    def get_ssh_for_role(self, nodes_dict, role):
        node_name = sorted(filter(lambda name: role in nodes_dict[name], nodes_dict.keys()))[0]
        return self.get_ssh_for_node(node_name)

    @logwrap
    def is_node_discovered(self, nailgun_node):
        return any(
            map(
                lambda node: node["mac"] == nailgun_node["mac"] and node["status"] == "discover",
                self.client.list_nodes(),
            )
        )

    @logwrap
    def run_network_verify(self, cluster_id):
        return self.client.verify_networks(cluster_id, self.client.get_networks(cluster_id)["networks"])

    @logwrap
開發者ID:piousbox,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例4: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
    @logwrap
    def get_last_created_cluster(self):
        # return id of last created cluster
        clusters = self.client.list_clusters()
        if len(clusters) > 0:
            return clusters.pop()['id']
        return None

    @logwrap
    def get_nailgun_node_roles(self, nodes_dict):
        nailgun_node_roles = []
        for node_name in nodes_dict:
            slave = self.environment.get_virtual_environment().\
                node_by_name(node_name)
            node = self.get_nailgun_node_by_devops_node(slave)
            nailgun_node_roles.append((node, nodes_dict[node_name]))
        return nailgun_node_roles

    @logwrap
    def get_nailgun_node_by_name(self, node_name):
        return self.get_nailgun_node_by_devops_node(
            self.environment.get_virtual_environment().node_by_name(node_name))

    @logwrap
    def get_nailgun_node_by_devops_node(self, devops_node):
        """
        Returns dict with nailgun slave node description if node is
        registered. Otherwise return None.
        """
        mac_addresses = map(
            lambda interface: interface.mac_address.capitalize(),
            devops_node.interfaces
        )
        for nailgun_node in self.client.list_nodes():
            if nailgun_node['mac'].capitalize() in mac_addresses:
                nailgun_node['devops_name'] = devops_node.name
                return nailgun_node

        return None

    @logwrap
    def get_ssh_for_node(self, node_name):
        ip = self.get_nailgun_node_by_devops_node(
            self.environment.get_virtual_environment().
            node_by_name(node_name))['ip']
        return self.environment.get_ssh_to_remote(ip)

    @logwrap
    def get_ssh_for_role(self, nodes_dict, role):
        node_name = sorted(filter(lambda name: role in nodes_dict[name],
                           nodes_dict.keys()))[0]
        return self.get_ssh_for_node(node_name)

    @logwrap
    def is_node_discovered(self, nailgun_node):
        return any(
            map(lambda node: node['mac'] == nailgun_node['mac']
                and node['status'] == 'discover', self.client.list_nodes()))

    @logwrap
    def run_network_verify(self, cluster_id):
        return self.client.verify_networks(
            cluster_id, self.client.get_networks(cluster_id)['networks'])

    @logwrap
    def run_ostf(self, cluster_id, test_sets=None,
開發者ID:korshenin,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例5: len

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]
    # add nodes into cluster and set roles

    # simple check for enough nodes count
    # FIXME
    if assign_method == 'hw_pin':
        should_be_nodes = len(lab_config['nodes'].keys())
    else:
        should_be_nodes = lab_config['roller']['controller']['count'] + \
                          lab_config['roller']['compute']['count']
    wait_free_nodes(lab_config, should_be_nodes)

    # add nodes to cluster
    LOG.info("StageX:START Assign nodes to cluster")
    if assign_method == 'hw_pin':
        while len(client.list_cluster_nodes(cluster_id)) < should_be_nodes:
            for node in client.list_nodes():
                node_new = strict_pin_node_to_cluster(node, lab_config)
                if node_new:
                    client.update_node(node['id'], node_new)
            # FIXME add at least timeout
            time.sleep(5)
    else:
        client.update_nodes(simple_pin_nodes_to_cluster(client.list_nodes(),
                                                        lab_config['roller']))
    LOG.info("StageX: END Assign nodes to cluster")

    # assign\create network role to nic per node
    LOG.info("StageX: Assign network role to nic per node")
    if assign_method == 'hw_pin':
        for node in client.list_cluster_nodes(cluster_id):
            upd_ifs = strict_pin_nw_to_node(node, client.get_node_interfaces(
開發者ID:alexz-kh,項目名稱:fuel_manage_env,代碼行數:33,代碼來源:manage_env.py

示例6: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
    @logwrap
    def get_last_created_cluster(self):
        # return id of last created cluster
        logger.info('Get ID of a last created cluster')
        clusters = self.client.list_clusters()
        if len(clusters) > 0:
            return clusters.pop()['id']
        return None

    @logwrap
    def get_nailgun_node_roles(self, nodes_dict):
        nailgun_node_roles = []
        for node_name in nodes_dict:
            slave = self.environment.get_virtual_environment().\
                node_by_name(node_name)
            node = self.get_nailgun_node_by_devops_node(slave)
            nailgun_node_roles.append((node, nodes_dict[node_name]))
        return nailgun_node_roles

    @logwrap
    def get_nailgun_node_by_name(self, node_name):
        logger.info('Get nailgun node by %s devops node', node_name)
        return self.get_nailgun_node_by_devops_node(
            self.environment.get_virtual_environment().node_by_name(node_name))

    @logwrap
    def get_nailgun_node_by_devops_node(self, devops_node):
        """Return slave node description.
        Returns dict with nailgun slave node description if node is
        registered. Otherwise return None.
        """
        devops_macs = {i.mac_address.upper() for i in devops_node.interfaces}
        logger.debug('Look for nailgun node by macs %s', devops_macs)
        for nailgun_node in self.client.list_nodes():
            macs = {i['mac'] for i in nailgun_node['meta']['interfaces']}
            if devops_macs == macs:
                nailgun_node['devops_name'] = devops_node.name
                return nailgun_node
        return None

    @logwrap
    def get_ssh_for_node(self, node_name):
        ip = self.get_nailgun_node_by_devops_node(
            self.environment.get_virtual_environment().
            node_by_name(node_name))['ip']
        return self.environment.get_ssh_to_remote(ip)

    @logwrap
    def get_ssh_for_role(self, nodes_dict, role):
        node_name = sorted(filter(lambda name: role in nodes_dict[name],
                           nodes_dict.keys()))[0]
        return self.get_ssh_for_node(node_name)

    @logwrap
    def is_node_discovered(self, nailgun_node):
        return any(
            map(lambda node: node['mac'] == nailgun_node['mac']
                and node['status'] == 'discover', self.client.list_nodes()))

    @logwrap
    def run_network_verify(self, cluster_id):
        logger.info('Run network verification at cluster %s', cluster_id)
        return self.client.verify_networks(
            cluster_id, self.client.get_networks(cluster_id)['networks'])

    @logwrap
開發者ID:shaikapsar,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例7: setup_env

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
      network['network_size'] = len(list(IPNetwork((network['cidr']))))

  network_conf['networks'] = network_list

  # update neutron settings
  if "net_provider" in env.settings:
    if env.settings["net_provider"] == 'neutron':
      # check if we need to set vlan tags
      if env.settings["net_segment_type"] == 'vlan' and 'neutron_vlan_range' in env.settings:
        network_conf['neutron_parameters']['L2']['phys_nets']['physnet2']['vlan_range'] = env.settings['neutron_vlan_range']
      # check and update networks CIDR/netmask/size/etc
      if 'net04' in env.net_cidr:
        network_conf['neutron_parameters']['predefined_networks']['net04']['L3']['cidr'] = env.net_cidr['net04']
        network_conf['neutron_parameters']['predefined_networks']['net04']['L3']['gateway'] = str(list(IPNetwork(env.net_cidr['net04']))[1])
      if 'public' in env.net_cidr:
        network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['cidr'] = env.net_cidr['public']
        if env.gateway:
          network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['gateway'] = env.gateway
        else:
          network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['gateway'] = str(list(IPNetwork(env.net_cidr['public']))[1])
        if 'net04_ext' in env.net_ip_ranges:
          network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['floating'] = env.net_ip_ranges["net04_ext"]
        else:
          network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['floating'] = get_range(env.net_cidr['public'], 2)

  # push updated network to Fuel API
  client.update_network(cluster_id, networks=network_conf, all_set=True)

  # configure cluster attributes
  attributes = client.get_cluster_attributes(cluster_id)

  for option in env.settings:
    section = False
    if option in ('savanna', 'murano', 'ceilometer'):
      section = 'additional_components'
    if option in ('volumes_ceph', 'images_ceph', 'volumes_lvm'):
      section = 'storage'
    if option in ('libvirt_type', 'vlan_splinters'):
      section = 'common'
    if section:
      attributes['editable'][section][option]['value'] = env.settings[option]

  attributes['editable']['common']['debug']['value'] = True
  client.update_cluster_attributes(cluster_id, attributes)

  # get all nodes
  for i in range(18):
    all_nodes = client.list_nodes()
    if len(all_nodes) < len(env.node_roles) + len(env.special_roles):
      time.sleep(10)

  # check if we have enough nodes for our test case
  if len(all_nodes) < len(env.node_roles) + len(env.special_roles):
    return "Not enough nodes"

  nodes_data = []
  node_local_id = 0

  # go through unassigned nodes and update their pending_roles according to environment settings
  for node in all_nodes:
    if node['cluster'] == None and (node_local_id < len(env.node_roles) or node['mac'] in env.special_roles):
      if node['mac'] in env.special_roles:
        node_role = env.special_roles[node['mac']]
      else:
        node_role = env.node_roles[node_local_id]
        node_local_id += 1
      node_data = {
        'cluster_id': cluster_id,
        'id': node['id'],
        'pending_addition': "true",
        'pending_roles': node_role
      }
      nodes_data.append(node_data)

  # add nodes to cluster
  client.update_nodes(nodes_data)

  # check if we assigned all nodes we wanted to
  cluster_nodes = client.list_cluster_nodes(cluster_id)
  if len(cluster_nodes) != len(env.node_roles) + len(env.special_roles):
    return "Not enough nodes"

  # move networks to appropriate nodes interfaces (according to environment settings)
  for node in cluster_nodes:
    node_id = node['id']
    interfaces_dict = env.interfaces
    interfaces = client.get_node_interfaces(node_id)
    for interface in interfaces:
      interface_name = interface['name']
      interface['assigned_networks'] = []
      for allowed_network in interface['allowed_networks']:
        key_exists = interface_name in interfaces_dict
        if key_exists and \
        allowed_network['name'] \
        in interfaces_dict[interface_name]:
          interface['assigned_networks'].append(allowed_network)

    client.put_node_interfaces(
      [{'id': node_id, 'interfaces': interfaces}])
  return "OK"
開發者ID:teran,項目名稱:fuel_bm_tests,代碼行數:104,代碼來源:manage_env.py

示例8: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
            return clusters.pop()['id']
        return None

    @logwrap
    def get_nailgun_node_roles(self, nodes_dict):
        nailgun_node_roles = []
        for node_name in nodes_dict:
            slave = self.environment.get_virtual_environment().\
                node_by_name(node_name)
            node = self.get_nailgun_node_by_devops_node(slave)
            nailgun_node_roles.append((node, nodes_dict[node_name]))
        return nailgun_node_roles

    @logwrap
    def get_nailgun_node_by_name(self, node_name):
        logger.info('Get nailgun node by %s devops node', node_name)
        return self.get_nailgun_node_by_devops_node(
            self.environment.get_virtual_environment().node_by_name(node_name))

    @logwrap
    def get_nailgun_node_by_devops_node(self, devops_node):
        """Return slave node description.
        Returns dict with nailgun slave node description if node is
        registered. Otherwise return None.
        """
        d_macs = {i.mac_address.upper() for i in devops_node.interfaces}
        logger.debug('Verify that nailgun api is running')
        attempts = ATTEMPTS
        while attempts > 0:
            logger.debug(
                'current timeouts is {0} count of '
                'attempts is {1}'.format(TIMEOUT, attempts))
            try:
                self.client.list_nodes()
                attempts = 0
            except Exception:
                logger.debug(traceback.format_exc())
                attempts -= 1
                time.sleep(TIMEOUT)
        logger.debug('Look for nailgun node by macs %s', d_macs)
        for nailgun_node in self.client.list_nodes():
            macs = {i['mac'] for i in nailgun_node['meta']['interfaces']}
            logger.debug('Look for macs returned by nailgun {0}'.format(macs))
            # Because our HAproxy may create some interfaces
            if d_macs.issubset(macs):
                nailgun_node['devops_name'] = devops_node.name
                return nailgun_node
        return None

    @logwrap
    def find_devops_node_by_nailgun_fqdn(self, fqdn, devops_nodes):
        def get_nailgun_node(fqdn):
            for nailgun_node in self.client.list_nodes():
                if nailgun_node['meta']['system']['fqdn'] == fqdn:
                    return nailgun_node

        nailgun_node = get_nailgun_node(fqdn)
        macs = {i['mac'] for i in nailgun_node['meta']['interfaces']}
        for devops_node in devops_nodes:
            devops_macs = {i.mac_address.upper()
                           for i in devops_node.interfaces}
            if devops_macs == macs:
                return devops_node

    @logwrap
    def get_ssh_for_node(self, node_name):
開發者ID:igajsin,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例9: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import list_nodes [as 別名]

#.........這裏部分代碼省略.........
    def get_cluster_block_devices(self, node_name):
        remote = self.get_ssh_for_node(node_name)
        ret = remote.check_call("/bin/lsblk")
        return "".join(ret["stdout"])

    @logwrap
    def get_last_created_cluster(self):
        # return id of last created cluster
        clusters = self.client.list_clusters()
        if len(clusters) > 0:
            return clusters.pop()["id"]
        return None

    @logwrap
    def get_nailgun_node_roles(self, nodes_dict):
        nailgun_node_roles = []
        for node_name in nodes_dict:
            slave = self.environment.get_virtual_environment().node_by_name(node_name)
            node = self.get_nailgun_node_by_devops_node(slave)
            nailgun_node_roles.append((node, nodes_dict[node_name]))
        return nailgun_node_roles

    @logwrap
    def get_nailgun_node_by_name(self, node_name):
        return self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))

    @logwrap
    def get_nailgun_node_by_devops_node(self, devops_node):
        """
        Returns dict with nailgun slave node description if node is
        registered. Otherwise return None.
        """
        mac_addresses = map(lambda interface: interface.mac_address.capitalize(), devops_node.interfaces)
        for nailgun_node in self.client.list_nodes():
            if nailgun_node["mac"].capitalize() in mac_addresses:
                nailgun_node["devops_name"] = devops_node.name
                return nailgun_node

        return None

    @logwrap
    def get_ssh_for_node(self, node_name):
        ip = self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))[
            "ip"
        ]
        return self.environment.get_ssh_to_remote(ip)

    @logwrap
    def get_ssh_for_role(self, nodes_dict, role):
        node_name = sorted(filter(lambda name: role in nodes_dict[name], nodes_dict.keys()))[0]
        return self.get_ssh_for_node(node_name)

    @logwrap
    def is_node_discovered(self, nailgun_node):
        return any(
            map(
                lambda node: node["mac"] == nailgun_node["mac"] and node["status"] == "discover",
                self.client.list_nodes(),
            )
        )

    @logwrap
    def run_network_verify(self, cluster_id):
        return self.client.verify_networks(cluster_id, self.client.get_networks(cluster_id)["networks"])

    @logwrap
開發者ID:justasabc,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py


注:本文中的fuelweb_test.models.nailgun_client.NailgunClient.list_nodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。