fix openstack metadata

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Василий Толстов 2016-09-27 09:05:53 +03:00
parent f33a90587f
commit 002446413d
2 changed files with 9 additions and 4 deletions

2
build
View File

@ -14,7 +14,7 @@ mkdir -p $GOBIN
mkdir -p $GOPATH mkdir -p $GOPATH
mkdir -p bin tmp mkdir -p bin tmp
go version | grep -q go1.5 go version | grep -q go
if [ "x$?" != "x0" ]; then if [ "x$?" != "x0" ]; then
export GOROOT=$(pwd)/goroot export GOROOT=$(pwd)/goroot

View File

@ -31,6 +31,7 @@ import (
"github.com/coreos/coreos-cloudinit/datasource" "github.com/coreos/coreos-cloudinit/datasource"
"github.com/coreos/coreos-cloudinit/datasource/configdrive" "github.com/coreos/coreos-cloudinit/datasource/configdrive"
"github.com/coreos/coreos-cloudinit/datasource/file" "github.com/coreos/coreos-cloudinit/datasource/file"
"github.com/coreos/coreos-cloudinit/datasource/metadata/openstack"
"github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean" "github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean"
"github.com/coreos/coreos-cloudinit/datasource/metadata/ec2" "github.com/coreos/coreos-cloudinit/datasource/metadata/ec2"
"github.com/coreos/coreos-cloudinit/datasource/metadata/packet" "github.com/coreos/coreos-cloudinit/datasource/metadata/packet"
@ -61,6 +62,7 @@ var (
waagent string waagent string
metadataService bool metadataService bool
ec2MetadataService string ec2MetadataService string
openstackMetadataService string
// cloudSigmaMetadataService bool // cloudSigmaMetadataService bool
digitalOceanMetadataService string digitalOceanMetadataService string
packetMetadataService string packetMetadataService string
@ -88,7 +90,7 @@ func init() {
flag.StringVar(&flags.sources.ec2MetadataService, "from-ec2-metadata", "", "Download EC2 data from the provided url") flag.StringVar(&flags.sources.ec2MetadataService, "from-ec2-metadata", "", "Download EC2 data from the provided url")
// flag.BoolVar(&flags.sources.cloudSigmaMetadataService, "from-cloudsigma-metadata", false, "Download data from CloudSigma server context") // flag.BoolVar(&flags.sources.cloudSigmaMetadataService, "from-cloudsigma-metadata", false, "Download data from CloudSigma server context")
flag.StringVar(&flags.sources.digitalOceanMetadataService, "from-digitalocean-metadata", "", "Download DigitalOcean data from the provided url") flag.StringVar(&flags.sources.digitalOceanMetadataService, "from-digitalocean-metadata", "", "Download DigitalOcean data from the provided url")
flag.StringVar(&flags.sources.ec2MetadataService, "from-openstack-metadata", "", "Download OpenStack data from the provided url") flag.StringVar(&flags.sources.openstackMetadataService, "from-openstack-metadata", "", "Download OpenStack data from the provided url")
flag.StringVar(&flags.sources.packetMetadataService, "from-packet-metadata", "", "Download Packet data from metadata service") flag.StringVar(&flags.sources.packetMetadataService, "from-packet-metadata", "", "Download Packet data from metadata service")
flag.StringVar(&flags.sources.url, "from-url", "", "Download user-data from provided url") flag.StringVar(&flags.sources.url, "from-url", "", "Download user-data from provided url")
flag.BoolVar(&flags.sources.procCmdLine, "from-proc-cmdline", false, fmt.Sprintf("Parse %s for '%s=<url>', using the cloud-config served by an HTTP GET to <url>", proc_cmdline.ProcCmdlineLocation, proc_cmdline.ProcCmdlineCloudConfigFlag)) flag.BoolVar(&flags.sources.procCmdLine, "from-proc-cmdline", false, fmt.Sprintf("Parse %s for '%s=<url>', using the cloud-config served by an HTTP GET to <url>", proc_cmdline.ProcCmdlineLocation, proc_cmdline.ProcCmdlineCloudConfigFlag))
@ -188,10 +190,10 @@ func main() {
dss := getDatasources() dss := getDatasources()
if len(dss) == 0 { if len(dss) == 0 {
fmt.Println("Provide at least one of --from-file, --from-configdrive, --from-ec2-metadata, --from-cloudsigma-metadata, --from-packet-metadata, --from-digitalocean-metadata, --from-vmware-guestinfo, --from-waagent, --from-url or --from-proc-cmdline") fmt.Println("Provide at least one of --from-file, --from-configdrive, --from-openstack-metadata, --from-ec2-metadata, --from-cloudsigma-metadata, --from-packet-metadata, --from-digitalocean-metadata, --from-vmware-guestinfo, --from-waagent, --from-url or --from-proc-cmdline")
os.Exit(2) os.Exit(2)
} }
fmt.Printf("%#+v\n", dss)
ds := selectDatasource(dss) ds := selectDatasource(dss)
if ds == nil { if ds == nil {
log.Println("No datasources available in time") log.Println("No datasources available in time")
@ -333,6 +335,9 @@ func getDatasources() []datasource.Datasource {
if flags.sources.metadataService { if flags.sources.metadataService {
dss = append(dss, ec2.NewDatasource(ec2.DefaultAddress)) dss = append(dss, ec2.NewDatasource(ec2.DefaultAddress))
} }
if flags.sources.openstackMetadataService != "" {
dss = append(dss, openstack.NewDatasource(flags.sources.openstackMetadataService))
}
if flags.sources.ec2MetadataService != "" { if flags.sources.ec2MetadataService != "" {
dss = append(dss, ec2.NewDatasource(flags.sources.ec2MetadataService)) dss = append(dss, ec2.NewDatasource(flags.sources.ec2MetadataService))
} }