soko

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2015 License: MIT Imports: 14 Imported by: 0

README

soko (倉庫)

Server metadata inventory Manager, backended with Consul, EC2, OpenStack Nova and so on

Why soko?

In some case we need to know the server's role(web server? api server?), or master/slave (in case of MySQL, Solr, &c.), or some kind of metadata.

soko is designed for handling such metadata from Server inventory in one liner.

soko is very friendly with shell scripts(which are easy and available in cloud-init), ohai for Chef, facter for Puppet, run_command in Itamae, and so on.

Inventory backends with:

  • Consul KV
  • EC2's Tags
  • Metadata attribute in OpenStack Compute API v2

And more, soon...

Install

[cloud-user@www901 ~]$ ./soko help
Usage of ./soko:
  -server-id="f6809f77-e7b2-4d66-832e-XXXX": Target server's ID to get/put/delete. Defaults to cloud-init's server ID
[cloud-user@www901 ~]$ ./soko get Hi
Value for Hi seems to be empty.

[cloud-user@www901 ~]$ ./soko get Test
Value for Test seems to be empty.

[cloud-user@www901 ~]$ ./soko put Test Hello
OK
[cloud-user@www901 ~]$ ./soko get Test
Hello
[cloud-user@www901 ~]$ ./soko delete Test
OK
[cloud-user@www901 ~]$ ./soko get Test
Value for Test seems to be empty.

Configuration

  • Exists /etc/soko.toml
[default]
# backend should be in [consul, aws, openstack]
backend = "consul"

[consul]
# Set just a consul backend URL
url = "consul://foo.example.consul:8500/"

[openstack]
# OpenStack specific config
username = "udzura"
password = "XXXXXXXXXXXXXX"
tenant_name = "soko-test"
auth_url = "https://keystone.example.com:1234/v2.0"
region = "RegionOne"

[aws]
# AWS specific config
access_key_id = "AKIXXXXXXXXXXXXX"
secret_access_key = "4Jr6DXXXXXXXXXXXXXXXXXXXXXX"
region = "ap-northeast-1"
  • You can configure soko by one liner:
$ soko open aws access_key_id=$AWS_ACCESS_KEY_ID secret_access_key=$AWS_SECRET_ACCESS_KEY region=ap-northeast-1
# It goes such a way with other backends

soko will work on

  • Cloud servers(such as EC2, OpenStack... with file /var/lib/cloud/data/instance-id existing)
  • Cousul cluster backended
Under testing
  • OpenStack compute API v2
  • AWS EC2

Yaruzo!!

  • Google Compute Engine
  • etcd....???
  • Redis....??????

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Variables

This section is empty.

Functions

func CloudServerID

func CloudServerID() string

Types

type AWSBackend added in v0.1.0

type AWSBackend struct {
	SectionConfig
	// contains filtered or unexported fields
}

func NewAWSBackend added in v0.1.0

func NewAWSBackend(config SectionConfig) (*AWSBackend, error)

func (*AWSBackend) Delete added in v0.1.0

func (b *AWSBackend) Delete(serverID string, key string) error

func (*AWSBackend) Get added in v0.1.0

func (b *AWSBackend) Get(serverID string, key string) (string, error)

func (*AWSBackend) Put added in v0.1.0

func (b *AWSBackend) Put(serverID string, key string, value string) error

func (*AWSBackend) Save added in v0.1.0

func (b *AWSBackend) Save() error

type Backend

type Backend interface {
	// Saves current configuration to a specific file
	Save() error

	// APIs to control backend metadata
	// Gets value from key
	Get(serverID string, key string) (string, error)

	// Put value on the key
	Put(serverID string, key string, value string) error

	// Delete value on the key
	Delete(serverID string, key string) error
}

func FindBackend

func FindBackend(config *Config) (Backend, error)

type Config added in v0.0.2

type Config struct {
	Backend string
	SectionConfig
}

func DefaultConfig added in v0.0.2

func DefaultConfig() (*Config, error)

func NewConfig added in v0.1.0

func NewConfig(backend string, args []string) (*Config, error)

func (*Config) SetConfigByBackend added in v0.1.0

func (c *Config) SetConfigByBackend(data *toml.TomlTree) error

type ConsulBackend

type ConsulBackend struct {
	// contains filtered or unexported fields
}

func NewConsulBackend

func NewConsulBackend(hostWithPort string, ssl bool) (*ConsulBackend, error)

func (*ConsulBackend) Delete

func (b *ConsulBackend) Delete(serverID string, key string) error

func (*ConsulBackend) Get

func (b *ConsulBackend) Get(serverID string, key string) (string, error)

func (*ConsulBackend) Put

func (b *ConsulBackend) Put(serverID string, key string, value string) error

func (*ConsulBackend) Save

func (b *ConsulBackend) Save() error

type OpenStackBackend added in v0.1.0

type OpenStackBackend struct {
	SectionConfig
	// contains filtered or unexported fields
}

func NewOpenStackBackend added in v0.1.0

func NewOpenStackBackend(config SectionConfig) (*OpenStackBackend, error)

func (*OpenStackBackend) Delete added in v0.1.0

func (b *OpenStackBackend) Delete(serverID string, key string) error

func (*OpenStackBackend) Get added in v0.1.0

func (b *OpenStackBackend) Get(serverID string, key string) (string, error)

func (*OpenStackBackend) Put added in v0.1.0

func (b *OpenStackBackend) Put(serverID string, key string, value string) error

func (*OpenStackBackend) Save added in v0.1.0

func (b *OpenStackBackend) Save() error

type Runner

type Runner struct {
	ServerID string
	// contains filtered or unexported fields
}

func (*Runner) Delete

func (r *Runner) Delete(key string)

func (*Runner) Get

func (r *Runner) Get(key string)

func (*Runner) Put

func (r *Runner) Put(key string, value string)

func (*Runner) Run

func (r *Runner) Run(subcommand string, args []string)

func (*Runner) Save added in v0.1.0

func (r *Runner) Save()

type SectionConfig added in v0.1.0

type SectionConfig map[string]string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL