All Projects → gophercloud → Gophercloud

gophercloud / Gophercloud

Licence: other
Gophercloud: an OpenStack SDK for Go

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Gophercloud

SelfPortal
One for all virtualization abstraction layer.
Stars: ✭ 22 (-95.68%)
Mutual labels:  openstack
cbtool
Cloud Rapid Experimentation and Analysis Toolkit
Stars: ✭ 65 (-87.23%)
Mutual labels:  openstack
Openstack Grizzly Install Guide
A full install guide for OpenStack Grizzly
Stars: ✭ 358 (-29.67%)
Mutual labels:  openstack
taco-scripts
Step-by-step scripts to deploy TACO AIO
Stars: ✭ 24 (-95.28%)
Mutual labels:  openstack
fortigate-terraform-deploy
Deployment templates for FortiGate-VM on cloud platforms with terraform
Stars: ✭ 30 (-94.11%)
Mutual labels:  openstack
Openstack4j
A Fluent OpenStack SDK / Client Library for Java
Stars: ✭ 271 (-46.76%)
Mutual labels:  openstack
openstack-study
The repository for study activities in OpenStack Korea User Group (오픈스택 한국 커뮤니티 스터디를 위한 저장소입니다)
Stars: ✭ 32 (-93.71%)
Mutual labels:  openstack
Inframap
Read your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.
Stars: ✭ 430 (-15.52%)
Mutual labels:  openstack
meetups
Repository to gather all presentations and info from all Taiwan Cloud Native meetups.
Stars: ✭ 96 (-81.14%)
Mutual labels:  openstack
Pentest Lab
Pentest Lab on OpenStack with Heat, Chef provisioning and Docker
Stars: ✭ 353 (-30.65%)
Mutual labels:  openstack
f5-openstack-lbaasv2-driver
F5 LBaaSv2 service provider driver for OpenStack Liberty and beyond
Stars: ✭ 20 (-96.07%)
Mutual labels:  openstack
sftpcloudfs
SFTP interface to OpenStack Object Storage (Swift)
Stars: ✭ 37 (-92.73%)
Mutual labels:  openstack
Kubenow
Deploy Kubernetes. Now!
Stars: ✭ 285 (-44.01%)
Mutual labels:  openstack
summit-app-ios
The official app for the OpenStack Summit
Stars: ✭ 35 (-93.12%)
Mutual labels:  openstack
Cloud Provider Openstack
Stars: ✭ 366 (-28.09%)
Mutual labels:  openstack
tripleo-lab
Custom lab for tripleo - deployed on a physical node with libvirt
Stars: ✭ 20 (-96.07%)
Mutual labels:  openstack
heat-examples
Heat examples tested against the SysEleven Stack infrastructure cloud.
Stars: ✭ 36 (-92.93%)
Mutual labels:  openstack
Conjure Up
Deploying complex solutions, magically.
Stars: ✭ 454 (-10.81%)
Mutual labels:  openstack
Openstack Workflow
Openstack Sequence Diagrams(Openstack操作序列图)
Stars: ✭ 409 (-19.65%)
Mutual labels:  openstack
Kubeoperator
KubeOperator 是一个开源的轻量级 Kubernetes 发行版,专注于帮助企业规划、部署和运营生产级别的 K8s 集群。
Stars: ✭ 4,147 (+714.73%)
Mutual labels:  openstack

Gophercloud: an OpenStack SDK for Go

Build Status Coverage Status

Gophercloud is an OpenStack Go SDK.

Useful links

How to install

Before installing, you need to ensure that your GOPATH environment variable is pointing to an appropriate directory where you want to install Gophercloud:

mkdir $HOME/go
export GOPATH=$HOME/go

To protect yourself against changes in your dependencies, we highly recommend choosing a dependency management solution for your projects, such as godep. Once this is set up, you can install Gophercloud as a dependency like so:

go get github.com/gophercloud/gophercloud

# Edit your code to import relevant packages from "github.com/gophercloud/gophercloud"

godep save ./...

This will install all the source files you need into a Godeps/_workspace directory, which is referenceable from your own source files when you use the godep go command.

Getting started

Credentials

Because you'll be hitting an API, you will need to retrieve your OpenStack credentials and either store them as environment variables or in your local Go files. The first method is recommended because it decouples credential information from source code, allowing you to push the latter to your version control system without any security risk.

You will need to retrieve the following:

  • username
  • password
  • a valid Keystone identity URL

For users that have the OpenStack dashboard installed, there's a shortcut. If you visit the project/access_and_security path in Horizon and click on the "Download OpenStack RC File" button at the top right hand corner, you will download a bash file that exports all of your access details to environment variables. To execute the file, run source admin-openrc.sh and you will be prompted for your password.

Authentication

NOTE: It is now recommended to use the clientconfig package found at https://github.com/gophercloud/utils/tree/master/openstack/clientconfig for all authentication purposes.

The below documentation is still relevant. clientconfig simply implements the below and presents it in an easier and more flexible way.

Once you have access to your credentials, you can begin plugging them into Gophercloud. The next step is authentication, and this is handled by a base "Provider" struct. To get one, you can either pass in your credentials explicitly, or tell Gophercloud to use environment variables:

import (
  "github.com/gophercloud/gophercloud"
  "github.com/gophercloud/gophercloud/openstack"
  "github.com/gophercloud/gophercloud/openstack/utils"
)

// Option 1: Pass in the values yourself
opts := gophercloud.AuthOptions{
  IdentityEndpoint: "https://openstack.example.com:5000/v2.0",
  Username: "{username}",
  Password: "{password}",
}

// Option 2: Use a utility function to retrieve all your environment variables
opts, err := openstack.AuthOptionsFromEnv()

Once you have the opts variable, you can pass it in and get back a ProviderClient struct:

provider, err := openstack.AuthenticatedClient(opts)

The ProviderClient is the top-level client that all of your OpenStack services derive from. The provider contains all of the authentication details that allow your Go code to access the API - such as the base URL and token ID.

Provision a server

Once we have a base Provider, we inject it as a dependency into each OpenStack service. In order to work with the Compute API, we need a Compute service client; which can be created like so:

client, err := openstack.NewComputeV2(provider, gophercloud.EndpointOpts{
  Region: os.Getenv("OS_REGION_NAME"),
})

We then use this client for any Compute API operation we want. In our case, we want to provision a new server - so we invoke the Create method and pass in the flavor ID (hardware specification) and image ID (operating system) we're interested in:

import "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"

server, err := servers.Create(client, servers.CreateOpts{
  Name:      "My new server!",
  FlavorRef: "flavor_id",
  ImageRef:  "image_id",
}).Extract()

The above code sample creates a new server with the parameters, and embodies the new resource in the server variable (a servers.Server struct).

Advanced Usage

Have a look at the FAQ for some tips on customizing the way Gophercloud works.

Backwards-Compatibility Guarantees

None. Vendor it and write tests covering the parts you use.

Contributing

See the contributing guide.

Help and feedback

If you're struggling with something or have spotted a potential bug, feel free to submit an issue to our bug tracker.

Thank You

We'd like to extend special thanks and appreciation to the following:

OpenLab

OpenLab is providing a full CI environment to test each PR and merge for a variety of OpenStack releases.

VEXXHOST

VEXXHOST is providing their services to assist with the development and testing of Gophercloud.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].