├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── cloud-provider-setup.md ├── e2e ├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── cloud_config.tf ├── cloud_config.yaml ├── config.env ├── data.tf ├── destroy.sh ├── entrypoint.sh ├── etcd.tf ├── hack │ ├── keepalive │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.md │ │ ├── keepalive.go │ │ └── periodic_writes.sh │ └── turn.sh ├── input.tf ├── k8s.tf ├── load_balancer.tf ├── output.tf ├── providers.tf ├── sonobuoy.yaml ├── tls_ca.tf ├── upload_e2e.py ├── vmc │ ├── k8s_admin.tf │ ├── load_balancer.tf │ ├── placeholder.tf │ ├── providers_aws.tf │ ├── providers_local.tf │ ├── providers_tls.tf │ └── tls_ca.tf └── vsphere.tf ├── hack ├── new-ca.sh ├── new-cert.sh └── new-kubeconfig.sh ├── ova ├── .gitignore ├── Makefile ├── README.md ├── cli │ └── sk8-cli.sh ├── doc │ ├── provision-on-vmc-with-ova.md │ └── provision-on-vsphere-with-ova.md ├── hack │ ├── centos │ │ ├── centos-prep.sh │ │ └── centos-seal.sh │ ├── get-k8s-artifacts-url.sh │ ├── init-local-env.sh │ ├── photon │ │ ├── photon-prep.sh │ │ └── photon-seal.sh │ └── prep.sh ├── kube-update │ ├── README.md │ ├── kube-update.service │ └── kube-update.sh ├── ovf │ ├── centos.ovf │ ├── photon.ovf │ └── product-section.ovf ├── rpctool │ ├── .gitignore │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── Makefile │ ├── README.md │ ├── hack │ │ └── make.sh │ ├── main.go │ └── vendor │ │ └── github.com │ │ └── vmware │ │ ├── govmomi │ │ ├── CONTRIBUTORS │ │ ├── LICENSE.txt │ │ ├── govc │ │ │ └── test │ │ │ │ └── license.bats │ │ ├── ovf │ │ │ ├── cim.go │ │ │ ├── doc.go │ │ │ ├── env.go │ │ │ ├── envelope.go │ │ │ ├── manager.go │ │ │ └── ovf.go │ │ ├── scripts │ │ │ ├── contributors.sh │ │ │ └── license.sh │ │ └── vim25 │ │ │ ├── client.go │ │ │ ├── doc.go │ │ │ ├── methods │ │ │ ├── methods.go │ │ │ └── service_content.go │ │ │ ├── mo │ │ │ ├── ancestors.go │ │ │ ├── entity.go │ │ │ ├── extra.go │ │ │ ├── mo.go │ │ │ ├── reference.go │ │ │ ├── registry.go │ │ │ ├── retrieve.go │ │ │ └── type_info.go │ │ │ ├── progress │ │ │ ├── aggregator.go │ │ │ ├── doc.go │ │ │ ├── prefix.go │ │ │ ├── reader.go │ │ │ ├── report.go │ │ │ ├── scale.go │ │ │ ├── sinker.go │ │ │ └── tee.go │ │ │ ├── retry.go │ │ │ ├── soap │ │ │ ├── client.go │ │ │ ├── debug.go │ │ │ ├── error.go │ │ │ └── soap.go │ │ │ ├── types │ │ │ ├── base.go │ │ │ ├── enum.go │ │ │ ├── fault.go │ │ │ ├── helpers.go │ │ │ ├── if.go │ │ │ ├── registry.go │ │ │ └── types.go │ │ │ └── xml │ │ │ ├── LICENSE │ │ │ ├── extras.go │ │ │ ├── marshal.go │ │ │ ├── read.go │ │ │ ├── typeinfo.go │ │ │ └── xml.go │ │ └── vmw-guestinfo │ │ ├── LICENSE │ │ ├── bdoor │ │ ├── bdoor.go │ │ ├── bdoor_386.go │ │ ├── bdoor_386.s │ │ ├── bdoor_amd64.go │ │ ├── bdoor_amd64.s │ │ └── word.go │ │ ├── message │ │ ├── log.go │ │ └── message.go │ │ ├── rpcout │ │ └── rpcout.go │ │ ├── rpcvmx │ │ └── rpcvmx.go │ │ └── vmcheck │ │ ├── vmcheck.go │ │ ├── vmcheck_386.s │ │ ├── vmcheck_amd64.s │ │ ├── vmcheck_general.go │ │ └── vmcheck_linux.go ├── sk8-ca.sh ├── sk8-cluster.sh ├── sk8-common.sh ├── sk8-config-keys.env ├── sk8-guestinfo.sh ├── sk8-hostname.sh ├── sk8-kubeconfig.sh ├── sk8-load-balancer.sh ├── sk8-ssh.sh ├── sk8-update.sh ├── sk8-vsphere.sh ├── sk8.service └── sysprep │ ├── sysprep-centos.sh │ └── sysprep-photon.sh ├── sk8.sh ├── uml ├── .gitignore ├── Makefile ├── install-process.puml └── node-components.puml └── vagrant ├── .gitignore ├── README.md ├── Vagrantfile ├── hack ├── common.sh ├── dig.sh ├── kubectl.sh └── vagrant.sh ├── sk8.service └── tail-log.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the marker files. 2 | /.Dockerfile* 3 | 4 | # Ignore the private TLS files 5 | *.crt 6 | *.key 7 | *.srl 8 | 9 | # Ignore kubeconfig files 10 | kubeconfig 11 | 12 | # Ignore the data directories and secure files 13 | /.terraform/ 14 | /data 15 | /*/data 16 | /.terraform/ 17 | /*.tfstate* 18 | /secure.auto.tfvars 19 | /secure.env 20 | /config.env 21 | 22 | # Ignore the hack dir 23 | /hack/Dockerfile* 24 | /hack/*.tar.gz 25 | /hack/Makefile 26 | 27 | # Ignore scratch files 28 | /vm.json 29 | /ova/import* 30 | /ova/hack/import* -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | simple-kubernetes-test-environment 2 | 3 | Copyright (c) 2018 VMware, Inc. All Rights Reserved. 4 | 5 | This product is licensed to you under the Apache 2.0 license (the "License"). You may not use this product except in compliance with the Apache 2.0 License. 6 | 7 | This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | VMware has ended active development of this project, and its repository will no longer be updated. 4 | 5 | --- 6 | 7 | # Simple Kubernetes Test Environment 8 | The Simple Kubernetes Test Enviornment (sk8) project is: 9 | 10 | * _For developers building and testing Kubernetes and core Kubernetes components_ 11 | * Capable of deploying *any* [version](https://github.com/vmware/simple-k8s-test-env/wiki/Kubernetes-version) of Kubernetes (+1.10) on generic Linux distributions 12 | * Designed to deploy single-node, multi-node, and even multi-control plane node clusters 13 | * Able to deploy nodes on DHCP networks with support for both node FQDNs and IPv4 addresses 14 | * A single, POSIX-compliant shell script, making it portable and customizable 15 | 16 | ## Quick start 17 | The quickest way to provision a Kubernetes cluster with sk8 is on vSphere 18 | using the [OVA](ova/doc/provision-on-vsphere-with-ova.md). 19 | 20 | ## Getting started 21 | * [How does sk8 work?](#how-does-sk8-work) 22 | * [What does sk8 install?](#what-does-sk8-install) 23 | * [How to provision Kubernetes with sk8](#how-to-provision-kubernetes-sk8-sk8) 24 | 25 | ### How does sk8 work? 26 | The sk8 project revolves around a single, POSIX-compliant shell script designed 27 | to be compatible with most Linux distributions. This 28 | [model](https://s3-us-west-2.amazonaws.com/cnx.vmware/cicd/sk8/svg/install-process.svg) 29 | illustrates an example sk8 execution. 30 | 31 | ### What does sk8 install? 32 | A sk8-provisioned cluster passes the Kubernetes e2e conformance test suite 33 | because sk8 uses a well-known, standard set of components to the control 34 | plane and worker nodes: 35 | 36 | ![Node components](https://s3-us-west-2.amazonaws.com/cnx.vmware/cicd/sk8/svg/node-components.svg?v2) 37 | 38 | ### How to provision Kubernetes with sk8 39 | There are several ways to provision a Kubernetes cluster with sk8: 40 | 41 | * [Provision a multi-node cluster on vSphere with the sk8 OVA](ova/doc/provision-on-vsphere-with-ova.md) 42 | * [Provision a multi-node cluster on VMware Cloud (VMC) on AWS with the sk8 OVA](ova/doc/provision-on-vmc-with-ova.md) 43 | * [Provision single-node and multi-node clusters with sk8 and Vagrant](vagrant/) 44 | 45 | ## Todo 46 | * Better testing 47 | * Better documentaton 48 | 49 | ## License 50 | Please the [LICENSE](LICENSE) file for information about this project's license. 51 | -------------------------------------------------------------------------------- /e2e/.dockerignore: -------------------------------------------------------------------------------- 1 | data/ 2 | -------------------------------------------------------------------------------- /e2e/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the marker files. 2 | /.Dockerfile* 3 | 4 | # Ignore scratch files. 5 | /vprep.sh 6 | /scratch.txt 7 | /hack/*.tar.gz 8 | /hack/crio* 9 | /hack/Dockerfile* 10 | /hack/Makefile 11 | 12 | # Ignore the private TLS files 13 | *.crt 14 | *.key 15 | *.srl 16 | 17 | # Ignore the data directories and secure files 18 | /.terraform/ 19 | /data 20 | /*/data 21 | /.terraform/ 22 | /*.tfstate* 23 | /secure.auto.tfvars 24 | /secure.env 25 | /config.env 26 | 27 | # Ignore the hack dir 28 | /hack/Dockerfile* 29 | /hack/*.tar.gz 30 | /hack/Makefile 31 | -------------------------------------------------------------------------------- /e2e/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stretch-20190204-slim 2 | LABEL "maintainer" "Andrew Kutz " 3 | 4 | # Update the CA certificates and clean up the apt cache. 5 | RUN apt-get -y update && \ 6 | apt-get -y --no-install-recommends install \ 7 | ca-certificates curl jq locales python3 ruby tar unzip && \ 8 | rm -rf /var/cache/apt/* /var/lib/apt/lists/* 9 | 10 | # Set the locale so that the gist command is happy. 11 | ENV LANG=en_US.UTF-8 12 | ENV LC_ALL=C.UTF-8 13 | 14 | # Install pip 15 | RUN curl -sSL https://bootstrap.pypa.io/get-pip.py | python3 - 16 | 17 | # Install the ruby gem that enables the uploading of files as gists. 18 | RUN gem install gist 19 | 20 | # Install the AWS CLI 21 | RUN pip3 install awscli --upgrade 22 | 23 | # Download the Google Cloud SDK 24 | RUN curl -sSL https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-217.0.0-linux-x86_64.tar.gz | \ 25 | tar xzC / && \ 26 | /google-cloud-sdk/bin/gcloud components update 27 | 28 | # Download Sonobuoy 29 | RUN curl -sSL https://github.com/heptio/sonobuoy/releases/download/v0.13.0/sonobuoy_0.13.0_linux_amd64.tar.gz | \ 30 | tar xzC /usr/local/bin --exclude=LICENSE 31 | 32 | # Download Terraform and place its binary in /usr/local/bin. 33 | ENV TF_VERSION=0.11.8 34 | ENV TF_ZIP=terraform_${TF_VERSION}_linux_amd64.zip 35 | ENV TF_URL=https://releases.hashicorp.com/terraform/${TF_VERSION}/${TF_ZIP} 36 | RUN curl -sSLO "${TF_URL}" && unzip "${TF_ZIP}" -d /usr/local/bin && rm -f "${TF_ZIP}" 37 | 38 | # Download the kubectl binary. 39 | RUN k8s_version="$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)" && \ 40 | curl -sSLo /usr/local/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/${k8s_version}/bin/linux/amd64/kubectl" && \ 41 | chmod 0755 /usr/local/bin/kubectl 42 | 43 | # Copy the keepalive program to /usr/local/bin. 44 | COPY hack/keepalive/keepalive.linux_amd64 /usr/local/bin/keepalive 45 | 46 | # Download govc 47 | RUN curl -sSL https://github.com/vmware/govmomi/releases/download/v0.20.0/govc_linux_amd64.gz | \ 48 | gzip -d >/usr/local/bin/govc && chmod 0755 /usr/local/bin/govc 49 | 50 | # Create the directory structure. 51 | RUN mkdir -p /tf/vmc 52 | 53 | # Copy the assets into the /tf directory. 54 | COPY *.tf cloud_config.yaml destroy.sh entrypoint.sh upload_e2e.py sonobuoy.yaml /tf/ 55 | COPY vmc/*.tf /tf/vmc/ 56 | 57 | # Make sure all of the scripts are marked as executable. 58 | RUN chmod 0755 /tf/*.sh /tf/*.py 59 | 60 | # The entrypoint command will be executed from the following working directory. 61 | WORKDIR /tf 62 | 63 | # Update the PATH to include the Google Cloud SDK. 64 | ENV PATH=/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 65 | 66 | # Download the Terraform plug-ins. 67 | RUN cp data.tf data.tf.bak && \ 68 | ./entrypoint.sh null plugins && \ 69 | mv -f data.tf.bak data.tf 70 | 71 | # The default argument for the entrypoint will drop the user into a shell. 72 | CMD [ "bash" ] 73 | ENTRYPOINT [ "/tf/entrypoint.sh" ] 74 | -------------------------------------------------------------------------------- /e2e/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | IMAGE := gcr.io/kubernetes-conformance-testing/sk8e2e 4 | TAG ?= $(shell git describe --always --dirty) 5 | KEEPALIVE := hack/keepalive/keepalive.linux_amd64 6 | 7 | $(KEEPALIVE): 8 | $(MAKE) -C hack/keepalive keepalive.linux_amd64 9 | 10 | build: image 11 | image: $(KEEPALIVE) 12 | docker build -t "$(IMAGE):$(TAG)" . 13 | docker tag "$(IMAGE):$(TAG)" "$(IMAGE):latest" 14 | 15 | push: image 16 | docker push "$(IMAGE):$(TAG)" 17 | docker push "$(IMAGE):latest" 18 | 19 | .PHONY: build image push 20 | -------------------------------------------------------------------------------- /e2e/README.md: -------------------------------------------------------------------------------- 1 | # sk8e2e 2 | This project provides a turn-key solution for running the Kubernetes 3 | conformance tests on the VMware vSphere on VMC platform. In other words, 4 | it's **Y**et **A**nother **K**ubernetes **e2e** runner :) 5 | 6 | ## Quick start 7 | To run the Kubernetes conformance tests follow these steps: 8 | 9 | 1. Create a file named `config.env` with Terraform properties that 10 | reflect the environment to which the cluster will be deployed. For a 11 | full list of the properties available (as well as their default values), 12 | please see `input.tf`. 13 | 14 | 2. Create a file named `secure.env` with vSphere and AWS credentials 15 | used to access the vSphere on VMC environment. For example: 16 | 17 | ``` 18 | TF_VAR_vsphere_server=1.2.3.4 19 | TF_VAR_vsphere_user=admin 20 | TF_VAR_vsphere_password=password 21 | 22 | AWS_ACCESS_KEY_ID=abc123 23 | AWS_SECRET_ACCESS_KEY=edf456 24 | AWS_DEFAULT_REGION=us-west-2 25 | ``` 26 | 27 | 3. Turn up a cluster named `stable`: 28 | ```shell 29 | $ docker run -it --rm \ 30 | -v "$(pwd)/data":/tf/data \ 31 | --env-file config.env \ 32 | --env-file secure.env \ 33 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 34 | stable up 35 | ``` 36 | 37 | 4. Run the e2e conformance tests as job on the turned-up cluster: 38 | ```shell 39 | $ docker run -it --rm \ 40 | -v "$(pwd)/data":/tf/data \ 41 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 42 | stable test 43 | ``` 44 | 45 | 5. Turn down the cluster: 46 | ```shell 47 | $ docker run -it --rm \ 48 | -v "$(pwd)/data":/tf/data \ 49 | --env-file config.env \ 50 | --env-file secure.env \ 51 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 52 | stable down 53 | ``` 54 | 55 | ## Run the e2e tests with an external cloud-provider 56 | The cluster turned up in the [quick start](#quick-start) section is 57 | deployed with the in-tree vSphere cloud provider. To turn up a cluster 58 | using the out-of-tree vSphere cloud provider simply modify the third 59 | step: 60 | 61 | ```shell 62 | $ docker run -it --rm \ 63 | -v "$(pwd)/data":/tf/data \ 64 | --env-file config.env \ 65 | --env-file secure.env \ 66 | --env TF_VAR_cloud_provider=external \ 67 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 68 | stable up 69 | ``` 70 | 71 | Beyond that all the other steps are the same. 72 | 73 | ## Download the e2e test results 74 | The following command will block until the e2e tests have completed 75 | and then download the test results as a tarball: 76 | 77 | ```shell 78 | $ docker run -it --rm \ 79 | -v "$(pwd)/data":/tf/data \ 80 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 81 | stable tget 82 | ``` 83 | 84 | ## Upload the e2e test results to GCS 85 | After using `tget`, the following command will upload the test results 86 | to a GCS bucket: 87 | 88 | ```shell 89 | $ docker run -it --rm \ 90 | -v "$(pwd)/data":/tf/data \ 91 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 92 | stable tput gs://path-to-bucket google-cloud-key-file.json 93 | ``` 94 | 95 | ## Stop the e2e test 96 | The following command stops any in-progress e2e test job: 97 | 98 | ```shell 99 | $ docker run -it --rm \ 100 | -v "$(pwd)/data":/tf/data \ 101 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 102 | stable tdel 103 | ``` 104 | 105 | ## Run the e2e tests on Prow 106 | The same image may also be used as the basis of a Prow job: 107 | 108 | ```shell 109 | $ docker run -it --rm \ 110 | --env-file config.env \ 111 | --env-file secure.env \ 112 | -e ARTIFACTS=/tmp/artifacts \ 113 | -v "$(pwd)/.artifacts":/tmp/artifacts \ 114 | -v "$(pwd)/data":/tf/data \ 115 | gcr.io/kubernetes-conformance-testing/sk8e2e \ 116 | stable prow 117 | ``` 118 | 119 | The target `prow` executes the following steps: 120 | 1. Turn up the cluster 121 | 2. Run conformance tests 122 | 3. Download results to the `${ARTIFACTS}` directory provided by Prow 123 | 4. Destroys the cluster 124 | -------------------------------------------------------------------------------- /e2e/cloud_config.yaml: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | 3 | groups: 4 | - k8s-admin 5 | 6 | users: 7 | ${users} 8 | 9 | write_files: 10 | - path: /etc/default/sk8 11 | owner: root:root 12 | permissions: 0644 13 | encoding: gzip 14 | content: !!binary | 15 | ${sk8_env} 16 | 17 | runcmd: 18 | - mkdir -p /opt/bin 19 | - curl -sSL -o /opt/bin/sk8.sh ${sk8_url} 20 | - chmod 0755 /opt/bin/sk8.sh 21 | - /opt/bin/sk8.sh ${node_type} 2>&1 | tee /var/log/sk8.log 22 | -------------------------------------------------------------------------------- /e2e/config.env: -------------------------------------------------------------------------------- 1 | AWS_LOAD_BALANCER=true 2 | -------------------------------------------------------------------------------- /e2e/data.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "local" { 3 | path = "data/terraform.state" 4 | } 5 | } -------------------------------------------------------------------------------- /e2e/etcd.tf: -------------------------------------------------------------------------------- 1 | // 2 | // This file may be replaced when run via Docker. The replacement 3 | // uses the etcd discovery URL response returned from a previous 4 | // apply operation. 5 | // 6 | data "http" "etcd_discovery" { 7 | url = "https://discovery.etcd.io/new?size=${var.ctl_count}" 8 | } 9 | 10 | locals { 11 | etcd_discovery = "${data.http.etcd_discovery.body}" 12 | } 13 | -------------------------------------------------------------------------------- /e2e/hack/keepalive/.gitignore: -------------------------------------------------------------------------------- 1 | /keepalive 2 | /keepalive.linux_amd64 -------------------------------------------------------------------------------- /e2e/hack/keepalive/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: keepalive keepalive.linux_amd64 4 | 5 | keepalive: keepalive.go 6 | CGO_ENABLED=0 \ 7 | go build -a -tags netgo -ldflags '-w' -o "$@" "$<" 8 | 9 | keepalive.linux_amd64: keepalive.go 10 | CGO_ENABLED=0 \ 11 | GOOS=linux \ 12 | GOARCH=amd64 \ 13 | go build -a -tags netgo -ldflags '-w' -o "$@" "$<" 14 | 15 | test: keepalive 16 | ./"$<" \ 17 | -quiet-tolerance 5s \ 18 | -sleep-for 1s \ 19 | -- \ 20 | $$(pwd)/periodic_writes.sh Do some periodic writes 21 | 22 | clean: 23 | rm -f keepalive keepalive.linux_amd64 24 | 25 | .PHONY: test clean 26 | -------------------------------------------------------------------------------- /e2e/hack/keepalive/README.md: -------------------------------------------------------------------------------- 1 | # Keepalive 2 | A small command-line utility that writes one or more characters to stdout in 3 | repeating interval after a child process has not written to stdout for a set 4 | amount of time. 5 | 6 | ## Getting started 7 | The following example illustrates using `keepalive` with the scirpt 8 | `periodic_writes.sh`. The script: 9 | 10 | 1. Writes to stdout 11 | 2. Sleeps for `6` seconds 12 | 3. Writes to stdout 13 | 4. Sleeps for `4` seconds 14 | 5. Writes to stdout 15 | 6. Sleeps for `11` seconds 16 | 7. Writes to stdout 17 | 18 | The `keepalive` program will ensure that there is data being written 19 | to standard out during the script's quiet periods: 20 | 21 | ```shell 22 | ./keepalive \ 23 | -quiet-tolerance 5s \ 24 | -sleep-for 1s \ 25 | -- \ 26 | $(pwd)/periodic_writes.sh Do some periodic writes 27 | Do 28 | . 29 | some 30 | periodic 31 | . 32 | . 33 | . 34 | . 35 | . 36 | . 37 | writes 38 | ``` 39 | -------------------------------------------------------------------------------- /e2e/hack/keepalive/keepalive.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | "os/exec" 7 | "sync" 8 | "syscall" 9 | "time" 10 | ) 11 | 12 | // keepalive is a small command line utility that can be used to start 13 | // a process and pipe its IO to this process. If there is no IO coming 14 | // from the spawned process, and the process isn't dead and hasn't 15 | // written anything to stdout for five minutes, this process 16 | // will write a single "." character to stdout for every 20 seconds the 17 | // spawned process remains quiet. When the spawned process begins writing 18 | // again, the countdown to keepalive is reset. 19 | func main() { 20 | flag.DurationVar( 21 | &quietTolerance, 22 | "quiet-tolerance", 23 | 5*time.Minute, 24 | "The duration the program waits before writing keep-alive characters to stdout") 25 | flag.DurationVar( 26 | &sleepFor, 27 | "sleep-for", 28 | 20*time.Second, 29 | "The duration the program sleeps in between writing keep-alive characters") 30 | flag.StringVar( 31 | &keepAliveString, 32 | "keep-alive-chars", 33 | ".\n", 34 | "The characters that are written to stdout to keep the program alive") 35 | 36 | flag.Parse() 37 | 38 | keepAliveChars = []byte(keepAliveString) 39 | quietToleranceSecs = quietTolerance.Seconds() 40 | 41 | if flag.NArg() == 0 { 42 | flag.Usage() 43 | os.Exit(1) 44 | } 45 | 46 | cmd := &exec.Cmd{ 47 | Path: flag.Arg(0), 48 | Args: flag.Args()[0:], 49 | Stdout: &ioKeepAlive{}, 50 | Stderr: os.Stderr, 51 | } 52 | 53 | go func() { 54 | for { 55 | lastWriteMu.RLock() 56 | secsSinceLastWrite := time.Since(lastWrite).Seconds() 57 | lastWriteMu.RUnlock() 58 | if secsSinceLastWrite >= quietToleranceSecs { 59 | os.Stdout.Write(keepAliveChars) 60 | } 61 | time.Sleep(sleepFor) 62 | } 63 | }() 64 | 65 | if err := cmd.Run(); err != nil { 66 | if exitError, ok := err.(*exec.ExitError); ok { 67 | ws := exitError.Sys().(syscall.WaitStatus) 68 | os.Exit(ws.ExitStatus()) 69 | } 70 | os.Exit(1) 71 | } 72 | } 73 | 74 | var ( 75 | quietTolerance time.Duration 76 | keepAliveString string 77 | sleepFor time.Duration 78 | 79 | quietToleranceSecs float64 80 | keepAliveChars []byte 81 | 82 | lastWrite = time.Now() 83 | lastWriteMu sync.RWMutex 84 | ) 85 | 86 | type ioKeepAlive struct { 87 | } 88 | 89 | func (k *ioKeepAlive) Write(b []byte) (int, error) { 90 | lastWriteMu.Lock() 91 | lastWrite = time.Now() 92 | lastWriteMu.Unlock() 93 | return os.Stdout.Write(b) 94 | } 95 | -------------------------------------------------------------------------------- /e2e/hack/keepalive/periodic_writes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "${1:-no 1st arg}" 4 | sleep 6 5 | echo "${2:-no 2nd arg}" 6 | sleep 4 7 | echo "${3:-no 3rd arg}" 8 | sleep 11 9 | echo "${4:-no 4th arg}" 10 | -------------------------------------------------------------------------------- /e2e/hack/turn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o pipefail 4 | 5 | hackd=$(python -c "import os; print(os.path.realpath('$(dirname "${0}")'))") 6 | xdir="${hackd}/.." 7 | 8 | # Make sure the docker image is up to date. 9 | #make -C "${xdir}" image 10 | 11 | # Build the docker run command line. 12 | drun="docker run -it --rm -v '${xdir}/data':/tf/data" 13 | 14 | # Create a directory in which to store the test artifacts. 15 | [ -d "${ARTIFACTS}" ] || ARTIFACTS="$(mktemp -p "$(pwd)" -d)" 16 | drun="${drun} -v '${ARTIFACTS}':/tmp/artifacts" 17 | drun="${drun} -e ARTIFACTS=/tmp/artifacts" 18 | 19 | # Map the terraform plug-ins directory into the Docker image so any 20 | # plug-ins Terraform needs are persisted beyond the lifetime of the 21 | # container and saves time when launching new containers. 22 | drun="${drun} -v '${xdir}/.terraform/plugins':/tf/.terraform/plugins" 23 | 24 | # If GIST and SK8 are both set to valid file paths then 25 | # mount GIST to /root/.gist and SK8 to /tmp/sk8.sh 26 | # so the local sk8 source may be uploaded to a gist and made 27 | # available to Terraform's http provider. 28 | [ -f "${HOME}/.gist" ] && \ 29 | drun="${drun} -v '${HOME}/.gist':/root/.gist:ro" 30 | [ -f "${xdir}/../sk8.sh" ] && \ 31 | drun="${drun} -v '${xdir}/../sk8.sh':/tmp/sk8.sh:ro" 32 | 33 | # Find all the exported Terraform vars that are not usernames or passwords. 34 | for e in $(env | grep 'TF_VAR_'); do 35 | echo "${e}" | grep -iq '_\(\(user\(name\)\{0,1\}\)\|password\)=' || \ 36 | drun="${drun} -e ${e}" 37 | done 38 | 39 | # Add the environment files if they exist. 40 | [ -f "${xdir}/config.env" ] && drun="${drun} --env-file '${xdir}/config.env'" 41 | [ -f "${xdir}/secure.env" ] && drun="${drun} --env-file '${xdir}/secure.env'" 42 | 43 | # Check the first argument to see if it's a size. The sizes are: 44 | # 45 | # sm A single node cluster 46 | # md A cluster with one control-plane node and one worker node 47 | # lg A cluster with two control-plane nodes that can also schedule 48 | # workloads and three worker nodes 49 | case "${1}" in 50 | sm) 51 | TF_VAR_ctl_count=1 52 | TF_VAR_bth_count=1 53 | TF_VAR_wrk_count=0 54 | shift 55 | ;; 56 | md) 57 | TF_VAR_ctl_count=1 58 | TF_VAR_bth_count=1 59 | TF_VAR_wrk_count=1 60 | shift 61 | ;; 62 | lg) 63 | TF_VAR_ctl_count=2 64 | TF_VAR_bth_count=2 65 | TF_VAR_wrk_count=3 66 | shift 67 | ;; 68 | *) 69 | # Use the existing values for the size, if set. Otherwise the size 70 | # defaults to "sm". 71 | TF_VAR_ctl_count=${TF_VAR_ctl_count:-1} 72 | TF_VAR_bth_count=${TF_VAR_bth_count:-1} 73 | TF_VAR_wrk_count=${TF_VAR_wrk_count:-0} 74 | ;; 75 | esac 76 | 77 | # Run docker. 78 | drun="${drun} \ 79 | -e DEBUG='${DEBUG}' \ 80 | -e E2E_FOCUS='${E2E_FOCUS-}' \ 81 | -e E2E_SKIP='${E2E_SKIP-}' \ 82 | -e KUBE_CONFORMANCE_IMAGE='${KUBE_CONFORMANCE_IMAGE-}' \ 83 | -e TF_VAR_k8s_version='${TF_VAR_k8s_version:-${K8S_VERSION-}}' \ 84 | -e TF_VAR_ctl_count=${TF_VAR_ctl_count} \ 85 | -e TF_VAR_bth_count=${TF_VAR_bth_count} \ 86 | -e TF_VAR_wrk_count=${TF_VAR_wrk_count} \ 87 | gcr.io/kubernetes-conformance-testing/sk8e2e" 88 | 89 | printf "%s " "${drun}" && echo "${@}" && echo 90 | 91 | # Run docker. 92 | eval "${drun}" "${@}" 93 | -------------------------------------------------------------------------------- /e2e/load_balancer.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | external_fqdn = "" 3 | } -------------------------------------------------------------------------------- /e2e/output.tf: -------------------------------------------------------------------------------- 1 | output "controllers" { 2 | value = "${vsphere_virtual_machine.controller.*.default_ip_address}" 3 | } 4 | 5 | output "controllers-with-kubelets" { 6 | value = "${var.bth_count}" 7 | } 8 | 9 | output "workers" { 10 | value = "${vsphere_virtual_machine.worker.*.default_ip_address}" 11 | } 12 | 13 | output "etcd" { 14 | value = "${local.etcd_discovery}" 15 | } 16 | 17 | output "external_fqdn" { 18 | value = "${local.external_fqdn}" 19 | } -------------------------------------------------------------------------------- /e2e/providers.tf: -------------------------------------------------------------------------------- 1 | provider "http" { 2 | version = "1.0" 3 | } 4 | 5 | provider "template" { 6 | version = "1.0" 7 | } 8 | 9 | provider vsphere { 10 | version = "1.8" 11 | 12 | user = "${var.vsphere_user}" 13 | password = "${var.vsphere_password}" 14 | vsphere_server = "${var.vsphere_server}" 15 | allow_unverified_ssl = "${var.vsphere_allow_unverified_ssl}" 16 | } -------------------------------------------------------------------------------- /e2e/tls_ca.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | tls_ca_crt = "${base64decode(var.tls_ca_crt)}" 3 | tls_ca_key = "${base64decode(var.tls_ca_key)}" 4 | } -------------------------------------------------------------------------------- /e2e/vmc/k8s_admin.tf: -------------------------------------------------------------------------------- 1 | resource "tls_private_key" "k8s_admin" { 2 | algorithm = "RSA" 3 | rsa_bits = "${var.tls_bits}" 4 | } 5 | 6 | resource "tls_cert_request" "k8s_admin" { 7 | key_algorithm = "RSA" 8 | private_key_pem = "${tls_private_key.k8s_admin.private_key_pem}" 9 | 10 | subject { 11 | common_name = "admin" 12 | organization = "system:masters" 13 | organizational_unit = "${var.tls_ou}" 14 | country = "${var.tls_country}" 15 | province = "${var.tls_province}" 16 | locality = "${var.tls_locality}" 17 | } 18 | } 19 | 20 | resource "tls_locally_signed_cert" "k8s_admin" { 21 | cert_request_pem = "${tls_cert_request.k8s_admin.cert_request_pem}" 22 | ca_key_algorithm = "RSA" 23 | ca_private_key_pem = "${local.tls_ca_key}" 24 | ca_cert_pem = "${local.tls_ca_crt}" 25 | validity_period_hours = "${var.tls_days * 24}" 26 | 27 | allowed_uses = [ 28 | "key_encipherment", 29 | "digital_signature", 30 | "server_auth", 31 | "client_auth", 32 | ] 33 | } 34 | 35 | data "template_file" "k8s_admin_kubeconfig" { 36 | template = < ssl.conf < "${PEM_FILE}" 112 | cat crt.pem >> "${PEM_FILE}" 113 | fi 114 | 115 | # Copy the key and crt files to TLS_CA_KEY and TLS_CA_CRT. 116 | if [ -n "${TLS_CA_KEY}" ]; then 117 | KEY_FILE=$(abs_path "${TLS_CA_KEY}") 118 | mkdir -p "$(dirname "${KEY_FILE}")" 119 | cp -f key.pem "${KEY_FILE}" 120 | fi 121 | if [ -n "${TLS_CA_CRT}" ]; then 122 | CRT_FILE=$(abs_path "${TLS_CA_CRT}") 123 | mkdir -p "$(dirname "${CRT_FILE}")" 124 | cp -f crt.pem "${CRT_FILE}" 125 | fi 126 | 127 | # Print the certificate's information if requested. 128 | if [ "${TLS_PLAIN_TEXT}" = "true" ]; then 129 | echo && openssl x509 -in crt.pem -noout -text 130 | fi 131 | 132 | exit 0 133 | -------------------------------------------------------------------------------- /hack/new-kubeconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # USAGE: new-kubeconfig.sh 20 | # This script generates a kubeconfig. 21 | # 22 | # CONFIGURATION 23 | # This script is configured via the following environment 24 | # variables: 25 | # 26 | 27 | require() { 28 | val=$(eval "echo \${${1}}") 29 | [ -z "${val}" ] && echo "${1} required" 1>&2 && exit 1 30 | } 31 | 32 | require KUBECONFIG 33 | require SERVER 34 | require TLS_CA_CRT 35 | require TLS_CRT 36 | require TLS_KEY 37 | require USER 38 | 39 | CLUSTER="${CLUSTER:-kubernetes}" 40 | CONTEXT="${CONTEXT:-default}" 41 | 42 | cat <"${KUBECONFIG}" 43 | apiVersion: v1 44 | clusters: 45 | - cluster: 46 | certificate-authority-data: $({ base64 -w0 || base64; } <"${TLS_CA_CRT}") 47 | server: ${SERVER} 48 | name: ${CLUSTER} 49 | contexts: 50 | - context: 51 | cluster: ${CLUSTER} 52 | user: ${USER} 53 | name: ${CONTEXT} 54 | current-context: ${CONTEXT} 55 | kind: Config 56 | preferences: {} 57 | users: 58 | - name: ${USER} 59 | user: 60 | client-certificate-data: $({ base64 -w0 || base64; } <"${TLS_CRT}") 61 | client-key-data: $({ base64 -w0 || base64; } <"${TLS_KEY}") 62 | EOF 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /ova/.gitignore: -------------------------------------------------------------------------------- 1 | /*.ova 2 | /*.nvram 3 | /*.vmdk 4 | /govc-linux-amd64 5 | /sk8-*.ovf -------------------------------------------------------------------------------- /ova/Makefile: -------------------------------------------------------------------------------- 1 | # simple-kubernetes-test-environment 2 | # 3 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # This product is licensed to you under the Apache 2.0 license (the "License"). 6 | # You may not use this product except in compliance with the Apache 2.0 License. 7 | # 8 | # This product may include a number of subcomponents with separate copyright 9 | # notices and license terms. Your use of these subcomponents is subject to the 10 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 11 | # file. 12 | 13 | all: build 14 | 15 | LINUX_DISTRO ?= photon 16 | OVF_EXPORT_DIR ?= $(HOME)/Downloads 17 | 18 | govc: govc-linux-amd64 19 | govc-linux-amd64: 20 | go get github.com/vmware/govmomi/govc 21 | GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ 22 | go build -a -tags netgo -ldflags "-w" \ 23 | -o $@ github.com/vmware/govmomi/govc 24 | 25 | turn-up-$(LINUX_DISTRO): prep-$(LINUX_DISTRO) 26 | prep-$(LINUX_DISTRO): govc-linux-amd64 27 | LINUX_DISTRO=$(LINUX_DISTRO) hack/prep.sh 28 | 29 | seal-$(LINUX_DISTRO): govc-linux-amd64 30 | LINUX_DISTRO=$(LINUX_DISTRO) hack/prep.sh seal 31 | 32 | turn-down-$(LINUX_DISTRO): 33 | LINUX_DISTRO=$(LINUX_DISTRO) hack/turn-down.sh 34 | 35 | prep turn-up: prep-$(LINUX_DISTRO) 36 | seal: seal-$(LINUX_DISTRO) 37 | turn-up: prep-$(LINUX_DISTRO) 38 | turn-down: turn-down-$(LINUX_DISTRO) 39 | 40 | %-1.vmdk: $(OVF_EXPORT_DIR)/%-1.vmdk 41 | cp -f $? $@ 42 | 43 | sk8-%.ovf: ovf/%.ovf ovf/product-section.ovf 44 | @rm -f $@ 45 | cat $^ >>$@ 46 | printf '\n \n' >> $@ 47 | 48 | sk8-%.ova: sk8-%.ovf sk8-%-1.vmdk 49 | @rm -f $@ 50 | tar -cf $@ $^ 51 | 52 | ova: build 53 | build: sk8-$(LINUX_DISTRO).ova 54 | 55 | upload: upload-$(LINUX_DISTRO) 56 | 57 | upload-%: sk8-%.ova 58 | aws s3 cp $< s3://cnx.vmware/cicd/$< \ 59 | --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers && \ 60 | echo https://s3-us-west-2.amazonaws.com/cnx.vmware/cicd/$< 61 | 62 | .PHONY: prep seal turn-up turn-down upload 63 | 64 | .PRECIOUS: %-1.vmdk sk8-%.ovf 65 | -------------------------------------------------------------------------------- /ova/README.md: -------------------------------------------------------------------------------- 1 | # The sk8 OVA 2 | Sk8 can be deployed many ways, but perhaps the simplest is onto a 3 | vSphere platform using an OVA. This directory contains the bits 4 | necessary to build the sk8 OVA. 5 | 6 | ## Supported Linux Distributions 7 | The sk8 OVA comes in a variety of flavors: 8 | * PhotonOS 2 ([OVA](https://s3-us-west-2.amazonaws.com/cnx.vmware/cicd/sk8-photon.ova)) 9 | * CentOS 7 ([OVA](https://s3-us-west-2.amazonaws.com/cnx.vmware/cicd/sk8-centos.ova)) 10 | 11 | ## Building the OVA 12 | The OVA is built using a staging VM that lives on a vSphere platform. 13 | The `hack/prep.sh` script uses the [`govc`](https://github.com/vmware/govmomi/tree/master/govc) 14 | command to interact with the staging VM. Therefore building the OVA has 15 | the following prerequisites: 16 | 17 | 1. Access to a vSphere platform 18 | 2. A staging VM based on PhotonOS 2 or CentOS 7 19 | 3. The [`govc`](https://github.com/vmware/govmomi/tree/master/govc) command. 20 | 21 | ## Preparing the staging VM 22 | A staging VM is nothing more than a VM deployed with CentOS7 Minimal Server 23 | edition or PhotonOS 2. The VM should have the following, minmal hardware 24 | specs: 25 | 26 | * 1 CPU 27 | * 2GiB RAM 28 | * 16GiB HDD 29 | 30 | Once the VM is deployed, copy a public SSH key to it and snapshot the VM. 31 | 32 | ### Preparing a PhotonOS staging VM 33 | After remote access is enabled, take a snapshot of the VM and write down 34 | the name. 35 | 36 | The PhotonOS VM is ready to be sealed or debugged. 37 | 38 | ### Preparing a CentOS staging VM 39 | Once the CentOS VM is accessible remotely, execute the contents 40 | of the file `hack/centos/centos-prep.sh` on the VM. Shut down the guest 41 | when the prep script has completed and take a snapshot of the VM and 42 | remember the name. 43 | 44 | The CentOS staging VM is now ready to be sealed or debugged. 45 | 46 | ## Modifying the prep script 47 | The file `hack/prep.sh` contains environment variables that define 48 | the inventory path of the staging VM as well as the name of the snapshot 49 | taken in the previous section. Please modify the script where necessary. 50 | 51 | ## Sealing the staging VM 52 | The following command can be used to prep the staging VM and seal it in 53 | preparation to be exported as an OVA: 54 | 55 | ```shell 56 | $ make seal 57 | ``` 58 | 59 | ## Debugging the staging VM 60 | The following command performs all of the same tasks involved in sealing 61 | the staging VM right up to the sealing part. Therefore the prep command 62 | is ideal when it comes to debugging the OVA: 63 | 64 | ```shell 65 | $ make prep 66 | ``` 67 | 68 | ## Building the OVA 69 | The first step to building the OVA is sealing the staging VM and then 70 | exporting it to an OVF. Export the OVF as `sk8-centos` or `sk8-photon` 71 | and then use the following command to build the OVA: 72 | 73 | ```shell 74 | $ make build 75 | ``` 76 | 77 | If the command fails it may be necessary to run it with the following 78 | environment variables: 79 | 80 | ```shell 81 | $ SK8_CENTOS_VMDK=PATH_TO_OVF_VMDK \ 82 | SK8_CENTOS_NVRAM=PATH_TO_OVF_NVRAM \ 83 | make build 84 | ``` 85 | -------------------------------------------------------------------------------- /ova/cli/sk8-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # posix compliant 4 | # verified by https://www.shellcheck.net 5 | 6 | # 7 | # A command-line interface (CLI) client for Kubernetes clusters turned 8 | # up with the sk8 OVA. 9 | # 10 | 11 | set -e 12 | set -o pipefail 13 | 14 | # echo2 echoes the provided arguments to stderr. 15 | echo2() { echo "${@}" 1>&2; }; export echo2 16 | 17 | # printf2 prints the provided format and arguments to stderr. 18 | # shellcheck disable=SC2059 19 | printf2() { _f="${1}"; shift; printf "${_f}" "${@}" 1>&2; }; export printf2 20 | -------------------------------------------------------------------------------- /ova/hack/centos/centos-prep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # The below commands are what are used to prep a vanilla CentOS 7 minimal 16 | # installation in preparation to be processed by the sk8 prep 17 | # scripts. 18 | yum install -y libicu && \ 19 | yum install -y open-vm-tools && \ 20 | yum update -y && \ 21 | yum autoremove -y postfix firewalld && \ 22 | yum install -y yum-utils yum-cron \ 23 | iptables-services \ 24 | ipvsadm unzip && \ 25 | { cat >/etc/sysconfig/iptables </etc/machine-id && \ 23 | rm -fr /var/lib/cloud/instances && \ 24 | rm -f /var/log/*-???????? /var/log/*.gz && \ 25 | rm -f /var/log/dmesg.old && \ 26 | rm -rf /var/log/anaconda && \ 27 | cat /dev/null > /var/log/audit/audit.log && \ 28 | cat /dev/null > /var/log/wtmp && \ 29 | cat /dev/null > /var/log/lastlog && \ 30 | cat /dev/null > /var/log/grubby && \ 31 | rm -f /etc/udev/rules.d/70* && \ 32 | sed -i '/^(HWADDR|UUID)=/d' /etc/sysconfig/network-scripts/ifcfg-e* && \ 33 | rm -rf /tmp/* && \ 34 | rm -rf /var/tmp/* && \ 35 | rm -rf /etc/ssh/*key* /root/.ssh && \ 36 | rm -f /root/anaconda-ks.cfg && \ 37 | rm -rf /var/log && mkdir -p /var/log && \ 38 | echo 'clearing history & sealing the VM...' && \ 39 | unset HISTFILE && history -c && rm -fr /root/.bash_history && \ 40 | sys-unconfig 41 | -------------------------------------------------------------------------------- /ova/hack/get-k8s-artifacts-url.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # 16 | # usage: get-k8s-artifacts-url.sh K8S_VERSION 17 | # 18 | # K8S_VERSION may be set to: 19 | # 20 | # * release/(latest|stable|) 21 | # A pattern that matches one of the builds staged in the public 22 | # GCS bucket kubernetes-release 23 | # 24 | # * ci/(latest|) 25 | # A pattern that matches one of the builds staged in the public 26 | # GCS bucket kubernetes-release-dev 27 | # 28 | # * https{0,1}:// 29 | # An URL that points to a remote location that follows the rules 30 | # for staging K8s builds. This option enables sk8 to use a custom 31 | # build staged with "kubetest". 32 | # 33 | # Whether a URL is discerned from K8S_VERSION or it is set to a URL, the 34 | # URL is used to build the paths to the following K8s artifacts: 35 | # 36 | # 1. https://URL/kubernetes.tar.gz 37 | # 2. https://URL/kubernetes-client-OS-ARCH.tar.gz 38 | # 3. https://URL/kubernetes-node-OS-ARCH.tar.gz 39 | # 3. https://URL/kubernetes-server-OS-ARCH.tar.gz 40 | # 4. https://URL/kubernetes-test-OS-ARCH.tar.gz 41 | # 42 | # To see a full list of supported versions use the Google Storage 43 | # utility, gsutil, and execute "gsutil ls gs://kubernetes-release/release" 44 | 45 | # Executes a HEAD request against a URL and verfieis the request returns 46 | # the provided HTTP status and optional response message. 47 | http_stat() { 48 | ${CURL} -sSLI "${3}" | grep -q \ 49 | '^HTTP/[1-2]\(\.[0-9]\)\{0,1\} '"${1}"'[[:space:]]\{0,\}\('"${2}"'\)\{0,1\}[[:space:]]\{0,\}$' 50 | } 51 | http_200() { http_stat 200 "OK" "${1}"; } 52 | http_204() { http_stat 204 "No Content" "${1}"; } 53 | 54 | # Parses K8S_VERSION and returns the URL used to access the Kubernetes 55 | # artifacts for the provided version string. 56 | get_k8s_artifacts_url() { 57 | { [ -z "${1}" ] && return 1; } || ver="${1}" 58 | 59 | # If the version begins with https?:// then the version *is* the 60 | # artifact prefix. 61 | echo "${ver}" | grep -iq '^https\{0,1\}://' && echo "${ver}" && return 0 62 | 63 | # Determine if the version points to a release or a CI build. 64 | url=https://storage.googleapis.com/kubernetes-release 65 | 66 | # If the version does *not* begin with release/ then it's a dev version. 67 | echo "${ver}" | grep -q '^release/' || url=${url}-dev 68 | 69 | # If the version is ci/latest, release/latest, or release/stable then 70 | # append .txt to the version string so the next if block gets triggered. 71 | echo "${ver}" | \ 72 | grep -q '^\(ci/latest\)\|\(\(release/\(latest\|stable\)\)\(-[[:digit:]]\{1,\}\(\.[[:digit:]]\{1,\}\)\{0,1\}\)\{0,1\}\)$' && \ 73 | ver="${ver}.txt" 74 | 75 | # If the version points to a .txt file then its *that* file that contains 76 | # the actual version information. 77 | if echo "${ver}" | grep -q '\.txt$'; then 78 | ver_real="$(curl -sSL "${url}/${ver}")" 79 | ver_prefix=$(echo "${ver}" | awk -F/ '{print $1}') 80 | ver="${ver_prefix}/${ver_real}" 81 | fi 82 | 83 | # Return the artifact URL. 84 | echo "${url}/${ver}" && return 0 85 | } 86 | 87 | get_k8s_artifacts_url "${@}" 88 | -------------------------------------------------------------------------------- /ova/hack/photon/photon-prep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # The below commands are what are used to prep a vanilla PhotonOS2 16 | # installation in preparation to be processed by the sk8 prep 17 | # scripts. 18 | tdnf upgrade -y && \ 19 | tdnf install -y gawk \ 20 | ipvsadm \ 21 | unzip \ 22 | lsof \ 23 | bindutils \ 24 | iputils \ 25 | tar \ 26 | inotify-tools && \ 27 | { cat >/etc/sysconfig/iptables </etc/machine-id && \ 17 | rm -fr /var/lib/cloud/instances && \ 18 | rm -rf /etc/ssh/*key* /root/.ssh && \ 19 | rm -fr /var/log && mkdir -p /var/log && \ 20 | echo 'clearing history & sealing the VM...' && \ 21 | unset HISTFILE && history -c && rm -fr /root/.bash_history -------------------------------------------------------------------------------- /ova/kube-update/README.md: -------------------------------------------------------------------------------- 1 | # kube-update 2 | When deployed on vSphere as an OVA, sk8 supports the `kube-update` service -- 3 | updating Kubernetes components on a live cluster with incremental builds from a 4 | developer's desktop. 5 | 6 | ## Uploading a new version of a program 7 | To upload a new version of one or more programs, simply SCP the files to the 8 | `/kube-update` directory on any of the cluster's nodes. A member of the cluster 9 | will redistribute the files until all members receive updated copies. 10 | -------------------------------------------------------------------------------- /ova/kube-update/kube-update.service: -------------------------------------------------------------------------------- 1 | # simple-kubernetes-test-environment 2 | # 3 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # This product is licensed to you under the Apache 2.0 license (the "License"). 6 | # You may not use this product except in compliance with the Apache 2.0 License. 7 | # 8 | # This product may include a number of subcomponents with separate copyright 9 | # notices and license terms. Your use of these subcomponents is subject to the 10 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 11 | # file. 12 | 13 | [Unit] 14 | Description=kube-update.service 15 | 16 | After= network.target network-online.target \ 17 | syslog.target rc-local.service \ 18 | cloud-final.service \ 19 | kube-apiserver.service \ 20 | kube-controller-manager.service \ 21 | kube-proxy.service \ 22 | kube-scheduler.service \ 23 | kubelet.service 24 | 25 | [Install] 26 | WantedBy=multi-user.target 27 | 28 | [Service] 29 | Type=simple 30 | TimeoutSec=0 31 | WorkingDirectory=/var/lib/sk8 32 | 33 | # Create the sk8 log directory. 34 | ExecStartPre=/bin/mkdir -p /var/log/sk8 35 | 36 | # This script monitors /kube-update for uploaded files and replaces K8s 37 | # components with updated copies. 38 | ExecStart=/bin/sh -c '/var/lib/sk8/kube-update.sh 2>&1 | tee /var/log/sk8/kube-update.log' 39 | -------------------------------------------------------------------------------- /ova/rpctool/.gitignore: -------------------------------------------------------------------------------- 1 | /dep 2 | /rpctool -------------------------------------------------------------------------------- /ova/rpctool/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:540e177abbebed1ffc5071ae9b8a9f31b1f137fc1eabbe161cf28c78fe50aa86" 6 | name = "github.com/vmware/govmomi" 7 | packages = [ 8 | "ovf", 9 | "vim25", 10 | "vim25/debug", 11 | "vim25/methods", 12 | "vim25/mo", 13 | "vim25/progress", 14 | "vim25/soap", 15 | "vim25/types", 16 | "vim25/xml", 17 | ] 18 | pruneopts = "NUT" 19 | revision = "3617f28d167d448f93f282a867870f109516d2a5" 20 | version = "v0.19.0" 21 | 22 | [[projects]] 23 | branch = "master" 24 | digest = "1:3f8f243b8b4ebd09c52535a2ed7c96953bad2702c4c4b3356d9ccf1a81c0a944" 25 | name = "github.com/vmware/vmw-guestinfo" 26 | packages = [ 27 | "bdoor", 28 | "message", 29 | "rpcout", 30 | "rpcvmx", 31 | "vmcheck", 32 | ] 33 | pruneopts = "NUT" 34 | revision = "25eff159a728be87e103a0b8045e08273f4dbec4" 35 | 36 | [solve-meta] 37 | analyzer-name = "dep" 38 | analyzer-version = 1 39 | input-imports = [ 40 | "github.com/vmware/govmomi/ovf", 41 | "github.com/vmware/vmw-guestinfo/rpcvmx", 42 | "github.com/vmware/vmw-guestinfo/vmcheck", 43 | ] 44 | solver-name = "gps-cdcl" 45 | solver-version = 1 46 | -------------------------------------------------------------------------------- /ova/rpctool/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 2 | # for detailed Gopkg.toml documentation. 3 | # 4 | # Refer to https://github.com/toml-lang/toml for detailed TOML docs. 5 | # 6 | [prune] 7 | non-go = true 8 | go-tests = true 9 | unused-packages = true 10 | 11 | [[constraint]] 12 | name = "github.com/vmware/govmomi" 13 | version = "0.19.0" 14 | 15 | [[constraint]] 16 | branch = "master" 17 | name = "github.com/vmware/vmw-guestinfo" 18 | -------------------------------------------------------------------------------- /ova/rpctool/Makefile: -------------------------------------------------------------------------------- 1 | # simple-kubernetes-test-environment 2 | # 3 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # This product is licensed to you under the Apache 2.0 license (the "License"). 6 | # You may not use this product except in compliance with the Apache 2.0 License. 7 | # 8 | # This product may include a number of subcomponents with separate copyright 9 | # notices and license terms. Your use of these subcomponents is subject to the 10 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 11 | # file. 12 | 13 | all: build 14 | 15 | vendor: | dep 16 | ./dep ensure -v 17 | 18 | Gopkg.lock: main.go Gopkg.toml | dep 19 | ./dep ensure -v 20 | 21 | Gopkg.toml: | dep 22 | ./dep init -v 23 | 24 | rpctool: main.go Gopkg.lock | vendor 25 | CGO_ENABLED=0 go build -a -tags netgo -ldflags "-w" -o "$@" 26 | 27 | build: rpctool 28 | 29 | clean: 30 | rm -fr dep rpctool 31 | 32 | .PHONY: clean 33 | -------------------------------------------------------------------------------- /ova/rpctool/README.md: -------------------------------------------------------------------------------- 1 | # rpctool 2 | The program `rpctool` allows users on VMs running on vSphere to manipulate the 3 | VM's GuestInfo and OVF environment data. 4 | 5 | ```shell 6 | root@photon-machine [ ~ ]# /var/lib/sk8/rpctool 7 | COMMAND is required 8 | usage: /var/lib/sk8/rpctool [FLAGS] COMMAND [ARGS] 9 | COMMANDS 10 | get KEY 11 | Gets the value for the specified guestinfo key 12 | 13 | set KEY VAL 14 | Sets the value for the specified guestinfo key. If VAL is "-" then 15 | the program's standard input stream is used as the value. 16 | 17 | get.ovf [KEY] 18 | Gets the OVF environment. If a KEY is specified then the value of the 19 | OVF envionment property with the matching key will be returned. 20 | 21 | set.ovf [KEY] [VAL] 22 | Sets the OVF environment. If VAL is "-" then the program's standard 23 | input stream is used as the value. 24 | 25 | If a single argument is provided then KEY is treated as VAL and 26 | the program treats the argument as the entire OVF environment payload. 27 | When two arguments are provided then the OVF environment property 28 | with the matching key is updated with the provided value. 29 | 30 | FLAGS 31 | -ovf.format string 32 | The format of the OVF environment payload when returned by "get.ovf" or set via "set.ovf". The format string may be set to "xml" or "json". (default "json") 33 | ``` 34 | 35 | ## Get a GuestInfo property 36 | ```shell 37 | root@photon-machine [ ~ ]# /var/lib/sk8/rpctool get sk8.k8s.version 38 | release/v1.11.2 39 | ``` 40 | 41 | ## Set a GuestInfo property 42 | ```shell 43 | root@photon-machine [ ~ ]# /var/lib/sk8/rpctool set sk8.url https://raw.githubusercontent.com/akutz/sk8/master/sk8.sh 44 | 45 | root@photon-machine [ ~ ]# /var/lib/sk8/rpctool get sk8.url 46 | https://raw.githubusercontent.com/akutz/sk8/master/sk8.sh 47 | ``` 48 | 49 | ## Set a GuestInfo property to the contents of `STDIN` 50 | ```shell 51 | root@photon-machine [ ~ ]# /var/lib/sk8/rpctool set sk8.service - 132 | 133 | VMware ESXi 134 | 6.8.1 135 | VMware, Inc. 136 | en 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | ``` 150 | -------------------------------------------------------------------------------- /ova/rpctool/hack/make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | script_dir=$(python -c "import os; print(os.path.realpath('$(dirname "${0}")'))") 16 | parent_dir="${script_dir}/.." 17 | 18 | # Download dep 19 | if [ ! -f 'dep' ]; then 20 | docker run -it \ 21 | --rm \ 22 | -v "${parent_dir}":/go/src/rpctool \ 23 | golang:1.11.1 \ 24 | /bin/sh -c 'cd /go/src/rpctool && { [ -f dep ] || curl -Lo dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && chmod 0755 dep; }' 25 | fi 26 | 27 | # Build rpctool 28 | docker run -it \ 29 | --rm \ 30 | -v "${parent_dir}":/go/src/rpctool \ 31 | golang:1.11.1 \ 32 | make -C /go/src/rpctool 33 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # People who can (and typically have) contributed to this repository. 2 | # 3 | # This script is generated by contributors.sh 4 | # 5 | 6 | Abhijeet Kasurde 7 | abrarshivani 8 | Adam Shannon 9 | akutz 10 | Alessandro Cortiana 11 | Alex Bozhenko 12 | Alvaro Miranda 13 | amandahla 14 | Amanda H. L. de Andrade 15 | Amit Bathla 16 | amit bezalel 17 | Andrew Chin 18 | Anfernee Yongkun Gui 19 | aniketGslab 20 | Arran Walker 21 | Aryeh Weinreb 22 | Austin Parker 23 | Balu Dontu 24 | bastienbc 25 | Bob Killen 26 | Brad Fitzpatrick 27 | Bruce Downs 28 | Cédric Blomart 29 | Chris Marchesi 30 | Christian Höltje 31 | Clint Greenwood 32 | CuiHaozhi 33 | Danny Lockard 34 | Dave Tucker 35 | Davide Agnello 36 | David Stark 37 | Deric Crago 38 | Doug MacEachern 39 | Eloy Coto 40 | Eric Gray 41 | Eric Yutao 42 | Erik Hollensbe 43 | Fabio Rapposelli 44 | Faiyaz Ahmed 45 | forkbomber 46 | freebsdly 47 | Gavin Gray 48 | Gavrie Philipson 49 | George Hicken 50 | Gerrit Renker 51 | gthombare 52 | Hasan Mahmood 53 | Henrik Hodne 54 | Isaac Rodman 55 | Ivan Porto Carrero 56 | Jason Kincl 57 | Jeremy Canady 58 | jeremy-clerc 59 | Jiatong Wang 60 | João Pereira 61 | Jorge Sevilla 62 | kayrus 63 | Kevin George 64 | leslie-qiwa 65 | Louie Jiang 66 | Marc Carmier 67 | Maria Ntalla 68 | Marin Atanasov Nikolov 69 | Matthew Cosgrove 70 | Matt Moriarity 71 | Mevan Samaratunga 72 | Michal Jankowski 73 | mingwei 74 | Nicolas Lamirault 75 | Omar Kohl 76 | Parham Alvani 77 | Pieter Noordhuis 78 | prydin 79 | Rowan Jacobs 80 | runner.mei 81 | S.Çağlar Onur 82 | Sergey Ignatov 83 | Steve Purcell 84 | Takaaki Furukawa 85 | tanishi 86 | Ted Zlatanov 87 | Thibaut Ackermann 88 | Trevor Dawe 89 | Uwe Bessle 90 | Vadim Egorov 91 | Volodymyr Bobyr 92 | Witold Krecicki 93 | Yang Yang 94 | Yuya Kusakabe 95 | Zach Tucker 96 | Zee Yang 97 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/govc/test/license.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | # These tests should only run against a server running an evaluation license. 6 | verify_evaluation() { 7 | if [ "$(govc license.ls -json | jq -r .[0].EditionKey)" != "eval" ]; then 8 | skip "requires evaluation license" 9 | fi 10 | } 11 | 12 | get_key() { 13 | jq ".[] | select(.LicenseKey == \"$1\")" 14 | } 15 | 16 | get_property() { 17 | jq -r ".Properties[] | select(.Key == \"$1\") | .Value" 18 | } 19 | 20 | @test "license.add" { 21 | esx_env 22 | 23 | verify_evaluation 24 | 25 | run govc license.add -json 00000-00000-00000-00000-00001 00000-00000-00000-00000-00002 26 | assert_success 27 | 28 | # Expect to see an entry for both the first and the second key 29 | assert_equal "License is not valid for this product" "$(get_key 00000-00000-00000-00000-00001 <<<${output} | get_property diagnostic)" 30 | assert_equal "License is not valid for this product" "$(get_key 00000-00000-00000-00000-00002 <<<${output} | get_property diagnostic)" 31 | } 32 | 33 | @test "license.remove" { 34 | esx_env 35 | 36 | verify_evaluation 37 | 38 | run govc license.remove -json 00000-00000-00000-00000-00001 39 | assert_success 40 | } 41 | 42 | @test "license.ls" { 43 | vcsim_env 44 | 45 | verify_evaluation 46 | 47 | run govc license.ls -json 48 | assert_success 49 | 50 | # Expect the test instance to run in evaluation mode 51 | assert_equal "Evaluation Mode" "$(get_key 00000-00000-00000-00000-00000 <<<$output | jq -r ".Name")" 52 | } 53 | 54 | @test "license.decode" { 55 | esx_env 56 | 57 | verify_evaluation 58 | 59 | key=00000-00000-00000-00000-00000 60 | assert_equal "eval" $(govc license.decode $key | grep $key | awk '{print $2}') 61 | } 62 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/ovf/cim.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ovf 18 | 19 | /* 20 | Source: http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_VirtualSystemSettingData.xsd 21 | */ 22 | 23 | type CIMVirtualSystemSettingData struct { 24 | ElementName string `xml:"ElementName"` 25 | InstanceID string `xml:"InstanceID"` 26 | 27 | AutomaticRecoveryAction *uint8 `xml:"AutomaticRecoveryAction"` 28 | AutomaticShutdownAction *uint8 `xml:"AutomaticShutdownAction"` 29 | AutomaticStartupAction *uint8 `xml:"AutomaticStartupAction"` 30 | AutomaticStartupActionDelay *string `xml:"AutomaticStartupActionDelay>Interval"` 31 | AutomaticStartupActionSequenceNumber *uint16 `xml:"AutomaticStartupActionSequenceNumber"` 32 | Caption *string `xml:"Caption"` 33 | ConfigurationDataRoot *string `xml:"ConfigurationDataRoot"` 34 | ConfigurationFile *string `xml:"ConfigurationFile"` 35 | ConfigurationID *string `xml:"ConfigurationID"` 36 | CreationTime *string `xml:"CreationTime"` 37 | Description *string `xml:"Description"` 38 | LogDataRoot *string `xml:"LogDataRoot"` 39 | Notes []string `xml:"Notes"` 40 | RecoveryFile *string `xml:"RecoveryFile"` 41 | SnapshotDataRoot *string `xml:"SnapshotDataRoot"` 42 | SuspendDataRoot *string `xml:"SuspendDataRoot"` 43 | SwapFileDataRoot *string `xml:"SwapFileDataRoot"` 44 | VirtualSystemIdentifier *string `xml:"VirtualSystemIdentifier"` 45 | VirtualSystemType *string `xml:"VirtualSystemType"` 46 | } 47 | 48 | /* 49 | Source: http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_ResourceAllocationSettingData.xsd 50 | */ 51 | 52 | type CIMResourceAllocationSettingData struct { 53 | ElementName string `xml:"ElementName"` 54 | InstanceID string `xml:"InstanceID"` 55 | 56 | ResourceType *uint16 `xml:"ResourceType"` 57 | OtherResourceType *string `xml:"OtherResourceType"` 58 | ResourceSubType *string `xml:"ResourceSubType"` 59 | 60 | AddressOnParent *string `xml:"AddressOnParent"` 61 | Address *string `xml:"Address"` 62 | AllocationUnits *string `xml:"AllocationUnits"` 63 | AutomaticAllocation *bool `xml:"AutomaticAllocation"` 64 | AutomaticDeallocation *bool `xml:"AutomaticDeallocation"` 65 | Caption *string `xml:"Caption"` 66 | Connection []string `xml:"Connection"` 67 | ConsumerVisibility *uint16 `xml:"ConsumerVisibility"` 68 | Description *string `xml:"Description"` 69 | HostResource []string `xml:"HostResource"` 70 | Limit *uint64 `xml:"Limit"` 71 | MappingBehavior *uint `xml:"MappingBehavior"` 72 | Parent *string `xml:"Parent"` 73 | PoolID *string `xml:"PoolID"` 74 | Reservation *uint64 `xml:"Reservation"` 75 | VirtualQuantity *uint `xml:"VirtualQuantity"` 76 | VirtualQuantityUnits *string `xml:"VirtualQuantityUnits"` 77 | Weight *uint `xml:"Weight"` 78 | } 79 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/ovf/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package ovf provides functionality to unmarshal and inspect the structure 19 | of an OVF file. It is not a complete implementation of the specification and 20 | is intended to be used to import virtual infrastructure into vSphere. 21 | 22 | For a complete specification of the OVF standard, refer to: 23 | https://www.dmtf.org/sites/default/files/standards/documents/DSP0243_2.1.0.pdf 24 | */ 25 | package ovf 26 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/ovf/env.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ovf 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | 23 | "github.com/vmware/govmomi/vim25/xml" 24 | ) 25 | 26 | const ( 27 | ovfEnvHeader = `` 34 | ovfEnvPlatformSection = ` 35 | %s 36 | %s 37 | %s 38 | %s 39 | ` 40 | ovfEnvPropertyHeader = `` 41 | ovfEnvPropertyEntry = `` 42 | ovfEnvPropertyFooter = `` 43 | ovfEnvFooter = `` 44 | ) 45 | 46 | type Env struct { 47 | XMLName xml.Name `xml:"http://schemas.dmtf.org/ovf/environment/1 Environment"` 48 | ID string `xml:"id,attr"` 49 | EsxID string `xml:"http://www.vmware.com/schema/ovfenv esxId,attr"` 50 | 51 | Platform *PlatformSection `xml:"PlatformSection"` 52 | Property *PropertySection `xml:"PropertySection"` 53 | } 54 | 55 | type PlatformSection struct { 56 | Kind string `xml:"Kind"` 57 | Version string `xml:"Version"` 58 | Vendor string `xml:"Vendor"` 59 | Locale string `xml:"Locale"` 60 | } 61 | 62 | type PropertySection struct { 63 | Properties []EnvProperty `xml:"Property"` 64 | } 65 | 66 | type EnvProperty struct { 67 | Key string `xml:"key,attr"` 68 | Value string `xml:"value,attr"` 69 | } 70 | 71 | // Marshal marshals Env to xml by using xml.Marshal. 72 | func (e Env) Marshal() (string, error) { 73 | x, err := xml.Marshal(e) 74 | if err != nil { 75 | return "", err 76 | } 77 | 78 | return fmt.Sprintf("%s%s", xml.Header, x), nil 79 | } 80 | 81 | // MarshalManual manually marshals Env to xml suitable for a vApp guest. 82 | // It exists to overcome the lack of expressiveness in Go's XML namespaces. 83 | func (e Env) MarshalManual() string { 84 | var buffer bytes.Buffer 85 | 86 | buffer.WriteString(xml.Header) 87 | buffer.WriteString(fmt.Sprintf(ovfEnvHeader, e.EsxID)) 88 | buffer.WriteString(fmt.Sprintf(ovfEnvPlatformSection, e.Platform.Kind, e.Platform.Version, e.Platform.Vendor, e.Platform.Locale)) 89 | 90 | buffer.WriteString(fmt.Sprintf(ovfEnvPropertyHeader)) 91 | for _, p := range e.Property.Properties { 92 | buffer.WriteString(fmt.Sprintf(ovfEnvPropertyEntry, p.Key, p.Value)) 93 | } 94 | buffer.WriteString(fmt.Sprintf(ovfEnvPropertyFooter)) 95 | 96 | buffer.WriteString(fmt.Sprintf(ovfEnvFooter)) 97 | 98 | return buffer.String() 99 | } 100 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/ovf/manager.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2017 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ovf 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/vmware/govmomi/vim25" 23 | "github.com/vmware/govmomi/vim25/methods" 24 | "github.com/vmware/govmomi/vim25/mo" 25 | "github.com/vmware/govmomi/vim25/types" 26 | ) 27 | 28 | type Manager struct { 29 | types.ManagedObjectReference 30 | 31 | c *vim25.Client 32 | } 33 | 34 | func NewManager(c *vim25.Client) *Manager { 35 | return &Manager{*c.ServiceContent.OvfManager, c} 36 | } 37 | 38 | // CreateDescriptor wraps methods.CreateDescriptor 39 | func (m *Manager) CreateDescriptor(ctx context.Context, obj mo.Reference, cdp types.OvfCreateDescriptorParams) (*types.OvfCreateDescriptorResult, error) { 40 | req := types.CreateDescriptor{ 41 | This: m.Reference(), 42 | Obj: obj.Reference(), 43 | Cdp: cdp, 44 | } 45 | 46 | res, err := methods.CreateDescriptor(ctx, m.c, &req) 47 | if err != nil { 48 | return nil, err 49 | } 50 | 51 | return &res.Returnval, nil 52 | } 53 | 54 | // CreateImportSpec wraps methods.CreateImportSpec 55 | func (m *Manager) CreateImportSpec(ctx context.Context, ovfDescriptor string, resourcePool mo.Reference, datastore mo.Reference, cisp types.OvfCreateImportSpecParams) (*types.OvfCreateImportSpecResult, error) { 56 | req := types.CreateImportSpec{ 57 | This: m.Reference(), 58 | OvfDescriptor: ovfDescriptor, 59 | ResourcePool: resourcePool.Reference(), 60 | Datastore: datastore.Reference(), 61 | Cisp: cisp, 62 | } 63 | 64 | res, err := methods.CreateImportSpec(ctx, m.c, &req) 65 | if err != nil { 66 | return nil, err 67 | } 68 | 69 | return &res.Returnval, nil 70 | } 71 | 72 | // ParseDescriptor wraps methods.ParseDescriptor 73 | func (m *Manager) ParseDescriptor(ctx context.Context, ovfDescriptor string, pdp types.OvfParseDescriptorParams) (*types.OvfParseDescriptorResult, error) { 74 | req := types.ParseDescriptor{ 75 | This: m.Reference(), 76 | OvfDescriptor: ovfDescriptor, 77 | Pdp: pdp, 78 | } 79 | 80 | res, err := methods.ParseDescriptor(ctx, m.c, &req) 81 | if err != nil { 82 | return nil, err 83 | } 84 | 85 | return &res.Returnval, nil 86 | } 87 | 88 | // ValidateHost wraps methods.ValidateHost 89 | func (m *Manager) ValidateHost(ctx context.Context, ovfDescriptor string, host mo.Reference, vhp types.OvfValidateHostParams) (*types.OvfValidateHostResult, error) { 90 | req := types.ValidateHost{ 91 | This: m.Reference(), 92 | OvfDescriptor: ovfDescriptor, 93 | Host: host.Reference(), 94 | Vhp: vhp, 95 | } 96 | 97 | res, err := methods.ValidateHost(ctx, m.c, &req) 98 | if err != nil { 99 | return nil, err 100 | } 101 | 102 | return &res.Returnval, nil 103 | } 104 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/ovf/ovf.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ovf 18 | 19 | import ( 20 | "io" 21 | 22 | "github.com/vmware/govmomi/vim25/xml" 23 | ) 24 | 25 | func Unmarshal(r io.Reader) (*Envelope, error) { 26 | var e Envelope 27 | 28 | dec := xml.NewDecoder(r) 29 | err := dec.Decode(&e) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &e, nil 35 | } 36 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/scripts/contributors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | file="$(git rev-parse --show-toplevel)/CONTRIBUTORS" 4 | 5 | cat < "$file" 6 | # People who can (and typically have) contributed to this repository. 7 | # 8 | # This script is generated by $(basename "$0") 9 | # 10 | 11 | EOF 12 | 13 | git log --format='%aN <%aE>' | sort -uf >> "$file" 14 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/scripts/license.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | header_dir=$(dirname $0)/headers 6 | 7 | tmpfile=$(mktemp) 8 | trap "rm -f ${tmpfile}" EXIT 9 | 10 | git ls-files | while read file; do 11 | years=( $(git log --format='%ai' $file | cut -d- -f1 | sort -u) ) 12 | num_years=${#years[@]} 13 | 14 | if [ "${num_years}" == 0 ]; then 15 | export YEARS="$(date +%Y)" 16 | else 17 | yearA=${years[0]} 18 | yearB=${years[$((${num_years}-1))]} 19 | 20 | if [ ${yearA} == ${yearB} ]; then 21 | export YEARS="${yearA}" 22 | else 23 | export YEARS="${yearA}-${yearB}" 24 | fi 25 | fi 26 | 27 | case "$file" in 28 | vim25/xml/*) 29 | # Ignore 30 | ;; 31 | *.go) 32 | sed -e "s/\${YEARS}/${YEARS}/" ${header_dir}/go.txt > ${tmpfile} 33 | last_header_line=$(grep -n '\*/' ${file} | head -1 | cut -d: -f1) 34 | tail -n +$((${last_header_line} + 1)) ${file} >> ${tmpfile} 35 | mv ${tmpfile} ${file} 36 | ;; 37 | *.rb) 38 | sed -e "s/\${YEARS}/${YEARS}/" ${header_dir}/rb.txt > ${tmpfile} 39 | last_header_line=$(grep -n '^$' ${file} | head -1 | cut -d: -f1) 40 | tail -n +$((${last_header_line})) ${file} >> ${tmpfile} 41 | mv ${tmpfile} ${file} 42 | ;; 43 | *) 44 | echo "Unhandled file: $file" 45 | ;; 46 | esac 47 | done 48 | 49 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package vim25 18 | 19 | import ( 20 | "context" 21 | "encoding/json" 22 | "strings" 23 | 24 | "github.com/vmware/govmomi/vim25/methods" 25 | "github.com/vmware/govmomi/vim25/soap" 26 | "github.com/vmware/govmomi/vim25/types" 27 | ) 28 | 29 | const ( 30 | Namespace = "vim25" 31 | Version = "6.7" 32 | Path = "/sdk" 33 | ) 34 | 35 | var ( 36 | ServiceInstance = types.ManagedObjectReference{ 37 | Type: "ServiceInstance", 38 | Value: "ServiceInstance", 39 | } 40 | ) 41 | 42 | // Client is a tiny wrapper around the vim25/soap Client that stores session 43 | // specific state (i.e. state that only needs to be retrieved once after the 44 | // client has been created). This means the client can be reused after 45 | // serialization without performing additional requests for initialization. 46 | type Client struct { 47 | *soap.Client 48 | 49 | ServiceContent types.ServiceContent 50 | 51 | // RoundTripper is a separate field such that the client's implementation of 52 | // the RoundTripper interface can be wrapped by separate implementations for 53 | // extra functionality (for example, reauthentication on session timeout). 54 | RoundTripper soap.RoundTripper 55 | } 56 | 57 | // NewClient creates and returns a new client wirh the ServiceContent field 58 | // filled in. 59 | func NewClient(ctx context.Context, rt soap.RoundTripper) (*Client, error) { 60 | c := Client{ 61 | RoundTripper: rt, 62 | } 63 | 64 | // Set client if it happens to be a soap.Client 65 | if sc, ok := rt.(*soap.Client); ok { 66 | c.Client = sc 67 | 68 | if c.Namespace == "" { 69 | c.Namespace = "urn:" + Namespace 70 | } else if strings.Index(c.Namespace, ":") < 0 { 71 | c.Namespace = "urn:" + c.Namespace // ensure valid URI format 72 | } 73 | if c.Version == "" { 74 | c.Version = Version 75 | } 76 | } 77 | 78 | var err error 79 | c.ServiceContent, err = methods.GetServiceContent(ctx, rt) 80 | if err != nil { 81 | return nil, err 82 | } 83 | 84 | return &c, nil 85 | } 86 | 87 | // RoundTrip dispatches to the RoundTripper field. 88 | func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error { 89 | return c.RoundTripper.RoundTrip(ctx, req, res) 90 | } 91 | 92 | type marshaledClient struct { 93 | SoapClient *soap.Client 94 | ServiceContent types.ServiceContent 95 | } 96 | 97 | func (c *Client) MarshalJSON() ([]byte, error) { 98 | m := marshaledClient{ 99 | SoapClient: c.Client, 100 | ServiceContent: c.ServiceContent, 101 | } 102 | 103 | return json.Marshal(m) 104 | } 105 | 106 | func (c *Client) UnmarshalJSON(b []byte) error { 107 | var m marshaledClient 108 | 109 | err := json.Unmarshal(b, &m) 110 | if err != nil { 111 | return err 112 | } 113 | 114 | *c = Client{ 115 | Client: m.SoapClient, 116 | ServiceContent: m.ServiceContent, 117 | RoundTripper: m.SoapClient, 118 | } 119 | 120 | return nil 121 | } 122 | 123 | // Valid returns whether or not the client is valid and ready for use. 124 | // This should be called after unmarshalling the client. 125 | func (c *Client) Valid() bool { 126 | if c == nil { 127 | return false 128 | } 129 | 130 | if c.Client == nil { 131 | return false 132 | } 133 | 134 | // Use arbitrary pointer field in the service content. 135 | // Doesn't matter which one, as long as it is populated by default. 136 | if c.ServiceContent.SessionManager == nil { 137 | return false 138 | } 139 | 140 | return true 141 | } 142 | 143 | // IsVC returns true if we are connected to a vCenter 144 | func (c *Client) IsVC() bool { 145 | return c.ServiceContent.About.ApiType == "VirtualCenter" 146 | } 147 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package vim25 provides a minimal client implementation to use with other 19 | packages in the vim25 tree. The code in this package intentionally does not 20 | take any dependendies outside the vim25 tree. 21 | 22 | The client implementation in this package embeds the soap.Client structure. 23 | Additionally, it stores the value of the session's ServiceContent object. This 24 | object stores references to a variety of subsystems, such as the root property 25 | collector, the session manager, and the search index. The client is fully 26 | functional after serialization and deserialization, without the need for 27 | additional requests for initialization. 28 | */ 29 | package vim25 30 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/methods/service_content.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package methods 18 | 19 | import ( 20 | "context" 21 | "time" 22 | 23 | "github.com/vmware/govmomi/vim25/soap" 24 | "github.com/vmware/govmomi/vim25/types" 25 | ) 26 | 27 | // copy of vim25.ServiceInstance to avoid import cycle 28 | var serviceInstance = types.ManagedObjectReference{ 29 | Type: "ServiceInstance", 30 | Value: "ServiceInstance", 31 | } 32 | 33 | func GetServiceContent(ctx context.Context, r soap.RoundTripper) (types.ServiceContent, error) { 34 | req := types.RetrieveServiceContent{ 35 | This: serviceInstance, 36 | } 37 | 38 | res, err := RetrieveServiceContent(ctx, r, &req) 39 | if err != nil { 40 | return types.ServiceContent{}, err 41 | } 42 | 43 | return res.Returnval, nil 44 | } 45 | 46 | func GetCurrentTime(ctx context.Context, r soap.RoundTripper) (*time.Time, error) { 47 | req := types.CurrentTime{ 48 | This: serviceInstance, 49 | } 50 | 51 | res, err := CurrentTime(ctx, r, &req) 52 | if err != nil { 53 | return nil, err 54 | } 55 | 56 | return &res.Returnval, nil 57 | } 58 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/ancestors.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | 23 | "github.com/vmware/govmomi/vim25/soap" 24 | "github.com/vmware/govmomi/vim25/types" 25 | ) 26 | 27 | // Ancestors returns the entire ancestry tree of a specified managed object. 28 | // The return value includes the root node and the specified object itself. 29 | func Ancestors(ctx context.Context, rt soap.RoundTripper, pc, obj types.ManagedObjectReference) ([]ManagedEntity, error) { 30 | ospec := types.ObjectSpec{ 31 | Obj: obj, 32 | SelectSet: []types.BaseSelectionSpec{ 33 | &types.TraversalSpec{ 34 | SelectionSpec: types.SelectionSpec{Name: "traverseParent"}, 35 | Type: "ManagedEntity", 36 | Path: "parent", 37 | Skip: types.NewBool(false), 38 | SelectSet: []types.BaseSelectionSpec{ 39 | &types.SelectionSpec{Name: "traverseParent"}, 40 | }, 41 | }, 42 | &types.TraversalSpec{ 43 | SelectionSpec: types.SelectionSpec{}, 44 | Type: "VirtualMachine", 45 | Path: "parentVApp", 46 | Skip: types.NewBool(false), 47 | SelectSet: []types.BaseSelectionSpec{ 48 | &types.SelectionSpec{Name: "traverseParent"}, 49 | }, 50 | }, 51 | }, 52 | Skip: types.NewBool(false), 53 | } 54 | 55 | pspec := []types.PropertySpec{ 56 | { 57 | Type: "ManagedEntity", 58 | PathSet: []string{"name", "parent"}, 59 | }, 60 | { 61 | Type: "VirtualMachine", 62 | PathSet: []string{"parentVApp"}, 63 | }, 64 | } 65 | 66 | req := types.RetrieveProperties{ 67 | This: pc, 68 | SpecSet: []types.PropertyFilterSpec{ 69 | { 70 | ObjectSet: []types.ObjectSpec{ospec}, 71 | PropSet: pspec, 72 | }, 73 | }, 74 | } 75 | 76 | var ifaces []interface{} 77 | err := RetrievePropertiesForRequest(ctx, rt, req, &ifaces) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | var out []ManagedEntity 83 | 84 | // Build ancestry tree by iteratively finding a new child. 85 | for len(out) < len(ifaces) { 86 | var find types.ManagedObjectReference 87 | 88 | if len(out) > 0 { 89 | find = out[len(out)-1].Self 90 | } 91 | 92 | // Find entity we're looking for given the last entity in the current tree. 93 | for _, iface := range ifaces { 94 | me := iface.(IsManagedEntity).GetManagedEntity() 95 | 96 | if me.Name == "" { 97 | // The types below have their own 'Name' field, so ManagedEntity.Name (me.Name) is empty. 98 | // We only hit this case when the 'obj' param is one of these types. 99 | // In most cases, 'obj' is a Folder so Name isn't collected in this call. 100 | switch x := iface.(type) { 101 | case Network: 102 | me.Name = x.Name 103 | case DistributedVirtualSwitch: 104 | me.Name = x.Name 105 | case DistributedVirtualPortgroup: 106 | me.Name = x.Name 107 | case OpaqueNetwork: 108 | me.Name = x.Name 109 | default: 110 | // ManagedEntity always has a Name, if we hit this point we missed a case above. 111 | panic(fmt.Sprintf("%#v Name is empty", me.Reference())) 112 | } 113 | } 114 | 115 | if me.Parent == nil { 116 | // Special case for VirtualMachine within VirtualApp, 117 | // unlikely to hit this other than via Finder.Element() 118 | switch x := iface.(type) { 119 | case VirtualMachine: 120 | me.Parent = x.ParentVApp 121 | } 122 | } 123 | 124 | if me.Parent == nil { 125 | out = append(out, me) 126 | break 127 | } 128 | 129 | if *me.Parent == find { 130 | out = append(out, me) 131 | break 132 | } 133 | } 134 | } 135 | 136 | return out, nil 137 | } 138 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/entity.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | // Entity is the interface that is implemented by all managed objects 20 | // that extend ManagedEntity. 21 | type Entity interface { 22 | Reference 23 | Entity() *ManagedEntity 24 | } 25 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/extra.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | type IsManagedEntity interface { 20 | GetManagedEntity() ManagedEntity 21 | } 22 | 23 | func (m ComputeResource) GetManagedEntity() ManagedEntity { 24 | return m.ManagedEntity 25 | } 26 | 27 | func (m Datacenter) GetManagedEntity() ManagedEntity { 28 | return m.ManagedEntity 29 | } 30 | 31 | func (m Datastore) GetManagedEntity() ManagedEntity { 32 | return m.ManagedEntity 33 | } 34 | 35 | func (m DistributedVirtualSwitch) GetManagedEntity() ManagedEntity { 36 | return m.ManagedEntity 37 | } 38 | 39 | func (m DistributedVirtualPortgroup) GetManagedEntity() ManagedEntity { 40 | return m.ManagedEntity 41 | } 42 | 43 | func (m Folder) GetManagedEntity() ManagedEntity { 44 | return m.ManagedEntity 45 | } 46 | 47 | func (m HostSystem) GetManagedEntity() ManagedEntity { 48 | return m.ManagedEntity 49 | } 50 | 51 | func (m Network) GetManagedEntity() ManagedEntity { 52 | return m.ManagedEntity 53 | } 54 | 55 | func (m ResourcePool) GetManagedEntity() ManagedEntity { 56 | return m.ManagedEntity 57 | } 58 | 59 | func (m VirtualMachine) GetManagedEntity() ManagedEntity { 60 | return m.ManagedEntity 61 | } 62 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/reference.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | import "github.com/vmware/govmomi/vim25/types" 20 | 21 | // Reference is the interface that is implemented by all the managed objects 22 | // defined in this package. It specifies that these managed objects have a 23 | // function that returns the managed object reference to themselves. 24 | type Reference interface { 25 | Reference() types.ManagedObjectReference 26 | } 27 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/registry.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | import "reflect" 20 | 21 | var t = map[string]reflect.Type{} 22 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/mo/retrieve.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mo 18 | 19 | import ( 20 | "context" 21 | "reflect" 22 | 23 | "github.com/vmware/govmomi/vim25/methods" 24 | "github.com/vmware/govmomi/vim25/soap" 25 | "github.com/vmware/govmomi/vim25/types" 26 | ) 27 | 28 | func ignoreMissingProperty(ref types.ManagedObjectReference, p types.MissingProperty) bool { 29 | switch ref.Type { 30 | case "VirtualMachine": 31 | switch p.Path { 32 | case "environmentBrowser": 33 | // See https://github.com/vmware/govmomi/pull/242 34 | return true 35 | case "alarmActionsEnabled": 36 | // Seen with vApp child VM 37 | return true 38 | } 39 | } 40 | 41 | return false 42 | } 43 | 44 | // ObjectContentToType loads an ObjectContent value into the value it 45 | // represents. If the ObjectContent value has a non-empty 'MissingSet' field, 46 | // it returns the first fault it finds there as error. If the 'MissingSet' 47 | // field is empty, it returns a pointer to a reflect.Value. It handles contain 48 | // nested properties, such as 'guest.ipAddress' or 'config.hardware'. 49 | func ObjectContentToType(o types.ObjectContent) (interface{}, error) { 50 | // Expect no properties in the missing set 51 | for _, p := range o.MissingSet { 52 | if ignoreMissingProperty(o.Obj, p) { 53 | continue 54 | } 55 | 56 | return nil, soap.WrapVimFault(p.Fault.Fault) 57 | } 58 | 59 | ti := typeInfoForType(o.Obj.Type) 60 | v, err := ti.LoadFromObjectContent(o) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | return v.Elem().Interface(), nil 66 | } 67 | 68 | // ApplyPropertyChange converts the response of a call to WaitForUpdates 69 | // and applies it to the given managed object. 70 | func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) { 71 | t := typeInfoForType(obj.Reference().Type) 72 | v := reflect.ValueOf(obj) 73 | 74 | for _, p := range changes { 75 | rv, ok := t.props[p.Name] 76 | if !ok { 77 | continue 78 | } 79 | 80 | assignValue(v, rv, reflect.ValueOf(p.Val)) 81 | } 82 | } 83 | 84 | // LoadRetrievePropertiesResponse converts the response of a call to 85 | // RetrieveProperties to one or more managed objects. 86 | func LoadRetrievePropertiesResponse(res *types.RetrievePropertiesResponse, dst interface{}) error { 87 | rt := reflect.TypeOf(dst) 88 | if rt == nil || rt.Kind() != reflect.Ptr { 89 | panic("need pointer") 90 | } 91 | 92 | rv := reflect.ValueOf(dst).Elem() 93 | if !rv.CanSet() { 94 | panic("cannot set dst") 95 | } 96 | 97 | isSlice := false 98 | switch rt.Elem().Kind() { 99 | case reflect.Struct: 100 | case reflect.Slice: 101 | isSlice = true 102 | default: 103 | panic("unexpected type") 104 | } 105 | 106 | if isSlice { 107 | for _, p := range res.Returnval { 108 | v, err := ObjectContentToType(p) 109 | if err != nil { 110 | return err 111 | } 112 | 113 | vt := reflect.TypeOf(v) 114 | 115 | if !rv.Type().AssignableTo(vt) { 116 | // For example: dst is []ManagedEntity, res is []HostSystem 117 | if field, ok := vt.FieldByName(rt.Elem().Elem().Name()); ok && field.Anonymous { 118 | rv.Set(reflect.Append(rv, reflect.ValueOf(v).FieldByIndex(field.Index))) 119 | continue 120 | } 121 | } 122 | 123 | rv.Set(reflect.Append(rv, reflect.ValueOf(v))) 124 | } 125 | } else { 126 | switch len(res.Returnval) { 127 | case 0: 128 | case 1: 129 | v, err := ObjectContentToType(res.Returnval[0]) 130 | if err != nil { 131 | return err 132 | } 133 | 134 | vt := reflect.TypeOf(v) 135 | 136 | if !rv.Type().AssignableTo(vt) { 137 | // For example: dst is ComputeResource, res is ClusterComputeResource 138 | if field, ok := vt.FieldByName(rt.Elem().Name()); ok && field.Anonymous { 139 | rv.Set(reflect.ValueOf(v).FieldByIndex(field.Index)) 140 | return nil 141 | } 142 | } 143 | 144 | rv.Set(reflect.ValueOf(v)) 145 | default: 146 | // If dst is not a slice, expect to receive 0 or 1 results 147 | panic("more than 1 result") 148 | } 149 | } 150 | 151 | return nil 152 | } 153 | 154 | // RetrievePropertiesForRequest calls the RetrieveProperties method with the 155 | // specified request and decodes the response struct into the value pointed to 156 | // by dst. 157 | func RetrievePropertiesForRequest(ctx context.Context, r soap.RoundTripper, req types.RetrieveProperties, dst interface{}) error { 158 | res, err := methods.RetrieveProperties(ctx, r, &req) 159 | if err != nil { 160 | return err 161 | } 162 | 163 | return LoadRetrievePropertiesResponse(res, dst) 164 | } 165 | 166 | // RetrieveProperties retrieves the properties of the managed object specified 167 | // as obj and decodes the response struct into the value pointed to by dst. 168 | func RetrieveProperties(ctx context.Context, r soap.RoundTripper, pc, obj types.ManagedObjectReference, dst interface{}) error { 169 | req := types.RetrieveProperties{ 170 | This: pc, 171 | SpecSet: []types.PropertyFilterSpec{ 172 | { 173 | ObjectSet: []types.ObjectSpec{ 174 | { 175 | Obj: obj, 176 | Skip: types.NewBool(false), 177 | }, 178 | }, 179 | PropSet: []types.PropertySpec{ 180 | { 181 | All: types.NewBool(true), 182 | Type: obj.Type, 183 | }, 184 | }, 185 | }, 186 | }, 187 | } 188 | 189 | return RetrievePropertiesForRequest(ctx, r, req, dst) 190 | } 191 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/aggregator.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | import "sync" 20 | 21 | type Aggregator struct { 22 | downstream Sinker 23 | upstream chan (<-chan Report) 24 | 25 | done chan struct{} 26 | w sync.WaitGroup 27 | } 28 | 29 | func NewAggregator(s Sinker) *Aggregator { 30 | a := &Aggregator{ 31 | downstream: s, 32 | upstream: make(chan (<-chan Report)), 33 | 34 | done: make(chan struct{}), 35 | } 36 | 37 | a.w.Add(1) 38 | go a.loop() 39 | 40 | return a 41 | } 42 | 43 | func (a *Aggregator) loop() { 44 | defer a.w.Done() 45 | 46 | dch := a.downstream.Sink() 47 | defer close(dch) 48 | 49 | for { 50 | select { 51 | case uch := <-a.upstream: 52 | // Drain upstream channel 53 | for e := range uch { 54 | dch <- e 55 | } 56 | case <-a.done: 57 | return 58 | } 59 | } 60 | } 61 | 62 | func (a *Aggregator) Sink() chan<- Report { 63 | ch := make(chan Report) 64 | a.upstream <- ch 65 | return ch 66 | } 67 | 68 | // Done marks the aggregator as done. No more calls to Sink() may be made and 69 | // the downstream progress report channel will be closed when Done() returns. 70 | func (a *Aggregator) Done() { 71 | close(a.done) 72 | a.w.Wait() 73 | } 74 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | /* 20 | The progress package contains functionality to deal with progress reporting. 21 | The functionality is built to serve progress reporting for infrastructure 22 | operations when talking the vSphere API, but is generic enough to be used 23 | elsewhere. 24 | 25 | At the core of this progress reporting API lies the Sinker interface. This 26 | interface is implemented by any object that can act as a sink for progress 27 | reports. Callers of the Sink() function receives a send-only channel for 28 | progress reports. They are responsible for closing the channel when done. 29 | This semantic makes it easy to keep track of multiple progress report channels; 30 | they are only created when Sink() is called and assumed closed when any 31 | function that receives a Sinker parameter returns. 32 | */ 33 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/prefix.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | import "fmt" 20 | 21 | type prefixedReport struct { 22 | Report 23 | prefix string 24 | } 25 | 26 | func (r prefixedReport) Detail() string { 27 | if d := r.Report.Detail(); d != "" { 28 | return fmt.Sprintf("%s: %s", r.prefix, d) 29 | } 30 | 31 | return r.prefix 32 | } 33 | 34 | func prefixLoop(upstream <-chan Report, downstream chan<- Report, prefix string) { 35 | defer close(downstream) 36 | 37 | for r := range upstream { 38 | downstream <- prefixedReport{ 39 | Report: r, 40 | prefix: prefix, 41 | } 42 | } 43 | } 44 | 45 | func Prefix(s Sinker, prefix string) Sinker { 46 | fn := func() chan<- Report { 47 | upstream := make(chan Report) 48 | downstream := s.Sink() 49 | go prefixLoop(upstream, downstream, prefix) 50 | return upstream 51 | } 52 | 53 | return SinkFunc(fn) 54 | } 55 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/reader.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | import ( 20 | "container/list" 21 | "context" 22 | "fmt" 23 | "io" 24 | "sync/atomic" 25 | "time" 26 | ) 27 | 28 | type readerReport struct { 29 | t time.Time 30 | 31 | pos int64 32 | size int64 33 | bps *uint64 34 | 35 | err error 36 | } 37 | 38 | func (r readerReport) Percentage() float32 { 39 | return 100.0 * float32(r.pos) / float32(r.size) 40 | } 41 | 42 | func (r readerReport) Detail() string { 43 | const ( 44 | KiB = 1024 45 | MiB = 1024 * KiB 46 | GiB = 1024 * MiB 47 | ) 48 | 49 | // Use the reader's bps field, so this report returns an up-to-date number. 50 | // 51 | // For example: if there hasn't been progress for the last 5 seconds, the 52 | // most recent report should return "0B/s". 53 | // 54 | bps := atomic.LoadUint64(r.bps) 55 | 56 | switch { 57 | case bps >= GiB: 58 | return fmt.Sprintf("%.1fGiB/s", float32(bps)/float32(GiB)) 59 | case bps >= MiB: 60 | return fmt.Sprintf("%.1fMiB/s", float32(bps)/float32(MiB)) 61 | case bps >= KiB: 62 | return fmt.Sprintf("%.1fKiB/s", float32(bps)/float32(KiB)) 63 | default: 64 | return fmt.Sprintf("%dB/s", bps) 65 | } 66 | } 67 | 68 | func (p readerReport) Error() error { 69 | return p.err 70 | } 71 | 72 | // reader wraps an io.Reader and sends a progress report over a channel for 73 | // every read it handles. 74 | type reader struct { 75 | r io.Reader 76 | 77 | pos int64 78 | size int64 79 | bps uint64 80 | 81 | ch chan<- Report 82 | ctx context.Context 83 | } 84 | 85 | func NewReader(ctx context.Context, s Sinker, r io.Reader, size int64) *reader { 86 | pr := reader{ 87 | r: r, 88 | ctx: ctx, 89 | size: size, 90 | } 91 | 92 | // Reports must be sent downstream and to the bps computation loop. 93 | pr.ch = Tee(s, newBpsLoop(&pr.bps)).Sink() 94 | 95 | return &pr 96 | } 97 | 98 | // Read calls the Read function on the underlying io.Reader. Additionally, 99 | // every read causes a progress report to be sent to the progress reader's 100 | // underlying channel. 101 | func (r *reader) Read(b []byte) (int, error) { 102 | n, err := r.r.Read(b) 103 | r.pos += int64(n) 104 | 105 | if err != nil && err != io.EOF { 106 | return n, err 107 | } 108 | 109 | q := readerReport{ 110 | t: time.Now(), 111 | pos: r.pos, 112 | size: r.size, 113 | bps: &r.bps, 114 | } 115 | 116 | select { 117 | case r.ch <- q: 118 | case <-r.ctx.Done(): 119 | } 120 | 121 | return n, err 122 | } 123 | 124 | // Done marks the progress reader as done, optionally including an error in the 125 | // progress report. After sending it, the underlying channel is closed. 126 | func (r *reader) Done(err error) { 127 | q := readerReport{ 128 | t: time.Now(), 129 | pos: r.pos, 130 | size: r.size, 131 | bps: &r.bps, 132 | err: err, 133 | } 134 | 135 | select { 136 | case r.ch <- q: 137 | close(r.ch) 138 | case <-r.ctx.Done(): 139 | } 140 | } 141 | 142 | // newBpsLoop returns a sink that monitors and stores throughput. 143 | func newBpsLoop(dst *uint64) SinkFunc { 144 | fn := func() chan<- Report { 145 | sink := make(chan Report) 146 | go bpsLoop(sink, dst) 147 | return sink 148 | } 149 | 150 | return fn 151 | } 152 | 153 | func bpsLoop(ch <-chan Report, dst *uint64) { 154 | l := list.New() 155 | 156 | for { 157 | var tch <-chan time.Time 158 | 159 | // Setup timer for front of list to become stale. 160 | if e := l.Front(); e != nil { 161 | dt := time.Second - time.Now().Sub(e.Value.(readerReport).t) 162 | tch = time.After(dt) 163 | } 164 | 165 | select { 166 | case q, ok := <-ch: 167 | if !ok { 168 | return 169 | } 170 | 171 | l.PushBack(q) 172 | case <-tch: 173 | l.Remove(l.Front()) 174 | } 175 | 176 | // Compute new bps 177 | if l.Len() == 0 { 178 | atomic.StoreUint64(dst, 0) 179 | } else { 180 | f := l.Front().Value.(readerReport) 181 | b := l.Back().Value.(readerReport) 182 | atomic.StoreUint64(dst, uint64(b.pos-f.pos)) 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/report.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | // Report defines the interface for types that can deliver progress reports. 20 | // Examples include uploads/downloads in the http client and the task info 21 | // field in the task managed object. 22 | type Report interface { 23 | Percentage() float32 24 | Detail() string 25 | Error() error 26 | } 27 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/scale.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | type scaledReport struct { 20 | Report 21 | n int 22 | i int 23 | } 24 | 25 | func (r scaledReport) Percentage() float32 { 26 | b := 100 * float32(r.i) / float32(r.n) 27 | return b + (r.Report.Percentage() / float32(r.n)) 28 | } 29 | 30 | type scaleOne struct { 31 | s Sinker 32 | n int 33 | i int 34 | } 35 | 36 | func (s scaleOne) Sink() chan<- Report { 37 | upstream := make(chan Report) 38 | downstream := s.s.Sink() 39 | go s.loop(upstream, downstream) 40 | return upstream 41 | } 42 | 43 | func (s scaleOne) loop(upstream <-chan Report, downstream chan<- Report) { 44 | defer close(downstream) 45 | 46 | for r := range upstream { 47 | downstream <- scaledReport{ 48 | Report: r, 49 | n: s.n, 50 | i: s.i, 51 | } 52 | } 53 | } 54 | 55 | type scaleMany struct { 56 | s Sinker 57 | n int 58 | i int 59 | } 60 | 61 | func Scale(s Sinker, n int) Sinker { 62 | return &scaleMany{ 63 | s: s, 64 | n: n, 65 | } 66 | } 67 | 68 | func (s *scaleMany) Sink() chan<- Report { 69 | if s.i == s.n { 70 | s.n++ 71 | } 72 | 73 | ch := scaleOne{s: s.s, n: s.n, i: s.i}.Sink() 74 | s.i++ 75 | return ch 76 | } 77 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/sinker.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | // Sinker defines what is expected of a type that can act as a sink for 20 | // progress reports. The semantics are as follows. If you call Sink(), you are 21 | // responsible for closing the returned channel. Closing this channel means 22 | // that the related task is done, or resulted in error. 23 | type Sinker interface { 24 | Sink() chan<- Report 25 | } 26 | 27 | // SinkFunc defines a function that returns a progress report channel. 28 | type SinkFunc func() chan<- Report 29 | 30 | // Sink makes the SinkFunc implement the Sinker interface. 31 | func (fn SinkFunc) Sink() chan<- Report { 32 | return fn() 33 | } 34 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/progress/tee.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package progress 18 | 19 | // Tee works like Unix tee; it forwards all progress reports it receives to the 20 | // specified sinks 21 | func Tee(s1, s2 Sinker) Sinker { 22 | fn := func() chan<- Report { 23 | d1 := s1.Sink() 24 | d2 := s2.Sink() 25 | u := make(chan Report) 26 | go tee(u, d1, d2) 27 | return u 28 | } 29 | 30 | return SinkFunc(fn) 31 | } 32 | 33 | func tee(u <-chan Report, d1, d2 chan<- Report) { 34 | defer close(d1) 35 | defer close(d2) 36 | 37 | for r := range u { 38 | d1 <- r 39 | d2 <- r 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/retry.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package vim25 18 | 19 | import ( 20 | "context" 21 | "net" 22 | "net/url" 23 | "time" 24 | 25 | "github.com/vmware/govmomi/vim25/soap" 26 | ) 27 | 28 | type RetryFunc func(err error) (retry bool, delay time.Duration) 29 | 30 | // TemporaryNetworkError returns a RetryFunc that retries up to a maximum of n 31 | // times, only if the error returned by the RoundTrip function is a temporary 32 | // network error (for example: a connect timeout). 33 | func TemporaryNetworkError(n int) RetryFunc { 34 | return func(err error) (retry bool, delay time.Duration) { 35 | var nerr net.Error 36 | var ok bool 37 | 38 | // Never retry if this is not a network error. 39 | switch rerr := err.(type) { 40 | case *url.Error: 41 | if nerr, ok = rerr.Err.(net.Error); !ok { 42 | return false, 0 43 | } 44 | case net.Error: 45 | nerr = rerr 46 | default: 47 | return false, 0 48 | } 49 | 50 | if !nerr.Temporary() { 51 | return false, 0 52 | } 53 | 54 | // Don't retry if we're out of tries. 55 | if n--; n <= 0 { 56 | return false, 0 57 | } 58 | 59 | return true, 0 60 | } 61 | } 62 | 63 | type retry struct { 64 | roundTripper soap.RoundTripper 65 | 66 | // fn is a custom function that is called when an error occurs. 67 | // It returns whether or not to retry, and if so, how long to 68 | // delay before retrying. 69 | fn RetryFunc 70 | } 71 | 72 | // Retry wraps the specified soap.RoundTripper and invokes the 73 | // specified RetryFunc. The RetryFunc returns whether or not to 74 | // retry the call, and if so, how long to wait before retrying. If 75 | // the result of this function is to not retry, the original error 76 | // is returned from the RoundTrip function. 77 | func Retry(roundTripper soap.RoundTripper, fn RetryFunc) soap.RoundTripper { 78 | r := &retry{ 79 | roundTripper: roundTripper, 80 | fn: fn, 81 | } 82 | 83 | return r 84 | } 85 | 86 | func (r *retry) RoundTrip(ctx context.Context, req, res soap.HasFault) error { 87 | var err error 88 | 89 | for { 90 | err = r.roundTripper.RoundTrip(ctx, req, res) 91 | if err == nil { 92 | break 93 | } 94 | 95 | // Invoke retry function to see if another attempt should be made. 96 | if retry, delay := r.fn(err); retry { 97 | time.Sleep(delay) 98 | continue 99 | } 100 | 101 | break 102 | } 103 | 104 | return err 105 | } 106 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/soap/debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package soap 18 | 19 | import ( 20 | "fmt" 21 | "io" 22 | "net/http" 23 | "net/http/httputil" 24 | "strings" 25 | "sync/atomic" 26 | "time" 27 | 28 | "github.com/vmware/govmomi/vim25/debug" 29 | ) 30 | 31 | // teeReader wraps io.TeeReader and patches through the Close() function. 32 | type teeReader struct { 33 | io.Reader 34 | io.Closer 35 | } 36 | 37 | func newTeeReader(rc io.ReadCloser, w io.Writer) io.ReadCloser { 38 | return teeReader{ 39 | Reader: io.TeeReader(rc, w), 40 | Closer: rc, 41 | } 42 | } 43 | 44 | // debugRoundTrip contains state and logic needed to debug a single round trip. 45 | type debugRoundTrip struct { 46 | cn uint64 // Client number 47 | rn uint64 // Request number 48 | log io.WriteCloser // Request log 49 | cs []io.Closer // Files that need closing when done 50 | } 51 | 52 | func (d *debugRoundTrip) logf(format string, a ...interface{}) { 53 | now := time.Now().Format("2006-01-02T15-04-05.000000000") 54 | fmt.Fprintf(d.log, "%s - %04d: ", now, d.rn) 55 | fmt.Fprintf(d.log, format, a...) 56 | fmt.Fprintf(d.log, "\n") 57 | } 58 | 59 | func (d *debugRoundTrip) enabled() bool { 60 | return d != nil 61 | } 62 | 63 | func (d *debugRoundTrip) done() { 64 | for _, c := range d.cs { 65 | c.Close() 66 | } 67 | } 68 | 69 | func (d *debugRoundTrip) newFile(suffix string) io.WriteCloser { 70 | return debug.NewFile(fmt.Sprintf("%d-%04d.%s", d.cn, d.rn, suffix)) 71 | } 72 | 73 | func (d *debugRoundTrip) ext(h http.Header) string { 74 | ext := "xml" 75 | if strings.Contains(h.Get("Content-Type"), "/json") { 76 | ext = "json" 77 | } 78 | return ext 79 | } 80 | 81 | func (d *debugRoundTrip) debugRequest(req *http.Request) { 82 | if d == nil { 83 | return 84 | } 85 | 86 | var wc io.WriteCloser 87 | 88 | // Capture headers 89 | wc = d.newFile("req.headers") 90 | b, _ := httputil.DumpRequest(req, false) 91 | wc.Write(b) 92 | wc.Close() 93 | 94 | // Capture body 95 | wc = d.newFile("req." + d.ext(req.Header)) 96 | req.Body = newTeeReader(req.Body, wc) 97 | 98 | // Delay closing until marked done 99 | d.cs = append(d.cs, wc) 100 | } 101 | 102 | func (d *debugRoundTrip) debugResponse(res *http.Response) { 103 | if d == nil { 104 | return 105 | } 106 | 107 | var wc io.WriteCloser 108 | 109 | // Capture headers 110 | wc = d.newFile("res.headers") 111 | b, _ := httputil.DumpResponse(res, false) 112 | wc.Write(b) 113 | wc.Close() 114 | 115 | // Capture body 116 | wc = d.newFile("res." + d.ext(res.Header)) 117 | res.Body = newTeeReader(res.Body, wc) 118 | 119 | // Delay closing until marked done 120 | d.cs = append(d.cs, wc) 121 | } 122 | 123 | var cn uint64 // Client counter 124 | 125 | // debugContainer wraps the debugging state for a single client. 126 | type debugContainer struct { 127 | cn uint64 // Client number 128 | rn uint64 // Request counter 129 | log io.WriteCloser // Request log 130 | } 131 | 132 | func newDebug() *debugContainer { 133 | d := debugContainer{ 134 | cn: atomic.AddUint64(&cn, 1), 135 | rn: 0, 136 | } 137 | 138 | if !debug.Enabled() { 139 | return nil 140 | } 141 | 142 | d.log = debug.NewFile(fmt.Sprintf("%d-client.log", d.cn)) 143 | return &d 144 | } 145 | 146 | func (d *debugContainer) newRoundTrip() *debugRoundTrip { 147 | if d == nil { 148 | return nil 149 | } 150 | 151 | drt := debugRoundTrip{ 152 | cn: d.cn, 153 | rn: atomic.AddUint64(&d.rn, 1), 154 | log: d.log, 155 | } 156 | 157 | return &drt 158 | } 159 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/soap/error.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package soap 18 | 19 | import ( 20 | "fmt" 21 | "reflect" 22 | 23 | "github.com/vmware/govmomi/vim25/types" 24 | ) 25 | 26 | type regularError struct { 27 | err error 28 | } 29 | 30 | func (r regularError) Error() string { 31 | return r.err.Error() 32 | } 33 | 34 | type soapFaultError struct { 35 | fault *Fault 36 | } 37 | 38 | func (s soapFaultError) Error() string { 39 | msg := s.fault.String 40 | 41 | if msg == "" { 42 | if s.fault.Detail.Fault == nil { 43 | msg = "unknown fault" 44 | } else { 45 | msg = reflect.TypeOf(s.fault.Detail.Fault).Name() 46 | } 47 | } 48 | 49 | return fmt.Sprintf("%s: %s", s.fault.Code, msg) 50 | } 51 | 52 | type vimFaultError struct { 53 | fault types.BaseMethodFault 54 | } 55 | 56 | func (v vimFaultError) Error() string { 57 | typ := reflect.TypeOf(v.fault) 58 | for typ.Kind() == reflect.Ptr { 59 | typ = typ.Elem() 60 | } 61 | 62 | return typ.Name() 63 | } 64 | 65 | func (v vimFaultError) Fault() types.BaseMethodFault { 66 | return v.fault 67 | } 68 | 69 | func Wrap(err error) error { 70 | switch err.(type) { 71 | case regularError: 72 | return err 73 | case soapFaultError: 74 | return err 75 | case vimFaultError: 76 | return err 77 | } 78 | 79 | return WrapRegularError(err) 80 | } 81 | 82 | func WrapRegularError(err error) error { 83 | return regularError{err} 84 | } 85 | 86 | func IsRegularError(err error) bool { 87 | _, ok := err.(regularError) 88 | return ok 89 | } 90 | 91 | func ToRegularError(err error) error { 92 | return err.(regularError).err 93 | } 94 | 95 | func WrapSoapFault(f *Fault) error { 96 | return soapFaultError{f} 97 | } 98 | 99 | func IsSoapFault(err error) bool { 100 | _, ok := err.(soapFaultError) 101 | return ok 102 | } 103 | 104 | func ToSoapFault(err error) *Fault { 105 | return err.(soapFaultError).fault 106 | } 107 | 108 | func WrapVimFault(v types.BaseMethodFault) error { 109 | return vimFaultError{v} 110 | } 111 | 112 | func IsVimFault(err error) bool { 113 | _, ok := err.(vimFaultError) 114 | return ok 115 | } 116 | 117 | func ToVimFault(err error) types.BaseMethodFault { 118 | return err.(vimFaultError).fault 119 | } 120 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/soap/soap.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2018 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package soap 18 | 19 | import ( 20 | "github.com/vmware/govmomi/vim25/types" 21 | "github.com/vmware/govmomi/vim25/xml" 22 | ) 23 | 24 | // Header includes optional soap Header fields. 25 | type Header struct { 26 | Action string `xml:"-"` // Action is the 'SOAPAction' HTTP header value. Defaults to "Client.Namespace/Client.Version". 27 | Cookie string `xml:"vcSessionCookie,omitempty"` // Cookie is a vCenter session cookie that can be used with other SDK endpoints (e.g. pbm). 28 | ID string `xml:"operationID,omitempty"` // ID is the operationID used by ESX/vCenter logging for correlation. 29 | Security interface{} `xml:",omitempty"` // Security is used for SAML token authentication and request signing. 30 | } 31 | 32 | type Envelope struct { 33 | XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"` 34 | Header *Header `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header,omitempty"` 35 | Body interface{} 36 | } 37 | 38 | type Fault struct { 39 | XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"` 40 | Code string `xml:"faultcode"` 41 | String string `xml:"faultstring"` 42 | Detail struct { 43 | Fault types.AnyType `xml:",any,typeattr"` 44 | } `xml:"detail"` 45 | } 46 | 47 | func (f *Fault) VimFault() types.AnyType { 48 | return f.Detail.Fault 49 | } 50 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/types/base.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | type AnyType interface{} 20 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/types/fault.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | type HasFault interface { 20 | Fault() BaseMethodFault 21 | } 22 | 23 | func IsFileNotFound(err error) bool { 24 | if f, ok := err.(HasFault); ok { 25 | switch f.Fault().(type) { 26 | case *FileNotFound: 27 | return true 28 | } 29 | } 30 | 31 | return false 32 | } 33 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/types/helpers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2017 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | import ( 20 | "reflect" 21 | "strings" 22 | "time" 23 | ) 24 | 25 | func NewBool(v bool) *bool { 26 | return &v 27 | } 28 | 29 | func NewInt32(v int32) *int32 { 30 | return &v 31 | } 32 | 33 | func NewInt64(v int64) *int64 { 34 | return &v 35 | } 36 | 37 | func NewTime(v time.Time) *time.Time { 38 | return &v 39 | } 40 | 41 | func NewReference(r ManagedObjectReference) *ManagedObjectReference { 42 | return &r 43 | } 44 | 45 | func (r ManagedObjectReference) Reference() ManagedObjectReference { 46 | return r 47 | } 48 | 49 | func (r ManagedObjectReference) String() string { 50 | return strings.Join([]string{r.Type, r.Value}, ":") 51 | } 52 | 53 | func (r *ManagedObjectReference) FromString(o string) bool { 54 | s := strings.SplitN(o, ":", 2) 55 | 56 | if len(s) < 2 { 57 | return false 58 | } 59 | 60 | r.Type = s[0] 61 | r.Value = s[1] 62 | 63 | return true 64 | } 65 | 66 | func (c *PerfCounterInfo) Name() string { 67 | return c.GroupInfo.GetElementDescription().Key + "." + c.NameInfo.GetElementDescription().Key + "." + string(c.RollupType) 68 | } 69 | 70 | func defaultResourceAllocationInfo() ResourceAllocationInfo { 71 | return ResourceAllocationInfo{ 72 | Reservation: NewInt64(0), 73 | ExpandableReservation: NewBool(true), 74 | Limit: NewInt64(-1), 75 | Shares: &SharesInfo{ 76 | Level: SharesLevelNormal, 77 | }, 78 | } 79 | } 80 | 81 | // DefaultResourceConfigSpec returns a ResourceConfigSpec populated with the same default field values as vCenter. 82 | // Note that the wsdl marks these fields as optional, but they are required to be set when creating a resource pool. 83 | // They are only optional when updating a resource pool. 84 | func DefaultResourceConfigSpec() ResourceConfigSpec { 85 | return ResourceConfigSpec{ 86 | CpuAllocation: defaultResourceAllocationInfo(), 87 | MemoryAllocation: defaultResourceAllocationInfo(), 88 | } 89 | } 90 | 91 | func init() { 92 | // Known 6.5 issue where this event type is sent even though it is internal. 93 | // This workaround allows us to unmarshal and avoid NPEs. 94 | t["HostSubSpecificationUpdateEvent"] = reflect.TypeOf((*HostEvent)(nil)).Elem() 95 | } 96 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/types/registry.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | import ( 20 | "reflect" 21 | "strings" 22 | ) 23 | 24 | var t = map[string]reflect.Type{} 25 | 26 | func Add(name string, kind reflect.Type) { 27 | t[name] = kind 28 | } 29 | 30 | type Func func(string) (reflect.Type, bool) 31 | 32 | func TypeFunc() Func { 33 | return func(name string) (reflect.Type, bool) { 34 | typ, ok := t[name] 35 | if !ok { 36 | // The /sdk endpoint does not prefix types with the namespace, 37 | // but extension endpoints, such as /pbm/sdk do. 38 | name = strings.TrimPrefix(name, "vim25:") 39 | typ, ok = t[name] 40 | } 41 | return typ, ok 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/xml/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/govmomi/vim25/xml/extras.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 VMware, Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xml 18 | 19 | import ( 20 | "reflect" 21 | "time" 22 | ) 23 | 24 | var xmlSchemaInstance = Name{Space: "http://www.w3.org/2001/XMLSchema-instance", Local: "type"} 25 | 26 | var xsiType = Name{Space: "xsi", Local: "type"} 27 | 28 | var stringToTypeMap = map[string]reflect.Type{ 29 | "xsd:boolean": reflect.TypeOf((*bool)(nil)).Elem(), 30 | "xsd:byte": reflect.TypeOf((*int8)(nil)).Elem(), 31 | "xsd:short": reflect.TypeOf((*int16)(nil)).Elem(), 32 | "xsd:int": reflect.TypeOf((*int32)(nil)).Elem(), 33 | "xsd:long": reflect.TypeOf((*int64)(nil)).Elem(), 34 | "xsd:unsignedByte": reflect.TypeOf((*uint8)(nil)).Elem(), 35 | "xsd:unsignedShort": reflect.TypeOf((*uint16)(nil)).Elem(), 36 | "xsd:unsignedInt": reflect.TypeOf((*uint32)(nil)).Elem(), 37 | "xsd:unsignedLong": reflect.TypeOf((*uint64)(nil)).Elem(), 38 | "xsd:float": reflect.TypeOf((*float32)(nil)).Elem(), 39 | "xsd:double": reflect.TypeOf((*float64)(nil)).Elem(), 40 | "xsd:string": reflect.TypeOf((*string)(nil)).Elem(), 41 | "xsd:dateTime": reflect.TypeOf((*time.Time)(nil)).Elem(), 42 | "xsd:base64Binary": reflect.TypeOf((*[]byte)(nil)).Elem(), 43 | } 44 | 45 | // Return a reflect.Type for the specified type. Nil if unknown. 46 | func stringToType(s string) reflect.Type { 47 | return stringToTypeMap[s] 48 | } 49 | 50 | // Return a string for the specified reflect.Type. Panic if unknown. 51 | func typeToString(typ reflect.Type) string { 52 | switch typ.Kind() { 53 | case reflect.Bool: 54 | return "xsd:boolean" 55 | case reflect.Int8: 56 | return "xsd:byte" 57 | case reflect.Int16: 58 | return "xsd:short" 59 | case reflect.Int32: 60 | return "xsd:int" 61 | case reflect.Int, reflect.Int64: 62 | return "xsd:long" 63 | case reflect.Uint8: 64 | return "xsd:unsignedByte" 65 | case reflect.Uint16: 66 | return "xsd:unsignedShort" 67 | case reflect.Uint32: 68 | return "xsd:unsignedInt" 69 | case reflect.Uint, reflect.Uint64: 70 | return "xsd:unsignedLong" 71 | case reflect.Float32: 72 | return "xsd:float" 73 | case reflect.Float64: 74 | return "xsd:double" 75 | case reflect.String: 76 | name := typ.Name() 77 | if name == "string" { 78 | return "xsd:string" 79 | } 80 | return name 81 | case reflect.Struct: 82 | if typ == stringToTypeMap["xsd:dateTime"] { 83 | return "xsd:dateTime" 84 | } 85 | 86 | // Expect any other struct to be handled... 87 | return typ.Name() 88 | case reflect.Slice: 89 | if typ.Elem().Kind() == reflect.Uint8 { 90 | return "xsd:base64Binary" 91 | } 92 | case reflect.Array: 93 | if typ.Elem().Kind() == reflect.Uint8 { 94 | return "xsd:base64Binary" 95 | } 96 | } 97 | 98 | panic("don't know what to do for type: " + typ.String()) 99 | } 100 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package bdoor 16 | 17 | const ( 18 | BackdoorPort = uint16(0x5658) 19 | BackdoorHighBWPort = uint16(0x5659) 20 | 21 | CommandGetVersion = uint32(10) 22 | 23 | CommandMessage = uint16(0x1e) 24 | CommandHighBWMessage = uint16(0) 25 | CommandFlagCookie = uint32(0x80000000) 26 | ) 27 | 28 | func (p *BackdoorProto) InOut() *BackdoorProto { 29 | p.DX.AsUInt32().Low = BackdoorPort 30 | p.AX.SetValue(BackdoorMagic) 31 | 32 | retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_inout( 33 | p.AX.Value(), 34 | p.BX.Value(), 35 | p.CX.Value(), 36 | p.DX.Value(), 37 | p.SI.Value(), 38 | p.DI.Value(), 39 | p.BP.Value(), 40 | ) 41 | 42 | ret := &BackdoorProto{} 43 | ret.AX.SetValue(retax) 44 | ret.BX.SetValue(retbx) 45 | ret.CX.SetValue(retcx) 46 | ret.DX.SetValue(retdx) 47 | ret.SI.SetValue(retsi) 48 | ret.DI.SetValue(retdi) 49 | ret.BP.SetValue(retbp) 50 | 51 | return ret 52 | } 53 | 54 | func (p *BackdoorProto) HighBandwidthOut() *BackdoorProto { 55 | p.DX.AsUInt32().Low = BackdoorHighBWPort 56 | p.AX.SetValue(BackdoorMagic) 57 | 58 | retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbout( 59 | p.AX.Value(), 60 | p.BX.Value(), 61 | p.CX.Value(), 62 | p.DX.Value(), 63 | p.SI.Value(), 64 | p.DI.Value(), 65 | p.BP.Value(), 66 | ) 67 | 68 | ret := &BackdoorProto{} 69 | ret.AX.SetValue(retax) 70 | ret.BX.SetValue(retbx) 71 | ret.CX.SetValue(retcx) 72 | ret.DX.SetValue(retdx) 73 | ret.SI.SetValue(retsi) 74 | ret.DI.SetValue(retdi) 75 | ret.BP.SetValue(retbp) 76 | 77 | return ret 78 | } 79 | 80 | func (p *BackdoorProto) HighBandwidthIn() *BackdoorProto { 81 | p.DX.AsUInt32().Low = BackdoorHighBWPort 82 | p.AX.SetValue(BackdoorMagic) 83 | 84 | retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbin( 85 | p.AX.Value(), 86 | p.BX.Value(), 87 | p.CX.Value(), 88 | p.DX.Value(), 89 | p.SI.Value(), 90 | p.DI.Value(), 91 | p.BP.Value(), 92 | ) 93 | 94 | ret := &BackdoorProto{} 95 | ret.AX.SetValue(retax) 96 | ret.BX.SetValue(retbx) 97 | ret.CX.SetValue(retcx) 98 | ret.DX.SetValue(retdx) 99 | ret.SI.SetValue(retsi) 100 | ret.DI.SetValue(retdi) 101 | ret.BP.SetValue(retbp) 102 | 103 | return ret 104 | } 105 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package bdoor 16 | 17 | const ( 18 | BackdoorMagic = uint32(0x564D5868) 19 | ) 20 | 21 | type BackdoorProto struct { 22 | // typedef union { 23 | // struct { 24 | // DECLARE_REG_NAMED_STRUCT(ax); 25 | // size_t size; /* Register bx. */ 26 | // DECLARE_REG_NAMED_STRUCT(cx); 27 | // DECLARE_REG_NAMED_STRUCT(dx); 28 | // DECLARE_REG_NAMED_STRUCT(si); 29 | // DECLARE_REG_NAMED_STRUCT(di); 30 | // } in; 31 | // struct { 32 | // DECLARE_REG_NAMED_STRUCT(ax); 33 | // DECLARE_REG_NAMED_STRUCT(bx); 34 | // DECLARE_REG_NAMED_STRUCT(cx); 35 | // DECLARE_REG_NAMED_STRUCT(dx); 36 | // DECLARE_REG_NAMED_STRUCT(si); 37 | // DECLARE_REG_NAMED_STRUCT(di); 38 | // } out; 39 | // } proto; 40 | 41 | AX, BX, CX, DX, SI, DI, BP UInt32 42 | size uint32 43 | } 44 | 45 | func bdoor_inout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 46 | func bdoor_hbout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 47 | func bdoor_hbin(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 48 | func bdoor_inout_test(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 49 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_386.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // Doc of the golang plan9 assembler 4 | // http://p9.nyx.link/labs/sys/doc/asm.html 5 | // 6 | // A good primer of how to write golang with some plan9 flavored assembly 7 | // http://www.doxsey.net/blog/go-and-assembly 8 | // 9 | // Some x86 references 10 | // http://www.eecg.toronto.edu/~amza/www.mindsec.com/files/x86regs.html 11 | // https://cseweb.ucsd.edu/classes/sp10/cse141/pdf/02/S01_x86_64.key.pdf 12 | // https://en.wikibooks.org/wiki/X86_Assembly/Other_Instructions 13 | // 14 | // (This one is invaluable. Has a working example of how a standard function 15 | // call looks on the stack with the associated assembly.) 16 | // https://www.recurse.com/blog/7-understanding-c-by-learning-assembly 17 | // 18 | // Reference with raw form of the Opcode 19 | // http://x86.renejeschke.de/html/file_module_x86_id_139.html 20 | // 21 | // Massive x86_64 reference 22 | // http://ref.x86asm.net/coder64.html#xED 23 | // 24 | // Adding instructions to the go assembler 25 | // https://blog.klauspost.com/adding-unsupported-instructions-in-golang-assembler/ 26 | // 27 | // Backdoor commands 28 | // https://sites.google.com/site/chitchatvmback/backdoor 29 | 30 | // func bdoor_inout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 31 | TEXT ·bdoor_inout(SB), NOSPLIT|WRAPPER, $0 32 | MOVL ax+0(FP), AX 33 | MOVL bx+4(FP), BX 34 | MOVL cx+8(FP), CX 35 | MOVL dx+12(FP), DX 36 | MOVL si+16(FP), SI 37 | MOVL di+20(FP), DI 38 | MOVL bp+24(FP), BP 39 | 40 | // IN to DX from EAX 41 | INL 42 | 43 | MOVL AX, retax+28(FP) 44 | MOVL BX, retbx+32(FP) 45 | MOVL CX, retcx+36(FP) 46 | MOVL DX, retdx+40(FP) 47 | MOVL SI, retsi+44(FP) 48 | MOVL DI, retdi+48(FP) 49 | MOVL BP, retbp+52(FP) 50 | RET 51 | 52 | // func bdoor_hbout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 53 | TEXT ·bdoor_hbout(SB), NOSPLIT|WRAPPER, $0 54 | MOVL ax+0(FP), AX 55 | MOVL bx+4(FP), BX 56 | MOVL cx+8(FP), CX 57 | MOVL dx+12(FP), DX 58 | MOVL si+16(FP), SI 59 | MOVL di+20(FP), DI 60 | MOVL bp+24(FP), BP 61 | 62 | CLD; REP; OUTSB 63 | 64 | MOVL AX, retax+28(FP) 65 | MOVL BX, retbx+32(FP) 66 | MOVL CX, retcx+36(FP) 67 | MOVL DX, retdx+40(FP) 68 | MOVL SI, retsi+44(FP) 69 | MOVL DI, retdi+48(FP) 70 | MOVL BP, retbp+52(FP) 71 | RET 72 | 73 | // func bdoor_hbin(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 74 | TEXT ·bdoor_hbin(SB), NOSPLIT|WRAPPER, $0 75 | MOVL ax+0(FP), AX 76 | MOVL bx+4(FP), BX 77 | MOVL cx+8(FP), CX 78 | MOVL dx+12(FP), DX 79 | MOVL si+16(FP), SI 80 | MOVL di+20(FP), DI 81 | MOVL bp+24(FP), BP 82 | 83 | CLD; REP; INSB 84 | 85 | MOVL AX, retax+28(FP) 86 | MOVL BX, retbx+32(FP) 87 | MOVL CX, retcx+40(FP) 88 | MOVL DX, retdx+44(FP) 89 | MOVL SI, retsi+48(FP) 90 | MOVL DI, retdi+52(FP) 91 | MOVL BP, retbp+56(FP) 92 | RET 93 | 94 | // func bdoor_inout_test(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32) 95 | TEXT ·bdoor_inout_test(SB), NOSPLIT|WRAPPER, $0 96 | MOVL ax+0(FP), AX 97 | MOVL bx+4(FP), BX 98 | MOVL cx+8(FP), CX 99 | MOVL dx+12(FP), DX 100 | MOVL si+16(FP), SI 101 | MOVL di+20(FP), DI 102 | MOVL bp+24(FP), BP 103 | 104 | MOVL AX, retax+28(FP) 105 | MOVL BX, retbx+32(FP) 106 | MOVL CX, retcx+36(FP) 107 | MOVL DX, retdx+40(FP) 108 | MOVL SI, retsi+44(FP) 109 | MOVL DI, retdi+48(FP) 110 | MOVL BP, retbp+52(FP) 111 | RET 112 | 113 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package bdoor 16 | 17 | const ( 18 | BackdoorMagic = uint64(0x564D5868) 19 | ) 20 | 21 | type BackdoorProto struct { 22 | // typedef union { 23 | // struct { 24 | // DECLARE_REG_NAMED_STRUCT(ax); 25 | // size_t size; /* Register bx. */ 26 | // DECLARE_REG_NAMED_STRUCT(cx); 27 | // DECLARE_REG_NAMED_STRUCT(dx); 28 | // DECLARE_REG_NAMED_STRUCT(si); 29 | // DECLARE_REG_NAMED_STRUCT(di); 30 | // } in; 31 | // struct { 32 | // DECLARE_REG_NAMED_STRUCT(ax); 33 | // DECLARE_REG_NAMED_STRUCT(bx); 34 | // DECLARE_REG_NAMED_STRUCT(cx); 35 | // DECLARE_REG_NAMED_STRUCT(dx); 36 | // DECLARE_REG_NAMED_STRUCT(si); 37 | // DECLARE_REG_NAMED_STRUCT(di); 38 | // } out; 39 | // } proto; 40 | 41 | AX, BX, CX, DX, SI, DI, BP UInt64 42 | size uint32 43 | } 44 | 45 | func bdoor_inout(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 46 | func bdoor_hbout(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 47 | func bdoor_hbin(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 48 | func bdoor_inout_test(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 49 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_amd64.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // Doc of the golang plan9 assembler 4 | // http://p9.nyx.link/labs/sys/doc/asm.html 5 | // 6 | // A good primer of how to write golang with some plan9 flavored assembly 7 | // http://www.doxsey.net/blog/go-and-assembly 8 | // 9 | // Some x86 references 10 | // http://www.eecg.toronto.edu/~amza/www.mindsec.com/files/x86regs.html 11 | // https://cseweb.ucsd.edu/classes/sp10/cse141/pdf/02/S01_x86_64.key.pdf 12 | // https://en.wikibooks.org/wiki/X86_Assembly/Other_Instructions 13 | // 14 | // (This one is invaluable. Has a working example of how a standard function 15 | // call looks on the stack with the associated assembly.) 16 | // https://www.recurse.com/blog/7-understanding-c-by-learning-assembly 17 | // 18 | // Reference with raw form of the Opcode 19 | // http://x86.renejeschke.de/html/file_module_x86_id_139.html 20 | // 21 | // Massive x86_64 reference 22 | // http://ref.x86asm.net/coder64.html#xED 23 | // 24 | // Adding instructions to the go assembler 25 | // https://blog.klauspost.com/adding-unsupported-instructions-in-golang-assembler/ 26 | // 27 | // Backdoor commands 28 | // https://sites.google.com/site/chitchatvmback/backdoor 29 | 30 | // func bdoor_inout(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 31 | TEXT ·bdoor_inout(SB), NOSPLIT|WRAPPER, $0 32 | MOVQ ax+0(FP), AX 33 | MOVQ bx+8(FP), BX 34 | MOVQ cx+16(FP), CX 35 | MOVQ dx+24(FP), DX 36 | MOVQ si+32(FP), SI 37 | MOVQ di+40(FP), DI 38 | MOVQ bp+48(FP), BP 39 | 40 | // IN to DX from EAX 41 | INL 42 | 43 | MOVQ AX, retax+56(FP) 44 | MOVQ BX, retbx+64(FP) 45 | MOVQ CX, retcx+72(FP) 46 | MOVQ DX, retdx+80(FP) 47 | MOVQ SI, retsi+88(FP) 48 | MOVQ DI, retdi+96(FP) 49 | MOVQ BP, retbp+104(FP) 50 | RET 51 | 52 | // func bdoor_hbout(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 53 | TEXT ·bdoor_hbout(SB), NOSPLIT|WRAPPER, $0 54 | MOVQ ax+0(FP), AX 55 | MOVQ bx+8(FP), BX 56 | MOVQ cx+16(FP), CX 57 | MOVQ dx+24(FP), DX 58 | MOVQ si+32(FP), SI 59 | MOVQ di+40(FP), DI 60 | MOVQ bp+48(FP), BP 61 | 62 | CLD; REP; OUTSB 63 | 64 | MOVQ AX, retax+56(FP) 65 | MOVQ BX, retbx+64(FP) 66 | MOVQ CX, retcx+72(FP) 67 | MOVQ DX, retdx+80(FP) 68 | MOVQ SI, retsi+88(FP) 69 | MOVQ DI, retdi+96(FP) 70 | MOVQ BP, retbp+104(FP) 71 | RET 72 | 73 | // func bdoor_hbin(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 74 | TEXT ·bdoor_hbin(SB), NOSPLIT|WRAPPER, $0 75 | MOVQ ax+0(FP), AX 76 | MOVQ bx+8(FP), BX 77 | MOVQ cx+16(FP), CX 78 | MOVQ dx+24(FP), DX 79 | MOVQ si+32(FP), SI 80 | MOVQ di+40(FP), DI 81 | MOVQ bp+48(FP), BP 82 | 83 | CLD; REP; INSB 84 | 85 | MOVQ AX, retax+56(FP) 86 | MOVQ BX, retbx+64(FP) 87 | MOVQ CX, retcx+72(FP) 88 | MOVQ DX, retdx+80(FP) 89 | MOVQ SI, retsi+88(FP) 90 | MOVQ DI, retdi+96(FP) 91 | MOVQ BP, retbp+104(FP) 92 | RET 93 | 94 | // func bdoor_inout_test(ax, bx, cx, dx, si, di, bp uint64) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint64) 95 | TEXT ·bdoor_inout_test(SB), NOSPLIT|WRAPPER, $0 96 | MOVQ ax+0(FP), AX 97 | MOVQ bx+8(FP), BX 98 | MOVQ cx+16(FP), CX 99 | MOVQ dx+24(FP), DX 100 | MOVQ si+32(FP), SI 101 | MOVQ di+40(FP), DI 102 | MOVQ bp+48(FP), BP 103 | 104 | MOVQ AX, retax+56(FP) 105 | MOVQ BX, retbx+64(FP) 106 | MOVQ CX, retcx+72(FP) 107 | MOVQ DX, retdx+80(FP) 108 | MOVQ SI, retsi+88(FP) 109 | MOVQ DI, retdi+96(FP) 110 | MOVQ BP, retbp+104(FP) 111 | RET 112 | 113 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/bdoor/word.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package bdoor 16 | 17 | import "unsafe" 18 | 19 | type UInt32 struct { 20 | High uint16 21 | Low uint16 22 | } 23 | 24 | func (u *UInt32) Word() uint32 { 25 | return uint32(u.High)<<16 + uint32(u.Low) 26 | } 27 | 28 | func (u *UInt32) SetWord(w uint32) { 29 | u.High = uint16(w >> 16) 30 | u.Low = uint16(w) 31 | } 32 | 33 | func (u *UInt32) AsUInt32() *UInt32 { 34 | return u 35 | } 36 | 37 | func (u *UInt32) Value() uint32 { 38 | return u.Word() 39 | } 40 | 41 | func (u *UInt32) SetValue(val uint32) { 42 | u.SetWord(val) 43 | } 44 | 45 | func (u *UInt32) SetPointer(p unsafe.Pointer) { 46 | u.SetWord(uint32(uintptr(p))) 47 | } 48 | 49 | type UInt64 struct { 50 | High UInt32 51 | Low UInt32 52 | } 53 | 54 | func (u *UInt64) Quad() uint64 { 55 | return uint64(u.High.Word())<<32 + uint64(u.Low.Word()) 56 | } 57 | 58 | func (u *UInt64) SetQuad(w uint64) { 59 | u.High.SetWord(uint32(w >> 32)) 60 | u.Low.SetWord(uint32(w)) 61 | } 62 | 63 | func (u *UInt64) AsUInt32() *UInt32 { 64 | return &u.Low 65 | } 66 | 67 | func (u *UInt64) Value() uint64 { 68 | return u.Quad() 69 | } 70 | 71 | func (u *UInt64) SetValue(val uint64) { 72 | u.SetQuad(val) 73 | } 74 | 75 | func (u *UInt64) SetPointer(p unsafe.Pointer) { 76 | u.SetQuad(uint64(uintptr(p))) 77 | } 78 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/message/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 VMware, Inc. All Rights Reserved. 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 | package message 16 | 17 | import "log" 18 | 19 | var DefaultLogger Logger 20 | 21 | type Logger interface { 22 | Errorf(format string, args ...interface{}) 23 | Debugf(format string, args ...interface{}) 24 | Infof(format string, args ...interface{}) 25 | } 26 | 27 | func init() { 28 | DefaultLogger = &logger{} 29 | } 30 | 31 | type logger struct { 32 | DebugLevel bool 33 | } 34 | 35 | func (l *logger) Errorf(format string, args ...interface{}) { 36 | log.Printf(format, args...) 37 | } 38 | 39 | func (l *logger) Debugf(format string, args ...interface{}) { 40 | if !l.DebugLevel { 41 | return 42 | } 43 | 44 | log.Printf(format, args...) 45 | } 46 | 47 | func (l *logger) Infof(format string, args ...interface{}) { 48 | log.Printf(format, args...) 49 | } 50 | 51 | func Errorf(format string, args ...interface{}) { 52 | DefaultLogger.Errorf(format, args...) 53 | } 54 | 55 | func Debugf(format string, args ...interface{}) { 56 | DefaultLogger.Debugf(format, args...) 57 | } 58 | 59 | func Infof(format string, args ...interface{}) { 60 | DefaultLogger.Infof(format, args...) 61 | } 62 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/rpcout/rpcout.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 VMware, Inc. All Rights Reserved. 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 | package rpcout 16 | 17 | import ( 18 | "errors" 19 | "fmt" 20 | 21 | "github.com/vmware/vmw-guestinfo/message" 22 | ) 23 | 24 | // ErrRpciFormat represents an invalid result format 25 | var ErrRpciFormat = errors.New("invalid format for RPCI command result") 26 | 27 | const rpciProtocolNum uint32 = 0x49435052 28 | 29 | // SendOne is a command-oriented wrapper for SendOneRaw 30 | func SendOne(format string, a ...interface{}) (reply []byte, ok bool, err error) { 31 | request := fmt.Sprintf(format, a...) 32 | return SendOneRaw([]byte(request)) 33 | } 34 | 35 | // SendOneRaw uses a throw-away RPCOut to send a request 36 | func SendOneRaw(request []byte) (reply []byte, ok bool, err error) { 37 | out := &RPCOut{} 38 | if err = out.Start(); err != nil { 39 | return 40 | } 41 | if reply, ok, err = out.Send(request); err != nil { 42 | return 43 | } 44 | if err = out.Stop(); err != nil { 45 | return 46 | } 47 | return 48 | } 49 | 50 | // RPCOut is an ougoing connection from the VM to the hypervisor 51 | type RPCOut struct { 52 | channel *message.Channel 53 | } 54 | 55 | // Start opens the connection 56 | func (out *RPCOut) Start() error { 57 | channel, err := message.NewChannel(rpciProtocolNum) 58 | if err != nil { 59 | return err 60 | } 61 | out.channel = channel 62 | return nil 63 | } 64 | 65 | // Stop closes the connection 66 | func (out *RPCOut) Stop() error { 67 | err := out.channel.Close() 68 | out.channel = nil 69 | return err 70 | } 71 | 72 | // Send emits a request and receives a response 73 | func (out *RPCOut) Send(request []byte) (reply []byte, ok bool, err error) { 74 | if err = out.channel.Send(request); err != nil { 75 | return 76 | } 77 | 78 | var resp []byte 79 | if resp, err = out.channel.Receive(); err != nil { 80 | return 81 | } 82 | 83 | switch string(resp[:2]) { 84 | case "0 ": 85 | reply = resp[2:] 86 | case "1 ": 87 | reply = resp[2:] 88 | ok = true 89 | default: 90 | err = ErrRpciFormat 91 | } 92 | return 93 | } 94 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/rpcvmx/rpcvmx.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 VMware, Inc. All Rights Reserved. 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 | package rpcvmx 16 | 17 | import ( 18 | "fmt" 19 | "strconv" 20 | "strings" 21 | 22 | "github.com/vmware/vmw-guestinfo/rpcout" 23 | ) 24 | 25 | const ( 26 | prefix = "guestinfo" 27 | ) 28 | 29 | // Config gives access to the vmx config through the VMware backdoor 30 | type Config struct{} 31 | 32 | // NewConfig creates a new Config object 33 | func NewConfig() *Config { 34 | return &Config{} 35 | } 36 | 37 | // String returns the config string in the guestinfo.* namespace 38 | func (c *Config) String(key string, defaultValue string) (string, error) { 39 | // add "guestinfo." prefix if missing 40 | if !strings.HasPrefix(key, prefix) { 41 | key = fmt.Sprintf("%s.%s", prefix, key) 42 | } 43 | 44 | out, ok, err := rpcout.SendOne("info-get %s", key) 45 | if err != nil { 46 | return "", err 47 | } else if !ok { 48 | return defaultValue, nil 49 | } 50 | return string(out), nil 51 | } 52 | 53 | // Bool returns the config boolean in the guestinfo.* namespace 54 | func (c *Config) Bool(key string, defaultValue bool) (bool, error) { 55 | val, err := c.String(key, fmt.Sprintf("%t", defaultValue)) 56 | if err != nil { 57 | return false, err 58 | } 59 | res, err := strconv.ParseBool(val) 60 | if err != nil { 61 | return defaultValue, nil 62 | } 63 | return res, nil 64 | } 65 | 66 | // Int returns the config integer in the guestinfo.* namespace 67 | func (c *Config) Int(key string, defaultValue int) (int, error) { 68 | val, err := c.String(key, "") 69 | if err != nil { 70 | return 0, err 71 | } 72 | res, err := strconv.Atoi(val) 73 | if err != nil { 74 | return defaultValue, nil 75 | } 76 | return res, nil 77 | } 78 | 79 | // SetString sets the guestinfo.KEY with the string VALUE 80 | func (c *Config) SetString(key string, value string) error { 81 | // add "guestinfo." prefix if missing 82 | if !strings.HasPrefix(key, prefix) { 83 | key = fmt.Sprintf("%s.%s", prefix, key) 84 | } 85 | 86 | _, _, err := rpcout.SendOne("info-set %s %s", key, value) 87 | if err != nil { 88 | return err 89 | } 90 | return nil 91 | } 92 | 93 | // SetString sets the guestinfo.KEY with the bool VALUE 94 | func (c *Config) SetBool(key string, value bool) error { 95 | return c.SetString(key, strconv.FormatBool(value)) 96 | } 97 | 98 | // SetString sets the guestinfo.KEY with the int VALUE 99 | func (c *Config) SetInt(key string, value int) error { 100 | return c.SetString(key, strconv.Itoa(value)) 101 | } 102 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package vmcheck 16 | 17 | import ( 18 | "encoding/binary" 19 | 20 | "github.com/vmware/vmw-guestinfo/bdoor" 21 | ) 22 | 23 | // From https://github.com/intel-go/cpuid/blob/master/cpuidlow_amd64.s 24 | // Get the CPU ID low level leaf values. 25 | func cpuid_low(arg1, arg2 uint32) (eax, ebx, ecx, edx uint32) 26 | 27 | // IsVirtualWorld returns true if running in a VM and the backdoor is available. 28 | func IsVirtualWorld() (bool, error) { 29 | // Test the HV bit is set 30 | if !IsVirtualCPU() { 31 | return false, nil 32 | } 33 | 34 | // Test if backdoor port is available. 35 | if isVM, err := hypervisorPortCheck(); err != nil || !isVM { 36 | return isVM, err 37 | } 38 | 39 | return true, nil 40 | } 41 | 42 | // hypervisorPortCheck tests the availability of the HV port. 43 | func hypervisorPortCheck() (bool, error) { 44 | // Privilege level 3 to access all ports above 0x3ff 45 | if err := openPortsAccess(); err != nil { 46 | return false, err 47 | } 48 | 49 | p := &bdoor.BackdoorProto{} 50 | 51 | p.CX.AsUInt32().SetWord(bdoor.CommandGetVersion) 52 | out := p.InOut() 53 | // if there is no device, we get back all 1s 54 | return (0xffffffff != out.AX.AsUInt32().Word()) && (0 != out.AX.AsUInt32().Word()), nil 55 | } 56 | 57 | // IsVirtualCPU checks if the cpu is a virtual CPU running on ESX. It checks for 58 | // the HV bit in the ECX register of the CPUID leaf 0x1. Intel and AMD CPUs 59 | // reserve this bit to indicate if the CPU is running in a HV. See 60 | // https://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits 61 | // for details. If this bit is set, the reserved cpuid levels are used to pass 62 | // information from the HV to the guest. In ESX, this is the repeating string 63 | // "VMwareVMware". 64 | func IsVirtualCPU() bool { 65 | HV := uint32(1 << 31) 66 | _, _, c, _ := cpuid_low(0x1, 0) 67 | if (c & HV) != HV { 68 | return false 69 | } 70 | 71 | _, b, c, d := cpuid_low(0x40000000, 0) 72 | 73 | buf := make([]byte, 12) 74 | binary.LittleEndian.PutUint32(buf, b) 75 | binary.LittleEndian.PutUint32(buf[4:], c) 76 | binary.LittleEndian.PutUint32(buf[8:], d) 77 | 78 | if string(buf) != "VMwareVMware" { 79 | return false 80 | } 81 | 82 | return true 83 | } 84 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_386.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // From https://github.com/intel-go/cpuid/blob/master/cpuidlow_amd64.s 4 | // func cpuid_low(arg1, arg2 uint32) (eax, ebx, ecx, edx uint32) 5 | TEXT ·cpuid_low(SB), NOSPLIT, $0-24 6 | MOVL arg1+0(FP), AX 7 | MOVL arg2+4(FP), CX 8 | CPUID 9 | MOVL AX, eax+8(FP) 10 | MOVL BX, ebx+12(FP) 11 | MOVL CX, ecx+16(FP) 12 | MOVL DX, edx+20(FP) 13 | RET 14 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_amd64.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // From https://github.com/intel-go/cpuid/blob/master/cpuidlow_amd64.s 4 | // func cpuid_low(arg1, arg2 uint32) (eax, ebx, ecx, edx uint32) 5 | TEXT ·cpuid_low(SB), NOSPLIT, $0-24 6 | MOVL arg1+0(FP), AX 7 | MOVL arg2+4(FP), CX 8 | CPUID 9 | MOVL AX, eax+8(FP) 10 | MOVL BX, ebx+12(FP) 11 | MOVL CX, ecx+16(FP) 12 | MOVL DX, edx+20(FP) 13 | RET 14 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_general.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | // +build !linux 16 | 17 | package vmcheck 18 | 19 | // probably not gonna work. Instead, implement a platform-specific variant, and 20 | // add the platform to above build flags 21 | func openPortsAccess() error { 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /ova/rpctool/vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 VMware, Inc. All Rights Reserved. 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 | package vmcheck 16 | 17 | import "syscall" 18 | 19 | func openPortsAccess() error { 20 | // Privilege level 3 to access all ports above 0x3ff 21 | return syscall.Iopl(3) 22 | } 23 | -------------------------------------------------------------------------------- /ova/sk8-ca.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # Used by the sk8 service to generate a self-signed CA if one does not 20 | # exist or is not set in TLS_CA_PEM. 21 | # 22 | 23 | # Load the sk8 commons library. 24 | # shellcheck disable=SC1090 25 | . "$(pwd)/sk8-common.sh" 26 | 27 | _done_file="$(pwd)/.$(basename "${0}").done" 28 | [ ! -f "${_done_file}" ] || exit 0 29 | touch "${_done_file}" 30 | 31 | export TLS_CA_CRT=/etc/ssl/ca.crt 32 | export TLS_CA_KEY=/etc/ssl/ca.key 33 | mkdir -p /etc/ssl && chmod 0755 /etc/ssl 34 | 35 | generate_ca() { 36 | TLS_DEFAULT_BITS="$(rpc_get TLS_DEFAULT_BITS)" 37 | TLS_DEFAULT_DAYS="$(rpc_get TLS_DEFAULT_DAYS)" 38 | TLS_COUNTRY_NAME="$(rpc_get TLS_COUNTRY_NAME)" 39 | TLS_STATE_OR_PROVINCE_NAME="$(rpc_get TLS_STATE_OR_PROVINCE_NAME)" 40 | TLS_LOCALITY_NAME="$(rpc_get TLS_LOCALITY_NAME)" 41 | TLS_ORG_NAME="$(rpc_get TLS_ORG_NAME)" 42 | TLS_OU_NAME="$(rpc_get TLS_OU_NAME)" 43 | TLS_EMAIL="$(rpc_get TLS_EMAIL)" 44 | TLS_COMMON_NAME="$(rpc_get TLS_COMMON_NAME)" 45 | 46 | [ -z "${TLS_DEFAULT_BITS}" ] || export TLS_DEFAULT_BITS 47 | [ -z "${TLS_DEFAULT_DAYS}" ] || export TLS_DEFAULT_DAYS 48 | [ -z "${TLS_COUNTRY_NAME}" ] || export TLS_COUNTRY_NAME 49 | [ -z "${TLS_STATE_OR_PROVINCE_NAME}" ] || export TLS_STATE_OR_PROVINCE_NAME 50 | [ -z "${TLS_LOCALITY_NAME}" ] || export TLS_LOCALITY_NAME 51 | [ -z "${TLS_ORG_NAME}" ] || export TLS_ORG_NAME 52 | [ -z "${TLS_OU_NAME}" ] || export TLS_OU_NAME 53 | [ -z "${TLS_OU_NAME}" ] || export TLS_OU_NAME 54 | [ -z "${TLS_EMAIL}" ] || export TLS_EMAIL 55 | [ -z "${TLS_COMMON_NAME}" ] || export TLS_COMMON_NAME 56 | 57 | # Generate a new CA for the cluster. 58 | ./new-ca.sh 59 | } 60 | 61 | if val="$(rpc_get TLS_CA_PEM)" && [ -n "${val}" ]; then 62 | info "using CA from TLS_CA_PEM..." 63 | echo "${val}" | unmangle_pem | openssl x509 1>"${TLS_CA_CRT}" 64 | echo "${val}" | unmangle_pem | openssl rsa 1>"${TLS_CA_KEY}" 65 | else 66 | info "generating x509 self-signed certificate authority..." 67 | generate_ca 68 | fi 69 | 70 | chmod 0644 "${TLS_CA_CRT}" 71 | chmod 0400 "${TLS_CA_KEY}" 72 | rpc_set TLS_CA_PEM - <"${TLS_CA_CRT}" 73 | openssl x509 -noout -text <"${TLS_CA_CRT}" 74 | 75 | exit 0 76 | 77 | -------------------------------------------------------------------------------- /ova/sk8-config-keys.env: -------------------------------------------------------------------------------- 1 | NUM_BOTH 2 | NUM_CONTROLLERS 3 | NUM_NODES 4 | CLUSTER_ID 5 | LOAD_BALANCER_ID 6 | LOG_LEVEL 7 | DEBUG 8 | BIN_DIR 9 | NETWORK_DNS_1 10 | NETWORK_DNS_2 11 | ETCD_LEASE_TTL 12 | IPTABLES_ALLOW_ALL 13 | CLEANUP_DISABLED 14 | CNI_BIN_DIR 15 | LOG_LEVEL_KUBERNETES 16 | LOG_LEVEL_KUBE_APISERVER 17 | LOG_LEVEL_KUBE_SCHEDULER 18 | LOG_LEVEL_KUBE_CONTROLLER_MANAGER 19 | LOG_LEVEL_KUBELET 20 | LOG_LEVEL_KUBE_PROXY 21 | LOG_LEVEL_CLOUD_CONTROLLER_MANAGER 22 | INSTALL_CONFORMANCE_TESTS 23 | RUN_CONFORMANCE_TESTS 24 | CLOUD_PROVIDER 25 | CLOUD_CONFIG 26 | CLOUD_PROVIDER_EXTERNAL 27 | CLOUD_PROVIDER_IMAGE 28 | CLOUD_PROVIDER_IMAGE_SECRETS 29 | MANIFEST_YAML_BEFORE_RBAC 30 | MANIFEST_YAML_AFTER_RBAC_1 31 | MANIFEST_YAML_AFTER_RBAC_2 32 | MANIFEST_YAML_AFTER_ALL 33 | ENCRYPTION_KEY 34 | CLUSTER_ADMIN 35 | CLUSTER_NAME 36 | CLUSTER_FQDN 37 | EXTERNAL_FQDN 38 | CLUSTER_CIDR 39 | POD_CIDR_FORMAT 40 | SECURE_PORT 41 | SERVICE_CIDR 42 | SERVICE_IPV4_ADDRESS 43 | SERVICE_DNS_PROVIDER 44 | SERVICE_DNS_IPV4_ADDRESS 45 | SERVICE_DOMAIN 46 | SERVICE_NAME 47 | HOST_NAME_OVERRIDE 48 | K8S_VERSION 49 | CNI_PLUGINS_VERSION 50 | CONTAINERD_VERSION 51 | COREDNS_VERSION 52 | CRICTL_VERSION 53 | ETCD_VERSION 54 | JQ_VERSION 55 | NGINX_VERSION 56 | RUNC_VERSION 57 | RUNSC_VERSION 58 | TLS_DEFAULT_BITS 59 | TLS_DEFAULT_DAYS 60 | TLS_COUNTRY_NAME 61 | TLS_STATE_OR_PROVINCE_NAME 62 | TLS_LOCALITY_NAME 63 | TLS_ORG_NAME 64 | TLS_OU_NAME 65 | TLS_COMMON_NAME 66 | TLS_EMAIL 67 | TLS_IS_CA 68 | TLS_KEY_USAGE 69 | TLS_EXT_KEY_USAGE 70 | TLS_SAN 71 | TLS_SAN_DNS 72 | TLS_SAN_IP 73 | TLS_KEY_UID 74 | TLS_KEY_GID 75 | TLS_KEY_PERM 76 | TLS_CRT_UID 77 | TLS_CRT_GID 78 | TLS_CRT_PERM 79 | -------------------------------------------------------------------------------- /ova/sk8-guestinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # Used by the sk8 service to write the sk8 environment 20 | # file by reading properties from the VMware GuestInfo interface. 21 | # 22 | 23 | # Load the sk8 commons library. 24 | # shellcheck disable=SC1090 25 | . "$(pwd)/sk8-common.sh" 26 | 27 | _done_file="$(pwd)/.$(basename "${0}").done" 28 | [ ! -f "${_done_file}" ] || exit 0 29 | touch "${_done_file}" 30 | 31 | SK8_DEFAULTS="${SK8_DEFAULTS:-/etc/default/sk8}" 32 | 33 | write_config_val() { 34 | if [ -n "${2}" ]; then 35 | printf '%s="%s"\n' "${1}" "${2}" >>"${SK8_DEFAULTS}" 36 | printf 'set config val\n key = %s\n' "${1}" 1>&2 37 | elif val="$(rpc_get "${1}")" && [ -n "${val}" ]; then 38 | printf '%s="%s"\n' "${1}" "${val}" >>"${SK8_DEFAULTS}" 39 | printf 'set config val\n key = %s\n' "${1}" 1>&2 40 | fi 41 | } 42 | 43 | # Write the following config keys to the config file. 44 | write_config_val NODE_TYPE 45 | write_config_val ETCD_DISCOVERY 46 | 47 | # Iterate over the common config keys to write to the config file. 48 | while IFS= read -r key; do 49 | write_config_val "${key}" 50 | done >/root/.ssh/authorized_keys 43 | fi 44 | chmod 0400 /root/.ssh/authorized_keys 45 | echo "${val}" >>/root/.ssh/authorized_keys 46 | fi 47 | 48 | # If there is no SSH key at all then generate one. 49 | if [ ! -f /root/.ssh/id_rsa ]; then 50 | info "generating a new SSH key pair" 51 | 52 | cluster_name="$(rpc_get CLUSTER_NAME)" 53 | cluster_name="${cluster_name:-kubernetes}" 54 | domain_name="$(rpc_get NETWORK_DOMAIN)" 55 | domain_name="${domain_name:-$(hostname -d)}" 56 | cluster_fqdn="${cluster_name}.${domain_name}" 57 | 58 | ssh-keygen \ 59 | -b 2048 \ 60 | -t rsa \ 61 | -C "root@${cluster_fqdn}" \ 62 | -N "" \ 63 | -f /root/.ssh/id_rsa 64 | 65 | chmod 0400 /root/.ssh/id_rsa 66 | chmod 0400 /root/.ssh/id_rsa.pub 67 | 68 | if [ -f /root/.ssh/authorized_keys ]; then 69 | echo >>/root/.ssh/authorized_keys 70 | fi 71 | cat /root/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys 72 | chmod 0400 /root/.ssh/authorized_keys 73 | fi 74 | 75 | rpc_set SSH_PRV_KEY - &1 | tee /var/log/sk8/sysprep.log' 36 | 37 | # Update the host name with the value from the OVF environment. 38 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-hostname.sh 2>&1 | tee /var/log/sk8/hostname.log' 39 | 40 | # This command ensures the sk8 service will wait until the network 41 | # is truly online before continuing with any of the subsequent 42 | # ExecStartPre commands or the ExecStart command. 43 | ExecStartPre=/bin/sh -c "while true; do ping -c1 google.com >/dev/null && break; done" 44 | 45 | # Create a load balancer if configured to do so. 46 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-load-balancer.sh create 2>&1 | tee /var/log/sk8/load-balancer.log' 47 | 48 | # Get information about the vSphere platform and select the cloud provider. 49 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-vsphere.sh 2>&1 | tee /var/log/sk8/vsphere.log' 50 | 51 | # Generate a self-signed CA if one is unavailable. 52 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-ca.sh generate 2>&1 | tee /var/log/sk8/ca.log' 53 | 54 | # Generate an SSH key pair if one is not available. 55 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-ssh.sh 2>&1 | tee /var/log/sk8/ssh.log' 56 | 57 | # This command generates a kubeconfig that can be used to access the cluster 58 | # (if EXTERNAL_FQDN is set) or the control plane nodes. The kubeconfig file 59 | # is assigned to the guestinfo property "sk8.kubeconfig". 60 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-kubeconfig.sh 2>&1 | tee /var/log/sk8/kubeconfig.log' 61 | 62 | # Create the cluster. 63 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-cluster.sh 2>&1 | tee /var/log/sk8/cluster.log' 64 | 65 | # This command checks to see if there were custom/updated versions of the 66 | # sk8-guestinfo and sk8 scripts specified in the OVF data. If there 67 | # were then this command will download the new versions and replace the 68 | # ones on disk prior to the commands being executed. 69 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-update.sh 2>&1 | tee /var/log/sk8/update.log' 70 | 71 | # This program reads the OVF environment for sk8 configuration data 72 | # and writes the sk8 configuration file to /etc/default/sk8. 73 | ExecStartPre=/bin/sh -c '/var/lib/sk8/sk8-guestinfo.sh 2>&1 | tee /var/log/sk8/guestinfo.log' 74 | 75 | # The sk8 script is responsible for turning up the Kubernetes cluster. 76 | ExecStart=/bin/sh -c '/var/lib/sk8/sk8.sh 2>&1 | tee /var/log/sk8/sk8.log' 77 | 78 | # Update the load balancer if configured to do so. 79 | ExecStartPost=/bin/sh -c '/var/lib/sk8/sk8-load-balancer.sh connect 2>&1 | tee -a /var/log/sk8/load-balancer.log' 80 | 81 | # This command ensures that this service is not run on subsequent boots. 82 | ExecStartPost=/bin/touch /var/lib/sk8/.sk8.service.done 83 | 84 | # Finally, this command moves the sk8 configuration file to the 85 | # /tmp directory so the file is cleaned up automatically the next time 86 | # the temp space is reclaimed. This ensures the configuration file is 87 | # still available for debugging errors, but *will* get cleaned up 88 | # eventually. 89 | ExecStartPost=/bin/mv -f /etc/default/sk8 /tmp/sk8.defaults 90 | -------------------------------------------------------------------------------- /ova/sysprep/sysprep-centos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # posix compliant 4 | # verified by https://www.shellcheck.net 5 | 6 | # Load the sk8 commons library. 7 | # shellcheck disable=SC1090 8 | . "$(pwd)/sk8-common.sh" 9 | 10 | _done_file="$(pwd)/.$(basename "${0}").done" 11 | [ ! -f "${_done_file}" ] || exit 0 12 | 13 | is_true "$(rpc_get SYSPREP)" || exit 0 14 | touch "${_done_file}" 15 | 16 | service rsyslog stop && \ 17 | service auditd stop && \ 18 | package-cleanup -y --oldkernels --count=1 && \ 19 | yum clean -y all && \ 20 | logrotate -f /etc/logrotate.conf && \ 21 | printf '' >/etc/machine-id && \ 22 | rm -fr /var/lib/cloud/instances && \ 23 | rm -f /var/log/*-???????? /var/log/*.gz && \ 24 | rm -f /var/log/dmesg.old && \ 25 | rm -rf /var/log/anaconda && \ 26 | cat /dev/null > /var/log/audit/audit.log && \ 27 | cat /dev/null > /var/log/wtmp && \ 28 | cat /dev/null > /var/log/lastlog && \ 29 | cat /dev/null > /var/log/grubby && \ 30 | rm -f /etc/udev/rules.d/70* && \ 31 | sed -i '/^(HWADDR|UUID)=/d' /etc/sysconfig/network-scripts/ifcfg-e* && \ 32 | rm -rf /tmp/* && \ 33 | rm -rf /var/tmp/* && \ 34 | rm -rf /etc/ssh/*key* && \ 35 | rm -f /root/anaconda-ks.cfg && \ 36 | rm -rf /var/log && mkdir -p /var/log && \ 37 | echo 'clearing history & sealing the VM...' && \ 38 | unset HISTFILE && history -c && rm -fr /root/.bash_history && \ 39 | sys-unconfig 40 | -------------------------------------------------------------------------------- /ova/sysprep/sysprep-photon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # posix compliant 4 | # verified by https://www.shellcheck.net 5 | 6 | # Load the sk8 commons library. 7 | # shellcheck disable=SC1090 8 | . "$(pwd)/sk8-common.sh" 9 | 10 | _done_file="$(pwd)/.$(basename "${0}").done" 11 | [ ! -f "${_done_file}" ] || exit 0 12 | 13 | is_true "$(rpc_get SYSPREP)" || exit 0 14 | touch "${_done_file}" 15 | 16 | printf '' >/etc/machine-id && \ 17 | rm -fr /var/lib/cloud/instances && \ 18 | rm -rf /etc/ssh/*key* && \ 19 | rm -fr /var/log && mkdir -p /var/log && \ 20 | echo 'clearing history & sealing the VM...' && \ 21 | unset HISTFILE && history -c && rm -fr /root/.bash_history && \ 22 | shutdown -P now -------------------------------------------------------------------------------- /uml/.gitignore: -------------------------------------------------------------------------------- 1 | /*.svg -------------------------------------------------------------------------------- /uml/Makefile: -------------------------------------------------------------------------------- 1 | # simple-kubernetes-test-environment 2 | # 3 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # This product is licensed to you under the Apache 2.0 license (the "License"). 6 | # You may not use this product except in compliance with the Apache 2.0 License. 7 | # 8 | # This product may include a number of subcomponents with separate copyright 9 | # notices and license terms. Your use of these subcomponents is subject to the 10 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 11 | # file. 12 | 13 | all: build 14 | 15 | PUML:=$(wildcard *.puml) 16 | SVGS:=$(patsubst %.puml,%.svg,$(PUML)) 17 | 18 | %.svg: %.puml 19 | plantuml -tsvg $? 20 | 21 | build: $(SVGS) 22 | 23 | upload: $(SVGS) 24 | aws s3 cp . s3://cnx.vmware/cicd/sk8/svg/ \ 25 | --recursive --exclude "*" \ 26 | $(foreach f,$(SVGS),--include "$(f)") \ 27 | --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers 28 | 29 | .PHONY: upload 30 | -------------------------------------------------------------------------------- /uml/install-process.puml: -------------------------------------------------------------------------------- 1 | /' 2 | simple-kubernetes-test-environment 3 | 4 | Copyright (c) 2018 VMware, Inc. All Rights Reserved. 5 | 6 | This product is licensed to you under the Apache 2.0 license (the "License"). 7 | You may not use this product except in compliance with the Apache 2.0 License. 8 | 9 | This product may include a number of subcomponents with separate copyright 10 | notices and license terms. Your use of these subcomponents is subject to the 11 | terms and conditions of the subcomponent's license, as noted in the LICENSE 12 | file. 13 | '/ 14 | 15 | @startuml install-process 16 | right header 17 | sk8 18 | endheader 19 | right footer 20 | 21 | akutz at VMware 22 | https://github.com/vmware/simple-k8s-test-env 23 | endfooter 24 | 25 | title Generic execution of sk8\n 26 | 27 | start 28 | :parse command line args; 29 | :load config from ""/etc/default/sk8""; 30 | :add ""/opt/bin"" to ""PATH""; 31 | :generate ""/opt/bin/node-type"" command; 32 | :configure the shell prompt; 33 | repeat 34 | :is network online?; 35 | repeat while (network is not available) 36 | :update guest OS packages; 37 | :parse kubernetes version; 38 | partition "Download Binaries" { 39 | :jq; 40 | :etcd; 41 | if (node is member of control plane?) then (yes) 42 | :kubernetes server; 43 | :nginx; 44 | :coredns; 45 | else (no) 46 | endif 47 | if (node can schedule workloads) then (yes) 48 | :kubernetes node; 49 | if (install e2e conformance tests?) then (yes) 50 | :kubernetes test; 51 | else (no) 52 | endif 53 | :containerd; 54 | :crictl; 55 | :runc; 56 | :runsc; 57 | :CNI plug-ins; 58 | else (no) 59 | endif 60 | } 61 | :create ""k8s-admin"" group; 62 | :configure iptables; 63 | if (network manager controls dns?) then (yes) 64 | :disable network manager dns; 65 | else (no) 66 | endif 67 | :install certificate authority; 68 | partition "Discovery" { 69 | if (node is member of control plane?) then (yes) 70 | :install etcd as systemd service; 71 | else (no) 72 | endif 73 | repeat 74 | :read etcd discovery url; 75 | repeat while (number of hosts in response is less than 76 | the number of expected control plane nodes) 77 | repeat 78 | :get etcd cluster members; 79 | repeat while (not all control plane members have joined the etcd cluster) 80 | :configure etcdctl; 81 | :grant etcd lease for sk8 properties; 82 | :upload host/node information to etcd; 83 | repeat 84 | :get node info from etcd; 85 | :does actual number of nodes match expected number?; 86 | repeat while (number of nodes in etcd does not match expected number) 87 | :register A-record and reverse IP entries for 88 | self under ""/skydns"" key; 89 | :register round-robin CNAME that points to IP 90 | addresses of control plane members; 91 | if (external FQDN is defined?) then (yes) 92 | :register CNAME for external FQDN that 93 | points to internal cluster CNAME to prevent 94 | requests for the external FQDN from paper- 95 | clipping; 96 | else (no) 97 | endif 98 | if (systemd-resolved service exists?) then (yes) 99 | :disable systemd-resolved service; 100 | else (no) 101 | endif 102 | if (node is member of control plane?) then (yes) 103 | :install coredns as systemd service; 104 | :modify ""/etc/resolv.conf"" to point to self; 105 | else (no) 106 | :modify ""/etc/resolv.conf"" to point to IP 107 | addresses of control plane members; 108 | endif 109 | repeat 110 | :resolve all nodes by reverse IP lookup; 111 | repeat while (one or more nodes cannot be resolved by reverse-IP lookup) 112 | } 113 | if (node can schedule workloads) then (yes) 114 | :enable bridge module; 115 | else (no) 116 | endif 117 | :enable IP forwarding; 118 | :create static routes that point to pod networks 119 | on other nodes; 120 | if (node can schedule workloads) then (yes) 121 | :install CNI plug-ins; 122 | :install containerd as systemd service; 123 | else (no) 124 | endif 125 | if (node is member of control plane?) then (yes) 126 | :install nginx as systemd service; 127 | else (no) 128 | endif 129 | partition Kubernetes { 130 | :generate or fetched shared kubernetes assets; 131 | if (node is member of control plane?) then (yes) 132 | :install kube-apiserver as systemd service; 133 | :apply RBAC; 134 | :install kube-controller-manager as systemd service; 135 | :install kube-scheduler as systemd service; 136 | :deploy kubernetes DNS provider manifest; 137 | :deploy kubernetes cloud-provider manifest; 138 | if (install e2e conformance tests?) then (yes) 139 | :create e2e conformance test manifest that 140 | can be accessed at ""http://API_FQDN/e2e/job.yaml"" 141 | to make executing the e2e conformance suite 142 | simple and fast; 143 | else (no) 144 | endif 145 | else (no) 146 | endif 147 | if (node can schedule workloads?) then (yes) 148 | :wait for healthy kubernetes cluster; 149 | :install kubelet as systemd service; 150 | :install kube-proxy as systemd service; 151 | else (no) 152 | endif 153 | } 154 | :so long and thanks for all the fish; 155 | stop 156 | @enduml -------------------------------------------------------------------------------- /uml/node-components.puml: -------------------------------------------------------------------------------- 1 | /' 2 | simple-kubernetes-test-environment 3 | 4 | Copyright (c) 2018 VMware, Inc. All Rights Reserved. 5 | 6 | This product is licensed to you under the Apache 2.0 license (the "License"). 7 | You may not use this product except in compliance with the Apache 2.0 License. 8 | 9 | This product may include a number of subcomponents with separate copyright 10 | notices and license terms. Your use of these subcomponents is subject to the 11 | terms and conditions of the subcomponent's license, as noted in the LICENSE 12 | file. 13 | '/ 14 | 15 | @startuml node-components 16 | rectangle "Control plane node(s)\n" { 17 | agent "coredns" 18 | database "etcd" 19 | agent "nginx" 20 | agent "kube-apiserver" as kube_apiserver 21 | agent "kube-controller-manager" as kube_controller_manager 22 | agent "kube-scheduler" as kube_scheduler 23 | 24 | nginx --> kube_apiserver 25 | nginx -[hidden]-> kube_controller_manager 26 | nginx -[hidden]-> kube_scheduler 27 | coredns -right-> etcd 28 | kube_apiserver -down-> etcd 29 | kube_controller_manager -right-> kube_apiserver 30 | kube_apiserver -down-> kube_scheduler 31 | } 32 | 33 | rectangle "Worker node(s)\n" { 34 | agent "kubelet" 35 | agent "kube-proxy" as kube_proxy 36 | agent "containerd" as cri 37 | agent "iptables" 38 | component "runc" 39 | component "runsc" 40 | component "cni" 41 | 42 | kube_scheduler -right-> kubelet 43 | kubelet -[hidden]right-> kube_proxy 44 | kubelet -right-> cri 45 | cri <-up-> runc 46 | cri <-up-> runsc 47 | cri <-up-> cni 48 | iptables -[hidden]right-> cni 49 | iptables <-down- kube_proxy 50 | } 51 | 52 | @enduml -------------------------------------------------------------------------------- /vagrant/.gitignore: -------------------------------------------------------------------------------- 1 | /.bin 2 | .vagrant 3 | *.crt 4 | *.key 5 | kubeconfig 6 | *console.log 7 | -------------------------------------------------------------------------------- /vagrant/hack/dig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # A wrapper for dig that queries the first node in the cluster. 20 | # 21 | 22 | export PROGRAM="dig" 23 | 24 | # Load the commons library. 25 | # shellcheck disable=SC1090 26 | . "$(dirname "${0}")/common.sh" 27 | 28 | #dns_port="$(cat "${DNSCONFIG}")" 29 | #exec dig +domain=sk8 -4 +tcp @127.0.0.1 -p "${dns_port}" "${@}" 30 | 31 | for a in "${@}"; do 32 | { [ -z "${args}" ] && args="'${a}'"; } || args="${args} '${a}'" 33 | done 34 | 35 | exec vagrant ssh --no-tty c01 -c "dig +domain=sk8 -4 +tcp @127.0.0.1 ${args}" 36 | -------------------------------------------------------------------------------- /vagrant/hack/kubectl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # A wrapper for kubectl that queries the first node in the cluster. 20 | # 21 | 22 | export PROGRAM="kubectl" 23 | 24 | # Load the commons library. 25 | # shellcheck disable=SC1090 26 | . "$(dirname "${0}")/common.sh" 27 | 28 | #exec kubectl "${@}" 29 | for a in "${@}"; do 30 | { [ -z "${args}" ] && args="'${a}'"; } || args="${args} '${a}'" 31 | done 32 | 33 | exec vagrant ssh --no-tty c01 -c "kubectl ${args}" 34 | -------------------------------------------------------------------------------- /vagrant/hack/vagrant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # simple-kubernetes-test-environment 4 | # 5 | # Copyright (c) 2018 VMware, Inc. All Rights Reserved. 6 | # 7 | # This product is licensed to you under the Apache 2.0 license (the "License"). 8 | # You may not use this product except in compliance with the Apache 2.0 License. 9 | # 10 | # This product may include a number of subcomponents with separate copyright 11 | # notices and license terms. Your use of these subcomponents is subject to the 12 | # terms and conditions of the subcomponent's license, as noted in the LICENSE 13 | # file. 14 | 15 | # posix compliant 16 | # verified by https://www.shellcheck.net 17 | 18 | # 19 | # A wrapper for vagrant that chooses its data directory from the input flags. 20 | # 21 | 22 | export PROGRAM="vagrant" 23 | _0d="$(dirname "${0}")" 24 | 25 | # Load the commons library. 26 | # shellcheck disable=SC1090 27 | . "$(dirname "${0}")/common.sh" 28 | 29 | box_out() { 30 | { [ "${box}" = "vmware/photon" ] && tail -n +3 | cat; } || cat 31 | } 32 | 33 | get_system_pods() { 34 | vagrant ssh --no-tty c01 \ 35 | -c "kubectl -n kube-system get pods" 2>/dev/null | box_out 36 | } 37 | 38 | get_cluster_status() { 39 | vagrant ssh --no-tty c01 -c "kubectl get all" | box_out 40 | } 41 | 42 | get_component_status() { 43 | vagrant ssh --no-tty c01 -c "kubectl get cs" | box_out 44 | } 45 | 46 | get_nodes() { 47 | vagrant ssh --no-tty c01 -c "kubectl get nodes" | box_out 48 | } 49 | 50 | kube_dns_running() { 51 | get_system_pods | grep -q 'kube-dns.\{0,\}[[:space:]]Running' 52 | } 53 | 54 | wait_until_cluster_is_online() { 55 | printf '\nwaiting for the cluster to finish coming online...' 56 | _i=0 && while [ "${_i}" -lt "300" ] && ! kube_dns_running; do 57 | printf '.'; sleep 1; _i=$((_i+1)) 58 | done 59 | [ "${_i}" -lt "300" ] || fatal "timed out" 60 | echo; echo 61 | } 62 | 63 | tail_log() { 64 | vagrant ssh --no-tty c01 -c 'sudo /var/lib/sk8/tail-log.sh' | box_out || \ 65 | fatal "failed to follow cluster deployment progress" 66 | } 67 | 68 | vagrant_up_slowly() { 69 | { vagrant up --provision-with init-guest && \ 70 | vagrant provision --provision-with file,init-sk8 && \ 71 | vagrant provision --provision-with start-sk8; } || \ 72 | fatal "vagrant up failed" 73 | } 74 | 75 | print_congrats() { 76 | echo 'CLUSTER ONLINE' 77 | echo '==============' 78 | get_cluster_status && echo 79 | echo 'COMPONENT STATUS' 80 | echo '================' 81 | get_component_status && echo 82 | echo 'NODES' 83 | echo '=====' 84 | get_nodes && echo 85 | echo 'SYSTEM PODS' 86 | echo '===========' 87 | get_system_pods && echo 88 | cat <&1 | tee /var/log/sk8/sk8.log' 24 | 25 | # This command ensures that this service is not run on subsequent boots. 26 | ExecStartPost=/bin/touch /var/lib/sk8/.sk8.service.done 27 | 28 | # Add the vagrant user to the k8s-admin group. 29 | ExecStartPost=/bin/bash -c 'usermod -aG k8s-admin vagrant || true' 30 | 31 | # Finally, this command moves the sk8 configuration file to the 32 | # /tmp directory so the file is cleaned up automatically the next time 33 | # the temp space is reclaimed. This ensures the configuration file is 34 | # still available for debugging errors, but *will* get cleaned up 35 | # eventually. 36 | ExecStartPost=/bin/mv -f /etc/default/sk8 /tmp/sk8.defaults -------------------------------------------------------------------------------- /vagrant/tail-log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This script is not meant to be used locally. It's copied to the 5 | # Vagrant boxes and used to tail the sk8 log from the client. 6 | # The log is followed only until the sk8 process is no longer 7 | # writing to the log. 8 | # 9 | log_file=/var/log/sk8/sk8.log 10 | done_file=/var/lib/sk8/.sk8.service.done 11 | printf 'waiting for sk8 to start...' 12 | i=0 && while [ "${i}" -lt "300" ] && \ 13 | [ -z "${pid}" ] && \ 14 | [ ! -f "${done_file}" ]; do 15 | if ! pid=$(sudo fuser /var/log/sk8/sk8.log 2>/dev/null | \ 16 | awk '{print $NF;exit}' | tr -d '\n\r'); then 17 | printf '.'; sleep 1; i=$((i+1)) 18 | fi 19 | done; echo 20 | if [ -f "${done_file}" ]; then 21 | exec cat "${log_file}" 22 | elif [ -z "${pid}" ]; then 23 | echo "timed out" 1>&2 && exit 1 24 | else 25 | exec tail --pid="${pid}" -f "${log_file}" 26 | fi --------------------------------------------------------------------------------