Rename Oracle BMCS builder to OCI

Oracle Bare Metal Cloud Services (BMCS) has been rebranded as Oracle
Cloud Infrastructure (OCI).
This commit is contained in:
Andrew Pryde 2017-09-12 16:30:39 +01:00 committed by Matthew Hooker
parent fa177c52c2
commit 6fd2f6701d
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
41 changed files with 139 additions and 143 deletions

View File

@ -1,8 +1,8 @@
package bmcs package oci
import ( import (
"fmt" "fmt"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
// Artifact is an artifact implementation that contains a built Custom Image. // Artifact is an artifact implementation that contains a built Custom Image.

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"testing" "testing"

View File

@ -1,12 +1,12 @@
// Package bmcs contains a packer.Builder implementation that builds Oracle // Package oci contains a packer.Builder implementation that builds Oracle
// Bare Metal Cloud Services (BMCS) images. // Bare Metal Cloud Services (OCI) images.
package bmcs package oci
import ( import (
"fmt" "fmt"
"log" "log"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
@ -14,12 +14,12 @@ import (
) )
// BuilderId uniquely identifies the builder // BuilderId uniquely identifies the builder
const BuilderId = "packer.oracle.bmcs" const BuilderId = "packer.oracle.oci"
// BMCS API version // OCI API version
const bmcsAPIVersion = "20160918" const ociAPIVersion = "20160918"
// Builder is a builder implementation that creates Oracle BMCS custom images. // Builder is a builder implementation that creates Oracle OCI custom images.
type Builder struct { type Builder struct {
config *Config config *Config
runner multistep.Runner runner multistep.Runner
@ -36,7 +36,7 @@ func (b *Builder) Prepare(rawConfig ...interface{}) ([]string, error) {
} }
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
driver, err := NewDriverBMCS(b.config) driver, err := NewDriverOCI(b.config)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -52,7 +52,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
steps := []multistep.Step{ steps := []multistep.Step{
&stepKeyPair{ &stepKeyPair{
Debug: b.config.PackerDebug, Debug: b.config.PackerDebug,
DebugKeyPath: fmt.Sprintf("bmcs_%s.pem", b.config.PackerBuildName), DebugKeyPath: fmt.Sprintf("oci_%s.pem", b.config.PackerBuildName),
PrivateKeyFile: b.config.Comm.SSHPrivateKey, PrivateKeyFile: b.config.Comm.SSHPrivateKey,
}, },
&stepCreateInstance{}, &stepCreateInstance{},

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"bytes" "bytes"
@ -14,7 +14,7 @@ const (
) )
// baseClient provides a basic (AND INTENTIONALLY INCOMPLETE) JSON REST client // baseClient provides a basic (AND INTENTIONALLY INCOMPLETE) JSON REST client
// that abstracts away some of the repetitive code required in the BMCS Client. // that abstracts away some of the repetitive code required in the OCI Client.
type baseClient struct { type baseClient struct {
httpClient *http.Client httpClient *http.Client
method string method string

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"net/http" "net/http"
@ -6,11 +6,11 @@ import (
const ( const (
apiVersion = "20160918" apiVersion = "20160918"
userAgent = "go-bmcs/" + apiVersion userAgent = "go-oci/" + apiVersion
baseURLPattern = "https://%s.%s.oraclecloud.com/%s/" baseURLPattern = "https://%s.%s.oraclecloud.com/%s/"
) )
// Client is the main interface through which consumers interact with the BMCS // Client is the main interface through which consumers interact with the OCI
// API. // API.
type Client struct { type Client struct {
UserAgent string UserAgent string
@ -18,7 +18,7 @@ type Client struct {
Config *Config Config *Config
} }
// NewClient creates a new Client for communicating with the BMCS API. // NewClient creates a new Client for communicating with the OCI API.
func NewClient(config *Config) (*Client, error) { func NewClient(config *Config) (*Client, error) {
transport := NewTransport(http.DefaultTransport, config) transport := NewTransport(http.DefaultTransport, config)
base := newBaseClient().Client(&http.Client{Transport: transport}) base := newBaseClient().Client(&http.Client{Transport: transport})

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"net/http" "net/http"
@ -16,7 +16,7 @@ var (
keyFile *os.File keyFile *os.File
) )
// setup sets up a test HTTP server along with a bmcs.Client that is // setup sets up a test HTTP server along with a oci.Client that is
// configured to talk to that test server. Tests should register handlers on // configured to talk to that test server. Tests should register handlers on
// mux which provide mock responses for the API method being tested. // mux which provide mock responses for the API method being tested.
func setup() { func setup() {

View File

@ -1,6 +1,6 @@
package bmcs package oci
// ComputeClient is a client for the BMCS Compute API. // ComputeClient is a client for the OCI Compute API.
type ComputeClient struct { type ComputeClient struct {
BaseURL string BaseURL string
Instances *InstanceService Instances *InstanceService
@ -9,7 +9,7 @@ type ComputeClient struct {
VNICs *VNICService VNICs *VNICService
} }
// NewComputeClient creates a new client for communicating with the BMCS // NewComputeClient creates a new client for communicating with the OCI
// Compute API. // Compute API.
func NewComputeClient(s *baseClient) *ComputeClient { func NewComputeClient(s *baseClient) *ComputeClient {
return &ComputeClient{ return &ComputeClient{

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"crypto/rand" "crypto/rand"
@ -28,7 +28,7 @@ type Config struct {
// Hex key fingerprint (e.g. b5:a0:62:57:28:0d:fd:c9:59:16:eb:d4:51:9f:70:e4) // Hex key fingerprint (e.g. b5:a0:62:57:28:0d:fd:c9:59:16:eb:d4:51:9f:70:e4)
Fingerprint string `ini:"fingerprint"` Fingerprint string `ini:"fingerprint"`
// Path to BMCS config file (e.g. ~/.oraclebmc/config) // Path to OCI config file (e.g. ~/.oci/config)
KeyFile string `ini:"key_file"` KeyFile string `ini:"key_file"`
// Passphrase used for the key, if it is encrypted. // Passphrase used for the key, if it is encrypted.
@ -50,11 +50,11 @@ func (c *Config) getBaseURL(service string) string {
return fmt.Sprintf(baseURLPattern, service, c.Region, apiVersion) return fmt.Sprintf(baseURLPattern, service, c.Region, apiVersion)
} }
// LoadConfigsFromFile loads all oracle bmcs configurations from a file // LoadConfigsFromFile loads all oracle oci configurations from a file
// (generally ~/.oraclebmc/config). // (generally ~/.oci/config).
func LoadConfigsFromFile(path string) (map[string]*Config, error) { func LoadConfigsFromFile(path string) (map[string]*Config, error) {
if _, err := os.Stat(path); err != nil { if _, err := os.Stat(path); err != nil {
return nil, fmt.Errorf("Oracle BMCS config file is missing: %s", path) return nil, fmt.Errorf("Oracle OCI config file is missing: %s", path)
} }
cfgFile, err := ini.Load(path) cfgFile, err := ini.Load(path)
@ -89,7 +89,7 @@ func LoadConfigsFromFile(path string) (map[string]*Config, error) {
return configs, nil return configs, nil
} }
// Loads an individual Config object from a ini.Section in the oraclebmc config // Loads an individual Config object from a ini.Section in the Oracle OCI config
// file. // file.
func loadConfigSection(f *ini.File, sectionName string, config *Config) (*Config, error) { func loadConfigSection(f *ini.File, sectionName string, config *Config) (*Config, error) {
if config == nil { if config == nil {

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"crypto/rand" "crypto/rand"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import "fmt" import "fmt"
@ -9,7 +9,7 @@ type APIError struct {
} }
func (e APIError) Error() string { func (e APIError) Error() string {
return fmt.Sprintf("BMCS: [%s] '%s'", e.Code, e.Message) return fmt.Sprintf("OCI: [%s] '%s'", e.Code, e.Message)
} }
// firstError is a helper function to work out which error to return from calls // firstError is a helper function to work out which error to return from calls

View File

@ -1,24 +1,24 @@
package bmcs package oci
import ( import (
"time" "time"
) )
// ImageService enables communicating with the BMCS compute API's instance // ImageService enables communicating with the OCI compute API's instance
// related endpoints. // related endpoints.
type ImageService struct { type ImageService struct {
client *baseClient client *baseClient
} }
// NewImageService creates a new ImageService for communicating with the // NewImageService creates a new ImageService for communicating with the
// BMCS compute API's instance related endpoints. // OCI compute API's instance related endpoints.
func NewImageService(s *baseClient) *ImageService { func NewImageService(s *baseClient) *ImageService {
return &ImageService{ return &ImageService{
client: s.New().Path("images/"), client: s.New().Path("images/"),
} }
} }
// Image details a BMCS boot disk image. // Image details a OCI boot disk image.
type Image struct { type Image struct {
// The OCID of the image originally used to launch the instance. // The OCID of the image originally used to launch the instance.
BaseImageID string `json:"baseImageId,omitempty"` BaseImageID string `json:"baseImageId,omitempty"`

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"
@ -34,12 +34,12 @@ func TestCreateImage(t *testing.T) {
defer teardown() defer teardown()
mux.HandleFunc("/images/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/images/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{"displayName": "go-bmcs test"}`) fmt.Fprint(w, `{"displayName": "go-oci test"}`)
}) })
params := &CreateImageParams{ params := &CreateImageParams{
CompartmentID: "ocid1.compartment.oc1..a", CompartmentID: "ocid1.compartment.oc1..a",
DisplayName: "go-bmcs test image", DisplayName: "go-oci test image",
InstanceID: "ocid1.image.oc1.phx.a", InstanceID: "ocid1.image.oc1.phx.a",
} }
@ -48,7 +48,7 @@ func TestCreateImage(t *testing.T) {
t.Errorf("Client.Compute.Images.Create() returned error: %v", err) t.Errorf("Client.Compute.Images.Create() returned error: %v", err)
} }
want := Image{DisplayName: "go-bmcs test"} want := Image{DisplayName: "go-oci test"}
if !reflect.DeepEqual(image, want) { if !reflect.DeepEqual(image, want) {
t.Errorf("Client.Compute.Images.Create() returned %+v, want %+v", image, want) t.Errorf("Client.Compute.Images.Create() returned %+v, want %+v", image, want)

View File

@ -1,24 +1,24 @@
package bmcs package oci
import ( import (
"time" "time"
) )
// InstanceService enables communicating with the BMCS compute API's instance // InstanceService enables communicating with the OCI compute API's instance
// related endpoints. // related endpoints.
type InstanceService struct { type InstanceService struct {
client *baseClient client *baseClient
} }
// NewInstanceService creates a new InstanceService for communicating with the // NewInstanceService creates a new InstanceService for communicating with the
// BMCS compute API's instance related endpoints. // OCI compute API's instance related endpoints.
func NewInstanceService(s *baseClient) *InstanceService { func NewInstanceService(s *baseClient) *InstanceService {
return &InstanceService{ return &InstanceService{
client: s.New().Path("instances/"), client: s.New().Path("instances/"),
} }
} }
// Instance details a BMCS compute instance. // Instance details a OCI compute instance.
type Instance struct { type Instance struct {
// The Availability Domain the instance is running in. // The Availability Domain the instance is running in.
AvailabilityDomain string `json:"availabilityDomain"` AvailabilityDomain string `json:"availabilityDomain"`
@ -90,7 +90,7 @@ type LaunchInstanceParams struct {
SubnetID string `json:"subnetId,omitempty"` SubnetID string `json:"subnetId,omitempty"`
} }
// Launch creates a new BMCS compute instance. It does *not* wait for the // Launch creates a new OCI compute instance. It does *not* wait for the
// instance to boot. // instance to boot.
func (s *InstanceService) Launch(params *LaunchInstanceParams) (Instance, error) { func (s *InstanceService) Launch(params *LaunchInstanceParams) (Instance, error) {
instance := &Instance{} instance := &Instance{}
@ -108,7 +108,7 @@ type TerminateInstanceParams struct {
ID string `url:"instanceId,omitempty"` ID string `url:"instanceId,omitempty"`
} }
// Terminate terminates a running BMCS compute instance. // Terminate terminates a running OCI compute instance.
// instance to boot. // instance to boot.
func (s *InstanceService) Terminate(params *TerminateInstanceParams) error { func (s *InstanceService) Terminate(params *TerminateInstanceParams) error {
e := &APIError{} e := &APIError{}

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"
@ -34,13 +34,13 @@ func TestLaunchInstance(t *testing.T) {
defer teardown() defer teardown()
mux.HandleFunc("/instances/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/instances/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{"displayName": "go-bmcs test"}`) fmt.Fprint(w, `{"displayName": "go-oci test"}`)
}) })
params := &LaunchInstanceParams{ params := &LaunchInstanceParams{
AvailabilityDomain: "aaaa:PHX-AD-1", AvailabilityDomain: "aaaa:PHX-AD-1",
CompartmentID: "ocid1.compartment.oc1..a", CompartmentID: "ocid1.compartment.oc1..a",
DisplayName: "go-bmcs test", DisplayName: "go-oci test",
ImageID: "ocid1.image.oc1.phx.a", ImageID: "ocid1.image.oc1.phx.a",
Shape: "VM.Standard1.1", Shape: "VM.Standard1.1",
SubnetID: "ocid1.subnet.oc1.phx.a", SubnetID: "ocid1.subnet.oc1.phx.a",
@ -51,7 +51,7 @@ func TestLaunchInstance(t *testing.T) {
t.Errorf("Client.Compute.Instances.Launch() returned error: %v", err) t.Errorf("Client.Compute.Instances.Launch() returned error: %v", err)
} }
want := Instance{DisplayName: "go-bmcs test"} want := Instance{DisplayName: "go-oci test"}
if !reflect.DeepEqual(instance, want) { if !reflect.DeepEqual(instance, want) {
t.Errorf("Client.Compute.Instances.Launch() returned %+v, want %+v", instance, want) t.Errorf("Client.Compute.Instances.Launch() returned %+v, want %+v", instance, want)

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"bytes" "bytes"
@ -23,13 +23,13 @@ func (nopCloser) Close() error {
return nil return nil
} }
// Transport adds BMCS signature authentication to each outgoing request. // Transport adds OCI signature authentication to each outgoing request.
type Transport struct { type Transport struct {
transport http.RoundTripper transport http.RoundTripper
config *Config config *Config
} }
// NewTransport creates a new Transport to add BMCS signature authentication // NewTransport creates a new Transport to add OCI signature authentication
// to each outgoing request. // to each outgoing request.
func NewTransport(transport http.RoundTripper, config *Config) *Transport { func NewTransport(transport http.RoundTripper, config *Config) *Transport {
return &Transport{ return &Transport{

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"net/http" "net/http"

View File

@ -1,17 +1,17 @@
package bmcs package oci
import ( import (
"time" "time"
) )
// VNICService enables communicating with the BMCS compute API's VNICs // VNICService enables communicating with the OCI compute API's VNICs
// endpoint. // endpoint.
type VNICService struct { type VNICService struct {
client *baseClient client *baseClient
} }
// NewVNICService creates a new VNICService for communicating with the // NewVNICService creates a new VNICService for communicating with the
// BMCS compute API's instance related endpoints. // OCI compute API's instance related endpoints.
func NewVNICService(s *baseClient) *VNICService { func NewVNICService(s *baseClient) *VNICService {
return &VNICService{client: s.New().Path("vnics/")} return &VNICService{client: s.New().Path("vnics/")}
} }

View File

@ -1,24 +1,24 @@
package bmcs package oci
import ( import (
"time" "time"
) )
// VNICAttachmentService enables communicating with the BMCS compute API's VNIC // VNICAttachmentService enables communicating with the OCI compute API's VNIC
// attachment endpoint. // attachment endpoint.
type VNICAttachmentService struct { type VNICAttachmentService struct {
client *baseClient client *baseClient
} }
// NewVNICAttachmentService creates a new VNICAttachmentService for communicating with the // NewVNICAttachmentService creates a new VNICAttachmentService for communicating with the
// BMCS compute API's instance related endpoints. // OCI compute API's instance related endpoints.
func NewVNICAttachmentService(s *baseClient) *VNICAttachmentService { func NewVNICAttachmentService(s *baseClient) *VNICAttachmentService {
return &VNICAttachmentService{ return &VNICAttachmentService{
client: s.New().Path("vnicAttachments/"), client: s.New().Path("vnicAttachments/"),
} }
} }
// VNICAttachment details the attachment of a VNIC to a BMCS instance. // VNICAttachment details the attachment of a VNIC to a OCI instance.
type VNICAttachment struct { type VNICAttachment struct {
AvailabilityDomain string `json:"availabilityDomain"` AvailabilityDomain string `json:"availabilityDomain"`
CompartmentID string `json:"compartmentId"` CompartmentID string `json:"compartmentId"`

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"errors" "errors"
@ -6,7 +6,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/config"
@ -64,7 +64,7 @@ func NewConfig(raws ...interface{}) (*Config, error) {
if c.AccessCfgFile != "" { if c.AccessCfgFile != "" {
accessCfgFile = c.AccessCfgFile accessCfgFile = c.AccessCfgFile
} else { } else {
accessCfgFile, err = getDefaultBMCSSettingsPath() accessCfgFile, err = getDefaultOCISettingsPath()
if err != nil { if err != nil {
accessCfgFile = "" // Access cfg might be in template accessCfgFile = "" // Access cfg might be in template
} }
@ -198,15 +198,15 @@ func NewConfig(raws ...interface{}) (*Config, error) {
return c, nil return c, nil
} }
// getDefaultBMCSSettingsPath uses mitchellh/go-homedir to compute the default // getDefaultOCISettingsPath uses mitchellh/go-homedir to compute the default
// config file location. // config file location ($HOME/.oci/config).
func getDefaultBMCSSettingsPath() (string, error) { func getDefaultOCISettingsPath() (string, error) {
home, err := homedir.Dir() home, err := homedir.Dir()
if err != nil { if err != nil {
return "", err return "", err
} }
path := filepath.Join(home, ".oraclebmc", "config") path := filepath.Join(home, ".oci", "config")
if _, err := os.Stat(path); err != nil { if _, err := os.Stat(path); err != nil {
return "", err return "", err
} }

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"io/ioutil" "io/ioutil"
@ -7,7 +7,7 @@ import (
"strings" "strings"
"testing" "testing"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
func testConfig(accessConfFile *os.File) map[string]interface{} { func testConfig(accessConfFile *os.File) map[string]interface{} {

View File

@ -1,10 +1,10 @@
package bmcs package oci
import ( import (
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
// Driver interfaces between the builder steps and the BMCS SDK. // Driver interfaces between the builder steps and the OCI SDK.
type Driver interface { type Driver interface {
CreateInstance(publicKey string) (string, error) CreateInstance(publicKey string) (string, error)
CreateImage(id string) (client.Image, error) CreateImage(id string) (client.Image, error)

View File

@ -1,11 +1,11 @@
package bmcs package oci
import ( import (
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
// driverMock implements the Driver interface and communicates with Oracle // driverMock implements the Driver interface and communicates with Oracle
// BMCS. // OCI.
type driverMock struct { type driverMock struct {
CreateInstanceID string CreateInstanceID string
CreateInstanceErr error CreateInstanceErr error

View File

@ -1,30 +1,30 @@
package bmcs package oci
import ( import (
"errors" "errors"
"fmt" "fmt"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
// driverBMCS implements the Driver interface and communicates with Oracle // driverOCI implements the Driver interface and communicates with Oracle
// BMCS. // OCI.
type driverBMCS struct { type driverOCI struct {
client *client.Client client *client.Client
cfg *Config cfg *Config
} }
// NewDriverBMCS Creates a new driverBMCS with a connected client. // NewDriverOCI Creates a new driverOCI with a connected client.
func NewDriverBMCS(cfg *Config) (Driver, error) { func NewDriverOCI(cfg *Config) (Driver, error) {
client, err := client.NewClient(cfg.AccessCfg) client, err := client.NewClient(cfg.AccessCfg)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &driverBMCS{client: client, cfg: cfg}, nil return &driverOCI{client: client, cfg: cfg}, nil
} }
// CreateInstance creates a new compute instance. // CreateInstance creates a new compute instance.
func (d *driverBMCS) CreateInstance(publicKey string) (string, error) { func (d *driverOCI) CreateInstance(publicKey string) (string, error) {
params := &client.LaunchInstanceParams{ params := &client.LaunchInstanceParams{
AvailabilityDomain: d.cfg.AvailabilityDomain, AvailabilityDomain: d.cfg.AvailabilityDomain,
CompartmentID: d.cfg.CompartmentID, CompartmentID: d.cfg.CompartmentID,
@ -44,7 +44,7 @@ func (d *driverBMCS) CreateInstance(publicKey string) (string, error) {
} }
// CreateImage creates a new custom image. // CreateImage creates a new custom image.
func (d *driverBMCS) CreateImage(id string) (client.Image, error) { func (d *driverOCI) CreateImage(id string) (client.Image, error) {
params := &client.CreateImageParams{ params := &client.CreateImageParams{
CompartmentID: d.cfg.CompartmentID, CompartmentID: d.cfg.CompartmentID,
InstanceID: id, InstanceID: id,
@ -59,12 +59,12 @@ func (d *driverBMCS) CreateImage(id string) (client.Image, error) {
} }
// DeleteImage deletes a custom image. // DeleteImage deletes a custom image.
func (d *driverBMCS) DeleteImage(id string) error { func (d *driverOCI) DeleteImage(id string) error {
return d.client.Compute.Images.Delete(&client.DeleteImageParams{ID: id}) return d.client.Compute.Images.Delete(&client.DeleteImageParams{ID: id})
} }
// GetInstanceIP returns the public IP corresponding to the given instance id. // GetInstanceIP returns the public IP corresponding to the given instance id.
func (d *driverBMCS) GetInstanceIP(id string) (string, error) { func (d *driverOCI) GetInstanceIP(id string) (string, error) {
// get nvic and cross ref to find pub ip address // get nvic and cross ref to find pub ip address
vnics, err := d.client.Compute.VNICAttachments.List( vnics, err := d.client.Compute.VNICAttachments.List(
&client.ListVnicAttachmentsParams{ &client.ListVnicAttachmentsParams{
@ -89,14 +89,14 @@ func (d *driverBMCS) GetInstanceIP(id string) (string, error) {
} }
// TerminateInstance terminates a compute instance. // TerminateInstance terminates a compute instance.
func (d *driverBMCS) TerminateInstance(id string) error { func (d *driverOCI) TerminateInstance(id string) error {
params := &client.TerminateInstanceParams{ID: id} params := &client.TerminateInstanceParams{ID: id}
return d.client.Compute.Instances.Terminate(params) return d.client.Compute.Instances.Terminate(params)
} }
// WaitForImageCreation waits for a provisioning custom image to reach the // WaitForImageCreation waits for a provisioning custom image to reach the
// "AVAILABLE" state. // "AVAILABLE" state.
func (d *driverBMCS) WaitForImageCreation(id string) error { func (d *driverOCI) WaitForImageCreation(id string) error {
return client.NewWaiter().WaitForResourceToReachState( return client.NewWaiter().WaitForResourceToReachState(
d.client.Compute.Images, d.client.Compute.Images,
id, id,
@ -107,7 +107,7 @@ func (d *driverBMCS) WaitForImageCreation(id string) error {
// WaitForInstanceState waits for an instance to reach the a given terminal // WaitForInstanceState waits for an instance to reach the a given terminal
// state. // state.
func (d *driverBMCS) WaitForInstanceState(id string, waitStates []string, terminalState string) error { func (d *driverOCI) WaitForInstanceState(id string, waitStates []string, terminalState string) error {
return client.NewWaiter().WaitForResourceToReachState( return client.NewWaiter().WaitForResourceToReachState(
d.client.Compute.Instances, d.client.Compute.Instances,
id, id,

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"crypto/rand" "crypto/rand"

View File

@ -1,4 +1,4 @@
package bmcs package oci
import ( import (
"bytes" "bytes"
@ -7,7 +7,7 @@ import (
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
client "github.com/hashicorp/packer/builder/oracle/bmcs/client" client "github.com/hashicorp/packer/builder/oracle/oci/client"
) )
// TODO(apryde): It would be good not to have to write a key file to disk to // TODO(apryde): It would be good not to have to write a key file to disk to

View File

@ -31,7 +31,7 @@ import (
nullbuilder "github.com/hashicorp/packer/builder/null" nullbuilder "github.com/hashicorp/packer/builder/null"
oneandonebuilder "github.com/hashicorp/packer/builder/oneandone" oneandonebuilder "github.com/hashicorp/packer/builder/oneandone"
openstackbuilder "github.com/hashicorp/packer/builder/openstack" openstackbuilder "github.com/hashicorp/packer/builder/openstack"
oraclebmcsbuilder "github.com/hashicorp/packer/builder/oracle/bmcs" oracleocibuilder "github.com/hashicorp/packer/builder/oracle/oci"
parallelsisobuilder "github.com/hashicorp/packer/builder/parallels/iso" parallelsisobuilder "github.com/hashicorp/packer/builder/parallels/iso"
parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm" parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm"
profitbricksbuilder "github.com/hashicorp/packer/builder/profitbricks" profitbricksbuilder "github.com/hashicorp/packer/builder/profitbricks"
@ -97,7 +97,7 @@ var Builders = map[string]packer.Builder{
"null": new(nullbuilder.Builder), "null": new(nullbuilder.Builder),
"oneandone": new(oneandonebuilder.Builder), "oneandone": new(oneandonebuilder.Builder),
"openstack": new(openstackbuilder.Builder), "openstack": new(openstackbuilder.Builder),
"oracle-bmcs": new(oraclebmcsbuilder.Builder), "oracle-oci": new(oracleocibuilder.Builder),
"parallels-iso": new(parallelsisobuilder.Builder), "parallels-iso": new(parallelsisobuilder.Builder),
"parallels-pvm": new(parallelspvmbuilder.Builder), "parallels-pvm": new(parallelspvmbuilder.Builder),
"profitbricks": new(profitbricksbuilder.Builder), "profitbricks": new(profitbricksbuilder.Builder),

View File

@ -1,23 +1,20 @@
--- ---
description: description:
with Oracle Bare Metal Cloud Services (BMCS). The builder takes an The oracle-oci builder is able to create new custom images for use with Oracle
Oracle-provided base image, runs any provisioning necessary on the base image Cloud Infrastructure (OCI).
after launching it, and finally snapshots it creating a reusable custom
image.
layout: docs layout: docs
page_title: 'Oracle BMCS - Builders' page_title: 'Oracle OCI - Builders'
sidebar_current: 'docs-builders-oracle-bmcs' sidebar_current: 'docs-builders-oracle-oci'
--- ---
# Oracle Bare Metal Cloud Services (BMCS) Builder # Oracle Cloud Infrastructure (OCI) Builder
Type: `oracle-bmcs` Type: `oracle-oci`
The `oracle-bmcs` Packer builder is able to create new custom images for use The `oracle-oci` Packer builder is able to create new custom images for use
with [Oracle Bare Metal Cloud Services](https://cloud.oracle.com/en_US/bare-metal-compute) with [Oracle Cloud Infrastructure](https://cloud.oracle.com) (OCI). The builder
(BMCS). The builder takes an Oracle-provided base image, runs any provisioning takes a base image, runs any provisioning necessary on the base image after
necessary on the base image after launching it, and finally snapshots it launching it, and finally snapshots it creating a reusable custom image.
creating a reusable custom image.
It is recommended that you familiarise yourself with the It is recommended that you familiarise yourself with the
[Key Concepts and Terminology](https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Concepts/concepts.htm) [Key Concepts and Terminology](https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Concepts/concepts.htm)
@ -28,7 +25,7 @@ to use it or delete it.
## Authorization ## Authorization
The Oracle BMCS API requires that requests be signed with the RSA public key The Oracle OCI API requires that requests be signed with the RSA public key
associated with your [IAM](https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/overview.htm) associated with your [IAM](https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/overview.htm)
user account. For a comprehensive example of how to configure the required user account. For a comprehensive example of how to configure the required
authentication see the documentation on authentication see the documentation on
@ -37,7 +34,7 @@ authentication see the documentation on
## Configuration Reference ## Configuration Reference
There are many configuration options available for the `oracle-bmcs` builder. There are many configuration options available for the `oracle-oci` builder.
In addition to the options listed here, a In addition to the options listed here, a
[communicator](/docs/templates/communicator.html) can be configured for this [communicator](/docs/templates/communicator.html) can be configured for this
builder. builder.
@ -54,8 +51,7 @@ builder.
[ListAvailabilityDomains](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/identity/latest/AvailabilityDomain/ListAvailabilityDomains) [ListAvailabilityDomains](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/identity/latest/AvailabilityDomain/ListAvailabilityDomains)
operation, which is available in the IAM Service API. operation, which is available in the IAM Service API.
- `base_image_ocid` (string) - The OCID of the - `base_image_ocid` (string) - The OCID of the [base image](https://docs.us-phoenix-1.oraclecloud.com/Content/Compute/References/images.htm)
[Oracle-provided base image](https://docs.us-phoenix-1.oraclecloud.com/Content/Compute/References/images.htm)
to use. This is the unique identifier of the image that will be used to to use. This is the unique identifier of the image that will be used to
launch a new instance and provision it. launch a new instance and provision it.
@ -66,9 +62,9 @@ builder.
- `compartment_ocid` (string) - The OCID of the - `compartment_ocid` (string) - The OCID of the
[compartment](https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Tasks/choosingcompartments.htm) [compartment](https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Tasks/choosingcompartments.htm)
- `fingerprint` (string) - Fingerprint for the BMCS API signing key. - `fingerprint` (string) - Fingerprint for the OCI API signing key.
Overrides value provided by the Overrides value provided by the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
- `shape` (string) - The template that determines the number of - `shape` (string) - The template that determines the number of
@ -94,37 +90,37 @@ builder.
### Optional ### Optional
- `access_cfg_file` (string) - The path to the - `access_cfg_file` (string) - The path to the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm). [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm).
Defaults to `$HOME/.oraclebmc/config`. Defaults to `$HOME/.oci/config`.
- `access_cfg_file_account` (string) - The specific account in the - `access_cfg_file_account` (string) - The specific account in the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
to use. Defaults to `DEFAULT`. to use. Defaults to `DEFAULT`.
- `image_name` (string) - The name to assign to the resulting custom image. - `image_name` (string) - The name to assign to the resulting custom image.
- `key_file` (string) - Full path and filename of the BMCS API signing key. - `key_file` (string) - Full path and filename of the OCI API signing key.
Overrides value provided by the Overrides value provided by the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
- `pass_phrase` (string) - Pass phrase used to decrypt the BMCS API signing - `pass_phrase` (string) - Pass phrase used to decrypt the OCI API signing
key. Overrides value provided by the key. Overrides value provided by the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
- `region` (string) - An Oracle Bare Metal Cloud Services region. Overrides - `region` (string) - An Oracle Cloud Infrastructure region. Overrides
value provided by the value provided by the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
- `tenancy_ocid` (string) - The OCID of your tenancy. Overrides value provided - `tenancy_ocid` (string) - The OCID of your tenancy. Overrides value provided
by the by the
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
- `user_ocid` (string) - The OCID of the user calling the BMCS API. Overrides - `user_ocid` (string) - The OCID of the user calling the OCI API. Overrides
value provided by the [BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) value provided by the [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. if present.
@ -142,6 +138,6 @@ substituted with the letter `a` and OCIDS have been shortened for brevity.
"shape": "VM.Standard1.1", "shape": "VM.Standard1.1",
"ssh_username": "opc", "ssh_username": "opc",
"subnet_ocid": "ocid1.subnet.oc1..aaa", "subnet_ocid": "ocid1.subnet.oc1..aaa",
"type": "oracle-bmcs" "type": "oracle-oci"
} }
``` ```

View File

@ -122,8 +122,8 @@
<li<%= sidebar_current("docs-builders-openstack") %>> <li<%= sidebar_current("docs-builders-openstack") %>>
<a href="/docs/builders/openstack.html">OpenStack</a> <a href="/docs/builders/openstack.html">OpenStack</a>
</li> </li>
<li<%= sidebar_current("docs-builders-oracle-bmcs") %>> <li<%= sidebar_current("docs-builders-oracle-oci") %>>
<a href="/docs/builders/oracle-bmcs.html">Oracle BMCS</a> <a href="/docs/builders/oracle-oci.html">Oracle OCI</a>
</li> </li>
<li<%= sidebar_current("docs-builders-parallels") %>> <li<%= sidebar_current("docs-builders-parallels") %>>
<a href="/docs/builders/parallels.html">Parallels</a> <a href="/docs/builders/parallels.html">Parallels</a>