Example #1
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Command accepts only the subnet ID as an"
                               " argument. Use snf-manage subnet-modify --help"
                               " for more info.")

        subnet_id = args[0]
        name = options["name"]

        if not name:
            raise CommandError("--name is mandatory")

        subnet = common.get_resource("subnet", subnet_id, for_update=True)
        user_id = common.get_resource("network", subnet.network.id).userid

        subnets.update_subnet(sub_id=subnet_id, name=name, user_id=user_id)
Example #2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Command accepts only the subnet ID as an"
                               " argument. Use snf-manage subnet-modify --help"
                               " for more info.")

        subnet_id = args[0]
        name = options["name"]

        if not name:
            raise CommandError("--name is mandatory")

        subnet = common.get_subnet(subnet_id)
        user_id = common.get_network(subnet.network.id).userid

        subnets.update_subnet(sub_id=subnet_id,
                              name=name,
                              user_id=user_id)
Example #3
0
def update_subnet(request, sub_id):
    """Update the fields of a subnet
    Only the name can be updated, everything else returns BadRequest

    """

    dictionary = utils.get_json_body(request)
    user_id = request.user_uniq

    try:
        subnet = dictionary['subnet']
    except KeyError:
        raise api.faults.BadRequest("Malformed request")

    if len(subnet) != 1 or "name" not in subnet:
        raise api.faults.BadRequest("Only the name of a subnet can be updated")

    name = subnet.get("name", None)

    subnet_dict = subnet_to_dict(subnets.update_subnet(sub_id, name, user_id))
    data = json.dumps({'subnet': subnet_dict})
    return HttpResponse(data, status=200)
Example #4
0
def update_subnet(request, sub_id):
    """Update the fields of a subnet
    Only the name can be updated, everything else returns BadRequest

    """

    dictionary = utils.get_json_body(request)
    user_id = request.credentials.userid

    try:
        subnet = dictionary['subnet']
    except KeyError:
        raise api.faults.BadRequest("Malformed request")

    if len(subnet) != 1 or "name" not in subnet:
        raise api.faults.BadRequest("Only the name of a subnet can be updated")

    name = subnet.get("name", None)

    subnet_dict = subnet_to_dict(subnets.update_subnet(sub_id, name, user_id))
    data = json.dumps({'subnet': subnet_dict})
    return HttpResponse(data, status=200)