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


Python NailgunClient.create_cluster方法代碼示例

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


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

示例1: FuelWebClient

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

#.........這裏部分代碼省略.........
                                   ''.format(passed, should_pass))
        assert_true(
            failed <= should_fail, 'Failed tests,  fails: {} should fail: {}'
                                   ''.format(failed, should_fail))

    def assert_release_state(self, release_name, state='available'):
        for release in self.client.get_releases():
            if release["name"].find(release_name) != -1:
                assert_equal(release['state'], state)
                return release["id"]

    @logwrap
    def assert_task_success(self, task, timeout=110 * 60, interval=5):
        task = self.task_wait(task, timeout, interval)
        assert_equal(
            task['status'], 'ready',
            "Task '{name}' has incorrect status. {} != {}".format(
                task['status'], 'ready', name=task["name"]
            )
        )

    @logwrap
    def assert_task_failed(self, task, timeout=70 * 60, interval=5):
        task = self.task_wait(task, timeout, interval)
        assert_equal(
            'error', task['status'],
            "Task '{name}' has incorrect status. {} != {}".format(
                task['status'], 'error', name=task["name"]
            )
        )

    @logwrap
    @upload_manifests
    def create_cluster(self,
                       name,
                       settings=None,
                       release_name=help_data.OPENSTACK_RELEASE,
                       mode=DEPLOYMENT_MODE_SIMPLE,
                       port=5514):
        """
        :param name:
        :param release_name:
        :param mode:
        :param settings:
        :param port:
        :return: cluster_id
        """
        #TODO back
        release_id = self.client.get_release_id(release_name=release_name)
        logging.info('Release_id is %s' % str(release_id))

        if settings is None:
            settings = {}

        logging.info('I pass if with settings')

        cluster_id = self.client.get_cluster_id(name)
        if not cluster_id:
            logging.info('I have no id')
            data = {
                "name": name,
                "release": str(release_id),
                "mode": mode
            }

            if "net_provider" in settings:
開發者ID:korshenin,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例2: FuelWebClient

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

#.........這裏部分代碼省略.........
    @logwrap
    def assert_task_failed(self, task, timeout=70 * 60, interval=5):
        task = self.task_wait(task, timeout, interval)
        assert_equal(
            "error",
            task["status"],
            "Task '{name}' has incorrect status. {} != {}".format(task["status"], "error", name=task["name"]),
        )

    @logwrap
    def fqdn(self, devops_node):
        nailgun_node = self.get_nailgun_node_by_devops_node(devops_node)
        if OPENSTACK_RELEASE_UBUNTU in OPENSTACK_RELEASE:
            return nailgun_node["meta"]["system"]["fqdn"]
        return nailgun_node["fqdn"]

    @logwrap
    def assert_pacemaker(self, ctrl_node, online_nodes, offline_nodes):
        fqdn_names = lambda nodes: sorted([self.fqdn(n) for n in nodes])

        # Assert online nodes list
        online = "Online: [ {0} ]".format(" ".join(fqdn_names(online_nodes)))
        wait(lambda: online in self.get_pacemaker_status(ctrl_node), timeout=30)
        assert_true(online in self.get_pacemaker_status(ctrl_node))

        # Assert offline nodes list
        if len(offline_nodes) > 0:
            offline = "OFFLINE: [ {0} ]".format(" ".join(fqdn_names(offline_nodes)))
            wait(lambda: offline in self.get_pacemaker_status(ctrl_node), timeout=30)
            assert_true(offline in self.get_pacemaker_status(ctrl_node))

    @logwrap
    @upload_manifests
    def create_cluster(
        self, name, settings=None, release_name=help_data.OPENSTACK_RELEASE, mode=DEPLOYMENT_MODE_SIMPLE, port=5514
    ):
        """Creates a cluster
        :param name:
        :param release_name:
        :param mode:
        :param settings:
        :param port:
        :return: cluster_id
        """

        release_id = self.client.get_release_id(release_name=release_name)
        logging.info("Release_id is %s" % str(release_id))

        if settings is None:
            settings = {}

        logging.info("I pass if with settings")

        cluster_id = self.client.get_cluster_id(name)
        if not cluster_id:
            logging.info("I have no id")
            data = {"name": name, "release": str(release_id), "mode": mode}

            if "net_provider" in settings:
                data.update(
                    {"net_provider": settings["net_provider"], "net_segment_type": settings["net_segment_type"]}
                )

            self.client.create_cluster(data=data)
            cluster_id = self.client.get_cluster_id(name)
