Beispiel #1
0
def check_node_group_template_update(node_group_template_id, data, **kwargs):
    if data.get('plugin_name') and not data.get('hadoop_version'):
        raise ex.InvalidReferenceException(
            _("You must specify a hadoop_version value "
              "for your plugin_name"))

    if data.get('plugin_name'):
        plugin = data.get('plugin_name')
        version = data.get('hadoop_version')
        b.check_plugin_name_exists(plugin)
        b.check_plugin_supports_version(plugin, version)
    else:
        ngt = api.get_node_group_template(node_group_template_id)
        plugin = ngt.plugin_name
        if data.get('hadoop_version'):
            version = data.get('hadoop_version')
            b.check_plugin_supports_version(plugin, version)
        else:
            version = ngt.hadoop_version

    if data.get('image_id'):
        b.check_image_registered(data['image_id'])
        b.check_required_image_tags(plugin,
                                    version,
                                    data['image_id'])

    b.check_node_group_basic_fields(plugin, version, data)

    if data.get('shares'):
        shares.check_shares(data['shares'])
def check_node_group_template_update(node_group_template_id, data, **kwargs):
    if data.get('plugin_name') and not data.get('hadoop_version'):
        raise ex.InvalidReferenceException(
            _("You must specify a hadoop_version value "
              "for your plugin_name"))

    if data.get('plugin_name'):
        plugin = data.get('plugin_name')
        version = data.get('hadoop_version')
        b.check_plugin_name_exists(plugin)
        b.check_plugin_supports_version(plugin, version)
    else:
        ngt = api.get_node_group_template(node_group_template_id)
        plugin = ngt.plugin_name
        if data.get('hadoop_version'):
            version = data.get('hadoop_version')
            b.check_plugin_supports_version(plugin, version)
        else:
            version = ngt.hadoop_version

    if data.get('image_id'):
        b.check_image_registered(data['image_id'])
        b.check_required_image_tags(plugin, version, data['image_id'])

    b.check_node_group_basic_fields(plugin, version, data)

    if data.get('shares'):
        shares.check_shares(data['shares'])
Beispiel #3
0
def check_resize(cluster, r_node_groups):
    ng_map = {}
    for ng in cluster.node_groups:
        ng_map[ng.name] = ng

    check_duplicates_node_groups_names(r_node_groups)

    for ng in r_node_groups:
        if ng['name'] not in ng_map.keys():
            raise ex.InvalidReferenceException(
                _("Cluster doesn't contain node group with name '%s'") %
                ng['name'])
        node_group = ng_map[ng['name']]
        if node_group.get('node_group_template_id'):
            ng_tmpl_id = node_group['node_group_template_id']
            check_node_group_template_exists(ng_tmpl_id)
            ng_tmp = api.get_node_group_template(ng_tmpl_id).to_wrapped_dict()
            check_node_group_basic_fields(cluster.plugin_name,
                                          cluster.hadoop_version,
                                          ng_tmp['node_group_template'])

    for scaling_ng in r_node_groups:
        current_count = ng_map[scaling_ng['name']].count
        new_count = scaling_ng['count']
        count_diff = current_count - new_count
        if 'instances' in scaling_ng:
            if len(scaling_ng['instances']) > count_diff:
                raise ex.InvalidDataException(
                    _("Number of specific instances (%(instance)s) to"
                      " delete can not be greater than the count difference"
                      " (%(count)s during scaling") % {
                          'instance': str(len(scaling_ng['instances'])),
                          'count': str(count_diff)
                      })
            else:
                if len(scaling_ng['instances']) > 0:
                    is_uuid = uuidutils.is_uuid_like(
                        scaling_ng['instances'][0])
                    if is_uuid:
                        for instance in scaling_ng['instances']:
                            if not uuidutils.is_uuid_like(instance):
                                raise ex.InvalidReferenceException(
                                    _("You can only reference instances by"
                                      " Name or UUID, not both on the same"
                                      " request"))
                    else:
                        for instance in scaling_ng['instances']:
                            if uuidutils.is_uuid_like(instance):
                                raise ex.InvalidReferenceException(
                                    _("You can only reference instances by"
                                      " Name or UUID, not both on the same"
                                      " request"))
                    _check_duplicates(
                        scaling_ng['instances'],
                        _("Duplicate entry for instances to"
                          " delete"))
Beispiel #4
0
def check_resize(cluster, r_node_groups):
    ng_map = {}
    for ng in cluster.node_groups:
        ng_map[ng.name] = ng

    check_duplicates_node_groups_names(r_node_groups)

    for ng in r_node_groups:
        if ng['name'] not in ng_map.keys():
            raise ex.InvalidReferenceException(
                _("Cluster doesn't contain node group with name '%s'")
                % ng['name'])
        node_group = ng_map[ng['name']]
        if node_group.get('node_group_template_id'):
            ng_tmpl_id = node_group['node_group_template_id']
            check_node_group_template_exists(ng_tmpl_id)
            ng_tmp = api.get_node_group_template(ng_tmpl_id).to_wrapped_dict()
            check_node_group_basic_fields(cluster.plugin_name,
                                          cluster.hadoop_version,
                                          ng_tmp['node_group_template'])

    for scaling_ng in r_node_groups:
        current_count = ng_map[scaling_ng['name']].count
        new_count = scaling_ng['count']
        count_diff = current_count - new_count
        if 'instances' in scaling_ng:
            if len(scaling_ng['instances']) > count_diff:
                raise ex.InvalidDataException(
                    _("Number of specific instances (%(instance)s) to"
                      " delete can not be greater than the count difference"
                      " (%(count)s during scaling")
                    % {'instance': str(len(scaling_ng['instances'])),
                       'count': str(count_diff)})
            else:
                if len(scaling_ng['instances']) > 0:
                    is_uuid = uuidutils.is_uuid_like(
                        scaling_ng['instances'][0])
                    if is_uuid:
                        for instance in scaling_ng['instances']:
                            if not uuidutils.is_uuid_like(instance):
                                raise ex.InvalidReferenceException(
                                    _("You can only reference instances by"
                                      " Name or UUID, not both on the same"
                                      " request"))
                    else:
                        for instance in scaling_ng['instances']:
                            if uuidutils.is_uuid_like(instance):
                                raise ex.InvalidReferenceException(
                                    _("You can only reference instances by"
                                      " Name or UUID, not both on the same"
                                      " request"))
                    _check_duplicates(scaling_ng['instances'],
                                      _("Duplicate entry for instances to"
                                        " delete"))
