<commit_before>package com.orange.oss.cloudfoundry.cscpi;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jclouds.cloudstack.domain.VirtualMachine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.orange.oss.cloudfoundry.cscpi.domain.Network;
import com.orange.oss.cloudfoundry.cscpi.domain.Networks;

/**
 * generates setting.json description to be exposed in bosh registry. Manages
 * setting.json update with attach / detach persistent disk (add disk_id
 * reference, and linux fs path /vokume id)
 * 
 * see
 * https://github.com/cloudfoundry/bosh-agent/blob/master/settings/settings.go
 * 
 * NB: yaml not json
 * 
 * @author poblin
 *
 */
public class VmSettingGeneratorImpl implements VmSettingGenerator {

	private static Logger logger = LoggerFactory
			.getLogger(VmSettingGeneratorImpl.class.getName());

	public static class Setting {
		public String agent_id;
		public BlobStore blobstore = new BlobStore();
		public Disks disks = new Disks();
		public Map<String, String> env = new HashMap<String, String>();
		// public NetworksSetting networks=new NetworksSetting();
		public Map<String, Network> networks;
		public List<String> ntp = new ArrayList<String>();
		public String mbus = "https://mbus:mbus-password@0.0.0.0:6868";
		public VM vm = new VM();
		public String trusted_certs;
	}

	public static class BlobStore {
		public String provider = "local"; // dav
		public Map<String, String> options = new HashMap<String, String>();
	}


	public static class Disks {
		String system = "/dev/xvda";
		String ephemeral = "/dev/sdb";
		// use sdb due to parsing issue with /dev/xvdb see
		// https://github.com/cloudfoundry/bosh-agent/blob/master/infrastructure/devicepathresolver/mapped_device_path_resolver.go
		// (line 45)
		Map<String, PersistentDisk> persistent = new HashMap<String, PersistentDisk>();
	}

	public static class PersistentDisk {
		String path;
		@JsonProperty(value="volume-id")
		String volumeId;<commit_msg>fix: attribut is volume_id (not volume-id)<commit_after>package com.orange.oss.cloudfoundry.cscpi;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jclouds.cloudstack.domain.VirtualMachine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.orange.oss.cloudfoundry.cscpi.domain.Network;
import com.orange.oss.cloudfoundry.cscpi.domain.Networks;

/**
 * generates setting.json description to be exposed in bosh registry. Manages
 * setting.json update with attach / detach persistent disk (add disk_id
 * reference, and linux fs path /vokume id)
 * 
 * see
 * https://github.com/cloudfoundry/bosh-agent/blob/master/settings/settings.go
 * 
 * NB: yaml not json
 * 
 * @author poblin
 *
 */
public class VmSettingGeneratorImpl implements VmSettingGenerator {

	private static Logger logger = LoggerFactory
			.getLogger(VmSettingGeneratorImpl.class.getName());

	public static class Setting {
		public String agent_id;
		public BlobStore blobstore = new BlobStore();
		public Disks disks = new Disks();
		public Map<String, String> env = new HashMap<String, String>();
		// public NetworksSetting networks=new NetworksSetting();
		public Map<String, Network> networks;
		public List<String> ntp = new ArrayList<String>();
		public String mbus = "https://mbus:mbus-password@0.0.0.0:6868";
		public VM vm = new VM();
		public String trusted_certs;
	}

	public static class BlobStore {
		public String provider = "local"; // dav
		public Map<String, String> options = new HashMap<String, String>();
	}


	public static class Disks {
		String system = "/dev/xvda";
		String ephemeral = "/dev/sdb";
		// use sdb due to parsing issue with /dev/xvdb see
		// https://github.com/cloudfoundry/bosh-agent/blob/master/infrastructure/devicepathresolver/mapped_device_path_resolver.go
		// (line 45)
		Map<String, PersistentDisk> persistent = new HashMap<String, PersistentDisk>();
	}

	public static class PersistentDisk {
		String path;
		@JsonProperty(value="volume_id")
		String volumeId;
{'fraction_non_alphanumeric': 0.10790179492469569, 'fraction_numerical': 0.004951516401898081, 'mean_word_length': 4.840963855421687, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5398382', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1442, 'n_words': 366}