Beispiel #1
0
class JobBinaryInternalsManager(base.ResourceManager):
    resource_class = JobBinaryInternal
    NotUpdated = base.NotUpdated()

    def create(self, name, data):
        """Create a Job Binary Internal.

        :param str data: raw data ot script text
        """
        return self._update('/job-binary-internals/%s' %
                            urlparse.quote(name.encode('utf-8')),
                            data,
                            'job_binary_internal',
                            dump_json=False)

    def list(self,
             search_opts=None,
             limit=None,
             marker=None,
             sort_by=None,
             reverse=None):
        """Get a list of Job Binary Internals."""
        query = base.get_query_string(search_opts,
                                      limit=limit,
                                      marker=marker,
                                      sort_by=sort_by,
                                      reverse=reverse)
        url = "/job-binary-internals%s" % query
        return self._page(url, 'binaries', limit)

    def get(self, job_binary_id):
        """Get information about a Job Binary Internal."""
        return self._get('/job-binary-internals/%s' % job_binary_id,
                         'job_binary_internal')

    def delete(self, job_binary_id):
        """Delete a Job Binary Internal."""
        self._delete('/job-binary-internals/%s' % job_binary_id)

    def update(self,
               job_binary_id,
               name=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated):
        """Update a Job Binary Internal."""

        data = {}
        self._copy_if_updated(data,
                              name=name,
                              is_public=is_public,
                              is_protected=is_protected)

        return self._patch('/job-binary-internals/%s' % job_binary_id, data)
Beispiel #2
0
class JobsManager(base.ResourceManager):
    resource_class = Job
    NotUpdated = base.NotUpdated()

    def create(self, name, type, mains=None, libs=None, description=None,
               interface=None, is_public=None, is_protected=None):
        """Create a Job."""
        data = {
            'name': name,
            'type': type
        }

        self._copy_if_defined(data, description=description, mains=mains,
                              libs=libs, interface=interface,
                              is_public=is_public, is_protected=is_protected)

        return self._create('/jobs', data, 'job')

    def list(self, search_opts=None):
        """Get a list of Jobs."""
        query = base.get_query_string(search_opts)
        return self._list('/jobs%s' % query, 'jobs')

    def get(self, job_id):
        """Get information about a Job"""
        return self._get('/jobs/%s' % job_id, 'job')

    def get_configs(self, job_type):
        """Get config hints for a specified Job type."""
        return self._get('/jobs/config-hints/%s' % job_type)

    def delete(self, job_id):
        """Delete a Job"""
        self._delete('/jobs/%s' % job_id)

    def update(self, job_id, name=NotUpdated, description=NotUpdated,
               is_public=NotUpdated, is_protected=NotUpdated):
        """Update a Job."""

        data = {}
        self._copy_if_updated(data, name=name, description=description,
                              is_public=is_public, is_protected=is_protected)

        return self._patch('/jobs/%s' % job_id, data)
Beispiel #3
0
class JobExecutionsManager(base.ResourceManager):
    resource_class = JobExecution
    NotUpdated = base.NotUpdated()

    def list(self, search_opts=None):
        """Get a list of Job Executions."""
        query = base.get_query_string(search_opts)
        return self._list('/job-executions%s' % query, 'job_executions')

    def get(self, obj_id):
        """Get information about a Job Execution."""
        return self._get('/job-executions/%s' % obj_id, 'job_execution')

    def delete(self, obj_id):
        """Delete a Job Execution."""
        self._delete('/job-executions/%s' % obj_id)

    def create(self, job_id, cluster_id, input_id=None,
               output_id=None, configs=None, interface=None, is_public=None,
               is_protected=None):
        """Launch a Job."""

        url = "/jobs/%s/execute" % job_id
        data = {
            "cluster_id": cluster_id,
        }

        self._copy_if_defined(data, input_id=input_id, output_id=output_id,
                              job_configs=configs, interface=interface,
                              is_public=is_public, is_protected=is_protected)

        return self._create(url, data, 'job_execution')

    def update(self, obj_id, is_public=NotUpdated, is_protected=NotUpdated):
        """Update a Job Execution."""

        data = {}
        self._copy_if_updated(data, is_public=is_public,
                              is_protected=is_protected)
        return self._patch('/job-executions/%s' % obj_id, data)
