operator

package module
v0.0.0-...-3a65669 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

README

mistify-operator-admin

The "Operator Admin API" is used by the system administrators to control the Mistify system. This includes such things as adding or removing users, adding or removing hypervisors, and general configuraion. Higher level functionality, like creating guests, will not handled here.

The API is implemented as a simple HTTP service in Go. The datastore is a redundant, replicated "cluster" of Postgres servers.

All data is datacenter specific unless otherwise specified. All ids are uuids unless otherwise specified. All entities except for config have a metadata map[string]string

List results are JSON arrays of of the particular objects (e.g. GET /hypervisors returns an array of Hypervisor objects). Single get and create results areturn the particular object. Relation results return empty objects.

Testing

Run make test. This will create the necessary test database and db user, run the tests for the various subpackages, and then clean up the database and db user. The clean happens at the beginning and the end, so there is no need to explicitly run make test_clean after a failed test run before the next.

API Endpoints

Config

Configuration is stored with namespaced keys. Keys will use set values and fall back to defaults. Custom namespaces and keys can be created and deleted, while core namespaces and keys can only be unset (the defaults remain).

  • /config
    • GET - Get the full config set
    • PUT - Set the full config set
    • PATCH - Set part of the config
  • /config/{namespace}
    • GET - Get a namespace config set
    • PUT - Set a namespace config set
    • DELETE - Delete a namespace config set
  • /config/{namespace}/{key}
    • DELETE - Delete a key
Flavors

Flavors represent a desired set of system resources, similar to AWS EC2's instance types m3.medium or c3.2xlarge

  • /flavors
    • GET - Get a list of flavors
    • POST - Create a new flavor
  • /flavors/{flavorID}
    • GET - Get a flavor
    • PATCH - Update a flavor
    • DELETE - Remove a flavor
Hypervisors

Hypervisors run on physical machines and manage the virtual guests.

  • /hypervisors
    • GET - Get a list of hypervisors
    • POST - Register a hypervisor
  • /hypervisors/{hypervisorID}
    • GET - Get a hypervisor
    • PATCH - Update a hypervisor
    • DELETE - Deregister a hypervisor
  • /hypervisors/{hypervisorID}/ipranges
    • GET - Get a list of ipranges related to a hypervisor
    • PUT - Set a list of ipranges related to a hypervisor
  • /hypervisors/{hypervisorID}/ipranges/{iprangeID}
    • PUT - Associate a hypervisor with an iprange
    • DELETE - Disassociate a hypervisor from an iprange
IP Ranges

IP ranges are configured ip blocks that are associated with hypervisors for guests to get allocated from.

  • /ipranges
    • GET - Get a list of IP ranges
    • POST - Create an IP range
  • /ipranges/{iprangeID}
    • GET - Get an IP range
    • PATCH - Update an IP range
    • DELETE - Delete an IP range
  • /ipranges/{iprangeID}/hypervisors
    • GET - Get a list of hypervisors associated with an IP range
    • PUT - Set a list of hypervisors associated with an IP range
  • /ipranges/{iprangeID}/hypervisors/{hypervisorID}
    • PUT - Associate an IP range with a hypervisor
    • DELETE - Disassociate an IP range from a hypervisor
  • /ipranges/{iprangeID}/network
    • GET - Get the network associated with an IP range
  • /ipranges/{iprangeID}/network/{networkID}
    • PUT - Set the network associated with an IP range
    • DELETE - Disassociate the network associated with an IP range
Networks

Networks are named sets of IP Ranges.

  • /networks
    • GET - Get a list of networks
    • POST - Create a network
  • /networks/{networkID}
    • GET - Get a network
    • PATCH - Update a network
    • DELETE - Delete a network
  • /networks/{networkID}/ipranges
    • GET - Get a list of IP ranges associated with a network
    • PUT - Set a list of IP ranges associated with a network
  • /networks/{networkID}/ipranges/{iprangeID}
    • PUT - Associate a network with an IP range
    • DELETE - Disassociate a network from an IP range
