Beispiel #1
0
    def post(self, request):
        """Create a Subnet for a given Network

        :param name (optional):  The subnet name.
        :param network_id: The ID of the attached network.
        :param tenant_id (optional): The ID of the tenant who owns the network.
                Only administrative users can specify a tenant ID other than
                their own.
        :param allocation_pools (optional): The start and end addresses for the
                allocation pools.
        :param gateway_ip (optional): The gateway IP address.
        :param ip_version: The IP version, which is 4 or 6.
        :param cidr: The CIDR.
        :param id (optional): The ID of the subnet.
        :param enable_dhcp (optional): Set to true if DHCP is enabled and false
                if DHCP is disabled.

        :return: JSON representation of a Subnet

        """
        new_subnet = api.neutron.subnet_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/neutron/subnets/%s' % new_subnet.id,
            new_subnet.to_dict()
        )
Beispiel #2
0
    def post(self, request, container, object_name):
        """Create or replace an object or pseudo-folder

        :param request:
        :param container:
        :param object_name:

        If the object_name (ie. POST path) ends in a '/' then a folder is
        created, rather than an object. Any file content passed along with
        the request will be ignored in that case.

        POST parameter:

        :param file: the file data for the upload.

        :return:
        """
        form = UploadObjectForm(request.POST, request.FILES)
        if not form.is_valid():
            raise rest_utils.AjaxError(500, 'Invalid request')

        data = form.clean()

        if object_name[-1] == '/':
            result = api.swift.swift_create_pseudo_folder(
                request, container, object_name)
        else:
            result = api.swift.swift_upload_object(request, container,
                                                   object_name, data['file'])

        return rest_utils.CreatedResponse(
            u'/api/swift/containers/%s/object/%s' % (container, result.name))
Beispiel #3
0
    def post(self, request):
        """Create a network

        :param  admin_state_up (optional): The administrative state of the
                network, which is up (true) or down (false).
        :param name (optional): The network name. A request body is optional:
                If you include it, it can specify this optional attribute.
        :param net_profile_id (optional): network profile id
        :param shared (optional): Indicates whether this network is shared
                across all tenants. By default, only administrative users can
                change this value.
        :param tenant_id (optional): Admin-only. The UUID of the tenant that
                will own the network. This tenant can be different from the
                tenant that makes the create network request. However, only
                administrative users can specify a tenant ID other than their
                own. You cannot change this value through authorization
                policies.

         :return: JSON representation of a Network
         """
        if not api.neutron.is_port_profiles_supported():
            request.DATA.pop("net_profile_id", None)
        new_network = api.neutron.network_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/neutron/networks/%s' % new_network.id,
            new_network.to_dict()
        )
Beispiel #4
0
    def post(self, request):
        flavor_access = request.DATA.get('flavor_access', [])
        flavor_id = request.DATA['id']
        is_public = not flavor_access

        flavor = api.nova.flavor_create(request,
                                        name=request.DATA['name'],
                                        memory=request.DATA['ram'],
                                        vcpu=request.DATA['vcpus'],
                                        disk=request.DATA['disk'],
                                        ephemeral=request
                                        .DATA['OS-FLV-EXT-DATA:ephemeral'],
                                        swap=request.DATA['swap'],
                                        flavorid=flavor_id,
                                        is_public=is_public
                                        )

        for project in flavor_access:
            api.nova.add_tenant_to_flavor(
                request, flavor.id, project.get('id'))

        return rest_utils.CreatedResponse(
            '/api/nova/flavors/%s' % flavor.id,
            flavor.to_dict()
        )
    def post(self, request):
        """Create ADC instance.
        """

        rlt = api.f5wafaas.adc_create(request)
        return rest_utils.CreatedResponse(
            '/api/f5services/adcs/%s' % rlt['id'], rlt)