Beispiel #4
0
class ClusterManager(base.ResourceManager):
    resource_class = Cluster
    NotUpdated = base.NotUpdated()

    def create(self,
               name,
               plugin_name,
               hadoop_version,
               cluster_template_id=None,
               default_image_id=None,
               is_transient=None,
               description=None,
               cluster_configs=None,
               node_groups=None,
               user_keypair_id=None,
               anti_affinity=None,
               net_id=None,
               count=None,
               use_autoconfig=None,
               shares=None,
               is_public=None,
               is_protected=None):
        """Launch a Cluster."""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'hadoop_version': hadoop_version,
        }

        # Checking if count is greater than 1, otherwise we set it to None
        # so the created dict in the _copy_if_defined method does not contain
        # the count parameter.
        if count and count <= 1:
            count = None

        self._copy_if_defined(data,
                              cluster_template_id=cluster_template_id,
                              is_transient=is_transient,
                              default_image_id=default_image_id,
                              description=description,
                              cluster_configs=cluster_configs,
                              node_groups=node_groups,
                              user_keypair_id=user_keypair_id,
                              anti_affinity=anti_affinity,
                              neutron_management_network=net_id,
                              count=count,
                              use_autoconfig=use_autoconfig,
                              shares=shares,
                              is_public=is_public,
                              is_protected=is_protected)

        if count:
            return self._create('/clusters/multiple', data)

        return self._create('/clusters', data, 'cluster')

    def scale(self, cluster_id, scale_object):
        """Scale an existing Cluster.

        :param scale_object: dict that describes scaling operation

        :Example:

        The following `scale_object` can be used to change the number of
        instances in the node group and add instances of new node group to
        existing cluster:

        .. sourcecode:: json

            {
                "add_node_groups": [
                    {
                        "count": 3,
                        "name": "new_ng",
                        "node_group_template_id": "ngt_id"
                    }
                ],
                "resize_node_groups": [
                    {
                        "count": 2,
                        "name": "old_ng"
                    }
                ]
            }

        """
        return self._update('/clusters/%s' % cluster_id, scale_object)

    def list(self, search_opts=None):
        """Get a list of Clusters."""
        query = base.get_query_string(search_opts)
        return self._list('/clusters%s' % query, 'clusters')

    def get(self, cluster_id, show_progress=False):
        """Get information about a Cluster."""
        url = ('/clusters/%(cluster_id)s?%(params)s' % {
            "cluster_id": cluster_id,
            "params": parse.urlencode({"show_progress": show_progress})
        })

        return self._get(url, 'cluster')

    def delete(self, cluster_id):
        """Delete a Cluster."""
        self._delete('/clusters/%s' % cluster_id)

    def update(self,
               cluster_id,
               name=NotUpdated,
               description=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated,
               shares=NotUpdated):
        """Update a Cluster."""

        data = {}
        self._copy_if_updated(data,
                              name=name,
                              description=description,
                              is_public=is_public,
                              is_protected=is_protected,
                              shares=shares)

        return self._patch('/clusters/%s' % cluster_id, data)

    def verification_update(self, cluster_id, status):
        """Start a verification for a Cluster."""
        data = {'verification': {'status': status}}
        return self._patch("/clusters/%s" % cluster_id, data)
Beispiel #5
0
class JobTemplatesManagerV2(base.ResourceManager):
    resource_class = JobTemplate
    NotUpdated = base.NotUpdated()

    def create(self,
               name,
               type,
               mains=None,
               libs=None,
               description=None,
               interface=None,
               is_public=None,
               is_protected=None):
        """Create a Job Template."""
        data = {'name': name, 'type': type}

        self._copy_if_defined(data,
                              description=description,
                              mains=mains,
                              libs=libs,
                              interface=interface,
                              is_public=is_public,
                              is_protected=is_protected)

        return self._create('/%s' % 'job-templates', data, 'job_template')

    def list(self,
             search_opts=None,
             limit=None,
             marker=None,
             sort_by=None,
             reverse=None):
        """Get a list of Job Templates."""
        query = base.get_query_string(search_opts,
                                      limit=limit,
                                      marker=marker,
                                      sort_by=sort_by,
                                      reverse=reverse)

        url = "/%s%s" % ('job-templates', query)
        return self._page(url, 'job_templates', limit)

    def get(self, job_id):
        """Get information about a Job Template."""
        return self._get('/%s/%s' % ('job-templates', job_id), 'job_template')

    def get_configs(self, job_type):
        """Get config hints for a specified Job Template type."""
        return self._get('/%s/config-hints/%s' % ('job-templates', job_type))

    def delete(self, job_id):
        """Delete a Job Template."""
        self._delete('/%s/%s' % ('job-templates', job_id))

    def update(self,
               job_id,
               name=NotUpdated,
               description=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated):
        """Update a Job Template."""

        data = {}
        self._copy_if_updated(data,
                              name=name,
                              description=description,
                              is_public=is_public,
                              is_protected=is_protected)

        return self._patch('/%s/%s' % ('job-templates', job_id), data)
