Skip to content

Instantly share code, notes, and snippets.

View nherbaut's full-sized avatar

Nicolas Herbaut nherbaut

View GitHub Profile
@nherbaut
nherbaut / gist:0ec0d5c3654de7281dea
Last active August 29, 2015 14:16
uploading binary data jersey
@POST
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.TEXT_PLAIN)
public String postIf(InputStream is) throws IOException, SAXException,
TikaException {
java.nio.file.Path path = Files.createTempFile(null, null);
FileOutputStream fos = new FileOutputStream(path.toFile());
ByteStreams.copy(is, fos);
fos.close();
is.close();
@nherbaut
nherbaut / gist:8e9712a2038bf199d560
Created March 13, 2015 09:33
file type test (without file name)
package testtype;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Consumer;
import java.util.stream.Stream;
@nherbaut
nherbaut / gist:46296403a5206d211ab4
Created March 27, 2015 14:42
jersey support several @consume with the same path
package net.viotech;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
@nherbaut
nherbaut / gist:318c807ab76a469fdcc4
Created August 28, 2015 09:41
vio vnf low level architecture
storage_net 14.0.0.0/24
______________________________________________________________________________ ___________________
||
||
core_net 10.0.0.0/24 ||
___________________________ ____________ ________________ __________ _____||__________ _________
|| || || || || || ||
|| ____||_____ __||_______ ____||_____ _||_____||_ ___||_____
|| | CORE-NODE1| | CORE-NODE2| | SWIFT PROXY| | SWIFT NODES| | CONTROLLER|
|| |___________| |___________| |____________| |____________| |___________|
root@proxy1:~# cat /etc/salt/grains
roles:
swift_proxy
root@object1:~# cat /etc/salt/grains
roles:
swift_object
@nherbaut
nherbaut / gist:20b4ae6af5765f11681e
Created September 8, 2015 08:10
http proxy jersey
package test;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.JerseyClientBuilder;
#
# This is a hello world HOT template just defining a single compute
# server.
#
heat_template_version: 2013-05-23
description: >
Hello world HOT template that just defines a single server.
Contains just base features to verify base HOT support.
parameters:
description: Template to deploy one instance with a private network developed on the
spot
heat_template_version: '2014-10-16'
parameters:
availability_zone: {default: 'nova:cnode3', description: The Availability Zone to
launch the instance., type: string}
flavor: {default: m1.medium, description: flavor to be used, label: flavor, type: string}
image: {default: 16cd76bb-af7d-46b9-b208-79dadbd45eca, description: Image to be used for compute instance, label: Image
name or ID, type: string}
public_net: {default: 121ad8e8-a656-4baf-a306-9b88db8de2a8, description: Id of the
import subprocess
import json
subprocess.call(["apt-get install salt-master --yes"],shell=True)
with open("data.json") as f:
data=json.loads(f.read())
{
"description" : "viotech vHG",
"version" : "0.0.1",
"vdus" : [
{
"id" : "vdu0",
"monitoring_parameters" : [
{
"desc" : "CPU Idle",
"metric" : "cpuidle",