Beispiel #6
0
    def post(self, request):
        """Create a user.

        Create a user using the parameters supplied in the POST
        application/json object. The base parameters are name (string), email
        (string, optional), password (string, optional), project_id (string,
        optional), enabled (boolean, defaults to true). The user will be
        created in the default domain.

        This action returns the new user object on success.
        """
        # not sure why email is forced to None, but other code does it
        domain = api.keystone.get_default_domain(request)
        new_user = api.keystone.user_create(
            request,
            name=request.DATA['name'],
            email=request.DATA.get('email') or None,
            password=request.DATA.get('password'),
            project=request.DATA.get('project_id'),
            enabled=True,
            domain=domain.id)

        # assign role to user
        api.keystone.add_tenant_user_role(
            request,
            project=request.DATA.get('project_id'),
            user=new_user.id,
            role=request.DATA.get('role_id'))

        return rest_utils.CreatedResponse(
            '/api/keystone/users/%s' % new_user.id, new_user.to_dict())
Beispiel #7
0
    def post(self, request):
        """Create a user.

        Create a user using the parameters supplied in the POST
        application/json object. The base parameters are name (string), email
        (string, optional), password (string), project (string,
        optional), enabled (boolean, defaults to true), description
        (string, optional). The user will be created in the default domain.

        This action returns the new user object on success.
        """

        domain = api.keystone.get_default_domain(request)

        new_user = api.keystone.user_create(
            request,
            name=request.DATA['name'],
            email=request.DATA.get('email') or None,
            password=request.DATA.get('password'),
            project=request.DATA.get('project') or None,
            enabled=request.DATA.get('enabled', True),
            description=request.DATA.get('description') or None,
            domain=request.DATA.get('domain_id') or domain.id)

        return rest_utils.CreatedResponse(
            '/api/keystone/users/%s' % new_user.id, new_user.to_dict())
Beispiel #8
0
    def post(self, request):
        """Create a new Pod.

        Returns the new Pod object on success.
        """
        new_pod = magnum.pod_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/containers/pod/%s' % new_pod.uuid, new_pod.to_dict())
Beispiel #9
0
    def post(self, request):
        """Create a new Bay.

        Returns the new Bay object on success.
        """
        new_bay = magnum.bay_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/containers/bay/%s' % new_bay.uuid, new_bay.to_dict())
Beispiel #10
0
    def post(self, request):
        """Create a new Certificate.

        Returns the new Cert.pem string from csr for a cluster on success.
        """
        new_cert = magnum.certificate_create(request, **request.DATA)
        return rest_utils.CreatedResponse('/api/container_infra/certificates/',
                                          new_cert.to_dict())
Beispiel #11
0
 def post(self, req, policy_id):
     minimum_bandwidth_rule = api.neutron.minimum_bandwidth_rule_create(
         req, policy_id, **req.DATA)
     return rest_utils.CreatedResponse(
         '/api/neutron/qospolicies/minimumbandwidthrules/%s'
         % minimum_bandwidth_rule.id,
         minimum_bandwidth_rule.to_dict()
     )
Beispiel #12
0
    def post(self, request, id):
        """Update a Secret.

        Returns the updated Secret object on success.
        """
        secret = client.secret_update(request, id, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/barbican/secret/%s' % secret.uuid, secret.to_dict())
Beispiel #13
0
    def get(self, request, subcloud_id):
        """Generate a config for a specific subcloud."""

        response = dc_manager.subcloud_generate_config(request, subcloud_id,
                                                       request.GET.dict())
        response = {'config': response}
        return rest_utils.CreatedResponse('/api/dc_manager/subclouds/',
                                          response)
Beispiel #14
0
    def put(self, request):
        """Create a new Secret.

        Returns the new Secret object on success.
        """
        secret = client.secret_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/barbican/secret/%s' % secret.uuid, secret.to_dict())
Beispiel #15
0
 def post(self, request, container, object_name):
     dest_container = request.DATA['dest_container']
     dest_name = request.DATA['dest_name']
     result = api.swift.swift_copy_object(request, container, object_name,
                                          dest_container, dest_name)
     return rest_utils.CreatedResponse(
         u'/api/swift/containers/%s/object/%s' %
         (dest_container, result.name))
    def post(self, request):
        """Create a new Image.

        Returns the new Image object on success.
        """
        new_image = client.image_create(request, **request.DATA)
        return rest_utils.CreatedResponse('/api/zun/image/%s' % new_image.uuid,
                                          new_image.to_dict())
Beispiel #17
0
    def post(self, request):
        """Create a new Cluster Template.

        Returns the new ClusterTemplate object on success.
        """
        new_template = magnum.cluster_template_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/container_infra/cluster_template/%s' % new_template.uuid,
            new_template.to_dict())