Beispiel #6
0
class ClusterTemplateManagerV1(base.ResourceManager):
    resource_class = ClusterTemplate
    NotUpdated = base.NotUpdated()

    def create(self,
               name,
               plugin_name,
               hadoop_version,
               description=None,
               cluster_configs=None,
               node_groups=None,
               anti_affinity=None,
               net_id=None,
               default_image_id=None,
               use_autoconfig=None,
               shares=None,
               is_public=None,
               is_protected=None,
               domain_name=None):
        """Create a Cluster Template."""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'hadoop_version': hadoop_version,
        }

        return self._do_create(data, description, cluster_configs, node_groups,
                               anti_affinity, net_id, default_image_id,
                               use_autoconfig, shares, is_public, is_protected,
                               domain_name)

    def _do_create(self, data, description, cluster_configs, node_groups,
                   anti_affinity, net_id, default_image_id, use_autoconfig,
                   shares, is_public, is_protected, domain_name):

        self._copy_if_defined(data,
                              description=description,
                              cluster_configs=cluster_configs,
                              node_groups=node_groups,
                              anti_affinity=anti_affinity,
                              neutron_management_network=net_id,
                              default_image_id=default_image_id,
                              use_autoconfig=use_autoconfig,
                              shares=shares,
                              is_public=is_public,
                              is_protected=is_protected,
                              domain_name=domain_name)

        return self._create('/cluster-templates', data, 'cluster_template')

    def update(self,
               cluster_template_id,
               name=NotUpdated,
               plugin_name=NotUpdated,
               hadoop_version=NotUpdated,
               description=NotUpdated,
               cluster_configs=NotUpdated,
               node_groups=NotUpdated,
               anti_affinity=NotUpdated,
               net_id=NotUpdated,
               default_image_id=NotUpdated,
               use_autoconfig=NotUpdated,
               shares=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated,
               domain_name=NotUpdated):
        """Update a Cluster Template."""

        data = {}
        self._copy_if_updated(data,
                              name=name,
                              plugin_name=plugin_name,
                              hadoop_version=hadoop_version,
                              description=description,
                              cluster_configs=cluster_configs,
                              node_groups=node_groups,
                              anti_affinity=anti_affinity,
                              neutron_management_network=net_id,
                              default_image_id=default_image_id,
                              use_autoconfig=use_autoconfig,
                              shares=shares,
                              is_public=is_public,
                              is_protected=is_protected,
                              domain_name=domain_name)

        return self._update('/cluster-templates/%s' % cluster_template_id,
                            data, 'cluster_template')

    def list(self,
             search_opts=None,
             marker=None,
             limit=None,
             sort_by=None,
             reverse=None):
        """Get list of Cluster Templates."""
        query = base.get_query_string(search_opts,
                                      marker=marker,
                                      limit=limit,
                                      sort_by=sort_by,
                                      reverse=reverse)
        url = "/cluster-templates%s" % query
        return self._page(url, 'cluster_templates', limit)

    def get(self, cluster_template_id):
        """Get information about a Cluster Template."""
        return self._get('/cluster-templates/%s' % cluster_template_id,
                         'cluster_template')

    def delete(self, cluster_template_id):
        """Delete a Cluster Template."""
        self._delete('/cluster-templates/%s' % cluster_template_id)

    def export(self, cluster_template_id):
        """Export a Cluster Template."""
        return self._get('/cluster-templates/%s/export' % cluster_template_id)