開發者ID:piousbox,項目名稱:fuel-main,代碼行數:69,代碼來源:fuel_web_client.py

示例3: remove_env

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import create_cluster [as 別名]
            'Skipping node ID:{0} not from cluster:{2},ID{1}'.format(
                node['id'], cluster['cluster_id'], cluster['name']))
        return None

############################################################
############################################################

if __name__ == '__main__':

    assign_method = lab_config.get('assign_method', 'simple')

    # remove cluster, and create new
    remove_env(lab_config["fuel-master"], lab_config["cluster"]["name"])
    LOG.info('Creating cluster with:{0}'.format(
        pprinter.pformat(lab_config["cluster"])))
    client.create_cluster(data=lab_config["cluster"])

    # update network and attributes
    cluster_id = client.get_cluster_id(lab_config["cluster"]["name"])
    if cluster_id is None:
        LOG.error(
            'Cluster with name %s not found!' % (lab_config["cluster"]["name"]))
        sys.exit(1)

    cluster_attributes = client.get_cluster_attributes(cluster_id)
    cluster_net = client.get_networks(cluster_id)

    for network in cluster_net["networks"]:
        network_name = network["name"]
        if network_name in lab_config["nets"]:
            for value in lab_config["nets"][network_name]:
開發者ID:alexz-kh,項目名稱:fuel_manage_env,代碼行數:33,代碼來源:manage_env.py

示例4: FuelWebClient

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

