Skip to content

Commit 4d1a063

Browse files
authored
Merge pull request #2089 from alaviss/push-xyxplqqtvqux
2 parents 1ee9f2a + f69c25b commit 4d1a063

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

docs/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Starting with this release, ignition-validate binaries are signed with the
1212

1313
### Features
1414

15+
- Support Oracle Cloud Infrastructure
16+
1517
### Changes
1618

1719
- Rename ignition.cfg -> 05_ignition.cfg

docs/supported-platforms.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Ignition is currently supported for the following platforms:
2424
* Bare Metal (`metal`) - Use the `ignition.config.url` kernel parameter to provide a URL to the configuration. The URL can use the `http://`, `https://`, `tftp://`, `s3://`, `arn:`, or `gs://` schemes to specify a remote config.
2525
* [Nutanix] (`nutanix`) - Ignition will read its configuration from the instance userdata via config drive. Cloud SSH keys are handled separately.
2626
* [OpenStack] (`openstack`) - Ignition will read its configuration from the instance userdata via either metadata service or config drive. Cloud SSH keys are handled separately.
27+
* [Oracle Cloud Infrastucture] (`oraclecloud`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
2728
* [Proxmox VE] (`proxmoxve`) - Ignition will read its configuration from the instance userdata via config drive. If there isn't any valid Ignition configuration in userdata it will check the vendordata next. Cloud SSH keys are handled separately.
2829
* [Equinix Metal] (`packet`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
2930
* [IBM Power Systems Virtual Server] (`powervs`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
@@ -55,6 +56,7 @@ For most cloud providers, cloud SSH keys and custom network configuration are ha
5556
[KubeVirt]: https://kubevirt.io
5657
[Nutanix]: https://www.nutanix.com/products/ahv
5758
[OpenStack]: https://www.openstack.org/
59+
[Oracle Cloud Infrastucture]: https://www.oracle.com/cloud
5860
[Proxmox VE]: https://www.proxmox.com/en/proxmox-virtual-environment/overview
5961
[Equinix Metal]: https://metal.equinix.com/product/
6062
[IBM Power Systems Virtual Server]: https://www.ibm.com/products/power-virtual-server
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2020 Red Hat
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// The oraclecloud provider fetches a remote configuration from Oracle's
16+
// Instance Metadata Service v2.
17+
// https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm
18+
19+
package oraclecloud
20+
21+
import (
22+
"encoding/base64"
23+
"fmt"
24+
"net/http"
25+
"net/url"
26+
27+
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
28+
"github.com/coreos/ignition/v2/internal/platform"
29+
"github.com/coreos/ignition/v2/internal/providers/util"
30+
"github.com/coreos/ignition/v2/internal/resource"
31+
32+
"github.com/coreos/vcontext/report"
33+
)
34+
35+
var userdataUrl = url.URL{
36+
Scheme: "http",
37+
Host: "169.254.169.254",
38+
Path: "opc/v2/instance/metadata/user_data",
39+
}
40+
41+
func init() {
42+
platform.Register(platform.Provider{
43+
Name: "oraclecloud",
44+
Fetch: fetchConfig,
45+
})
46+
}
47+
48+
func fetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
49+
data, err := f.FetchToBuffer(userdataUrl, resource.FetchOptions{
50+
Headers: http.Header{
51+
"Authorization": []string{"Bearer Oracle"},
52+
},
53+
RetryCodes: []int{http.StatusTooManyRequests},
54+
})
55+
if err != nil && err != resource.ErrNotFound {
56+
return types.Config{}, report.Report{}, fmt.Errorf("fetching to buffer: %w", err)
57+
}
58+
59+
userdata := make([]byte, base64.StdEncoding.DecodedLen(len(data)))
60+
size, err := base64.StdEncoding.Decode(userdata, data)
61+
if err != nil {
62+
return types.Config{}, report.Report{}, fmt.Errorf("decoding userdata: %w", err)
63+
}
64+
userdata = userdata[:size]
65+
66+
return util.ParseConfig(f.Logger, userdata)
67+
}

internal/register/providers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
_ "github.com/coreos/ignition/v2/internal/providers/metal"
3434
_ "github.com/coreos/ignition/v2/internal/providers/nutanix"
3535
_ "github.com/coreos/ignition/v2/internal/providers/openstack"
36+
_ "github.com/coreos/ignition/v2/internal/providers/oraclecloud"
3637
_ "github.com/coreos/ignition/v2/internal/providers/packet"
3738
_ "github.com/coreos/ignition/v2/internal/providers/powervs"
3839
_ "github.com/coreos/ignition/v2/internal/providers/proxmoxve"

0 commit comments

Comments
 (0)