Beispiel #7
0
class ClusterTemplateManagerV2(ClusterTemplateManagerV1):
    NotUpdated = base.NotUpdated()

    def create(self,
               name,
               plugin_name,
               plugin_version,
               description=None,
               cluster_configs=None,
               node_groups=None,
               anti_affinity=None,
               net_id=None,
               default_image_id=None,
               use_autoconfig=None,
               shares=None,
               is_public=None,
               is_protected=None,
               domain_name=None):
        """Create a Cluster Template."""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'plugin_version': plugin_version
        }

        return self._do_create(data, description, cluster_configs, node_groups,
                               anti_affinity, net_id, default_image_id,
                               use_autoconfig, shares, is_public, is_protected,
                               domain_name)

    def update(self,
               cluster_template_id,
               name=NotUpdated,
               plugin_name=NotUpdated,
               plugin_version=NotUpdated,
               description=NotUpdated,
               cluster_configs=NotUpdated,
               node_groups=NotUpdated,
               anti_affinity=NotUpdated,
               net_id=NotUpdated,
               default_image_id=NotUpdated,
               use_autoconfig=NotUpdated,
               shares=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated,
               domain_name=NotUpdated):
        """Update a Cluster Template."""

        data = {}
        self._copy_if_updated(data,
                              name=name,
                              plugin_name=plugin_name,
                              plugin_version=plugin_version,
                              description=description,
                              cluster_configs=cluster_configs,
                              node_groups=node_groups,
                              anti_affinity=anti_affinity,
                              neutron_management_network=net_id,
                              default_image_id=default_image_id,
                              use_autoconfig=use_autoconfig,
                              shares=shares,
                              is_public=is_public,
                              is_protected=is_protected,
                              domain_name=domain_name)

        return self._patch('/cluster-templates/%s' % cluster_template_id, data,
                           'cluster_template')
Beispiel #8
0
class NodeGroupTemplateManager(base.ResourceManager):
    resource_class = NodeGroupTemplate
    NotUpdated = base.NotUpdated()

    def create(self, name, plugin_name, hadoop_version, flavor_id,
               description=None, volumes_per_node=None, volumes_size=None,
               node_processes=None, node_configs=None, floating_ip_pool=None,
               security_groups=None, auto_security_group=None,
               availability_zone=None, volumes_availability_zone=None,
               volume_type=None, image_id=None, is_proxy_gateway=None,
               volume_local_to_instance=None, use_autoconfig=None,
               shares=None, is_public=None, is_protected=None,
               volume_mount_prefix=None):
        """Create a Node Group Template."""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'hadoop_version': hadoop_version,
            'flavor_id': flavor_id,
            'node_processes': node_processes
        }

        self._copy_if_defined(data,
                              description=description,
                              node_configs=node_configs,
                              floating_ip_pool=floating_ip_pool,
                              security_groups=security_groups,
                              auto_security_group=auto_security_group,
                              availability_zone=availability_zone,
                              image_id=image_id,
                              is_proxy_gateway=is_proxy_gateway,
                              use_autoconfig=use_autoconfig,
                              shares=shares,
                              is_public=is_public,
                              is_protected=is_protected
                              )

        if volumes_per_node:
            data.update({"volumes_per_node": volumes_per_node,
                         "volumes_size": volumes_size})
            if volumes_availability_zone:
                data.update({"volumes_availability_zone":
                             volumes_availability_zone})
            if volume_type:
                data.update({"volume_type": volume_type})
            if volume_local_to_instance:
                data.update(
                    {"volume_local_to_instance": volume_local_to_instance})
            if volume_mount_prefix:
                data.update({"volume_mount_prefix": volume_mount_prefix})

        return self._create('/node-group-templates', data,
                            'node_group_template')

    def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated,
               hadoop_version=NotUpdated, flavor_id=NotUpdated,
               description=NotUpdated, volumes_per_node=NotUpdated,
               volumes_size=NotUpdated, node_processes=NotUpdated,
               node_configs=NotUpdated, floating_ip_pool=NotUpdated,
               security_groups=NotUpdated, auto_security_group=NotUpdated,
               availability_zone=NotUpdated,
               volumes_availability_zone=NotUpdated, volume_type=NotUpdated,
               image_id=NotUpdated, is_proxy_gateway=NotUpdated,
               volume_local_to_instance=NotUpdated, use_autoconfig=NotUpdated,
               shares=NotUpdated, is_public=NotUpdated,
               is_protected=NotUpdated, volume_mount_prefix=NotUpdated):
        """Update a Node Group Template."""

        data = {}
        self._copy_if_updated(
            data, name=name, plugin_name=plugin_name,
            hadoop_version=hadoop_version, flavor_id=flavor_id,
            description=description, volumes_per_node=volumes_per_node,
            volumes_size=volumes_size, node_processes=node_processes,
            node_configs=node_configs, floating_ip_pool=floating_ip_pool,
            security_groups=security_groups,
            auto_security_group=auto_security_group,
            availability_zone=availability_zone,
            volumes_availability_zone=volumes_availability_zone,
            volume_type=volume_type, image_id=image_id,
            is_proxy_gateway=is_proxy_gateway,
            volume_local_to_instance=volume_local_to_instance,
            use_autoconfig=use_autoconfig, shares=shares,
            is_public=is_public, is_protected=is_protected,
            volume_mount_prefix=volume_mount_prefix
        )

        return self._update('/node-group-templates/%s' % ng_template_id, data,
                            'node_group_template')

    def list(self, search_opts=None, marker=None,
             limit=None, sort_by=None, reverse=None):
        """Get a list of Node Group Templates."""
        query = base.get_query_string(search_opts, limit=limit, marker=marker,
                                      sort_by=sort_by, reverse=reverse)
        url = "/node-group-templates%s" % query
        return self._page(url, 'node_group_templates', limit)

    def get(self, ng_template_id):
        """Get information about a Node Group Template."""
        return self._get('/node-group-templates/%s' % ng_template_id,
                         'node_group_template')

    def delete(self, ng_template_id):
        """Delete a Node Group Template."""
        self._delete('/node-group-templates/%s' % ng_template_id)