Permissions

Permissions are allowed actions on entities for services. Permissions are associated with projects, with users in those projects being granted the associated permissions.

  • /permissions
    • GET - Get a list of permissions
    • POST - Create a permission
  • /permissions/{permissionID}
    • GET - Get a permission
    • PATCH - Update a permission
    • DELETE - Delete a permission
  • /permissions/{permissionID}/projects
    • GET - Get a list of projects associated with a permission
    • PUT - Set a list of projects associated with a permission
  • /permissions/{permissionID}/projects/{projectID}
    • GET - Associate a project with a permission
    • DELETE - Disassociate a project from a permission
Projects

Projects are groups of users and are what take ownership of entities like guests.

  • /projects
    • GET - Get a list of projects
    • POST - Create a project
  • /projects/{projectID}
    • GET - Get a project
    • PATCH - Update a project
    • DELETE - Delete a project
  • /projects/{projectID}/users
    • GET - Get a list of users associated with a project
    • PUT - Set a list of users associated with a project
  • /projects/{projectID/users/{userID}
    • PUT - Associate a project with a user
    • DELETE - Disassociate a project from a user
  • /projects/{projectID}/permissions
    • GET - Get a list of permissions associated with a project
    • PUT - Set a list of permissions associated with a project
  • /projects/{projectID}/permissions/{permissionID}
    • PUT - Associate a project with a permission
    • DELETE - Disassociate a project from a permission
Users

Users in the system.

  • /users
    • GET - Get a list of users
    • POST - Create a user
  • /users/{userID}
    • GET - Get a user
    • PATCH - Update a user
    • DELETE - Remove a user
  • /users/{userID}/projects
    • GET - Get a list of projects the user is related to
    • PUT - Set a list of projects the user is related to
  • /users/{userID}/projects/{projectID}
    • PUT - Associate a user with a project
    • DELETE - Disassociate a user from a project

Contributing

See the contributing guidelines

Documentation

Overview

Package operator is the primary package of the Operator Admin API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHypervisorIPRange

func AddHypervisorIPRange(w http.ResponseWriter, r *http.Request)

AddHypervisorIPRange associates an iprange with the hypervisor

func AddIPRangeHypervisor

func AddIPRangeHypervisor(w http.ResponseWriter, r *http.Request)

AddIPRangeHypervisor associates a hypervisor with the iprange

func AddNetworkIPRange

func AddNetworkIPRange(w http.ResponseWriter, r *http.Request)

AddNetworkIPRange associates an iprange with the network

func AddPermissionProject

func AddPermissionProject(w http.ResponseWriter, r *http.Request)

AddPermissionProject associates a project with the permission

func AddProjectPermission

func AddProjectPermission(w http.ResponseWriter, r *http.Request)

AddProjectPermission associates a permission with the project

func AddProjectUser

func AddProjectUser(w http.ResponseWriter, r *http.Request)

AddProjectUser associates a user with the project

func AddUserProject

func AddUserProject(w http.ResponseWriter, r *http.Request)

AddUserProject associates a project with the user

func CreateFlavor

func CreateFlavor(w http.ResponseWriter, r *http.Request)

CreateFlavor creates a new flavor

func CreateHypervisor

func CreateHypervisor(w http.ResponseWriter, r *http.Request)

CreateHypervisor creates a new hypervisor

func CreateIPRange

func CreateIPRange(w http.ResponseWriter, r *http.Request)

CreateIPRange creates a new iprange

func CreateNetwork

func CreateNetwork(w http.ResponseWriter, r *http.Request)

CreateNetwork creates a new network

func CreatePermission

func CreatePermission(w http.ResponseWriter, r *http.Request)

CreatePermission creates a new permission

func CreateProject

func CreateProject(w http.ResponseWriter, r *http.Request)

CreateProject creates a new project

func CreateUser

func CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser creates a new user

func DeleteConfigKey

func DeleteConfigKey(w http.ResponseWriter, r *http.Request)

DeleteConfigKey deletes a particular key from the config

func DeleteConfigNamespace

func DeleteConfigNamespace(w http.ResponseWriter, r *http.Request)

DeleteConfigNamespace removes a particular namespace from the config

func DeleteFlavor

func DeleteFlavor(w http.ResponseWriter, r *http.Request)

DeleteFlavor deletes an existing flavor

func DeleteHypervisor

func DeleteHypervisor(w http.ResponseWriter, r *http.Request)

DeleteHypervisor deletes an existing hypervisor

func DeleteIPRange

func DeleteIPRange(w http.ResponseWriter, r *http.Request)

DeleteIPRange deletes an existing iprange

func DeleteNetwork

func DeleteNetwork(w http.ResponseWriter, r *http.Request)

DeleteNetwork deletes an existing network

func DeletePermission

func DeletePermission(w http.ResponseWriter, r *http.Request)

DeletePermission permission deletes an existing permission

func DeleteProject

func DeleteProject(w http.ResponseWriter, r *http.Request)

DeleteProject deletes an existing project

func DeleteUser

func DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser user deletes an existing user

func GetConfig

func GetConfig(w http.ResponseWriter, r *http.Request)

GetConfig gets the config

func GetConfigNamespace

func GetConfigNamespace(w http.ResponseWriter, r *http.Request)

GetConfigNamespace gets a particular namespace of the config

func GetFlavor

func GetFlavor(w http.ResponseWriter, r *http.Request)

GetFlavor gets a paritcular flavor

func GetHypervisor

func GetHypervisor(w http.ResponseWriter, r *http.Request)

GetHypervisor gets a particular hypervisor

func GetHypervisorIPRanges

func GetHypervisorIPRanges(w http.ResponseWriter, r *http.Request)

GetHypervisorIPRanges gets a list of ipranges associated with the hypervisor

func GetIPRange

func GetIPRange(w http.ResponseWriter, r *http.Request)

GetIPRange gets a particular iprange

func GetIPRangeHypervisors

func GetIPRangeHypervisors(w http.ResponseWriter, r *http.Request)

GetIPRangeHypervisors gets a list of hypervisors associated with the iprange

func GetIPRangeNetwork

func GetIPRangeNetwork(w http.ResponseWriter, r *http.Request)

GetIPRangeNetwork retrieves the network associated with the iprange

func GetNetwork

func GetNetwork(w http.ResponseWriter, r *http.Request)

GetNetwork gets a particular network

func GetNetworkIPRanges

func GetNetworkIPRanges(w http.ResponseWriter, r *http.Request)

GetNetworkIPRanges gets a list of ipranges associated with the network

func GetPermission

func GetPermission(w http.ResponseWriter, r *http.Request)

GetPermission gets a particular permission

func GetPermissionProjects

func GetPermissionProjects(w http.ResponseWriter, r *http.Request)

GetPermissionProjects gets a list of projects associated with the permission

func GetProject

func GetProject(w http.ResponseWriter, r *http.Request)

GetProject gets a particular project

func GetProjectPermissions

func GetProjectPermissions(w http.ResponseWriter, r *http.Request)

GetProjectPermissions gets a list of permissions associated with the project

func GetProjectUsers

func GetProjectUsers(w http.ResponseWriter, r *http.Request)

GetProjectUsers gets a list of users associated with the project

func GetUser

func GetUser(w http.ResponseWriter, r *http.Request)

GetUser gets a particular user

func GetUserProjects

func GetUserProjects(w http.ResponseWriter, r *http.Request)

GetUserProjects gets a list of projects associated with the user

func ListFlavors

func ListFlavors(w http.ResponseWriter, r *http.Request)

ListFlavors get a list of all flavors

func ListHypervisors

func ListHypervisors(w http.ResponseWriter, r *http.Request)

ListHypervisors gets a list of all hypervisors

func ListIPRanges

func ListIPRanges(w http.ResponseWriter, r *http.Request)

ListIPRanges gets a list of all ipranges

func ListNetworks

func ListNetworks(w http.ResponseWriter, r *http.Request)

ListNetworks gets a list of all networks

func ListPermissions

func ListPermissions(w http.ResponseWriter, r *http.Request)

ListPermissions gets a list of all permissions

func ListProjects

func ListProjects(w http.ResponseWriter, r *http.Request)

ListProjects gets a list of all projects

func ListUsers

func ListUsers(w http.ResponseWriter, r *http.Request)

ListUsers gets a list of all users

func RegisterConfigRoutes

func RegisterConfigRoutes(prefix string, router *mux.Router)

RegisterConfigRoutes registers the config routes and handlers

func RegisterFlavorRoutes

func RegisterFlavorRoutes(prefix string, router *mux.Router)

RegisterFlavorRoutes registers the flavor routes and handlers

func RegisterHypervisorRoutes

func RegisterHypervisorRoutes(prefix string, router *mux.Router)

RegisterHypervisorRoutes registers the hypervisor routes and handlers

func RegisterIPRangeRoutes

func RegisterIPRangeRoutes(prefix string, router *mux.Router)

RegisterIPRangeRoutes registers the iprange routes and handlers

func RegisterNetworkRoutes

func RegisterNetworkRoutes(prefix string, router *mux.Router)

RegisterNetworkRoutes registers the network routes and handlers

func RegisterOneRoute

func RegisterOneRoute(router *mux.Router, r RouteInfo)

RegisterOneRoute adds a route to the router, including the metrics wrapper if it was created without issues (and if a metrics key is given with the route info); for use by endpoint group register functions

func RegisterPermissionRoutes

func RegisterPermissionRoutes(prefix string, router *mux.Router)

RegisterPermissionRoutes registers the permission routes and handlers

func RegisterProjectRoutes

func RegisterProjectRoutes(prefix string, router *mux.Router)

RegisterProjectRoutes registers the project routes and handlers

func RegisterUserRoutes

func RegisterUserRoutes(prefix string, router *mux.Router)

RegisterUserRoutes registers the user routes and handlers

func RemoveHypervisorIPRange

func RemoveHypervisorIPRange(w http.ResponseWriter, r *http.Request)

RemoveHypervisorIPRange removes an association of an iprange with the hypervisor

func RemoveIPRangeHypervisor

func RemoveIPRangeHypervisor(w http.ResponseWriter, r *http.Request)

RemoveIPRangeHypervisor removes an association of a hypervisor with the iprange

func RemoveIPRangeNetwork

func RemoveIPRangeNetwork(w http.ResponseWriter, r *http.Request)

RemoveIPRangeNetwork unsets the network associated with the iprange

func RemoveNetworkIPRange

func RemoveNetworkIPRange(w http.ResponseWriter, r *http.Request)

RemoveNetworkIPRange removes an association of an iprange with the network

func RemovePermissionProject

func RemovePermissionProject(w http.ResponseWriter, r *http.Request)

RemovePermissionProject removes an association of a project with the permission

func RemoveProjectPermission

func RemoveProjectPermission(w http.ResponseWriter, r *http.Request)

RemoveProjectPermission disassociates a permission with the project

func RemoveProjectUser

func RemoveProjectUser(w http.ResponseWriter, r *http.Request)

RemoveProjectUser disassociates a user with the project

func RemoveUserProject

func RemoveUserProject(w http.ResponseWriter, r *http.Request)

RemoveUserProject removes an association of a project with the user

func Run

func Run(port uint) error

Run starts the server

func SetConfig

func SetConfig(w http.ResponseWriter, r *http.Request)

SetConfig sets the config

func SetConfigNamespace

func SetConfigNamespace(w http.ResponseWriter, r *http.Request)

SetConfigNamespace sets the config for a particular namespace

func SetHypervisorIPRanges

func SetHypervisorIPRanges(w http.ResponseWriter, r *http.Request)

SetHypervisorIPRanges sets the list of ipranges associated with the hypervisor

func SetIPRangeHypervisors

func SetIPRangeHypervisors(w http.ResponseWriter, r *http.Request)

SetIPRangeHypervisors sets the list of hypervisors associated with the iprange

func SetIPRangeNetwork

func SetIPRangeNetwork(w http.ResponseWriter, r *http.Request)

SetIPRangeNetwork sets the network associated with the iprange

func SetNetworkIPRanges

func SetNetworkIPRanges(w http.ResponseWriter, r *http.Request)

SetNetworkIPRanges sets the list of ipranges associated with the network

func SetPermissionProjects

func SetPermissionProjects(w http.ResponseWriter, r *http.Request)

SetPermissionProjects sets the list of projects associated with the permission

func SetProjectPermissions

func SetProjectPermissions(w http.ResponseWriter, r *http.Request)

SetProjectPermissions sets teh list of permissions associated with the project

func SetProjectUsers

func SetProjectUsers(w http.ResponseWriter, r *http.Request)

SetProjectUsers sets teh list of users associated with the project

func SetUserProjects

func SetUserProjects(w http.ResponseWriter, r *http.Request)

SetUserProjects sets the list of projects associated with the user

func UpdateConfig

func UpdateConfig(w http.ResponseWriter, r *http.Request)

UpdateConfig updates a portion of the config

func UpdateFlavor

func UpdateFlavor(w http.ResponseWriter, r *http.Request)

UpdateFlavor updates an existing flavor

func UpdateHypervisor

func UpdateHypervisor(w http.ResponseWriter, r *http.Request)

UpdateHypervisor updates an existing hypervisor

func UpdateIPRange

func UpdateIPRange(w http.ResponseWriter, r *http.Request)

UpdateIPRange updates an existing iprange

func UpdateNetwork

func UpdateNetwork(w http.ResponseWriter, r *http.Request)

UpdateNetwork updates an existing network

func UpdatePermission

func UpdatePermission(w http.ResponseWriter, r *http.Request)

UpdatePermission updates an existing permission

func UpdateProject

func UpdateProject(w http.ResponseWriter, r *http.Request)

UpdateProject updates an existing project

func UpdateUser

func UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser updates an existing user

Types

type HTTPError

type HTTPError struct {
	Message string   `json:"message"`
	Code    int      `json:"code"`
	Stack   []string `json:"stack"`
}

HTTPError contains information for http error responses

type HTTPResponse

type HTTPResponse struct {
	http.ResponseWriter
}

HTTPResponse is a wrapper for http.ResponseWriter which provides access to several convenience methods

func (*HTTPResponse) JSON

func (hr *HTTPResponse) JSON(code int, obj interface{})

JSON writes appropriate headers and JSON body to the http response

func (*HTTPResponse) JSONError

func (hr *HTTPResponse) JSONError(code int, err error)

JSONError prepares an HTTPError with a stack trace and writes it with HTTPResponse.JSON

func (*HTTPResponse) JSONMsg

func (hr *HTTPResponse) JSONMsg(code int, msg string)

JSONMsg is a convenience method to write a JSON response with just a message string

type RouteInfo

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

RouteInfo is used by RegisterOneRoute below for the most common route setup

Directories

Path Synopsis
cmd
Package config allows for reading configuration from a JSON file
Package config allows for reading configuration from a JSON file
Package models provides an interface for persisting and retrieving data to and from the database, as well as JSON marshalling/unmarshalling aids for such data.
Package models provides an interface for persisting and retrieving data to and from the database, as well as JSON marshalling/unmarshalling aids for such data.

Jump to

Keyboard shortcuts

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