|
| 1 | +# Dev Box "Photon Controller" |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +Dev Box uses [Vagrant], [Docker] and [Photon OS] to create a local VM and install the Photon Controller components in docker containers. These components are installed from source located in the local working copy. This allows you to make a change locally without committing it and testing it end to end. |
| 6 | + |
| 7 | +All of the components are compiled, packaged and started in their own containers inside the VM. The process does not make any changes to your working copy. |
| 8 | + |
| 9 | +The logs from the Photon Controller services are synced to the host and are located in `log` directory. |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +* vagrant (http://www.vagrantup.com/downloads.html) |
| 14 | + |
| 15 | +Steps to install: https://docs.vagrantup.com/v2/installation/index.html |
| 16 | + |
| 17 | +* virtualbox (https://www.virtualbox.org/wiki/Downloads) |
| 18 | + |
| 19 | +Steps to install: https://www.virtualbox.org/manual/ch01.html#intro-installing |
| 20 | + |
| 21 | +* vagrant plugin for Photon OS (http://artifactory.ec.eng.vmware.com/artifactory/vagrant-box-with-images/develop/27/vagrant-guests-photon-0.0.1.gem) |
| 22 | + |
| 23 | +The plugin is downloaded and installed by the install_photon_plugin.sh script listed below. |
| 24 | + |
| 25 | +## Instructions |
| 26 | + |
| 27 | +### Starting Devbox |
| 28 | + |
| 29 | +#### Photon OS plugin for Vagrant |
| 30 | + |
| 31 | +In order to control the Dev Box VM, Vagrant needs a plugin for Photon OS. The plugin is installed as a gem directly into Vagrant. Before starting Dev Box, run the following script to install the plugin: |
| 32 | + |
| 33 | + install_photon_plugin.sh |
| 34 | + |
| 35 | +The script can be invoked repeatedly if you want to make sure the plugin is installed or if you want to reinstall the plugin. |
| 36 | + |
| 37 | +#### Start and provision Dev Box |
| 38 | + |
| 39 | +Dev Box configuration and startup code is located in the Dev Box directory (`<code>/photon-devbox`). The following command starts Dev Box: |
| 40 | + |
| 41 | + vagrant up |
| 42 | + |
| 43 | +#### Setting Vagrant box name and location |
| 44 | + |
| 45 | +Dev Box Vagrant box file is located at `https://bintray.com/artifact/download/vmware-esxcloud/public/<build #>/resource/photon-devbox.box`. It is downloaded on-demand and cached locally. It is also associated with a name. Both name and URL can be redirected by using environment variables (`DEVBOX_NAME` and `DEVBOX_URL`). |
| 46 | + |
| 47 | +### Checking Dev Box status |
| 48 | + |
| 49 | +Dev Box status can be checked with the following command: |
| 50 | + |
| 51 | + vagrant status |
| 52 | + |
| 53 | +The API Frontend has been forwarded locally to port 9080. Status can be checked with the following commands: |
| 54 | + |
| 55 | + curl http://localhost:9080/status/ |
| 56 | + curl http://<devbox ip>:9000/status/ |
| 57 | + |
| 58 | +By default Dev Box starts with a private IP address (172.31.253.66). As described below, a public or a specific private IP address can be configured using environment variables. |
| 59 | + |
| 60 | +### Accessing Dev Box |
| 61 | + |
| 62 | +You can go into the Dev Box VM using the vagrant ssh command. |
| 63 | + |
| 64 | + vagrant ssh [photon] |
| 65 | + |
| 66 | +### Stopping and destroying Dev Box |
| 67 | + |
| 68 | + vagrant destroy [-f] [photon] |
| 69 | + |
| 70 | +Destroying Dev Box is the recommended way of cleaning up. |
| 71 | + |
| 72 | +### Recreate without destroying |
| 73 | + |
| 74 | +Vagrant supports reprovisioning and reloading of Dev Box VMs, but in order to perform complete cleanup, it is not recommended to use the Vagrant reload feature (`vagrant reload [photon]`). It is recommended to destroy and create the Dev Box VM as described above. |
| 75 | + |
| 76 | +### Emergency VM cleanup |
| 77 | + |
| 78 | +If for some reason Dev Box VM cannot be destroyed via Vagrang command (`vagrant destroy [-f] [photon]`), follow the next steps to manually power off and delete the VM: |
| 79 | + |
| 80 | +* Identify the running VMs |
| 81 | + |
| 82 | + `vboxmanage list runningvms` |
| 83 | + |
| 84 | +Sample output may look like this: |
| 85 | + |
| 86 | + "devbox-photon_photon_1446051688357_62198" {4b963230-c8b4-434d-b70d-39270373fa65} |
| 87 | + |
| 88 | +Notice the machine ID ("devbox-photon_photon_1446051688357_62198"). |
| 89 | + |
| 90 | +* If the VM is not running, identify it with the following command: |
| 91 | + |
| 92 | + `vboxmanage list vms` |
| 93 | + |
| 94 | +* Power off the VM: |
| 95 | + |
| 96 | + `vboxmanage controlvm <machine ID> poweroff` |
| 97 | + |
| 98 | +for example: |
| 99 | + |
| 100 | + vboxmanage controlvm devbox-photon_photon_1446051688357_62198 poweroff |
| 101 | + |
| 102 | +* Unregister the VM (with optional deletion of its artifacts) |
| 103 | + |
| 104 | + `vboxmanage unregistervm <machine ID> [--delete]` |
| 105 | + |
| 106 | +for example: |
| 107 | + |
| 108 | + vboxmanage unregistervm devbox-photon_photon_1446051688357_62198 --delete |
| 109 | + |
| 110 | +## Controlling Dev Box behavior with environment variables |
| 111 | + |
| 112 | +### Vagrant box file |
| 113 | +To override the default values of the vagrant box name and URL, define the following self-explanatory environment variables before starting Dev Box: |
| 114 | + |
| 115 | +* `DEVBOX_NAME` |
| 116 | +* `DEVBOX_URL` |
| 117 | + |
| 118 | +### IP Address |
| 119 | +By default Dev Box runs with a private IP address as part of the default configuration of VirtualBox (172.31.253.66). To specify your own private IP address define the following environment variable before starting Dev Box: |
| 120 | + |
| 121 | +* `PRIVATE_NETWORK_IP` |
| 122 | + |
| 123 | +To use a public IP address for the Dev Box, define the following environment variables before starting Dev Box: |
| 124 | + |
| 125 | +* `PUBLIC_NETWORK_IP` |
| 126 | +* `PUBLIC_NETWORK_MASK` |
| 127 | + |
| 128 | +The following self-explanatory variables are optional: |
| 129 | + |
| 130 | +* `BRIDGE_NETWORK` |
| 131 | +* `PUBLIC_NETWORK_GATEWAY` |
| 132 | + |
| 133 | +### Using Dev Box with Lightwave for authentication |
| 134 | +To enable authentication in Photon Controller services, a Lightwave STS must be installed, configured and available. In most cases a public IP address needs to be set on the Dev Box in order to access the Lightwave server. To enable authentication define the following environment variables before starting Dev Box: |
| 135 | + |
| 136 | +* `ENABLE_AUTH` - set to `true` to enable authentication, do not set or set to `false` to disable it |
| 137 | +* `PHOTON_AUTH_LS_ENDPOINT` - address of the Lightwave server |
| 138 | +* `PHOTON_AUTH_SERVER_PORT` - port of Lightwave server, currently fixed to 443 |
| 139 | +* `PHOTON_AUTH_SERVER_TENANT` - tenant (domain) of the Lightwave server |
| 140 | +* `PHOTON_SWAGGER_LOGIN_URL` - registered login URL for the client at the Lightwave server |
| 141 | +* `PHOTON_SWAGGER_LOGOUT_URL` - registered logout URL for the client at the Lightwave server |
| 142 | + |
| 143 | +### Using Dev Box with a real ESX host |
| 144 | +By default Dev Box uses an internal Photon Controller Agent, which mimics the ESX operations. To use with an actual ESX host, set the following environment variables before starting Dev Box: |
| 145 | + |
| 146 | +* `REAL_AGENT` set to `true` to use real ESX host. Do not set or set to false to use internal Agent |
| 147 | +* `ESX_IP` IP address of the ESX host |
| 148 | +* `ESX_DATASTORE` name of the data store on the ESX host to be used by Dev Box |
| 149 | + |
| 150 | +NOTE: When using real ESX host, Dev Box installs Photon Controller Agent's VIB on it. This setting is used frequently with a public IP address of the Dev Box. |
| 151 | + |
| 152 | +### Enable syslog log entries remoting |
| 153 | +To enable sending log entries to a remote syslog endpoint (such as VMware LogInsight), use the following environment variables before starting Dev Box: |
| 154 | + |
| 155 | +* `ENABLE_SYSLOG` - set to `true` to use a remote syslog endpoint |
| 156 | +* `SYSLOG_ENDPOINT` - address of the remote syslog endpoint |
| 157 | + |
| 158 | +### Other settings |
| 159 | + |
| 160 | +* `NO_PORT_FORWARDING` - define if you want to disable the Vagrant/VirtualBox port forwarding of the services from the VM to the host machine. For details on the forwarded ports, refer to the `Vagrantfile`. In most cases forwarding is not necessary as the ports are accessible directly on the VM via its IP address. |
| 161 | +* `DEVBOX_PHOTON_MEMORY` - override the memory setting for the Dev Box VM. Default is 3072MB. |
| 162 | +* `DEVBOX_PHOTON_CPUS` - override the CPUs assigned to the Dev Box VM. Default is 4. |
| 163 | +* `PROXY_PROFILE` - Allows configuring proxy inside the Dev Box VM. Requires a proxy setting file `/etc/profile.d/proxy.sh` which is used inside the VM for setting up proxy. |
| 164 | +* `DEVBOX_NO_CLEAN_LOGS` - set if you don't want the logs directory cleaned up when bringin up Dev Box. |
| 165 | +* `DEVBOX_FORCE_PHOTON_PLUGIN_REINSTALL` - force reinstall of the Vagrant plugin for Photon OS even if it's already installed. |
| 166 | + |
| 167 | +## Remote debugging |
| 168 | +Remote debugging is enabled by default for the Java services in Dev Box. Debugger endpoints are available at the following ports: |
| 169 | + |
| 170 | +* API Frontend: 39000 |
| 171 | +* Chairman: 23000 |
| 172 | +* Root Scheduler: 23010 |
| 173 | +* Housekeeper: 26000 |
| 174 | +* Cloud Store: 29000 |
| 175 | +* Deployer: 28000 |
| 176 | + |
| 177 | +To connect the remote debugger, add a new remote debug configuration with the hostname set to Dev Box's IP address (default for private configuration is `172.31.253.66`) and the corresponding service port. |
| 178 | + |
| 179 | +[Vagrant]: http://vagrantup.com |
| 180 | +[Docker]: http://www.docker.com |
| 181 | +[Photon OS]: https://vmware.github.io/photon/ |
0 commit comments