Beispiel #9
0
class NodeGroupTemplateManagerV2(NodeGroupTemplateManagerV1):
    NotUpdated = base.NotUpdated()

    def create(self,
               name,
               plugin_name,
               plugin_version,
               flavor_id,
               description=None,
               volumes_per_node=None,
               volumes_size=None,
               node_processes=None,
               node_configs=None,
               floating_ip_pool=None,
               security_groups=None,
               auto_security_group=None,
               availability_zone=None,
               volumes_availability_zone=None,
               volume_type=None,
               image_id=None,
               is_proxy_gateway=None,
               volume_local_to_instance=None,
               use_autoconfig=None,
               shares=None,
               is_public=None,
               is_protected=None,
               volume_mount_prefix=None,
               boot_from_volume=None,
               boot_volume_type=None,
               boot_volume_availability_zone=None,
               boot_volume_local_to_instance=None):
        """Create a Node Group Template."""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'plugin_version': plugin_version,
            'flavor_id': flavor_id,
            'node_processes': node_processes
        }

        return self._do_create(
            data, description, volumes_per_node, volumes_size, node_configs,
            floating_ip_pool, security_groups, auto_security_group,
            availability_zone, volumes_availability_zone, volume_type,
            image_id, is_proxy_gateway, volume_local_to_instance,
            use_autoconfig, shares, is_public, is_protected,
            volume_mount_prefix, boot_from_volume, boot_volume_type,
            boot_volume_availability_zone, boot_volume_local_to_instance)

    def update(self,
               ng_template_id,
               name=NotUpdated,
               plugin_name=NotUpdated,
               plugin_version=NotUpdated,
               flavor_id=NotUpdated,
               description=NotUpdated,
               volumes_per_node=NotUpdated,
               volumes_size=NotUpdated,
               node_processes=NotUpdated,
               node_configs=NotUpdated,
               floating_ip_pool=NotUpdated,
               security_groups=NotUpdated,
               auto_security_group=NotUpdated,
               availability_zone=NotUpdated,
               volumes_availability_zone=NotUpdated,
               volume_type=NotUpdated,
               image_id=NotUpdated,
               is_proxy_gateway=NotUpdated,
               volume_local_to_instance=NotUpdated,
               use_autoconfig=NotUpdated,
               shares=NotUpdated,
               is_public=NotUpdated,
               is_protected=NotUpdated,
               volume_mount_prefix=NotUpdated,
               boot_from_volume=NotUpdated,
               boot_volume_type=NotUpdated,
               boot_volume_availability_zone=NotUpdated,
               boot_volume_local_to_instance=NotUpdated):
        """Update a Node Group Template."""

        data = {}
        self._copy_if_updated(
            data,
            name=name,
            plugin_name=plugin_name,
            plugin_version=plugin_version,
            flavor_id=flavor_id,
            description=description,
            volumes_per_node=volumes_per_node,
            volumes_size=volumes_size,
            node_processes=node_processes,
            node_configs=node_configs,
            floating_ip_pool=floating_ip_pool,
            security_groups=security_groups,
            auto_security_group=auto_security_group,
            availability_zone=availability_zone,
            volumes_availability_zone=volumes_availability_zone,
            volume_type=volume_type,
            image_id=image_id,
            is_proxy_gateway=is_proxy_gateway,
            volume_local_to_instance=volume_local_to_instance,
            use_autoconfig=use_autoconfig,
            shares=shares,
            is_public=is_public,
            is_protected=is_protected,
            volume_mount_prefix=volume_mount_prefix,
            boot_from_volume=boot_from_volume,
            boot_volume_type=boot_volume_type,
            boot_volume_availability_zone=boot_volume_availability_zone,
            boot_volume_local_to_instance=boot_volume_local_to_instance)

        return self._patch('/node-group-templates/%s' % ng_template_id, data,
                           'node_group_template')