Beispiel #18
0
 def post(self, req, policy_id):
     """Create QoS DSCP Marking rules."""
     dscp_marking_rule = api.neutron.dscp_marking_rule_create(
         req, policy_id, **req.DATA)
     return rest_utils.CreatedResponse(
         '/api/neutron/qospolicies/dscpmarkingrules/%s'
         % dscp_marking_rule.id,
         dscp_marking_rule.to_dict()
     )
Beispiel #19
0
    def create(self, request):
        """Create a new backup.

        Returns the new backup object on success.
        """
        new_backup = trove.backup_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/messaging/backups/%s' % new_backup.name,
            new_backup.to_dict())
Beispiel #20
0
    def post(self, request):
        """Create a new Capsule.

        Returns the new Capsule object on success.
        """
        new_capsule = client.capsule_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/zun/capsules/%s' % new_capsule.uuid,
            new_capsule.to_dict())
Beispiel #21
0
    def post(self, request):
        """Create a new Quota.

        Returns the new Quota object on success.
        """
        created = magnum.quotas_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            ('/api/container_infra/quotas/%s/%s' %
             (created.project_id, created.resource)), created.to_dict())
Beispiel #22
0
    def post(self, request):
        """Create a new Container.

        Returns the new Container object on success.
        """
        container = magnum.container_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/containers/container/%s' % container.uuid,
            container.to_dict())
Beispiel #23
0
    def put(self, request):
        """Create a new {{cookiecutter.panel_func}}.

        Returns the new {{cookiecutter.panel_func}} object on success.
        """
        {{cookiecutter.panel}} = client.{{cookiecutter.panel}}_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}/%s' % {{cookiecutter.panel}}.uuid,
            {{cookiecutter.panel}}.to_dict())
Beispiel #24
0
    def post(self, request, queue_name):
        """Update a queue.

        Returns the updated queue object on success.
        """
        queue = zaqar.queue_update(request, queue_name, **request.DATA)
        location = '/api/zaqars/queue/%s' % queue._name
        response = {'name': queue._name, 'metadata': queue._metadata}
        return rest_utils.CreatedResponse(location, response)
Beispiel #25
0
    def post(self, request):
        """Create a new ReplicationController.

        Returns the new ReplicationController object on success.
        """
        new_rc = magnum.rc_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/containers/replicationcontrollers/%s' % new_rc.uuid,
            new_rc.to_dict())
Beispiel #26
0
 def post(self, req, policy_id):
     """Create QoS Minimum Packet Rate rules."""
     minimum_packet_rate_rule = api.neutron.minimum_packet_rate_rule_create(
         req, policy_id, **req.DATA)
     return rest_utils.CreatedResponse(
         '/api/neutron/qospolicies/minimumpacketraterules/%s'
         % minimum_packet_rate_rule.id,
         minimum_packet_rate_rule.to_dict()
     )
Beispiel #27
0
 def post(self, req, policy_id):
     """Create QoS Bandwidth Limit rules."""
     bandwidth_limit_rule = api.neutron.bandwidth_limit_rule_create(
         req, policy_id, **req.DATA)
     return rest_utils.CreatedResponse(
         '/api/neutron/qospolicies/bandwidthlimitrules/%s'
         % bandwidth_limit_rule.id,
         bandwidth_limit_rule.to_dict()
     )
Beispiel #28
0
    def post(self, request):
        """Create a new Service.

        Returns the new Service object on success.
        """
        new_service = magnum.service_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/containers/service/%s' % new_service.uuid,
            new_service.to_dict())
Beispiel #29
0
    def patch(self, request, cluster_id):
        """Update a Cluster.

        Returns the Cluster object on success.
        """
        params = request.DATA
        updated_cluster = magnum.cluster_update(request, cluster_id, **params)
        return rest_utils.CreatedResponse(
            '/api/container_infra/cluster/%s' % cluster_id,
            updated_cluster.to_dict())
    def post(self, request):
        """Create a new Container.

        Returns the new Container object on success.
        If 'run' attribute is set true, do 'run' instead 'create'
        """
        new_container = client.container_create(request, **request.DATA)
        return rest_utils.CreatedResponse(
            '/api/zun/container/%s' % new_container.uuid,
            new_container.to_dict())