Пример #1
0
 def test_create_multiple_clusters_success(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     clusters = api.create_multiple_clusters(MULTIPLE_CLUSTERS)
     self.assertEqual(2, check_cluster.call_count)
     result_cluster1 = api.get_cluster(clusters['clusters'][0])
     result_cluster2 = api.get_cluster(clusters['clusters'][1])
     self.assertEqual(c_u.CLUSTER_STATUS_ACTIVE, result_cluster1.status)
     self.assertEqual(c_u.CLUSTER_STATUS_ACTIVE, result_cluster2.status)
     expected_count = {
         'ng_1': 1,
         'ng_2': 3,
         'ng_3': 1,
     }
     ng_count = 0
     for ng in result_cluster1.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(3, ng_count)
     api.terminate_cluster(result_cluster1.id)
     api.terminate_cluster(result_cluster2.id)
     self.assertEqual(
         ['get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'ops.terminate_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #2
0
 def test_create_multiple_clusters_success(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     clusters = api.create_multiple_clusters(MULTIPLE_CLUSTERS)
     self.assertEqual(2, check_cluster.call_count)
     result_cluster1 = api.get_cluster(clusters['clusters'][0])
     result_cluster2 = api.get_cluster(clusters['clusters'][1])
     self.assertEqual('Active', result_cluster1.status)
     self.assertEqual('Active', result_cluster2.status)
     expected_count = {
         'ng_1': 1,
         'ng_2': 3,
         'ng_3': 1,
     }
     ng_count = 0
     for ng in result_cluster1.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(3, ng_count)
     api.terminate_cluster(result_cluster1.id)
     api.terminate_cluster(result_cluster2.id)
     self.assertEqual(
         ['get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'ops.terminate_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #3
0
def check_cluster_update(cluster_id, data, **kwargs):
    cluster = api.get_cluster(cluster_id)

    verification = verification_base.validate_verification_ops(cluster, data)
    acl.check_tenant_for_update(context.current(), cluster)
    if not verification:
        acl.check_protected_from_update(cluster, data)
Пример #4
0
def check_cluster_update(cluster_id, data, **kwargs):
    cluster = api.get_cluster(cluster_id)

    verification = verification_base.validate_verification_ops(
        cluster, data)
    acl.check_tenant_for_update(context.current(), cluster)
    if not verification:
        acl.check_protected_from_update(cluster, data)
Пример #5
0
def check_cluster_scaling(data, cluster_id, **kwargs):
    ctx = context.current()
    cluster = api.get_cluster(id=cluster_id)

    if cluster is None:
        raise ex.NotFoundException(
            {'id': cluster_id}, _('Object with %s not found'))

    acl.check_tenant_for_update(ctx, cluster)
    acl.check_protected_from_update(cluster, data)

    cluster_engine = cluster.sahara_info.get(
        'infrastructure_engine') if cluster.sahara_info else None

    engine_type_and_version = api.OPS.get_engine_type_and_version()
    if (not cluster_engine and
            not engine_type_and_version.startswith('direct')):
        raise ex.InvalidReferenceException(
            _("Cluster created before Juno release "
              "can't be scaled with %(engine)s engine") %
            {"engine": engine_type_and_version})

    if (cluster.sahara_info and
            cluster_engine != engine_type_and_version):
        raise ex.InvalidReferenceException(
            _("Cluster created with %(old_engine)s infrastructure engine "
              "can't be scaled with %(new_engine)s engine") %
            {"old_engine": cluster.sahara_info.get('infrastructure_engine'),
             "new_engine": engine_type_and_version})

    if not (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'scale_cluster') and (
            plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'decommission_nodes'))):
        raise ex.InvalidReferenceException(
            _("Requested plugin '%s' doesn't support cluster scaling feature")
            % cluster.plugin_name)

    if cluster.status != c_u.CLUSTER_STATUS_ACTIVE:
        raise ex.InvalidReferenceException(
            _("Cluster cannot be scaled not in 'Active' status. "
              "Cluster status: %s") % cluster.status)

    if data.get("resize_node_groups"):
        b.check_resize(cluster, data['resize_node_groups'])

    if data.get("add_node_groups"):
        b.check_add_node_groups(cluster, data['add_node_groups'])
        b.check_network_config(data['add_node_groups'],
                               cluster.has_proxy_gateway())
        b.check_cluster_hostnames_lengths(cluster.name,
                                          data['add_node_groups'])
Пример #6
0
def check_cluster_scaling(data, cluster_id, **kwargs):
    cluster = api.get_cluster(id=cluster_id)

    cluster_engine = cluster.sahara_info.get(
        'infrastructure_engine') if cluster.sahara_info else None

    if (not cluster_engine
            and not ops.get_engine_type_and_version().startswith('direct')):
        raise ex.InvalidException(
            _("Cluster created before Juno release "
              "can't be scaled with %(engine)s engine") %
            {"engine": ops.get_engine_type_and_version()})

    if (cluster.sahara_info
            and cluster_engine != ops.get_engine_type_and_version()):
        raise ex.InvalidException(
            _("Cluster created with %(old_engine)s infrastructure engine "
              "can't be scaled with %(new_engine)s engine") %
            {
                "old_engine": cluster.sahara_info.get('infrastructure_engine'),
                "new_engine": ops.get_engine_type_and_version()
            })

    if not (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'scale_cluster') and
            (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                      'decommission_nodes'))):
        raise ex.InvalidException(
            _("Requested plugin '%s' doesn't support cluster scaling feature")
            % cluster.plugin_name)

    if cluster.status != 'Active':
        raise ex.InvalidException(
            _("Cluster cannot be scaled not in 'Active' status. "
              "Cluster status: %s") % cluster.status)

    if data.get("resize_node_groups"):
        b.check_resize(cluster, data['resize_node_groups'])

    if data.get("add_node_groups"):
        b.check_add_node_groups(cluster, data['add_node_groups'])
        b.check_network_config(data['add_node_groups'])
        b.check_cluster_hostnames_lengths(cluster.name,
                                          data['add_node_groups'])
def check_cluster_scaling(data, cluster_id, **kwargs):
    cluster = api.get_cluster(id=cluster_id)

    cluster_engine = cluster.sahara_info.get(
        'infrastructure_engine') if cluster.sahara_info else None

    engine_type_and_version = api.OPS.get_engine_type_and_version()
    if (not cluster_engine and
            not engine_type_and_version.startswith('direct')):
        raise ex.InvalidException(
            _("Cluster created before Juno release "
              "can't be scaled with %(engine)s engine") %
            {"engine": engine_type_and_version})

    if (cluster.sahara_info and
            cluster_engine != engine_type_and_version):
        raise ex.InvalidException(
            _("Cluster created with %(old_engine)s infrastructure engine "
              "can't be scaled with %(new_engine)s engine") %
            {"old_engine": cluster.sahara_info.get('infrastructure_engine'),
             "new_engine": engine_type_and_version})

    if not (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'scale_cluster') and (
            plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'decommission_nodes'))):
        raise ex.InvalidException(
            _("Requested plugin '%s' doesn't support cluster scaling feature")
            % cluster.plugin_name)

    if cluster.status != 'Active':
        raise ex.InvalidException(
            _("Cluster cannot be scaled not in 'Active' status. "
              "Cluster status: %s") % cluster.status)

    if data.get("resize_node_groups"):
        b.check_resize(cluster, data['resize_node_groups'])

    if data.get("add_node_groups"):
        b.check_add_node_groups(cluster, data['add_node_groups'])
        b.check_network_config(data['add_node_groups'])
        b.check_cluster_hostnames_lengths(cluster.name,
                                          data['add_node_groups'])
