<commit_before>package network

import (
	"encoding/json"
	"errors"
	"net"

	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/socketplane/ecc"
)

const networkStore = "network"
const vlanStore = "vlan"
const DefaultNetworkName = "default"

const vlanCount = 4096

type Network struct {
	ID     string `json:"id"`
	Subnet string `json:"subnet"`
	Vlan   uint   `json:"vlan"`
}

func GetNetwork(id string) (*Network, error) {
	netByteArray, _, ok := ecc.Get(networkStore, id)
	if ok {
		network := &Network{}
		err := json.Unmarshal(netByteArray, network)
		if err != nil {
			return nil, err
		}
		return network, nil
	}
	return nil, errors.New("Network unavailable")
}

func CreateNetwork(id string, subnet *net.IPNet) (*Network, error) {
	network, err := GetNetwork(id)
	if err == nil {
		return network, nil<commit_msg>GetNetworks Support<commit_after>package network

import (
	"encoding/json"
	"errors"
	"net"

	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/socketplane/ecc"
)

const networkStore = "network"
const vlanStore = "vlan"
const DefaultNetworkName = "default"

const vlanCount = 4096

type Network struct {
	ID     string `json:"id"`
	Subnet string `json:"subnet"`
	Vlan   uint   `json:"vlan"`
}

func GetNetworks() ([]Network, error) {
	netByteArray, _, ok := ecc.GetAll(networkStore)
	if ok {
		var networks []Network
		for _, byteArray := range netByteArray {
			network := Network{}
			err := json.Unmarshal(byteArray, &network)
			if err != nil {
				return nil, err
			}
			networks = append(networks, network)
		}
		return networks, nil
	}
	return nil, errors.New("Network unavailable")
}

func GetNetwork(id string) (*Network, error) {
	netByteArray, _, ok := ecc.Get(networkStore, id)
	if ok {
		network := &Network{}
		err := json.Unmarshal(netByteArray, network)
		if err != nil {
			return nil, err
		}
		return network, nil
	}
	return nil, errors.New("Network unavailable")
}

func CreateNetwork(id string, subnet *net.IPNet) (*Network, error) {
	network, err := GetNetwork(id)
	if err == nil {
		return network, nil
{'fraction_non_alphanumeric': 0.13135186960690318, 'fraction_numerical': 0.003835091083413231, 'mean_word_length': 4.191542288557214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4898567', 'n_tokens_mistral': 757, 'n_tokens_neox': 707, 'n_words': 189}