Renamed project/datasource; Install script
This patch refactors the name of the project, datasource,
and adds an install script that can be curl bashed on
Linux distributions that do not yet have a proper package
for this datasource.
diff --git a/.gitignore b/.gitignore
index 04e2184..2d0bb33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@
/net.1.config
/metadata.json
/test.sh
-/userdata.yaml
\ No newline at end of file
+/userdata.yaml
+.DS_Store
\ No newline at end of file
diff --git a/99-DataSourceVMwareGuestInfo.cfg b/99-DataSourceVMwareGuestInfo.cfg
new file mode 100644
index 0000000..091d9a7
--- /dev/null
+++ b/99-DataSourceVMwareGuestInfo.cfg
@@ -0,0 +1 @@
+datasource_list: [ "VMwareGuestInfo" ]
diff --git a/99_vmx_guestinfo.cfg b/99_vmx_guestinfo.cfg
deleted file mode 100644
index 3d5a9b7..0000000
--- a/99_vmx_guestinfo.cfg
+++ /dev/null
@@ -1 +0,0 @@
-datasource_list: [ "VmxGuestinfo" ]
diff --git a/DataSourceVmxGuestinfo.py b/DataSourceVMwareGuestInfo.py
similarity index 90%
rename from DataSourceVmxGuestinfo.py
rename to DataSourceVMwareGuestInfo.py
index 60b68dd..8131253 100644
--- a/DataSourceVmxGuestinfo.py
+++ b/DataSourceVMwareGuestInfo.py
@@ -1,6 +1,6 @@
# vi: ts=4 expandtab
#
-# Copyright (C) 2017 VMware Inc.
+# Copyright (C) 2018 VMware Inc.
#
# Authors: Anish Swaminathan <anishs@vmware.com>
# Andrew Kutz <akutz@vmware.com>
@@ -19,8 +19,15 @@
LOG = logging.getLogger(__name__)
-# Used with CentOS 7 which installs cloud-init 0.7.9. The URL for
-# the DataSource class is http://bit.ly/cloudinit-datasource-0-7-9.
+# This cloud-init datasource was designed for use with CentOS 7,
+# which uses cloud-init 0.7.9. However, this datasource should
+# work with any Linux distribution for which cloud-init is
+# avaialble.
+#
+# The documentation for cloud-init 0.7.9's datasource is
+# available at http://bit.ly/cloudinit-datasource-0-7-9. The
+# current documentation for cloud-init is found at
+# https://cloudinit.readthedocs.io/en/latest/.
#
# Setting the hostname:
# The hostname is set by way of the metadata key "local-hostname".
@@ -47,7 +54,7 @@
# The metadata key "network.encoding" may be used to indicate the
# format of the metadata key "network". Valid encodings are base64
# and gzip+base64.
-class DataSourceVmxGuestinfo(sources.DataSource):
+class DataSourceVMwareGuestInfo(sources.DataSource):
def __init__(self, sys_cfg, distro, paths, ud_proc=None):
sources.DataSource.__init__(self, sys_cfg, distro, paths, ud_proc)
self.vmtoolsd = find_executable("vmtoolsd")
@@ -143,4 +150,4 @@
"""
Return a list of data sources that match this set of dependencies
"""
- return [DataSourceVmxGuestinfo]
+ return [DataSourceVMwareGuestInfo]
diff --git a/Makefile b/Makefile
index 50a6de6..1a6cf9d 100644
--- a/Makefile
+++ b/Makefile
@@ -11,12 +11,11 @@
-v $$(pwd)/rpmmacros:/root/.rpmmacros:ro \
-v $$(pwd)/rpmbuild/el7:/root/rpmbuild \
-v $$(pwd)/rpm.el7.spec:/root/rpmbuild/SPECS/rpm.spec:ro \
- -v $$(pwd)/99_vmx_guestinfo.cfg:/root/rpmbuild/BUILD/etc/cloud/cloud.cfg.d/99_vmx_guestinfo.cfg:ro \
- -v $$(pwd)/DataSourceVmxGuestinfo.py:/root/rpmbuild/BUILD/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceVmxGuestinfo.py:ro \
+ -v $$(pwd)/99-DataSourceVMwareGuestInfo.cfg:/root/rpmbuild/BUILD/etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg:ro \
+ -v $$(pwd)/DataSourceVMwareGuestInfo.py:/root/rpmbuild/BUILD/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceVMwareGuestInfo.py:ro \
rpmbuild:el7 \
rpmbuild -ba /root/rpmbuild/SPECS/rpm.spec
rpm: rpm-el7
build: rpm
-
diff --git a/README.md b/README.md
index a380be2..b7b2bb2 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# Cloud-Init Datasource for VMware VMX Guestinfo
+# Cloud-Init Datasource for VMware GuestInfo
This project provides a cloud-init datasource for pulling meta,
-user, and vendor data from VMware's VMX Guestinfo interface.
+user, and vendor data from VMware vSphere's GuestInfo interface.
## Installation
There are multiple methods of installing the data source.
@@ -9,44 +9,15 @@
There is an RPM available for installing on RedHat/CentOS:
```shell
-$ yum install https://github.com/akutz/cloudinit-ds-vmx-guestinfo/releases/download/v1.0.0/cloud-init-vmx-guestinfo-1.0.0-1.el7.noarch.rpm
+$ yum install https://github.com/akutz/cloud-init-vmware-guestinfo/releases/download/v1.0.0/cloud-init-vmware-guestinfo-1.0.0-1.el7.noarch.rpm
```
### Installing on other Linux distributions
-The VMX Guestinfo datasource can be installed on any Linux distribution
-where cloud-init is already present. To do so, please follow these steps:
-
-1. Find the path to the `cloudinit/sources` Python package:
-```shell
-$ PY_SCRIPT='import os; from cloudinit import sources; print(os.path.dirname(sources.__file__));'
-$ CLOUDINIT_SOURCES=$(python -c ''"${PY_SCRIPT}"'' 2>/dev/null || python3 -c ''"${PY_SCRIPT}"'')
-```
-
-2. Verify `CLOUDINIT_SOURCES` is set to a valid path. If it isn't, then
-cloud-init is likely not installed and these instructions should be
-aborted.
-```shell
-$ [ -n "${CLOUDINIT_SOURCES}" ] || echo "cloud-init not found"
-```
-
-3. Write `DataSourceVmxGuestinfo.py` to `$CLOUDINIT_SOURCES`:
-```shell
-$ curl -sSLo "${CLOUDINIT_SOURCES}/DataSourceVmxGuestinfo.py" \
- https://raw.githubusercontent.com/akutz/cloudinit-ds-vmx-guestinfo/master/DataSourceVmxGuestinfo.py
-```
-
-4. Update the list of available datasources. This step can vary based on
-the Linux distribution. On Ubuntu 14.04 LTS (Trusty) the file
-`/etc/cloud.cfg.d/90_dpkg.cfg` contains the list of datasources that
-needs to be amended to include `VmxGuestinfo`. On Ubuntu 18.04 (Bionic)
-and other Linux distributions this file may not be present. In those cases
-use the following command to add a configuration file to cloud-init that
-overrides any existing datasource selection with the VMX Guestinfo
-datasource:
+The VMware GuestInfo datasource can be installed on any Linux distribution
+where cloud-init is already present. To do so, simply execute the following:
```shell
-$ curl -sSLo /etc/cloud/cloud.cfg.d/99_vmx_guestinfo.cfg \
- https://raw.githubusercontent.com/akutz/cloudinit-ds-vmx-guestinfo/master/99_vmx_guestinfo.cfg
+$ curl -sSL https://raw.githubusercontent.com/akutz/cloud-init-vmware-guestinfo/master/install.sh | sh -
```
## Configuration
@@ -67,7 +38,7 @@
## Walkthrough
The following series of steps is a demonstration on how to configure a VM
-with cloud-init and the VMX Guestinfo datasource.
+with cloud-init and the VMX GuestInfo datasource.
### Create a network configuration file
First, create the network configuration for the VM. Save the following
@@ -130,7 +101,7 @@
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDE0c5FczvcGSh/tG4iw+Fhfi/O5/EvUM/96js65tly4++YTXK1d9jcznPS5ruDlbIZ30oveCBd3kT8LLVFwzh6hepYTf0YmCTpF4eDunyqmpCXDvVscQYRXyasEm5olGmVe05RrCJSeSShAeptv4ueIn40kZKOghinGWLDSZG4+FFfgrmcMCpx5YSCtX2gvnEYZJr0czt4rxOZuuP7PkJKgC/mt2PcPjooeX00vAj81jjU2f3XKrjjz2u2+KIt9eba+vOQ6HiC8c2IzRkUAJ5i1atLy8RIbejo23+0P4N2jjk17QySFOVHwPBDTYb0/0M/4ideeU74EN/CgVsvO6JrLsPBR4dojkV5qNbMNxIVv5cUwIy2ThlLgqpNCeFIDLCWNZEFKlEuNeSQ2mPtIO7ETxEL2Cz5y/7AIuildzYMc6wi2bofRC8HmQ7rMXRWdwLKWsR0L7SKjHblIwarxOGqLnUI+k2E71YoP7SZSlxaKi17pqkr0OMCF+kKqvcvHAQuwGqyumTEWOlH6TCx1dSPrW+pVCZSHSJtSTfDW2uzL6y8k10MT06+pVunSrWo5LHAXcS91htHV1M1UrH/tZKSpjYtjMb5+RonfhaFRNzvj7cCE1f3Kp8UVqAdcGBTtReoE8eRUT63qIxjw03a7VwAyB2w+9cu1R9/vAo8SBeRqw== sakutz@gmail.com
```
-### Assigning the cloud-config data to the VM's Guestinfo
+### Assigning the cloud-config data to the VM's GuestInfo
Please note that this step requires that the VM be powered off. All of
the commands below use the VMware CLI tool,
[`govc`](https://github.com/vmware/govmomi/blob/master/govc).
@@ -170,7 +141,7 @@
* `base64`
* `gzip+base64`
-### Using the cloud-init VMX Guestinfo datasource
+### Using the cloud-init VMX GuestInfo datasource
Power the VM back on.
```shell
$ govc vm.power -vm "${VM}" -on
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..64e7eb2
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+#
+# usage: install.sh
+# curl -sSL https://raw.githubusercontent.com/akutz/cloud-init-vmware-guestinfo/master/install.sh | sh -
+#
+
+# The script to lookup the path to the cloud-init's datasource directory, "sources".
+PY_SCRIPT='import os; from cloudinit import sources; print(os.path.dirname(sources.__file__));'
+
+# Get the path to the cloud-init installation's datasource directory.
+CLOUD_INIT_SOURCES=$(python -c ''"${PY_SCRIPT}"'' 2>/dev/null || \
+ python3 -c ''"${PY_SCRIPT}"'' 2>/dev/null) ||
+ { exit_code="${?}"; echo "failed to find python runtime" 1>&2; exit "${exit_code}"; }
+
+# If no "sources" directory was located then it's likely cloud-init is not installed.
+[ -z "${CLOUD_INIT_SOURCES}" ] && echo "cloud-init not found" 1>&2 && exit 1
+
+# The repository from which to fetch the cloud-init datasource and config files.
+REPO_SLUG="${REPO_SLUG:-https://raw.githubusercontent.com/akutz/cloud-init-vmware-guestinfo}"
+
+# The git reference to use. This can be a branch or tag name as well as a commit ID.
+GIT_REF="${GIT_REF:-master}"
+
+# Download the cloud init datasource into the cloud-init's "sources" directory.
+curl -sSL -o "${CLOUD_INIT_SOURCES}/DataSourceVMwareGuestInfo.py" \
+ "${REPO_SLUG}/${GIT_REF}/DataSourceVMwareGuestInfo.py"
+
+# Add the configuration file that tells cloud-init what datasource to use.
+mkdir -p /etc/cloud.cfg.d
+curl -sSL -o /etc/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg \
+ "${REPO_SLUG}/${GIT_REF}/99-DataSourceVMwareGuestInfo.cfg"
+
+echo "So long, and thanks for all the fish."
diff --git a/rpm.el7.spec b/rpm.el7.spec
index 8eda749..793b7b4 100644
--- a/rpm.el7.spec
+++ b/rpm.el7.spec
@@ -1,14 +1,14 @@
#
-# spec file for package cloud-init-vmx-guestinfo
+# spec file for package cloud-init-vmware-guestinfo
#
#################################################################################
# common
#################################################################################
-Name: cloud-init-vmx-guestinfo
+Name: cloud-init-vmware-guestinfo
Version: 1.0.0
Release: 1.el7
-Summary: A cloud-init datasource that uses VMX Guestinfo
+Summary: A cloud-init datasource that uses VMware GuestInfo
License: Apache2
Requires: cloud-init
Group: Applications/System
@@ -18,7 +18,7 @@
# specific
#################################################################################
%description
-A cloud-init datasource that uses VMX Guestinfo
+A cloud-init datasource that uses VMware GuestInfo
%prep
@@ -33,5 +33,5 @@
%files
%defattr(0644, root,root, 0755)
-/etc/cloud/cloud.cfg.d/99_vmx_guestinfo.cfg
-/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceVmxGuestinfo.py
+/etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg
+/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceVMwareGuestInfo.py