hivy

package module
v0.1.1-0...-f25bbfc Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2013 License: Apache-2.0 Imports: 15 Imported by: 0

README

Unide logo

Hivy

Hivy is the restful interface of the Unide project that wires users commands and backends services.

Mostly it lets you setup and build a container powered by the dna, optimized as a development workspace and ready to connect to other services as databases, dashboards...

Out of the box it exposes juju command, users authentification, and admin related commands. Powerful IT infrasctructure building accessible from robust but simple http requests !

See it in action

Status

Build Status Coverage Status

Branch Version
Stable 0.1.5
Develop 0.2.9

Attention Project is in an early alpha, and under heavy development.

Note also I use it to improve my go and devops skills so there might be some extra dependencies I am testing.

Suit up

First make sure etcd binary is available in your $PATH. You will need also a redis server for workers (powered by resque, go port).

go get -v github.com/hivetech/hivy

Or For development (it will setup etcd)

$ git clone https://github.com/hivetech/hivy.git
$ cd app && rake

$ rake app:run

Usage

$ rake app:init  # Create admin user and set default hivy configuration
$ hivy --help
$ hivy -d .conf -n master --verbose  
$ # Or full deployement
$ cd $HIVY_PATH/hivy && forego start

$ # In another terminal
$ # Create a new standard user
$ curl --user admin:root http://127.0.0.1:8080/v0/methods/user?id=name&pass=pass&group=admin -X PUT
$ curl --user name:pass http://127.0.0.1:8080/v0/methods/dummy  # Test your installation

$ # With the provided clients and boxcars proxy on
$ ./scripts/request get help

$ ./scripts/request put node?id=hivelab
$ ./scripts/request put node?id=mysql
$ ./scripts/request put node/plug?id=hivelab&with=mysql

$ ./scripts/request get login > id_rsa
$ ./scripts/request get node?id=hivelab
$ ssh ubuntu@l$YOUR_HOST -p $SSH_PORT -i id_rsa

$ # Configuration management
$ ./scripts/config set hivy/security/{user}/password secret
$ ./scripts/config set {user}/{node}/series precise
$ ./scripts/config set {user}/{node}/expose True

API

Here are listed currently supported methods. With the hivy app, all need user:pass authentification, and permissions:

# Admin action methods
PUT /v0/methods/user?id={user}&pass={pass}&group={group}
DELETE /user?id={user}
# User methods
GET /v0/methods/dummy/
GET /v0/methods/help?method={method}  # method is optionnal
GET /v0/methods/login
GET /v0/methods/node
GET /v0/methods/node?id={name}
PUT /v0/methods/node?id={name}
DELETE /v0/methods/node?id={name}
PUT /v0/methods/node/plug?id={name}&with={relation}

# Configuration methods
#TODO This is on a different port (4001) for now
GET /v1/keys/{ topology below }

Etcd configuration storage topology

Etcd storage follows filesystem convention.

http://127.0.0.1:4001/v1/keys/hivy/setting1
                                   ...
                                   settingN
                                   security/user1
                                            ...
                                            userN/password
                                                  methods/method1
                                                          ...
                                                          methodN
                                                  ressources/ressource1
                                                             ...
                                                             ressourceN
                             /user1
                             ...
                             /userN/node1
                                    ...
                                   /nodeN/setting1
                                          ...
                                          settingN
                             /backends/localhost/name1
                                                 ...

Documentation

Check it out on gowalker, godoc, or browse it locally:

$ make doc
$ firefox http://localhost:6060/pkg/github.com/hivetech/hivy/

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here =)

License

Hivy is available under the Apache License, Version 2.0.


Gophaer

Documentation

Overview

Package hivy - REST framework ============================

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Gate between user requests and Hive jobs. The client sends authentified http requests to reach endpoints defined in the endpoints directory. Through the process a centralized configuration server, backed by etcd, stores user-defined and hive settings, and a central authority is asked for methods permissions. Login and password are provided through standard http mechanism and currently verified in etcd database after some base64 decoding.

Usage example:

$ go run hivy.hivy.go --verbose --listen 0.0.0.0:8080

Client usage example

$ GET -C name:pass http://localhost:8080/login/
$ curl --user name:pass http://127.0.0.1:8080/juju/deploy?project=trading
$ python -m "import requests; requests.delete('http://127.0.0.1:8080/user', data={'user': 'Chuck'}, auth=('user', 'pass')'"

Index

Constants

View Source
const (
	// GlobalHelp shows a sum up of the app
	GlobalHelp string = `
RESTful framework for busy people. Effectively expose secured, fully configurable background jobs.
`

	// NodeHelp explains juju exposed endpoints
	NodeHelp string = `` /* 539-byte string literal not displayed */

	// LoginHelp explains what happens when logging in
	LoginHelp string = `
Format: GET /login
If well authentified, hivy returns a private ssh key for further secured interactions.
`

	// UserHelp details endpoints relative to user management
	UserHelp string = `` /* 238-byte string literal not displayed */

	// HelpHelp explains the help endpoint
	HelpHelp string = `` /* 156-byte string literal not displayed */

	// ConfigHelp explains etcd interaction
	ConfigHelp string = `` /* 144-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(request *restful.Request, response *restful.Response)

CreateUser Stores given credentials and creates methods permission for the given user, regarding the given group (only admin and standard group are supported at the moment)

func DeleteUser

func DeleteUser(request *restful.Request, response *restful.Response)

DeleteUser removes from etcd storage evrything related to the given user-id

func Deploy

func Deploy(request *restful.Request, response *restful.Response)

Deploy creates new nodes

func Destroy

func Destroy(request *restful.Request, response *restful.Response)

Destroy removes nodes

func Dummy

func Dummy(request *restful.Request, response *restful.Response)

Dummy is the hello-world endpoint, for demo and test purpose

func EmptyJSON

func EmptyJSON() *simplejson.Json

EmptyJSON is a commodity shortcut

func Help

func Help(request *restful.Request, response *restful.Response)

Help provides a json object describing available commands

func JSON

func JSON(data string) *simplejson.Json

JSON converts string to simple.Json object

func Login

func Login(request *restful.Request, response *restful.Response)

Login is an endpoint that delivers a certificate, used later for etcd communication permission. It is used as a callback wen registered with a path at the authority server

func Plug

func Plug(request *restful.Request, response *restful.Response)

Plug allows interactions between two nodes

func Status

func Status(request *restful.Request, response *restful.Response)

Status fetchs informations about the given node id

Types

type Juju

type Juju struct {
	Path       string
	Controller *beacon.Controller
}

Juju is a provider used for Nodes management

func NewJuju

func NewJuju() (*Juju, error)

NewJuju initializes juju provider informations

func (*Juju) AddRelation

func (jj *Juju) AddRelation(user, serviceOne, serviceTwo string) (*simplejson.Json, error)

AddRelation links two juju services

func (*Juju) Charmstore

func (jj *Juju) Charmstore(service string) (string, string, error)

Charmstore search for the appropriate configuration

func (*Juju) Deploy

func (jj *Juju) Deploy(user, service string) (*simplejson.Json, error)

Deploy uses juju deploy to create a new service

func (*Juju) Destroy

func (jj *Juju) Destroy(user, service string) (*simplejson.Json, error)

Destroy uses juju destroy to remove a service

func (*Juju) Status

func (jj *Juju) Status(user, service string) (*simplejson.Json, error)

Status fetches given service informations

Directories

Path Synopsis
Package security takes care of user's https requests authentification
Package security takes care of user's https requests authentification

Jump to

Keyboard shortcuts

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