Пример #8
0
 def test_create_cluster_success(self, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual(1, check_cluster.call_count)
     result_cluster = api.get_cluster(cluster.id)
     self.assertEqual('Active', result_cluster.status)
     expected_count = {
         'ng_1': 1,
         'ng_2': 3,
         'ng_3': 1,
     }
     ng_count = 0
     for ng in result_cluster.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(3, ng_count)
     api.terminate_cluster(result_cluster.id)
     self.assertEqual(
         ['get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #9
0
 def test_create_cluster_success(self, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual(1, check_cluster.call_count)
     result_cluster = api.get_cluster(cluster.id)
     self.assertEqual(c_u.CLUSTER_STATUS_ACTIVE, result_cluster.status)
     expected_count = {
         'ng_1': 1,
         'ng_2': 3,
         'ng_3': 1,
     }
     ng_count = 0
     for ng in result_cluster.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(3, ng_count)
     api.terminate_cluster(result_cluster.id)
     self.assertEqual(
         ['get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #10
0
def check_cluster_scaling(data, cluster_id, **kwargs):
    cluster = api.get_cluster(id=cluster_id)
    if not (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'scale_cluster') and (
            plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'decommission_nodes'))):
        raise ex.InvalidException(
            "Requested plugin '%s' doesn't support cluster scaling feature"
            % cluster.plugin_name)

    if cluster.status != 'Active':
        raise ex.InvalidException("Cluster cannot be scaled not in 'Active' "
                                  "status. Cluster status: " + cluster.status)

    if data.get("resize_node_groups"):
        b.check_resize(cluster, data['resize_node_groups'])

    if data.get("add_node_groups"):
        b.check_add_node_groups(cluster, data['add_node_groups'])

        b.check_network_config(data['add_node_groups'])
Пример #11
0
def check_cluster_scaling(data, cluster_id, **kwargs):
    cluster = api.get_cluster(id=cluster_id)
    if not (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                     'scale_cluster') and
            (plugin_base.PLUGINS.is_plugin_implements(cluster.plugin_name,
                                                      'decommission_nodes'))):
        raise ex.InvalidException(
            "Requested plugin '%s' doesn't support cluster scaling feature" %
            cluster.plugin_name)

    if cluster.status != 'Active':
        raise ex.InvalidException("Cluster cannot be scaled not in 'Active' "
                                  "status. Cluster status: " + cluster.status)

    if data.get("resize_node_groups"):
        b.check_resize(cluster, data['resize_node_groups'])

    if data.get("add_node_groups"):
        b.check_add_node_groups(cluster, data['add_node_groups'])

        b.check_network_config(data['add_node_groups'])
Пример #12
0
 def test_scale_cluster_success(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     api.scale_cluster(cluster.id, SCALE_DATA)
     result_cluster = api.get_cluster(cluster.id)
     self.assertEqual('Scaled', result_cluster.status)
     expected_count = {
         'ng_1': 3,
         'ng_2': 2,
         'ng_3': 1,
         'ng_4': 1,
     }
     ng_count = 0
     for ng in result_cluster.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(4, ng_count)
     api.terminate_cluster(result_cluster.id)
     self.assertEqual(
         ['get_open_ports', 'validate', 'ops.provision_cluster',
          'get_open_ports', 'get_open_ports', 'validate_scaling',
          'ops.provision_scaled_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #13
0
 def test_scale_cluster_success(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     api.scale_cluster(cluster.id, SCALE_DATA)
     result_cluster = api.get_cluster(cluster.id)
     self.assertEqual('Scaled', result_cluster.status)
     expected_count = {
         'ng_1': 3,
         'ng_2': 2,
         'ng_3': 1,
         'ng_4': 1,
     }
     ng_count = 0
     for ng in result_cluster.node_groups:
         self.assertEqual(expected_count[ng.name], ng.count)
         ng_count += 1
     self.assertEqual(4, ng_count)
     api.terminate_cluster(result_cluster.id)
     self.assertEqual(
         ['get_open_ports', 'recommend_configs', 'validate',
          'ops.provision_cluster', 'get_open_ports', 'get_open_ports',
          'recommend_configs', 'validate_scaling',
          'ops.provision_scaled_cluster',
          'ops.terminate_cluster'], self.calls_order)
Пример #14
0
def check_edp_job_support(cluster_id):
    cluster = api.get_cluster(cluster_id)
    plugin_base.PLUGINS.get_plugin(cluster.plugin_name).validate_edp(cluster)
Пример #15
0
def check_cluster_exists(id):
    if not api.get_cluster(id):
        raise ex.InvalidException("Cluster with id '%s'" " doesn't exist" % id)
Пример #16
0
def clusters_get(cluster_id,**kwargs):
    all_tenants = kwargs.get('all_tenants', None)
    return u.render(api.get_cluster(cluster_id, all_tenants).to_wrapped_dict())
Пример #17
0
def clusters_get(cluster_id):
    return u.render(api.get_cluster(cluster_id).to_wrapped_dict())
Пример #18
0
def check_cluster_delete(cluster_id, **kwargs):
    cluster = api.get_cluster(cluster_id)

    acl.check_tenant_for_delete(context.current(), cluster)
    acl.check_protected_from_delete(cluster)
Пример #19
0
def clusters_get(cluster_id):
    return u.render(api.get_cluster(cluster_id).to_wrapped_dict())
Пример #20
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = unicode(data.get('show_progress', 'false')).lower() == 'true'
    return u.render(api.get_cluster(cluster_id, show_events).to_wrapped_dict())
Пример #21
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = unicode(data.get('show_progress', 'false')).lower() == 'true'
    return u.render(api.get_cluster(cluster_id, show_events).to_wrapped_dict())
Пример #22
0
def check_cluster_exists(id):
    if not api.get_cluster(id):
        raise ex.InvalidException("Cluster with id '%s'"
                                  " doesn't exist" % id)
Пример #23
0
def clusters_get(cluster_id, **kwargs):
    all_tenants = kwargs.get('all_tenants', None)
    return u.render(api.get_cluster(cluster_id, all_tenants).to_wrapped_dict())
Пример #24
0
def check_edp_job_support(cluster_id):
    cluster = api.get_cluster(cluster_id)
    plugin_base.PLUGINS.get_plugin(cluster.plugin_name).validate_edp(cluster)
Пример #25
0
def check_cluster_update(cluster_id, data, **kwargs):
    cluster = api.get_cluster(cluster_id)

    acl.check_tenant_for_update(context.current(), cluster)
    acl.check_protected_from_update(cluster, data)