Merge pull request #5331 from prydie/f-bmcs-to-oci
Rename Oracle BMCS builder to OCI
This commit is contained in:
commit
34cf4a712d
|
@ -1,8 +1,8 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"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.
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,12 +1,12 @@
|
|||
// Package bmcs contains a packer.Builder implementation that builds Oracle
|
||||
// Bare Metal Cloud Services (BMCS) images.
|
||||
package bmcs
|
||||
// Package oci contains a packer.Builder implementation that builds Oracle
|
||||
// Bare Metal Cloud Services (OCI) images.
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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/helper/communicator"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -14,12 +14,12 @@ import (
|
|||
)
|
||||
|
||||
// BuilderId uniquely identifies the builder
|
||||
const BuilderId = "packer.oracle.bmcs"
|
||||
const BuilderId = "packer.oracle.oci"
|
||||
|
||||
// BMCS API version
|
||||
const bmcsAPIVersion = "20160918"
|
||||
// OCI API version
|
||||
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 {
|
||||
config *Config
|
||||
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) {
|
||||
driver, err := NewDriverBMCS(b.config)
|
||||
driver, err := NewDriverOCI(b.config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
steps := []multistep.Step{
|
||||
&stepKeyPair{
|
||||
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,
|
||||
},
|
||||
&stepCreateInstance{},
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -14,7 +14,7 @@ const (
|
|||
)
|
||||
|
||||
// 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 {
|
||||
httpClient *http.Client
|
||||
method string
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
@ -6,11 +6,11 @@ import (
|
|||
|
||||
const (
|
||||
apiVersion = "20160918"
|
||||
userAgent = "go-bmcs/" + apiVersion
|
||||
userAgent = "go-oci/" + apiVersion
|
||||
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.
|
||||
type Client struct {
|
||||
UserAgent string
|
||||
|
@ -18,7 +18,7 @@ type Client struct {
|
|||
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) {
|
||||
transport := NewTransport(http.DefaultTransport, config)
|
||||
base := newBaseClient().Client(&http.Client{Transport: transport})
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
@ -16,7 +16,7 @@ var (
|
|||
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
|
||||
// mux which provide mock responses for the API method being tested.
|
||||
func setup() {
|
|
@ -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 {
|
||||
BaseURL string
|
||||
Instances *InstanceService
|
||||
|
@ -9,7 +9,7 @@ type ComputeClient struct {
|
|||
VNICs *VNICService
|
||||
}
|
||||
|
||||
// NewComputeClient creates a new client for communicating with the BMCS
|
||||
// NewComputeClient creates a new client for communicating with the OCI
|
||||
// Compute API.
|
||||
func NewComputeClient(s *baseClient) *ComputeClient {
|
||||
return &ComputeClient{
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"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)
|
||||
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"`
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// LoadConfigsFromFile loads all oracle bmcs configurations from a file
|
||||
// (generally ~/.oraclebmc/config).
|
||||
// LoadConfigsFromFile loads all oracle oci configurations from a file
|
||||
// (generally ~/.oci/config).
|
||||
func LoadConfigsFromFile(path string) (map[string]*Config, error) {
|
||||
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)
|
||||
|
@ -89,7 +89,7 @@ func LoadConfigsFromFile(path string) (map[string]*Config, error) {
|
|||
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.
|
||||
func loadConfigSection(f *ini.File, sectionName string, config *Config) (*Config, error) {
|
||||
if config == nil {
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -9,7 +9,7 @@ type APIError struct {
|
|||
}
|
||||
|
||||
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
|
|
@ -1,24 +1,24 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ImageService enables communicating with the BMCS compute API's instance
|
||||
// ImageService enables communicating with the OCI compute API's instance
|
||||
// related endpoints.
|
||||
type ImageService struct {
|
||||
client *baseClient
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return &ImageService{
|
||||
client: s.New().Path("images/"),
|
||||
}
|
||||
}
|
||||
|
||||
// Image details a BMCS boot disk image.
|
||||
// Image details a OCI boot disk image.
|
||||
type Image struct {
|
||||
// The OCID of the image originally used to launch the instance.
|
||||
BaseImageID string `json:"baseImageId,omitempty"`
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -34,12 +34,12 @@ func TestCreateImage(t *testing.T) {
|
|||
defer teardown()
|
||||
|
||||
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{
|
||||
CompartmentID: "ocid1.compartment.oc1..a",
|
||||
DisplayName: "go-bmcs test image",
|
||||
DisplayName: "go-oci test image",
|
||||
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)
|
||||
}
|
||||
|
||||
want := Image{DisplayName: "go-bmcs test"}
|
||||
want := Image{DisplayName: "go-oci test"}
|
||||
|
||||
if !reflect.DeepEqual(image, want) {
|
||||
t.Errorf("Client.Compute.Images.Create() returned %+v, want %+v", image, want)
|
|
@ -1,24 +1,24 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// InstanceService enables communicating with the BMCS compute API's instance
|
||||
// InstanceService enables communicating with the OCI compute API's instance
|
||||
// related endpoints.
|
||||
type InstanceService struct {
|
||||
client *baseClient
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return &InstanceService{
|
||||
client: s.New().Path("instances/"),
|
||||
}
|
||||
}
|
||||
|
||||
// Instance details a BMCS compute instance.
|
||||
// Instance details a OCI compute instance.
|
||||
type Instance struct {
|
||||
// The Availability Domain the instance is running in.
|
||||
AvailabilityDomain string `json:"availabilityDomain"`
|
||||
|
@ -90,7 +90,7 @@ type LaunchInstanceParams struct {
|
|||
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.
|
||||
func (s *InstanceService) Launch(params *LaunchInstanceParams) (Instance, error) {
|
||||
instance := &Instance{}
|
||||
|
@ -108,7 +108,7 @@ type TerminateInstanceParams struct {
|
|||
ID string `url:"instanceId,omitempty"`
|
||||
}
|
||||
|
||||
// Terminate terminates a running BMCS compute instance.
|
||||
// Terminate terminates a running OCI compute instance.
|
||||
// instance to boot.
|
||||
func (s *InstanceService) Terminate(params *TerminateInstanceParams) error {
|
||||
e := &APIError{}
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -34,13 +34,13 @@ func TestLaunchInstance(t *testing.T) {
|
|||
defer teardown()
|
||||
|
||||
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{
|
||||
AvailabilityDomain: "aaaa:PHX-AD-1",
|
||||
CompartmentID: "ocid1.compartment.oc1..a",
|
||||
DisplayName: "go-bmcs test",
|
||||
DisplayName: "go-oci test",
|
||||
ImageID: "ocid1.image.oc1.phx.a",
|
||||
Shape: "VM.Standard1.1",
|
||||
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)
|
||||
}
|
||||
|
||||
want := Instance{DisplayName: "go-bmcs test"}
|
||||
want := Instance{DisplayName: "go-oci test"}
|
||||
|
||||
if !reflect.DeepEqual(instance, want) {
|
||||
t.Errorf("Client.Compute.Instances.Launch() returned %+v, want %+v", instance, want)
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -23,13 +23,13 @@ func (nopCloser) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Transport adds BMCS signature authentication to each outgoing request.
|
||||
// Transport adds OCI signature authentication to each outgoing request.
|
||||
type Transport struct {
|
||||
transport http.RoundTripper
|
||||
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.
|
||||
func NewTransport(transport http.RoundTripper, config *Config) *Transport {
|
||||
return &Transport{
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,17 +1,17 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// VNICService enables communicating with the BMCS compute API's VNICs
|
||||
// VNICService enables communicating with the OCI compute API's VNICs
|
||||
// endpoint.
|
||||
type VNICService struct {
|
||||
client *baseClient
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return &VNICService{client: s.New().Path("vnics/")}
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// VNICAttachmentService enables communicating with the BMCS compute API's VNIC
|
||||
// VNICAttachmentService enables communicating with the OCI compute API's VNIC
|
||||
// attachment endpoint.
|
||||
type VNICAttachmentService struct {
|
||||
client *baseClient
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return &VNICAttachmentService{
|
||||
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 {
|
||||
AvailabilityDomain string `json:"availabilityDomain"`
|
||||
CompartmentID string `json:"compartmentId"`
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
"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/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
|
@ -64,7 +64,7 @@ func NewConfig(raws ...interface{}) (*Config, error) {
|
|||
if c.AccessCfgFile != "" {
|
||||
accessCfgFile = c.AccessCfgFile
|
||||
} else {
|
||||
accessCfgFile, err = getDefaultBMCSSettingsPath()
|
||||
accessCfgFile, err = getDefaultOCISettingsPath()
|
||||
if err != nil {
|
||||
accessCfgFile = "" // Access cfg might be in template
|
||||
}
|
||||
|
@ -198,15 +198,15 @@ func NewConfig(raws ...interface{}) (*Config, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// getDefaultBMCSSettingsPath uses mitchellh/go-homedir to compute the default
|
||||
// config file location.
|
||||
func getDefaultBMCSSettingsPath() (string, error) {
|
||||
// getDefaultOCISettingsPath uses mitchellh/go-homedir to compute the default
|
||||
// config file location ($HOME/.oci/config).
|
||||
func getDefaultOCISettingsPath() (string, error) {
|
||||
home, err := homedir.Dir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
path := filepath.Join(home, ".oraclebmc", "config")
|
||||
path := filepath.Join(home, ".oci", "config")
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return "", err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"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{} {
|
|
@ -1,10 +1,10 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
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 {
|
||||
CreateInstance(publicKey string) (string, error)
|
||||
CreateImage(id string) (client.Image, error)
|
|
@ -1,11 +1,11 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
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
|
||||
// BMCS.
|
||||
// OCI.
|
||||
type driverMock struct {
|
||||
CreateInstanceID string
|
||||
CreateInstanceErr error
|
|
@ -1,30 +1,30 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"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
|
||||
// BMCS.
|
||||
type driverBMCS struct {
|
||||
// driverOCI implements the Driver interface and communicates with Oracle
|
||||
// OCI.
|
||||
type driverOCI struct {
|
||||
client *client.Client
|
||||
cfg *Config
|
||||
}
|
||||
|
||||
// NewDriverBMCS Creates a new driverBMCS with a connected client.
|
||||
func NewDriverBMCS(cfg *Config) (Driver, error) {
|
||||
// NewDriverOCI Creates a new driverOCI with a connected client.
|
||||
func NewDriverOCI(cfg *Config) (Driver, error) {
|
||||
client, err := client.NewClient(cfg.AccessCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &driverBMCS{client: client, cfg: cfg}, nil
|
||||
return &driverOCI{client: client, cfg: cfg}, nil
|
||||
}
|
||||
|
||||
// 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{
|
||||
AvailabilityDomain: d.cfg.AvailabilityDomain,
|
||||
CompartmentID: d.cfg.CompartmentID,
|
||||
|
@ -44,7 +44,7 @@ func (d *driverBMCS) CreateInstance(publicKey string) (string, error) {
|
|||
}
|
||||
|
||||
// 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{
|
||||
CompartmentID: d.cfg.CompartmentID,
|
||||
InstanceID: id,
|
||||
|
@ -59,12 +59,12 @@ func (d *driverBMCS) CreateImage(id string) (client.Image, error) {
|
|||
}
|
||||
|
||||
// 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})
|
||||
}
|
||||
|
||||
// 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
|
||||
vnics, err := d.client.Compute.VNICAttachments.List(
|
||||
&client.ListVnicAttachmentsParams{
|
||||
|
@ -89,14 +89,14 @@ func (d *driverBMCS) GetInstanceIP(id string) (string, error) {
|
|||
}
|
||||
|
||||
// TerminateInstance terminates a compute instance.
|
||||
func (d *driverBMCS) TerminateInstance(id string) error {
|
||||
func (d *driverOCI) TerminateInstance(id string) error {
|
||||
params := &client.TerminateInstanceParams{ID: id}
|
||||
return d.client.Compute.Instances.Terminate(params)
|
||||
}
|
||||
|
||||
// WaitForImageCreation waits for a provisioning custom image to reach the
|
||||
// "AVAILABLE" state.
|
||||
func (d *driverBMCS) WaitForImageCreation(id string) error {
|
||||
func (d *driverOCI) WaitForImageCreation(id string) error {
|
||||
return client.NewWaiter().WaitForResourceToReachState(
|
||||
d.client.Compute.Images,
|
||||
id,
|
||||
|
@ -107,7 +107,7 @@ func (d *driverBMCS) WaitForImageCreation(id string) error {
|
|||
|
||||
// WaitForInstanceState waits for an instance to reach the a given terminal
|
||||
// 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(
|
||||
d.client.Compute.Instances,
|
||||
id,
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
|
@ -1,4 +1,4 @@
|
|||
package bmcs
|
||||
package oci
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/hashicorp/packer/packer"
|
||||
"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
|
|
@ -31,7 +31,7 @@ import (
|
|||
nullbuilder "github.com/hashicorp/packer/builder/null"
|
||||
oneandonebuilder "github.com/hashicorp/packer/builder/oneandone"
|
||||
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"
|
||||
parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm"
|
||||
profitbricksbuilder "github.com/hashicorp/packer/builder/profitbricks"
|
||||
|
@ -97,7 +97,7 @@ var Builders = map[string]packer.Builder{
|
|||
"null": new(nullbuilder.Builder),
|
||||
"oneandone": new(oneandonebuilder.Builder),
|
||||
"openstack": new(openstackbuilder.Builder),
|
||||
"oracle-bmcs": new(oraclebmcsbuilder.Builder),
|
||||
"oracle-oci": new(oracleocibuilder.Builder),
|
||||
"parallels-iso": new(parallelsisobuilder.Builder),
|
||||
"parallels-pvm": new(parallelspvmbuilder.Builder),
|
||||
"profitbricks": new(profitbricksbuilder.Builder),
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
---
|
||||
description:
|
||||
with Oracle Bare Metal Cloud Services (BMCS). The builder takes an
|
||||
Oracle-provided base image, runs any provisioning necessary on the base image
|
||||
after launching it, and finally snapshots it creating a reusable custom
|
||||
image.
|
||||
The oracle-oci builder is able to create new custom images for use with Oracle
|
||||
Cloud Infrastructure (OCI).
|
||||
layout: docs
|
||||
page_title: 'Oracle BMCS - Builders'
|
||||
sidebar_current: 'docs-builders-oracle-bmcs'
|
||||
page_title: 'Oracle OCI - Builders'
|
||||
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
|
||||
with [Oracle Bare Metal Cloud Services](https://cloud.oracle.com/en_US/bare-metal-compute)
|
||||
(BMCS). The builder takes an Oracle-provided base image, runs any provisioning
|
||||
necessary on the base image after launching it, and finally snapshots it
|
||||
creating a reusable custom image.
|
||||
The `oracle-oci` Packer builder is able to create new custom images for use
|
||||
with [Oracle Cloud Infrastructure](https://cloud.oracle.com) (OCI). The builder
|
||||
takes a base image, runs any provisioning necessary on the base image after
|
||||
launching it, and finally snapshots it creating a reusable custom image.
|
||||
|
||||
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)
|
||||
|
@ -28,7 +25,7 @@ to use it or delete it.
|
|||
|
||||
## 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)
|
||||
user account. For a comprehensive example of how to configure the required
|
||||
authentication see the documentation on
|
||||
|
@ -37,7 +34,7 @@ authentication see the documentation on
|
|||
|
||||
## 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
|
||||
[communicator](/docs/templates/communicator.html) can be configured for this
|
||||
builder.
|
||||
|
@ -54,8 +51,7 @@ builder.
|
|||
[ListAvailabilityDomains](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/identity/latest/AvailabilityDomain/ListAvailabilityDomains)
|
||||
operation, which is available in the IAM Service API.
|
||||
|
||||
- `base_image_ocid` (string) - The OCID of the
|
||||
[Oracle-provided base image](https://docs.us-phoenix-1.oraclecloud.com/Content/Compute/References/images.htm)
|
||||
- `base_image_ocid` (string) - The OCID of the [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
|
||||
launch a new instance and provision it.
|
||||
|
||||
|
@ -66,9 +62,9 @@ builder.
|
|||
- `compartment_ocid` (string) - The OCID of the
|
||||
[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
|
||||
[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.
|
||||
|
||||
- `shape` (string) - The template that determines the number of
|
||||
|
@ -94,37 +90,37 @@ builder.
|
|||
### Optional
|
||||
|
||||
- `access_cfg_file` (string) - The path to the
|
||||
[BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm).
|
||||
Defaults to `$HOME/.oraclebmc/config`.
|
||||
[OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm).
|
||||
Defaults to `$HOME/.oci/config`.
|
||||
|
||||
- `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`.
|
||||
|
||||
- `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
|
||||
[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.
|
||||
|
||||
- `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
|
||||
[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.
|
||||
|
||||
- `region` (string) - An Oracle Bare Metal Cloud Services region. Overrides
|
||||
- `region` (string) - An Oracle Cloud Infrastructure region. 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.
|
||||
|
||||
- `tenancy_ocid` (string) - The OCID of your tenancy. 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.
|
||||
|
||||
- `user_ocid` (string) - The OCID of the user calling the BMCS API. Overrides
|
||||
value provided by the [BMCS config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
|
||||
- `user_ocid` (string) - The OCID of the user calling the OCI API. Overrides
|
||||
value provided by the [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
|
||||
if present.
|
||||
|
||||
|
||||
|
@ -142,6 +138,6 @@ substituted with the letter `a` and OCIDS have been shortened for brevity.
|
|||
"shape": "VM.Standard1.1",
|
||||
"ssh_username": "opc",
|
||||
"subnet_ocid": "ocid1.subnet.oc1..aaa",
|
||||
"type": "oracle-bmcs"
|
||||
"type": "oracle-oci"
|
||||
}
|
||||
```
|
|
@ -122,8 +122,8 @@
|
|||
<li<%= sidebar_current("docs-builders-openstack") %>>
|
||||
<a href="/docs/builders/openstack.html">OpenStack</a>
|
||||
</li>
|
||||
<li<%= sidebar_current("docs-builders-oracle-bmcs") %>>
|
||||
<a href="/docs/builders/oracle-bmcs.html">Oracle BMCS</a>
|
||||
<li<%= sidebar_current("docs-builders-oracle-oci") %>>
|
||||
<a href="/docs/builders/oracle-oci.html">Oracle OCI</a>
|
||||
</li>
|
||||
<li<%= sidebar_current("docs-builders-parallels") %>>
|
||||
<a href="/docs/builders/parallels.html">Parallels</a>
|
||||
|
|
Loading…
Reference in New Issue