#.........這裏部分代碼省略.........
        logger.info('Get FQDN of a devops node %s', devops_node.name)
        nailgun_node = self.get_nailgun_node_by_devops_node(devops_node)
        if OPENSTACK_RELEASE_UBUNTU in OPENSTACK_RELEASE:
            return nailgun_node['meta']['system']['fqdn']
        return nailgun_node['fqdn']

    @logwrap
    def assert_pacemaker(self, ctrl_node, online_nodes, offline_nodes):
        logger.info('Assert pacemaker status at devops node %s', ctrl_node)
        fqdn_names = lambda nodes: sorted([self.fqdn(n) for n in nodes])

        # Assert online nodes list
        online = \
            'Online: [ {0} ]'.format(' '.join(fqdn_names(online_nodes)))
        wait(lambda: online in self.get_pacemaker_status(
            ctrl_node), timeout=30)
        assert_true(
            online in self.get_pacemaker_status(ctrl_node),
            'Online nodes {0}'.format(online))

        # Assert offline nodes list
        if len(offline_nodes) > 0:
            offline = \
                'OFFLINE: [ {0} ]'.format(
                    ' '.join(fqdn_names(offline_nodes)))
            wait(lambda: offline in self.get_pacemaker_status(
                ctrl_node), timeout=30)
            assert_true(
                offline in self.get_pacemaker_status(ctrl_node),
                'Offline nodes {0}'.format(offline_nodes))

    @logwrap
    @upload_manifests
    def create_cluster(self,
                       name,
                       settings=None,
                       release_name=help_data.OPENSTACK_RELEASE,
                       mode=DEPLOYMENT_MODE_SIMPLE,
                       port=5514):
        """Creates a cluster
        :param name:
        :param release_name:
        :param mode:
        :param settings:
        :param port:
        :return: cluster_id
        """
        logger.info('Create cluster with name %s', name)
        release_id = self.client.get_release_id(release_name=release_name)
        logger.info('Release_id of %s is %s', release_name, str(release_id))

        if settings is None:
            settings = {}

        cluster_id = self.client.get_cluster_id(name)
        if not cluster_id:
            logger.info('I have no id :(')
            data = {
                "name": name,
                "release": str(release_id),
                "mode": mode
            }

            if "net_provider" in settings:
                data.update(
                    {
開發者ID:shaikapsar,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例5: setup_env

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

  client = NailgunClient(admin_node_ip)
  cluster_id = client.get_cluster_id(env_name)
  release_id = client.get_release_id()

  # delete previous cluster with the same name
  if cluster_id:
    client.delete_cluster(cluster_id)

  for i in range(6):
    cluster_id = client.get_cluster_id(env_name)
    if cluster_id:
      time.sleep(5)

  if cluster_id:
    return "Can't delete cluster"

  # old cluster is gone so we're ok to create a new cluster
  env = load_env(env_name)
  data = env.data

  if "net_provider" in env.settings:
    data.update(
      {  
        'net_provider': env.settings["net_provider"],
        'net_segment_type': env.settings["net_segment_type"]
      }
    )

  client.create_cluster(data=data)
  time.sleep(5)
  cluster_id = client.get_cluster_id(env_name)

  # configure networks
  network_conf = client.get_networks(cluster_id)
  network_list = network_conf['networks']

  for network in network_list:
    # set vlan tags
    if network["name"] in env.net_tag:
      network['vlan_start'] = env.net_tag[network["name"]]
    # set CIDR and related net stuff
    if network["name"] in env.net_cidr:
      network['cidr'] = env.net_cidr[network["name"]]
      if network["name"] == "public":
        if env.gateway:
          network["gateway"] = env.gateway
        else:
          network["gateway"] = str(list(IPNetwork(network['cidr']))[1])
      if network["name"] in env.net_ip_ranges:
        network['ip_ranges'] = env.net_ip_ranges[network["name"]]
      else:
        if network["name"] == "public":
          network['ip_ranges'] = get_range(network['cidr'], -1)
        elif network["name"] == "floating":
          network['ip_ranges'] = get_range(network['cidr'], 1)
        else:
          network['ip_ranges'] = get_range(network['cidr'], 0)
      network['netmask'] = str(IPNetwork(network['cidr']).netmask)
      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:
#.........這裏部分代碼省略.........
開發者ID:teran,項目名稱:fuel_bm_tests,代碼行數:103,代碼來源:manage_env.py

示例6: FuelWebClient

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

#.........這裏部分代碼省略.........
        nailgun_node = self.get_nailgun_node_by_devops_node(devops_node)
        if OPENSTACK_RELEASE_UBUNTU in OPENSTACK_RELEASE:
            return nailgun_node['meta']['system']['fqdn']
        return nailgun_node['fqdn']

    @logwrap
    def assert_pacemaker(self, ctrl_node, online_nodes, offline_nodes):
        logger.info('Assert pacemaker status at devops node %s', ctrl_node)
        fqdn_names = lambda nodes: sorted([self.fqdn(n) for n in nodes])

        # Assert online nodes list
        online = \
            'Online: [ {0} ]'.format(' '.join(fqdn_names(online_nodes)))
        wait(lambda: online in self.get_pacemaker_status(
            ctrl_node), timeout=30)
        assert_true(
            online in self.get_pacemaker_status(ctrl_node),
            'Online nodes {0}'.format(online))

        # Assert offline nodes list
        if len(offline_nodes) > 0:
            offline = \
                'OFFLINE: [ {0} ]'.format(
                    ' '.join(fqdn_names(offline_nodes)))
            wait(lambda: offline in self.get_pacemaker_status(
                ctrl_node), timeout=30)
            assert_true(
                offline in self.get_pacemaker_status(ctrl_node),
                'Offline nodes {0}'.format(offline_nodes))

    @logwrap
    @upload_manifests
    @update_ostf
    def create_cluster(self,
                       name,
                       settings=None,
                       release_name=help_data.OPENSTACK_RELEASE,
                       mode=DEPLOYMENT_MODE_SIMPLE,
                       port=514,
                       release_id=None):
        """Creates a cluster
        :param name:
        :param release_name:
        :param mode:
        :param settings:
        :param port:
        :return: cluster_id
        """
        logger.info('Create cluster with name %s', name)
        if not release_id:
            release_id = self.client.get_release_id(release_name=release_name)
            logger.info('Release_id of %s is %s',
                        release_name, str(release_id))

        if settings is None:
            settings = {}

        cluster_id = self.client.get_cluster_id(name)
        if not cluster_id:
            data = {
                "name": name,
                "release": str(release_id),
                "mode": mode
            }

            if "net_provider" in settings:
開發者ID:igajsin,項目名稱:fuel-main,代碼行數:70,代碼來源:fuel_web_client.py

示例7: FuelWebClient

# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import create_cluster [as 別名]
class FuelWebClient(object):
    def __init__(self, admin_node_ip, environment):
        self.admin_node_ip = admin_node_ip
        self.client = NailgunClient(admin_node_ip)
        self._environment = environment
        super(FuelWebClient, self).__init__()

    @property
    def environment(self):
        """
        :rtype: EnvironmentModel
        """
        return self._environment

    @staticmethod
    @logwrap
    def get_cluster_status(ssh_remote, smiles_count, networks_count=1):
        verify_service_list(ssh_remote, smiles_count)
        verify_glance_index(ssh_remote)
        verify_network_list(networks_count, ssh_remote)

    @logwrap
    def _ostf_test_wait(self, cluster_id, timeout):
        wait(
            lambda: all([run["status"] == "finished" for run in self.client.get_ostf_test_run(cluster_id)]),
            timeout=timeout,
        )
        return self.client.get_ostf_test_run(cluster_id)

    @logwrap
    def _tasks_wait(self, tasks, timeout):
        return [self.task_wait(task, timeout) for task in tasks]

    @logwrap
    def add_syslog_server(self, cluster_id, host, port):
        self.client.add_syslog_server(cluster_id, host, port)

    @logwrap
    def assert_cluster_floating_list(self, node_name, expected_ips):
        current_ips = self.get_cluster_floating_list(node_name)
        assert_equal(set(expected_ips), set(current_ips))

    @logwrap
    def assert_cluster_ready(self, node_name, smiles_count, networks_count=1, timeout=300):
        remote = self.environment.get_ssh_to_remote(
            self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))[
                "ip"
            ]
        )
        _wait(
            lambda: self.get_cluster_status(remote, smiles_count=smiles_count, networks_count=networks_count),
            timeout=timeout,
        )

    @logwrap
    def assert_ostf_run(self, cluster_id, should_fail=0, should_pass=0, timeout=10 * 60):

        set_result_list = self._ostf_test_wait(cluster_id, timeout)

        passed = 0
        failed = 0
        for set_result in set_result_list:
            passed += len(filter(lambda test: test["status"] == "success", set_result["tests"]))
            failed += len(
                filter(lambda test: test["status"] == "failure" or test["status"] == "error", set_result["tests"])
            )
        assert_true(passed >= should_pass, "Passed tests, pass: {} should pass: {}" "".format(passed, should_pass))
        assert_true(failed <= should_fail, "Failed tests,  fails: {} should fail: {}" "".format(failed, should_fail))

    def assert_release_state(self, release_name, state="available"):
        for release in self.client.get_releases():
            if release["name"].find(release_name) != -1:
                assert_equal(release["state"], state)
                return release["id"]

    @logwrap
    def assert_task_success(self, task, timeout=90 * 60, interval=5):
        task = self.task_wait(task, timeout, interval)
        assert_equal(
            task["status"],
            "ready",
            "Task '{name}' has incorrect status. {} != {}".format(task["status"], "ready", name=task["name"]),
        )

    @logwrap
    def assert_task_failed(self, task, timeout=70 * 60, interval=5):
        task = self.task_wait(task, timeout, interval)
        assert_equal(
            "error",
            task["status"],
            "Task '{name}' has incorrect status. {} != {}".format(task["status"], "error", name=task["name"]),
        )

    @logwrap
    def create_cluster(
        self, name, settings=None, release_name=help_data.OPENSTACK_RELEASE, mode=DEPLOYMENT_MODE_SIMPLE, port=5514
    ):
        """
        :param name:
        :param release_name:
#.........這裏部分代碼省略.........
開發者ID:justasabc,項目名稱:fuel-main,代碼行數:103,代碼來源:fuel_web_client.py


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