Beispiel #5
0
def check_node_group_basic_fields(plugin_name,
                                  hadoop_version,
                                  ng,
                                  plugin_configs=None):

    if ng.get('node_group_template_id'):
        ng_tmpl_id = ng['node_group_template_id']
        check_node_group_template_exists(ng_tmpl_id)
        ng_tmpl = api.get_node_group_template(ng_tmpl_id).to_wrapped_dict()
        check_node_group_basic_fields(plugin_name, hadoop_version,
                                      ng_tmpl['node_group_template'],
                                      plugin_configs)

    if ng.get('node_configs'):
        check_node_group_configs(plugin_name, hadoop_version,
                                 ng['node_configs'], plugin_configs)
    if ng.get('flavor_id'):
        check_flavor_exists(ng['flavor_id'])

    if ng.get('node_processes'):
        check_node_processes(plugin_name, hadoop_version, ng['node_processes'])

    if ng.get('image_id'):
        check_image_registered(ng['image_id'])

    if ng.get('volumes_per_node'):
        if not cinder.check_cinder_exists():
            raise ex.InvalidReferenceException(_("Cinder is not supported"))

        if ng.get('volumes_availability_zone'):
            check_volume_availability_zone_exist(
                ng['volumes_availability_zone'])

        if ng.get('volume_type'):
            check_volume_type_exists(ng['volume_type'])

        if not ng.get('volumes_size'):
            raise ex.InvalidReferenceException(
                _("You must specify a volumes_size parameter"))

    if ng.get('floating_ip_pool'):
        check_floatingip_pool_exists(ng['name'], ng['floating_ip_pool'])

    if ng.get('security_groups'):
        check_security_groups_exist(ng['security_groups'])

    if ng.get('availability_zone'):
        check_availability_zone_exist(ng['availability_zone'])
Beispiel #6
0
def check_node_group_basic_fields(plugin_name, hadoop_version, ng,
                                  plugin_configs=None):

    if ng.get('node_group_template_id'):
        ng_tmpl_id = ng['node_group_template_id']
        check_node_group_template_exists(ng_tmpl_id)
        ng_tmpl = api.get_node_group_template(ng_tmpl_id).to_wrapped_dict()
        check_node_group_basic_fields(plugin_name, hadoop_version,
                                      ng_tmpl['node_group_template'],
                                      plugin_configs)

    if ng.get('node_configs'):
        check_node_group_configs(plugin_name, hadoop_version,
                                 ng['node_configs'], plugin_configs)
    if ng.get('flavor_id'):
        check_flavor_exists(ng['flavor_id'])

    if ng.get('node_processes'):
        check_node_processes(plugin_name, hadoop_version, ng['node_processes'])

    if ng.get('image_id'):
        check_image_registered(ng['image_id'])

    if ng.get('volumes_per_node'):
        if not cinder.check_cinder_exists():
            raise ex.InvalidReferenceException(_("Cinder is not supported"))

        if ng.get('volumes_availability_zone'):
            check_volume_availability_zone_exist(
                ng['volumes_availability_zone'])

        if ng.get('volume_type'):
            check_volume_type_exists(ng['volume_type'])

        if not ng.get('volumes_size'):
            raise ex.InvalidReferenceException(
                _("You must specify a volumes_size parameter"))

    if ng.get('floating_ip_pool'):
        check_floatingip_pool_exists(ng['name'], ng['floating_ip_pool'])

    if ng.get('security_groups'):
        check_security_groups_exist(ng['security_groups'])

    if ng.get('availability_zone'):
        check_availability_zone_exist(ng['availability_zone'])
Beispiel #7
0
def check_resize(cluster, r_node_groups):
    ng_map = {}
    for ng in cluster.node_groups:
        ng_map[ng.name] = ng

    check_duplicates_node_groups_names(r_node_groups)

    for ng in r_node_groups:
        if ng['name'] not in ng_map.keys():
            raise ex.InvalidReferenceException(
                _("Cluster doesn't contain node group with name '%s'") %
                ng['name'])
        node_group = ng_map[ng['name']]
        if node_group.get('node_group_template_id'):
            ng_tmpl_id = node_group['node_group_template_id']
            check_node_group_template_exists(ng_tmpl_id)
            ng_tmp = api.get_node_group_template(ng_tmpl_id).to_wrapped_dict()
            check_node_group_basic_fields(cluster.plugin_name,
                                          cluster.hadoop_version,
                                          ng_tmp['node_group_template'])
Beispiel #8
0
def check_node_group_template_exists(ng_tmpl_id):
    if not api.get_node_group_template(id=ng_tmpl_id):
        raise ex.NotFoundException(ng_tmpl_id, _("NodeGroup template with id '%s' not found"))
Beispiel #9
0
def check_node_group_template_exists(ng_tmpl_id):
    if not api.get_node_group_template(id=ng_tmpl_id):
        raise ex.NotFoundException(
            ng_tmpl_id, _("NodeGroup template with id '%s' not found"))