├── .gitignore ├── screenshots ├── metrics.png └── dashboard.png ├── Vagrantfile ├── vcenter-55-simulator.json ├── README.md └── scripts └── vcenter-55-simulator-setup.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | output/ 3 | output-vmware-vmx/ 4 | 5 | -------------------------------------------------------------------------------- /screenshots/metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tehranian/vagrant-vcenter-simulator/HEAD/screenshots/metrics.png -------------------------------------------------------------------------------- /screenshots/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tehranian/vagrant-vcenter-simulator/HEAD/screenshots/dashboard.png -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | 4 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 5 | config.vm.box = "vcenter-55-simulator" 6 | 7 | # VAMI port 8 | config.vm.network "forwarded_port", guest: 5480, host: 5480 9 | # The beloved vSphere Web Client UI 10 | config.vm.network "forwarded_port", guest: 9443, host: 9443 11 | end 12 | -------------------------------------------------------------------------------- /vcenter-55-simulator.json: -------------------------------------------------------------------------------- 1 | { 2 | "provisioners": [ 3 | { 4 | "type": "shell", 5 | "script": "scripts/vcenter-55-simulator-setup.sh" 6 | } 7 | ], 8 | "builders": [ 9 | { 10 | "type": "vmware-vmx", 11 | "headless": true, 12 | "source_path": "output/vcsa-55.vmx", 13 | "shutdown_command": "/sbin/shutdown -h now", 14 | "ssh_username": "root", 15 | "ssh_password": "vmware", 16 | "vm_name": "vcenter-55-simulator", 17 | "vmx_data": { 18 | "numvcpus": "4", 19 | "memsize": "4096", 20 | "ethernet0.connectionType": "nat" 21 | } 22 | } 23 | ], 24 | "post-processors": [ 25 | { 26 | "type": "vagrant", 27 | "output": "output/vcenter-55-simulator.box" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Packer template & setup script to create a Vagrant box of VMware 2 | vCenter Server Appliance running in simulator mode. 3 | 4 | The resulting Vagrant box will have a simulated inventory of 5 | several Hosts, Clusters, VMs, etc with metrics also being simulated. 6 | 7 | 8 | Requirements 9 | ============ 10 | 11 | * [ovftool](https://my.vmware.com/web/vmware/details?productId=352&downloadGroup=OVFTOOL350) 12 | * [packer](http://www.packer.io) 13 | * An OVA of VMware vCenter Server Appliance. Contact your VMware reseller for details :) 14 | 15 | Example 16 | ======= 17 | 18 | ``` 19 | $ ./build.sh -u VMware-vCenter-Server-Appliance-5.5.0.5100-1312297_OVF10.ova 20 | The manifest validates 21 | Source is signed and the certificate validates 22 | Opening VMX target: output/vcsa-55.vmx 23 | Writing VMX file: output/vcsa-55.vmx 24 | Transfer Completed 25 | Completed successfully 26 | + packer build vcenter-55-simulator.json 27 | vmware-vmx output will be in this color. 28 | 29 | ==> vmware-vmx: Cloning source VM... 30 | ==> vmware-vmx: Starting virtual machine... 31 | 32 | ... < snip > ... 33 | 34 | vmware-vmx (vagrant): Compressing: vcsa-55-disk1-cl1.vmdk 35 | vmware-vmx (vagrant): Compressing: vcsa-55-disk2-cl1.vmdk 36 | Build 'vmware-vmx' finished. 37 | 38 | ==> Builds finished. The artifacts of successful builds are: 39 | --> vmware-vmx: 'vmware' provider box: output/vcenter-55-simulator.box 40 | ``` 41 | 42 | Screen Shots 43 | ============ 44 | 45 | All of the entities & performance metrics below were automatically generated 46 | by the simulator: 47 | 48 | ![vSphere Web Client Dashboard](https://github.com/tehranian/vagrant-vcenter-simulator/raw/master/screenshots/dashboard.png) 49 | 50 | ![Showing off VM metrics](https://github.com/tehranian/vagrant-vcenter-simulator/raw/master/screenshots/metrics.png) 51 | -------------------------------------------------------------------------------- /scripts/vcenter-55-simulator-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | 6 | # Add vagrant user & vagrant ssh keys 7 | /usr/sbin/groupadd vagrant 8 | /usr/sbin/useradd vagrant -g vagrant -G wheel -s /bin/bash 9 | echo "vagrant"|passwd --stdin vagrant 10 | echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers 11 | 12 | mkdir -pm 700 /home/vagrant/.ssh 13 | wget --no-check-certificate \ 14 | 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' \ 15 | -O /home/vagrant/.ssh/authorized_keys 16 | chmod 0600 /home/vagrant/.ssh/authorized_keys 17 | chown -R vagrant:vagrant /home/vagrant 18 | 19 | 20 | # VMware configures sshd MaxSessions at 1 where the default is 10. this 21 | # breaks Vagrant. Remove the VMware configuration and set back to default 22 | # configuration. See: https://github.com/mitchellh/vagrant/issues/4044 23 | sed -i '/MaxSessions.*$/d' /etc/ssh/sshd_config 24 | 25 | 26 | # Install VMware HGFS driver for shared folders or else Vagrant will complain 27 | zypper addrepo --refresh --no-gpgcheck \ 28 | http://packages.vmware.com/tools/esx/5.5u1/sles11.2/x86_64/ vmware-tools 29 | zypper install -y vmware-tools-esx-nox vmware-tools-hgfs 30 | 31 | 32 | # Remove traces of mac address from network configuration 33 | rm -rfv /etc/udev/rules.d/70-persistent-net.rules \ 34 | /lib/udev/rules.d/75-persistent-net-generator.rules 35 | 36 | 37 | # Perform the initial vCenter configuration that normally needs to be done 38 | # via ths VAMI WWW UI. 39 | # @see: http://www.virtuallyghetto.com/2012/02/automating-vcenter-server-appliance.html 40 | echo "Performing initial vCenter configuration" 41 | echo "This will take several minutes ..." 42 | /usr/sbin/vpxd_servicecfg eula accept 43 | /usr/sbin/vpxd_servicecfg timesync write tools 44 | echo "Configuring DB ..." 45 | /usr/sbin/vpxd_servicecfg db write embedded 46 | echo "Configuring SSO ..." 47 | /usr/sbin/vpxd_servicecfg sso write embedded 48 | echo "Starting VPXD ..." 49 | /usr/sbin/vpxd_servicecfg service start 50 | 51 | 52 | # Needed otherwise vagrant's changing of the VM's hostname will 53 | # break SSL certs. 54 | # @see: http://www.virtuallyghetto.com/2013/04/automating-ssl-certificate-regeneration.html 55 | echo only-once > /etc/vmware-vpx/ssl/allow_regeneration 56 | 57 | 58 | # Setup vCenter Simulator config files. 59 | 60 | cat > /etc/vmware-vpx/vcsim/model/vcsim-vagrant.cfg < 62 | true 63 | true 64 | vcsim/model/initInventory-vagrant.cfg 65 | true 66 | vcsim/model/PerfCounterInfo.xml 67 | vcsim/model/metricMetadata.cfg 68 | 69 | EOF 70 | 71 | cat > ./insert_metricMd.txt < 73 | Triangle 74 | 0,200,50,300,0 75 | 600,300,600,900 76 | 77 | EOF 78 | 79 | sed -i '//r insert_metricMd.txt' \ 80 | /etc/vmware-vpx/vcsim/model/metricMetadata.cfg 81 | rm -v ./insert_metricMd.txt 82 | 83 | cat > /etc/vmware-vpx/vcsim/model/initInventory-vagrant.cfg < 85 | 86 | 1 87 | 0 88 | 0 89 | 0 90 | 2 91 | 8 92 | 8 93 | 8 94 | 6 95 | 0 96 | 97 | 98 | 2 99 | true 100 | 101 | EOF 102 | 103 | vmware-vcsim-start /etc/vmware-vpx/vcsim/model/vcsim-vagrant.cfg 104 | 105 | 106 | # setup the MOTD to tell people how to reconfigure vcsim 107 | cat > /etc/motd <