├── .gitignore
├── README.md
├── doc
├── centos7.md
├── images
│ ├── arch.png
│ ├── box-start.png
│ ├── virt-manager.png
│ └── virt-net.png
├── notes.md
├── scripts
│ ├── filter.table
│ └── nat.table
└── vmware.md
├── files
├── aliasrc
├── build.sh
├── createtmplt.sh
├── govc
├── libvhd.so.1.0
├── result.py
├── setup-systemvmtemplate.sh
├── smoketests.sh
├── sudoer.mbx
├── systemvm-map.json
├── vhd-util
└── xenfix.sh
├── marvin
├── examples
│ ├── kvm.marvin.cfg
│ ├── vmware.marvin.cfg
│ └── xenserver.marvin.cfg
├── kvm.cfg
├── vmw.cfg
└── xen.cfg
├── mbx
├── monkeynet.xml
├── packages
└── .gitkeep
├── templates
├── cache
│ └── .gitkeep
├── md5sum.txt
└── xmls
│ ├── mbxt-kvm-el7.xml
│ ├── mbxt-kvm-el8.xml
│ ├── mbxt-kvm-el9.xml
│ ├── mbxt-vmware67u3.xml
│ ├── mbxt-vmware7.xml
│ ├── mbxt-vmware8.xml
│ ├── mbxt-vmware8u3.xml
│ ├── mbxt-xcpng76.xml
│ ├── mbxt-xcpng82.xml
│ ├── mbxt-xcpng83.xml
│ ├── mbxt-xenserver71.xml
│ └── mbxt-xenserver84.xml
└── vpn
├── ovpn-data
└── .keep
└── run.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | boxes/boxes.list
2 | boxes/**
3 | templates/*.qcow2
4 | templates/cache/*
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mbx 🐒📦
2 |
3 |
4 |
5 | MonkeyBox `mbx` enables building CloudStack packages and deploying CloudStack
6 | dev and qa environment using pre-built DHCP-enabled VM templates.
7 |
8 | Table of Contents
9 | =================
10 |
11 | * [Architecture](#architecture)
12 | * [Storage](#storage)
13 | * [Networking](#networking)
14 | * [Deployment](#deployment)
15 | * [Compatibility](#compatibility)
16 | * [Installation and Setup](#installation-and-setup)
17 | * [Setup NFS Storage](#setup-nfs-storage)
18 | * [Setup KVM](#setup-kvm)
19 | * [Setup mbx](#setup-mbx)
20 | * [Using mbx](#using-mbx)
21 | * [CloudStack Development](#cloudstack-development)
22 | * [Install Development Tools](#install-development-tools)
23 | * [Setup MySQL Server](#setup-mysql-server)
24 | * [Setup NFS storage](#setup-nfs-storage-1)
25 | * [Dev: Build and Test CloudStack](#dev-build-and-test-cloudstack)
26 | * [Debugging CloudStack](#debugging-cloudstack)
27 | * [Contributing](#contributing)
28 | * [Troubleshooting](#troubleshooting)
29 | * [iptables](#iptables)
30 |
31 | ## Architecture
32 |
33 | 
34 |
35 | An `mbx` environment consists of VMs that runs the CloudStack management server
36 | and hypervisor hosts. These VMs are provisioned on a local host-only `monkeynet`
37 | network which is a /16 nat-ed RFC1918 IPv4 network. The diagram above shows how
38 | nested guest VMs and virtual router are plugged in nested-virtual networks that
39 | run in a nested KVM host VM.
40 |
41 | To learn more about CloudStack as a user, you may read:
42 |
43 | https://github.com/shapeblue/hackerbook/blob/main/0-init.md
44 |
45 | https://github.com/shapeblue/hackerbook/blob/main/1-user.md
46 |
47 | ### Storage
48 |
49 | `mbx` requires NFS storage to be setup and exported for the base path
50 | `/export/testing` for environment-specific primary and secondary storages.
51 |
52 | A typical `mbx` environment upon deployment creates two primary storage
53 | directories (`primary1` and `primary2`) and one secondary storage directory
54 | (`secondary`). The secondary storage directory is seeded with supported
55 | CloudStack version-specific `systemvmtemplates` if necessary when the env is
56 | launched using `mbx launch`. The seeded `systemvmtemplate` is then used to
57 | create system VMs such as the Secondary-Storage VM, Console-Proxy VM and Virtual
58 | Router in an `mbx` environment.
59 |
60 | ### Networking
61 |
62 | `mbx` requires a local 172.20.0.0/16 natted network such that the VMs on this
63 | network are only accessible from the workstation/host but not by the outside
64 | network. The `mbx init` command initialises this network.
65 |
66 | External Network
67 | . +-----------------+
68 | | virbr1 | MonkeyBox VM1 |
69 | | +--| IP: 172.20.0.10 |
70 | +-----------------+ | +-----------------+
71 | | Host x.x.x.x |--+
72 | | IP: 172.20.0.1 | | +-----------------+
73 | +-----------------+ +--| MonkeyBox VM2 |
74 | | IP: 172.20.x.y |
75 | +-----------------+
76 |
77 | The 172.20.0.0/16 RFC1918 private network is used, as the other 192.168.x.x and
78 | 10.x.x.x CIDRs may already be in use by VPN, lab resources and office/home networks.
79 |
80 | To keep the setup simple, all MonkeyBox VMs have a single NIC which can be
81 | used as a single physical network in CloudStack that has the public, private,
82 | management/control and storage networks. A complex setup is possible by adding
83 | multiple virtual networks and nics on them.
84 |
85 | ### Deployment
86 |
87 | For QA env, `mbx` will deploy a single `mgmt` VM that runs the management
88 | server, the usage server, MySQL server, marvin integration tests etc. and two
89 | hypervisor host VMs.
90 |
91 | For Dev env, `mbx` will deploy a single hypervisor host VM and the management
92 | server, usage server, MySQL server etc. are all run from the workstation/host by
93 | the developer.
94 |
95 | For both QA and Dev environments, the environment-specific NFS storage are
96 | generally directories under `/export/testing` which serve as both primary and
97 | secondary storage.
98 |
99 | The `mbx` templates are initialised and downloaded at
100 | `/export/monkeybox/templates/`.
101 |
102 | The `mbx` environments, their configurations and VM disks are hosted at
103 | `/export/monkeybox/boxes/`.
104 |
105 | ## Compatibility
106 |
107 | Host requirements:
108 | - Ubuntu 22.04 LTS (recommended) or EL8/9**
109 | - Recommended 32GB RAM with Intel VT-x or AMD-V enabled 4+cores CPU
110 | - Uninstall any other hypervisor software (such as VMware workstation, VirtualBox)
111 |
112 | **Note: `mbx` has been tested and developed on Ubuntu 20.04 and 22.04 LTS; VMware environment require vmxnet3 which may not be supported on EL environments
113 |
114 | Supported Management Server (Templates):
115 | - EL7 (CentOS 7)
116 | - EL8 (AlmaLinux 8)
117 | - EL9 (AlmaLinux 9)
118 |
119 | Supported Hypervisors (Templates):
120 | - KVM: EL7, EL8, EL9
121 | - VMware vSphere: 6.7u3, 7 (7.0u3), 8 (8.0)
122 | - XCP-ng: 8.2
123 | - XenServer: 7.1 LSTR
124 |
125 | Tested CloudStack versions:
126 | - 4.16
127 | - 4.17
128 | - 4.18
129 |
130 | - MBX QA environment deployment supported with CloudStack versions: 4.11 or later.
131 | - MBX development supported with CloudStack version 4.16 and later.
132 | - Smoketests supported CloudStack versions: 4.16 or later.
133 |
134 | Note: legacy CloudStack releases older than v4.11 that don't have
135 | `cloudstack-marvin` package will not work.
136 |
137 | Refer to https://docs.cloudstack.apache.org for CloudStack version-specific
138 | hypervisor and distro compatibility matrix.
139 |
140 | ## Installation and Setup
141 |
142 | Video: https://shapeblue-engineering-videos.s3.eu-west-1.amazonaws.com/mbx/mbx-installation.mp4
143 |
144 | `mbx` requires:
145 |
146 | - NFS storage
147 | - (Baremetal) QEMU/KVM host for running nested VMs (Ubuntu and CentOS have been tested)
148 | - Docker for building CloudStack packages: https://docs.docker.com/engine/install/ubuntu/
149 |
150 | Additional notes:
151 | - Default password for all `mbx` templates for the root user is `P@ssword123`.
152 | - Default password for CloudStack `admin` user is `password`.
153 |
154 | ### Setup NFS Storage
155 |
156 | On Ubuntu:
157 |
158 | apt-get install nfs-kernel-server quota sshpass wget jq bc
159 | echo "/export *(rw,sync,no_root_squash,no_subtree_check)" > /etc/exports
160 | mkdir -p /export/testing
161 | exportfs -a
162 | sed -i -e 's/^RPCMOUNTDOPTS="--manage-gids"$/RPCMOUNTDOPTS="-p 892 --manage-gids"/g' /etc/default/nfs-kernel-server
163 | sed -i -e 's/^STATDOPTS=$/STATDOPTS="--port 662 --outgoing-port 2020"/g' /etc/default/nfs-common
164 | echo "NEED_STATD=yes" >> /etc/default/nfs-common
165 | sed -i -e 's/^RPCRQUOTADOPTS=$/RPCRQUOTADOPTS="-p 875"/g' /etc/default/quota
166 | service nfs-kernel-server restart
167 |
168 | On EL8 (Rocky Linux 8):
169 |
170 | dnf install -y epel-release
171 | dnf install nfs-utils sshpass wget jq bc
172 | echo "/export *(rw,sync,no_root_squash,no_subtree_check)" > /etc/exports
173 | mkdir -p /export/testing
174 |
175 | # Add the following to /etc/sysconfig/nfs
176 | LOCKD_TCPPORT=32803
177 | LOCKD_UDPPORT=32769
178 | MOUNTD_PORT=892
179 | RQUOTAD_PORT=875
180 | STATD_PORT=662
181 | STATD_OUTGOING_PORT=2020
182 |
183 | # Start NFS and rpcbind
184 | systemctl enable --now rpcbind
185 | systemctl enable --now nfs-server
186 |
187 | # Disable/configure firewalld as necessary
188 | systemctl disable --now firewalld
189 |
190 | ### Setup KVM
191 |
192 | On Ubuntu:
193 |
194 | apt-get install qemu-kvm libvirt-daemon libvirt-daemon-system libvirt-clients bridge-utils virtinst cpu-checker libnss-libvirt sysfsutils
195 | kvm-ok
196 |
197 | On EL8 (Rocky Linux 8):
198 |
199 | yum install bridge-utils net-tools chrony qemu-kvm qemu-img libvirt libvirt-daemon libvirt-daemon-driver-qemu libvirt-nss virt-install
200 |
201 | On Ubuntu, fixing permissions for libvirt-qemu (for non-root users):
202 |
203 | sudo getfacl -e /export
204 | sudo setfacl -m u:libvirt-qemu:rx /export
205 |
206 | On EL8/Rocky Linux, add polkit rule to allow non-root users to use virsh (replace 'rohit' with your username):
207 |
208 | # cat /etc/polkit-1/rules.d/50-org.libvirt.unix.manage.rules
209 | polkit.addRule(function(action, subject) {
210 | if (action.id == "org.libvirt.unix.manage" &&
211 | subject.user == "rohit") {
212 | return polkit.Result.YES;
213 | polkit.log("action=" + action);
214 | polkit.log("subject=" + subject);
215 | }
216 | });
217 |
218 | Note: mbx depends on Libvirt NSS for name resolution; replace `rohit` with your username on the host.
219 |
220 | Next, add the `libvirt libvirt_guest` in the nss config file, following so that `grep -w 'hosts:' /etc/nsswitch.conf` returns: (note: ensure the same order as below)
221 |
222 | files libvirt libvirt_guest dns mymachines
223 |
224 | For Ubuntu, allow non-root users to add tap interfaces to a bridge:
225 |
226 | sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper
227 | sudo bash -c 'mkdir -p /etc/qemu && echo "allow virbr0" >>/etc/qemu/bridge.conf && echo "allow virbr1" >>/etc/qemu/bridge.conf'
228 |
229 | For EL8/Rocky Linux, do this:
230 |
231 | sudo bash -c 'mkdir -p /etc/qemu-kvm && echo "allow virbr0" >> /etc/qemu-kvm/bridge.conf && echo "allow virbr1" >> /etc/qemu-kvm/bridge.conf'
232 |
233 | Install `virt-manager`, the virtual machine manager graphical tool to manage VMs on your machine.
234 |
235 | On Ubuntu:
236 |
237 | apt-get install virt-manager
238 |
239 | On EL8 (Rocky Linux 8):
240 |
241 | yum install -y virt-manager
242 |
243 | 
244 |
245 | ### Setup `mbx`
246 |
247 | git clone https://github.com/shapeblue/mbx /export/monkeybox
248 |
249 | # Enable mbx under $PATH, for bash:
250 | echo export PATH="/export/monkeybox:$PATH" >> ~/.bashrc
251 | # Enable mbx under $PATH, for zsh:
252 | echo export PATH="/export/monkeybox:$PATH" >> ~/.zshrc
253 |
254 | # Initialise `mbx` by opening in another shell:
255 | mbx init
256 |
257 | The `mbx init` should be run on first install and on upgrade which will update
258 | templates and domain xmls. When mbx init is executed on upgrade, ensure no mbx
259 | VMs are running.
260 |
261 | The `mbx init` command initialises the `monkeynet` network. You can check and confirm the
262 | network using:
263 |
264 | $ virsh net-list --all
265 | Name State Autostart Persistent
266 | ----------------------------------------------------------
267 | default active yes yes
268 | monkeynet active yes yes
269 |
270 | Alternatively, you may open `virt-viewer` manager and click on:
271 |
272 | Edit -> Connection Details -> Virtual Networks
273 |
274 | You may also manually add/configure a virtual network with NAT in 172.20.0.0/16
275 | like below:
276 |
277 | 
278 |
279 | This will create a virtual network with NAT and CIDR 172.20.0.0/16, the gateway
280 | `172.20.0.1` is also the workstation/host's virtual bridge IP. The virtual network's
281 | bridge name `virbrX` may be different and it does not matter as long as you've a
282 | NAT-enabled virtual network in 172.20.0.0/16.
283 |
284 | Your workstation/host IP address is `172.20.0.1`.
285 |
286 | ## Using `mbx`
287 |
288 | Video: https://shapeblue-engineering-videos.s3.eu-west-1.amazonaws.com/mbx/mbx-usage-demo.mp4
289 |
290 | The `mbx` tool can be used to build CloudStack packages, deploy dev or QA
291 | environments with KVM, VMware, XenServer and XCP-ng hypervisors, and run
292 | smoketests on them.
293 |
294 | $ mbx
295 | MonkeyBox 🐵 v0.3
296 | Available commands are:
297 | init: initialises monkeynet and mbx templates
298 | package: builds packages from a git repo and sha/tag/branch
299 | list: lists available environments
300 | deploy: creates QA env with two monkeybox VMs and creates marvin cfg file
301 | launch: launches QA env zone using environment's marvin cfg file
302 | test: start marvin tests
303 | dev: creates dev env with a single monkeybox VM and creates marvin cfg file
304 | agentscp: updates KVM agent in dev environment using scp and restarts it
305 | ssh: ssh into a mbx VM
306 | stop: stop all env VMs
307 | start: start all env VMs
308 | destroy: destroy environment
309 |
310 | 0. On first run or when upgrading `mbx`, please run:
311 |
312 | mbx init
313 |
314 | 1. To list available environments and `mbx` templates (mbxts), run:
315 |
316 | mbx list
317 |
318 | 2. To deploy an environment, run:
319 |
320 | mbx deploy
321 |
322 | Example to deploy test matrix (kvm, vmware, xenserver) environments:
323 |
324 | mbx deploy 418-kenv mbxt-kvm-el8 mbxt-kvm-el8 # deploys ACS 4.18 + KVM EL8 env
325 | mbx deploy 418-venv mbxt-kvm-el8 mbxt-vmware7 # deploys ACS 4.18 + VMware7(u3) env
326 | mbx deploy 418-xenv mbxt-kvm-el8 mbxt-xcpng82 # deploys ACS 4.18 + XCP-ng 8.2 env
327 |
328 | More examples with custom packages repositories:
329 |
330 | mbx deploy cs417-kvm mbxt-kvm-el7 mbxt-kvm-el7 http://download.cloudstack.org/centos/7/4.17/
331 |
332 | 3. Once `mbx` environment is deployed, to launch a zone run:
333 |
334 | mbx launch
335 |
336 | 4. To run smoketests, run:
337 |
338 | mbx list # find your environment
339 | mbx ssh
340 | cd /marvin
341 | bash -x smoketests.sh
342 |
343 | 5. To destroy your mbx environment, run:
344 |
345 | mbx destroy
346 |
347 | Note: to use `qemu-ev` on EL7 KVM hosts, after deploying an environment you
348 | can run the following on KVM hosts (before launching the zone):
349 |
350 | yum install centos-release-qemu-ev
351 | yum install qemu-kvm-ev
352 |
353 | ### Accessing MBX Remotely
354 |
355 | This section is only for mbx users who want to access their mbx environments remotely.
356 | For this we suggest setting up wireguard VPN.
357 |
358 | To setup wireguard on Ubuntu: (note replace `LIBVIRT_PRT` with the chain name that libvirt uses for NAT rules)
359 |
360 | sudo apt-get install wireguard resolvconf
361 | wg genkey | sudo tee /etc/wireguard/private.key
362 | sudo cat /etc/wireguard/private.key | wg pubkey | sudo tee /etc/wireguard/public.key
363 |
364 | # cat /etc/wireguard/wg0.conf
365 | [Interface]
366 | PrivateKey =
367 | Address = 10.6.0.1/24
368 | PostUp = iptables -I FORWARD -i wg0 -j ACCEPT; iptables -t nat -I LIBVIRT_PRT -o cloudbr0 -j MASQUERADE
369 | PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D LIBVIRT_PRT -o cloudbr0 -j MASQUERADE
370 | #MTU = 1420
371 | ListenPort = 51820
372 | SaveConfig = true
373 |
374 | [Peer]
375 | <... add rest of the peer config here...>
376 |
377 | Note: you'll need to allow/enable port 51820/udp.
378 |
379 | You may need forwarding enabled if you're connecting to a peer WireGuard server,
380 | add the following to /etc/sysctl.conf:
381 |
382 | net.ipv4.ip_forward=1
383 |
384 | And then run:
385 |
386 | sysctl -p
387 |
388 | Finally enable the server:
389 |
390 | sudo systemctl enable wg-quick@wg0.service
391 | sudo systemctl start wg-quick@wg0.service
392 | sudo systemctl status wg-quick@wg0.service
393 |
394 | ## MBX CloudStack Development
395 |
396 | Note: this is not for developers of 3rd party integration/feature that don't
397 | require changes in CloudStack, such developers should use a QA environment. MBX
398 | development usage is supported to work with CloudStack 4.16 and onwards.
399 |
400 | This section covers how a CloudStack developer can run management server and
401 | MySQL server locally to do development of CloudStack using `mbx` dev boxes along
402 | side an IDE and other tools.
403 |
404 | For developer env, it is recommended that you run your favourite IDE such as
405 | IntelliJ IDEA, text-editors, your management server, MySQL server and NFS server
406 | (secondary and primary storages) on your workstation (not in a VM) where these
407 | services can be accessible to VMs, KVM hosts etc. at your host IP `172.20.0.1`.
408 |
409 | To deploy a dev env, you can run `mbx dev `.
410 | For example:
411 |
412 | $ mbx dev some-feature mbxt-kvm-el8
413 |
414 | The above will deploy a single hypervisor host and generate a marvin config file
415 | that you can use to deploy a zone.
416 |
417 | To ssh into deployed hypervisor VM (with NSS configured), you can login by
418 | simply using:
419 |
420 | $ mbx ssh
421 |
422 | Refer to hackerbook for up-to-date guidance on learning CloudStack development:
423 | https://github.com/shapeblue/hackerbook
424 |
425 | ### Install Development Tools
426 |
427 | Run this:
428 |
429 | $ sudo apt-get install openjdk-11-jdk maven python-mysql.connector libmysql-java mysql-server mysql-client bzip2 nfs-common uuid-runtime python-setuptools ipmitool genisoimage
430 |
431 | Setup IntelliJ (recommended) or any IDE of your choice. Get IntelliJ IDEA
432 | community edition from:
433 |
434 | https://www.jetbrains.com/idea/download/#section=linux
435 |
436 | Install pyenv, jenv as well.
437 |
438 | Setup `aliasrc` that defines some useful bash aliases, exports and utilities
439 | such as `agentscp`. Run the following while in the directory root:
440 |
441 | $ echo "source $PWD/files/aliasrc" >> ~/.bashrc
442 | $ echo "source $PWD/files/aliasrc" >> ~/.zshrc
443 |
444 | You may need to `source` your shell's rc/profile or relaunch shell/terminal
445 | to use `agentscp`.
446 |
447 | ### Setup MySQL Server
448 |
449 | After installing MySQL server, configure the following settings in its config
450 | file such as at `/etc/mysql/mysql.conf.d/mysqld.cnf` and restart mysql-server:
451 |
452 | [mysqld]
453 |
454 | sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
455 | server_id = 1
456 | innodb_rollback_on_timeout=1
457 | innodb_lock_wait_timeout=600
458 | max_connections=1000
459 | log-bin=mysql-bin
460 | binlog-format = 'ROW'
461 |
462 | ### Setup NFS storage
463 |
464 | After installing nfs server, configure the exports:
465 |
466 | echo "/export *(rw,async,no_root_squash,no_subtree_check)" > /etc/exports
467 | mkdir -p /export/testing/primary /export/testing/secondary
468 |
469 | Beware: For Dev env, before deploying a zone on your monkeybox environment, make
470 | sure to seed the correct systemvmtemplate applicable for your branch. In your
471 | cloned CloudStack git repository you can use the `cloud-install-sys-tmplt` to
472 | seed the systemvmtemplate. Also note this may or may not be necessary depending
473 | on your development base branch.
474 |
475 | The following is an example to setup `4.15` systemvmtemplate which you should
476 | run after deploying the CloudStack db: (please use CloudStack branch/version specific
477 | systemvmtemplate)
478 |
479 | cd /path/to/cloudstack/git/repo
480 | wget http://packages.shapeblue.com/systemvmtemplate/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2
481 | ./scripts/storage/secondary/cloud-install-sys-tmplt \
482 | -m /export/testing/secondary -f systemvmtemplate-4.15.1-kvm.qcow2.bz2 \
483 | -h kvm -o localhost -r cloud -d cloud
484 |
485 | ### Dev: Build and Test CloudStack
486 |
487 | It's assumed that the directory structure is something like:
488 |
489 | /
490 | ├── $HOME/lab/cloudstack
491 | └── /export/monkeybox
492 |
493 | Fork the repository at: github.com/apache/cloudstack, or get the code:
494 |
495 | $ git clone https://github.com/apache/cloudstack.git
496 |
497 | Noredist CloudStack builds requires additional jars that may be installed from:
498 |
499 | https://github.com/shapeblue/cloudstack-nonoss
500 |
501 | Clone the above repository and run the install.sh script, you'll need to do
502 | this only once or whenever the noredist jar dependencies are updated in the above
503 | repository.
504 |
505 | Build using:
506 |
507 | $ mvn clean install -Dnoredist -P developer,systemvm
508 |
509 | Deploy database using:
510 |
511 | $ mvn -q -Pdeveloper -pl developer -Ddeploydb
512 |
513 | Run management server using:
514 |
515 | $ mvn -pl :cloud-client-ui jetty:run -Dnoredist -Djava.net.preferIPv4Stack=true
516 |
517 | Install marvin:
518 |
519 | $ sudo pip install --upgrade tools/marvin/dist/Marvin*.tar.gz
520 |
521 | While in CloudStack's repo's root/top directory, run the folllowing to copy
522 | agent scripts, jars, configs to your KVM host:
523 |
524 | $ cd /path/to/git-repo/root
525 | $ mbx agentscp 172.20.1.10 # Use the appropriate KVM box IP
526 |
527 | Deploy datacenter using:
528 |
529 | $ python tools/marvin/marvin/deployDataCenter.py -i ../monkeybox/adv-kvm.cfg
530 |
531 | Example, to run a marvin test:
532 |
533 | $ nosetests --with-xunit --xunit-file=results.xml --with-marvin --marvin-config=../monkeybox/adv-kvm.cfg -s -a tags=advanced --zone=KVM-advzone1 --hypervisor=KVM test/integration/smoke/test_vm_life_cycle.py
534 |
535 | Note: Use nosetests-2.7 to run a smoketest, if you've nose installed for both Python2.7 and Python3.x in your environment.
536 |
537 | When you fix an issue, rebuild cloudstack and push new changes to your KVM host
538 | using `agentscp` which will also restart the agent:
539 |
540 | $ agentscp 172.20.1.10
541 |
542 | To push new changes to your Managment server use:
543 |
544 | $ mgmtscp 172.20.0.185
545 |
546 | Using IDEA IDE:
547 | - Import the `cloudstack` directory and select `Maven` as build system
548 | - Go through the defaults, in the profiles page at least select noredist, vmware
549 | etc.
550 | - Once IDEA builds the codebase cache you're good to go!
551 |
552 | ### Debugging CloudStack
553 |
554 | Prior to starting CloudStack management server using mvn (or otherwise), export
555 | this on your shell:
556 |
557 | export MAVEN_OPTS="$MAVEN_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
558 |
559 | To remote-debug the KVM agent, put the following in
560 | `/etc/default/cloudstack-agent` in your monkeybox and restart cloudstack-agent:
561 |
562 | JAVA=/usr/bin/java -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
563 |
564 | The above will ensure that JVM will start with debugging enabled on port 8787.
565 | In IntelliJ, or your IDE/editor you can attach a remote debugger to this
566 | address:port and put breakpoints (and watches) as applicable.
567 |
568 | ## Contributing
569 |
570 | Report issues on https://github.com/shapeblue/mbx/issues
571 |
572 | Send a pull request on https://github.com/shapeblue/mbx
573 |
--------------------------------------------------------------------------------
/doc/centos7.md:
--------------------------------------------------------------------------------
1 | [root@localhost yum.repos.d]# cat /etc/yum.repos.d/cloudstack.repo
2 | [cloudstack]
3 | name=cloudstack
4 | baseurl=http://download.cloudstack.org/el/8/4.17/
5 | enabled=1
6 | gpgcheck=0
7 |
8 | [root@localhost ~]# yum deplist cloudstack-management cloudstack-common cloudstack-usage cloudstack-cli | awk '/provider:/ {print $2}' | sort -u | grep -v java | grep -v cloudstack | xargs yum install -y
9 |
10 | hostnamectl set-hostname localhost --transient
11 |
12 | [root@localhost ~]# iptables-restore < /etc/sysconfig/iptables
13 | iptables -F ?
14 |
15 | [root@localhost ~]# systemctl stop firewalld
16 | [root@localhost ~]# systemctl disable firewalld
17 |
18 | rm -fr /var/lib/mysql/*
19 |
20 | [root@localhost ~]# systemctl stop mysqld
21 | [root@localhost ~]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
22 | [root@localhost ~]# systemctl start mysqld
23 | [root@localhost ~]#
24 | [root@localhost ~]# mysql -u root
25 | Welcome to the MySQL monitor. Commands end with ; or \g.
26 | Your MySQL connection id is 2
27 | Server version: 5.7.32-log MySQL Community Server (GPL)
28 |
29 | Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
30 |
31 | Oracle is a registered trademark of Oracle Corporation and/or its
32 | affiliates. Other names may be trademarks of their respective
33 | owners.
34 |
35 | Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
36 |
37 | mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssword123';
38 | ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
39 | mysql> flush privileges;
40 | Query OK, 0 rows affected (0.07 sec)
41 |
42 | mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'P@ssword123';
43 | Query OK, 0 rows affected (0.06 sec)
44 |
45 | mysql> flush privileges;
46 | Query OK, 0 rows affected (0.02 sec)
47 |
48 | mysql> ^DBye
49 |
50 |
51 | [root@localhost ~]# systemctl stop mysqld
52 |
53 | [root@localhost ~]#
54 | [root@localhost ~]# systemctl unset-environment MYSQLD_OPTS
55 | [root@localhost ~]# systemctl start mysqld
56 | [root@localhost ~]# mysql -u root
57 | ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
58 | [root@localhost ~]# mysql -u root -p
59 | Enter password:
60 | Welcome to the MySQL monitor
61 |
62 |
63 | In /etc/my.cnf:
64 | server-id=1
65 | sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
66 | binlog-format = 'ROW'
67 | log-bin=mysql-bin
68 | max_connections=700
69 | innodb_lock_wait_timeout=600
70 | innodb_rollback_on_timeout=1
71 | datadir=/var/lib/mysql
72 |
73 | mysql> SHOW VARIABLES LIKE 'validate_password%';
74 | mysql> SET GLOBAL validate_password_length = 5;
75 | mysql> set global validate_password_number_count = 0;
76 | mysql> set global validate_password_mixed_case_count = 0;
77 | Query OK, 0 rows affected (0.00 sec)
78 |
79 | mysql> set global validate_password_special_char_count = 0;
80 | Query OK, 0 rows affected (0.00 sec)
81 |
82 | mysql> set validate_password_policy = 'LOW';
83 | ERROR 1229 (HY000): Variable 'validate_password_policy' is a GLOBAL variable and should be set with SET GLOBAL
84 | mysql> set global validate_password_policy = 'LOW';
85 | Query OK, 0 rows affected (0.00 sec)
86 |
--------------------------------------------------------------------------------
/doc/images/arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/doc/images/arch.png
--------------------------------------------------------------------------------
/doc/images/box-start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/doc/images/box-start.png
--------------------------------------------------------------------------------
/doc/images/virt-manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/doc/images/virt-manager.png
--------------------------------------------------------------------------------
/doc/images/virt-net.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/doc/images/virt-net.png
--------------------------------------------------------------------------------
/doc/notes.md:
--------------------------------------------------------------------------------
1 | sshpass example:
2 | sshpass -p 'P@ssword123' ssh -o StrictHostKeyChecking=no root@qa-ry-xs1
3 |
4 | get host/ip from virsh via:
5 | ip=$(getent hosts qa-ry-c7kvm1 | awk '{ print $1 }')
6 |
7 | virsh list | awk '{ print $2 }' | xargs getent hosts
8 |
9 | For KVM:
10 | fix hostname
11 | fix repo URL/yum
12 | rm /etc/default/cloudstack-agent
13 | rm /etc/cloudstack/agent/agent.properties /etc/cloudstack/agent/environment.properties
14 | yum install -y cloudstack-agent
15 |
16 | For Vmware:
17 | manually start VC and then add hosts to Cluster
18 | then deploy zone
19 |
20 | For XenServer:
21 | on master, run:
22 | xe pool-param-set name-label=XS-Cluster1 uuid=`xe pool-list --minimal`
23 | Deploy Zone, and then run on nodes:
24 | HOSTNAME=$PASS_HOST_NAME_HERE
25 | service xapi stop
26 | sed -i "/INSTALLATION_UUID/c\INSTALLATION_UUID='$(uuidgen)'" /etc/xensource-inventory
27 | sed -i "/CONTROL_DOMAIN_UUID/c\CONTROL_DOMAIN_UUID='$(uuidgen)'" /etc/xensource-inventory
28 | rm -rf /var/xapi/state.db
29 | cert="/etc/xensource/xapi-ssl.pem"
30 | cert_backup="${cert}.`date -u +%Y%m%dT%TZ`"
31 | mv -f "${cert}" "${cert_backup}"
32 | /opt/xensource/libexec/generate_ssl_cert "${cert}" `hostname -f`
33 | service xapi start
34 | rm -f /etc/openvswitch/conf.db*
35 | sleep 10
36 | xe host-param-set uuid=$(xe host-list params=uuid|awk {'print $5'} | head -n 1) name-label=$HOSTNAME
37 | echo yes | /opt/xensource/bin/xe-reset-networking --device=eth0 --mode=dhcp
38 | #reboot
39 | xe pool-join master-address=172.20.0.194 master-username=root master-password=P@ssword123
40 |
41 |
42 | On mgmt server (CentOS7):
43 | # ssh into mgmt server and fix hostname, /etc/hosts etc.
44 | # fix issues with marvin pkgs
45 | yum remove -y python-netaddr
46 | pip uninstall cryptography
47 |
48 | # fix cloudsack repo?
49 | yum install -y cloudstack-agent cloudstack-management cloudstack-usage cloudstack-common cloudstack-integration-tests cloudstack-marvin
50 | systemctl enable --now mariadb
51 | cloudstack-setup-databases cloud:cloud@localhost --deploy-as=root: -i $(ip route get 8.8.8.8 | head -1 | awk '{print $7}')
52 | mysql -u root --execute="INSERT INTO cloud.configuration (category, instance, component, name, value) VALUES ('Advanced', 'DEFAULT', 'management-server', 'integration.api.port', '8096');"
53 | cloudstack-setup-management
54 | # copy marvin cfg here
55 | python /usr/lib/python2.7/site-packages/marvin/deployDataCenter.py -i vmware.marvin.cfg #cfg here
56 | # run tests
57 |
58 |
59 | vmware 7.0 -> vmxnet3
60 | older can use e1000
61 |
62 |
--------------------------------------------------------------------------------
/doc/scripts/filter.table:
--------------------------------------------------------------------------------
1 | iptables -A INPUT -i virbr1 -p udp -m udp --dport 53 -j ACCEPT
2 | iptables -A INPUT -i virbr1 -p tcp -m tcp --dport 53 -j ACCEPT
3 | iptables -A INPUT -i virbr1 -p udp -m udp --dport 67 -j ACCEPT
4 | iptables -A INPUT -i virbr1 -p tcp -m tcp --dport 67 -j ACCEPT
5 | iptables -A FORWARD -d 172.20.0.0/16 -o virbr1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
6 | iptables -A FORWARD -s 172.20.0.0/16 -i virbr1 -j ACCEPT
7 | iptables -A FORWARD -i virbr1 -o virbr1 -j ACCEPT
8 | iptables -A FORWARD -o virbr1 -j REJECT --reject-with icmp-port-unreachable
9 | iptables -A FORWARD -i virbr1 -j REJECT --reject-with icmp-port-unreachable
10 | iptables -A OUTPUT -o virbr1 -p udp -m udp --dport 68 -j ACCEPT
11 |
--------------------------------------------------------------------------------
/doc/scripts/nat.table:
--------------------------------------------------------------------------------
1 | iptables -t nat -P POSTROUTING ACCEPT
2 | iptables -t nat -A POSTROUTING -s 172.20.0.0/16 -d 224.0.0.0/24 -j RETURN
3 | iptables -t nat -A POSTROUTING -s 172.20.0.0/16 -d 255.255.255.255/32 -j RETURN
4 | iptables -t nat -A POSTROUTING -s 172.20.0.0/16 ! -d 172.20.0.0/16 -p tcp -j MASQUERADE --to-ports 1024-65535
5 | iptables -t nat -A POSTROUTING -s 172.20.0.0/16 ! -d 172.20.0.0/16 -p udp -j MASQUERADE --to-ports 1024-65535
6 | iptables -t nat -A POSTROUTING -s 172.20.0.0/16 ! -d 172.20.0.0/16 -j MASQUERADE
7 |
--------------------------------------------------------------------------------
/doc/vmware.md:
--------------------------------------------------------------------------------
1 | vmware 7.0 -> vmxnet3 or e1000e
2 | older can use e1000
3 |
4 | # vmware esxi template
5 |
6 | enable ssh+shell
7 | disable ipv6
8 | enable vmotion on vmk0
9 | make vmk0 nic to get dhcp as phy nic and vmk0 network/tcp stack to obtain info from dhcp/dns
10 |
11 | security setting fort vSwtich0: reject/accept/accept
12 |
13 | remove uuid, mac address and IP address from /etc/vmware/esx.conf
14 | remove dhcp leases from /etc/ and /var/lib/dhcp/ paths
15 | esxcfg-advcfg -s 1 /Net/FollowHardwareMac
16 |
17 | # Stop hostd
18 | /etc/init.d/hostd stop
19 |
20 | # Ensure the new MAC Address is automatically picked up once cloned
21 | localcli system settings advanced set -o /Net/FollowHardwareMac -i 1
22 |
23 | # Remove any potential old DHCP leases
24 | rm -f /etc/dhclient*lease
25 |
26 | # Ensure new system UUID is generated
27 | sed -i 's#/system/uuid.*##g' /etc/vmware/esx.conf
28 |
29 | # VMware 7 only: Remove these lines from /etc/vmware/esx.conf:
30 |
31 | /net/vmkernelnic/child[0000]/mac
32 | /net/pnic/child[0001]/mac
33 | /net/pnic/child[0000]/mac
34 |
35 | # Unload networking + vmfs3 modules which also contains system UUID mappings
36 | vmkload_mod -u vmfs3
37 | vmkload_mod -u e1000 (before VMware 7)
38 | vmkload_mod -u nvmxnet3 (VMware 7 only)
39 |
40 | # vCenter VM
41 |
42 | vcenter VM: enable bash and ssh, enable ntp pool, disable password expiry;
43 | on setup use FDQN as vcenterXX.local and add entry in local router (forward and reverse dns)
44 |
45 | from the VC.vmx remove:
46 | ethernet0.addressType
47 | uuid.location =
48 | uuid.bios =
49 | ethernet0.generatedAddress =
50 | ethernet0.generatedAddressOffset =
51 |
52 | In VC.vmx add at bottom: (replace vmwareXX.local pnid)
53 |
54 | guestInfo.cis.deployment.node.type = "embedded"
55 | guestInfo.cis.appliance.net.addr.family = "ipv4"
56 | guestInfo.cis.appliance.net.mode = "dhcp"
57 | guestInfo.cis.appliance.net.pnid = "vcenter70.local"
58 | guestInfo.cis.appliance.ssh.enabled = "True"
59 |
60 | vcenter debug services:
61 | service-control --stop --all
62 | service-control --start --all
63 |
--------------------------------------------------------------------------------
/files/aliasrc:
--------------------------------------------------------------------------------
1 | #
2 | # Source this file in your ~/.bashrc or ~/.zshrc using:
3 | # echo "source $PWD/aliasrc" >> ~/.bashrc
4 | # echo "source $PWD/aliasrc" >> ~/.zshrc
5 | #
6 |
7 | # Utf8 exports
8 | export LC_ALL=en_US.UTF-8
9 | export LANG=en_US.UTF-8
10 |
11 | # Local apps
12 | export PATH=$HOME/bin:$PATH
13 |
14 | # Maven
15 | export MAVEN_OPTS="-Xmx4096m -XX:MaxPermSize=500m -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
16 |
17 | # Jenv
18 | export PATH="$HOME/.jenv/bin:$PATH"
19 | eval "$(jenv init -)"
20 |
21 | # Pyenv
22 | #export PATH="$HOME/.pyenv/bin:$PATH"
23 | #eval "$(pyenv init -)"
24 | #eval "$(pyenv virtualenv-init -)"
25 |
26 | mgmtscp() {
27 | MS=$1
28 | ROOT=$PWD
29 | echo "[acs server] Stopping MS: $MS"
30 | sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "systemctl stop cloudstack-management"
31 | echo "[acs server] Cleaning old jar on server: $MS"
32 | sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "rm -f /usr/share/cloudstack-management/lib/cloudstack*jar"
33 | sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "rm -f /usr/share/cloudstack-management/lib/cloud-client-ui*jar"
34 | sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "mv /var/log/cloudstack/management/management-server.log /var/log/cloudstack/management/management-server.log-`date +%Y%m%dT%H%M%S`"
35 | echo "[acs server] Copying jar to server: $MS"
36 | sshpass -pP@ssword123 scp -Cv -o StrictHostKeyChecking=no $ROOT/client/target/cloud-client-ui-*.jar root@$MS:/usr/share/cloudstack-management/lib/
37 | echo "[acs server] Copying systemvm.iso"
38 | sshpass -pP@ssword123 scp -Cv -o StrictHostKeyChecking=no $ROOT/systemvm/dist/systemvm.iso root@$MS:/usr/share/cloudstack-common/vms/
39 | echo "[acs server] Starting MS: $MS"
40 | sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "systemctl start cloudstack-management"
41 | }
42 |
43 | agentscp() {
44 | ROOT=$PWD
45 | echo "[acs agent] Syncing changes to agent: $1"
46 |
47 | echo "[acs agent] Copied systemvm.iso"
48 | scp $ROOT/systemvm/dist/systemvm.iso root@$1:/usr/share/cloudstack-common/vms/
49 |
50 | echo "[acs agent] Syncing python lib changes to agent: $1"
51 | scp -r $ROOT/python/lib/* root@$1:/usr/lib64/python2.6/site-packages/ 2>/dev/null || true
52 | scp -r $ROOT/python/lib/* root@$1:/usr/lib64/python2.7/site-packages/ 2>/dev/null || true
53 |
54 | echo "[acs agent] Syncing scripts"
55 | scp -r $ROOT/scripts/* root@$1:/usr/share/cloudstack-common/scripts/
56 |
57 | echo "[acs agent] Syncing kvm hypervisor jars"
58 | ssh root@$1 "rm -f /usr/share/cloudstack-agent/lib/*"
59 | scp -r $ROOT/plugins/hypervisors/kvm/target/*jar root@$1:/usr/share/cloudstack-agent/lib/
60 | scp -r $ROOT/plugins/hypervisors/kvm/target/dependencies/*jar root@$1:/usr/share/cloudstack-agent/lib/
61 |
62 | echo "[acs agent] Syncing cloudstack-agent config and scripts"
63 | scp $ROOT/agent/target/transformed/log4j-cloud.xml root@$1:/etc/cloudstack/agent/
64 | ssh root@$1 "sed -i 's/INFO/DEBUG/g' /etc/cloudstack/agent/log4j-cloud.xml"
65 | ssh root@$1 "sed -i 's/logs\/agent.log/\/var\/log\/cloudstack\/agent\/agent.log/g' /etc/cloudstack/agent/log4j-cloud.xml"
66 | scp $ROOT/agent/target/transformed/libvirtqemuhook root@$1:/usr/share/cloudstack-agent/lib/
67 |
68 | scp $ROOT/agent/target/transformed/cloud-setup-agent root@$1:/usr/bin/cloudstack-setup-agent
69 | ssh root@$1 "sed -i 's/@AGENTSYSCONFDIR@/\/etc\/cloudstack\/agent/g' /usr/bin/cloudstack-setup-agent"
70 | scp $ROOT/agent/target/transformed/cloud-ssh root@$1:/usr/bin/cloudstack-ssh
71 | scp $ROOT/agent/target/transformed/cloudstack-agent-upgrade root@$1:/usr/bin/cloudstack-agent-upgrade
72 | ssh root@$1 "chmod +x /usr/bin/cloudstack*"
73 |
74 | ssh root@$1 "systemctl status cloudstack-agent && systemctl restart cloudstack-agent"
75 |
76 | echo "[acs agent] Copied all files, start hacking!"
77 | }
78 |
--------------------------------------------------------------------------------
/files/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 |
19 | set -e
20 |
21 | # printenv
22 |
23 | export ROOT=/jenkins
24 | cd $ROOT
25 | rm -fr deps/*jar deps/awsapi-lib deps/*.mar NONOSS
26 |
27 | if [[ "${PR_ID}" != "" ]]; then
28 | # Find base branch
29 | BASE=$(curl https://api.github.com/repos/apache/cloudstack/pulls/$PR_ID | jq -r '.base.ref')
30 | git checkout ${BASE}
31 | else
32 | git checkout ${ACS_BRANCH}
33 | fi
34 |
35 | # Add github remote
36 | git remote add gh https://github.com/apache/cloudstack.git || true
37 |
38 | # Apply PR
39 | if [[ "${PR_ID}" != "" ]]; then
40 | git config --global user.email "you@example.com"
41 | git config --global user.name "Your Name"
42 |
43 | sed -i 's/^repoName=.*/repoName=cloudstack/g' tools/git/git-pr
44 | bash tools/git/git-pr $PR_ID --force
45 | fi
46 |
47 | export PATH="$HOME/.jenv/bin:$PATH"
48 | if [[ $DISTRO == "centos6" ]]; then
49 | export PATH=/opt/rh/maven30/root/usr/bin:/opt/rh/rh-java-common/root/usr/bin:$PATH
50 | fi
51 |
52 | eval "$(jenv init -)"
53 | echo $0
54 | cat .java-version || true
55 | jenv shell $(cat .java-version) || true
56 | pwd
57 | whoami
58 | echo $PATH
59 | java -version
60 | javac -version
61 | mvn -version
62 |
63 | if [[ "${PR_ID}" != "" ]]; then
64 | export MINOR=shapeblue${PR_ID}
65 | else
66 | export MINOR=1
67 | fi
68 |
69 | export VERSION=$(grep '' pom.xml | head -2 | tail -1 | cut -d'>' -f2 |cut -d'<' -f1)
70 | export BASE_VERSION=$(echo $VERSION | awk -F . '{print $1"."$2}')
71 | export ACS_BUILD_OPTS="-Dnoredist -Dnonoss"
72 | export MAVEN_OPTS="-Xmx4096m -XX:MaxPermSize=800m"
73 |
74 | LIBS=NONOSS
75 | git clone https://github.com/shapeblue/cloudstack-nonoss.git $LIBS --depth=1
76 | cd $LIBS
77 | bash -x install-non-oss.sh
78 | cd $ROOT
79 | cp $LIBS/vhd-util scripts/vm/hypervisor/xenserver/
80 | chmod +x scripts/vm/hypervisor/xenserver/vhd-util
81 |
82 | # Debian stuff
83 | if [[ $DISTRO == "debian" ]]; then
84 | rm -frv ../cloudstack*deb
85 | rm -frv ../cloudstack*.tar.gz
86 | rm -frv ../cloudstack*.dsc
87 | rm -frv ../cloudstack*.changes
88 |
89 | echo "cloudstack (${VERSION}) unstable; urgency=low" > $ROOT/newchangelog
90 | echo "" >> $ROOT/newchangelog
91 | echo " * Update the version to ${PACKAGE_VERSION}" >> $ROOT/newchangelog
92 | echo "" >> $ROOT/newchangelog
93 | echo " -- Apache CloudStack Dev $(date +'%a, %-d %b %Y %H:%m:%S +0530')" >> $ROOT/newchangelog
94 | echo "" >> $ROOT/newchangelog
95 | cat $ROOT/debian/changelog >> $ROOT/newchangelog
96 | mv $ROOT/newchangelog $ROOT/debian/changelog
97 |
98 | cd $ROOT
99 |
100 | dpkg-buildpackage -uc -us -b
101 |
102 | mv ../cloudstack-*.deb $ROOT
103 |
104 | for pkg in $(ls cloud*.deb);
105 | do
106 | cp $pkg /output
107 | done
108 | else
109 | # Centos stuff
110 | cd $ROOT/packaging
111 | sed -i "s/DEFREL=.*$/DEFREL='-D_rel ${MINOR}'/g" package.sh
112 |
113 | case $DISTRO in
114 | centos6)
115 | bash -x package.sh -p noredist -d centos63
116 | ;;
117 | centos7)
118 | bash -x package.sh -p noredist -o rhel7 -d centos7 --release $MINOR
119 | ;;
120 | centos8)
121 | ln -sf /usr/bin/python2 /usr/bin/python
122 | bash -x package.sh -p noredist -o rhel8 -d centos8 --release $MINOR
123 | ;;
124 | esac
125 |
126 | cd $ROOT
127 | for pkg in $(ls dist/rpmbuild/RPMS/x86_64/);
128 | do
129 | cp dist/rpmbuild/RPMS/x86_64/$pkg /output
130 | done
131 | fi
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/files/createtmplt.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 |
19 |
20 |
21 | # $Id: createtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createtmplt.sh $
22 | # createtmplt.sh -- install a template
23 |
24 | usage() {
25 | printf "Usage: %s: -t -n -f -d -h [-u] [-v]\n" $(basename $0) >&2
26 | }
27 |
28 |
29 | #set -x
30 | ulimit -c 0
31 |
32 | rollback_if_needed() {
33 | if [ $2 -gt 0 ]
34 | then
35 | printf "$3\n"
36 | #back out all changes
37 | rm -rf $1
38 | exit 2
39 | fi
40 | }
41 |
42 | untar() {
43 | local ft=$(file $1| awk -F" " '{print $2}')
44 | case $ft in
45 | USTAR)
46 | printf "tar archives not supported\n" >&2
47 | return 1
48 | ;;
49 | *) printf "$1"
50 | return 0
51 | ;;
52 | esac
53 |
54 | }
55 |
56 | is_compressed() {
57 | local ft=$(file $1| awk -F" " '{print $2}')
58 | local tmpfile=${1}.tmp
59 |
60 | case $ft in
61 | gzip) ctype="gzip"
62 | ;;
63 | bzip2) ctype="bz2"
64 | ;;
65 | [zZ][iI][pP]) ctype="zip"
66 | ;;
67 | *) echo "File $1 does not appear to be compressed" >&2
68 | return 1
69 | ;;
70 | esac
71 | echo "Uncompressing to $tmpfile (type $ctype)...could take a long time" >&2
72 | return 0
73 | }
74 |
75 | uncompress() {
76 | local ft=$(file $1| awk -F" " '{print $2}')
77 | local tmpfile=${1}.tmp
78 |
79 | case $ft in
80 | gzip) gunzip -q -c $1 > $tmpfile
81 | ;;
82 | bzip2) bunzip2 -q -c $1 > $tmpfile
83 | ;;
84 | [zZ][iI][pP]) unzip -q -p $1 | cat > $tmpfile
85 | ;;
86 | *) printf "$1"
87 | return 0
88 | ;;
89 | esac
90 |
91 | if [ $? -gt 0 ]
92 | then
93 | printf "Failed to uncompress file (filetype=$ft), exiting "
94 | return 1
95 | fi
96 |
97 | rm -f $1
98 | printf $tmpfile
99 |
100 | return 0
101 | }
102 |
103 | create_from_file() {
104 | local tmpltfs=$1
105 | local tmpltimg=$2
106 | local tmpltname=$3
107 |
108 | [ -n "$verbose" ] && echo "Moving to $tmpltfs/$tmpltname...could take a while" >&2
109 | mv $tmpltimg /$tmpltfs/$tmpltname
110 |
111 | }
112 |
113 | tflag=
114 | nflag=
115 | fflag=
116 | sflag=
117 | hflag=
118 | hvm=false
119 | cleanup=false
120 | dflag=
121 |
122 | while getopts 'vuht:n:f:s:d:S:' OPTION
123 | do
124 | case $OPTION in
125 | t) tflag=1
126 | tmpltfs="$OPTARG"
127 | ;;
128 | n) nflag=1
129 | tmpltname="$OPTARG"
130 | ;;
131 | f) fflag=1
132 | tmpltimg="$OPTARG"
133 | ;;
134 | s) sflag=1
135 | ;;
136 | d) dflag=1
137 | descr="$OPTARG"
138 | ;;
139 | S) Sflag=1
140 | size=$OPTARG
141 | let "size>>=10"
142 | ulimit -f $size
143 | ;;
144 | h) hflag=1
145 | hvm="true"
146 | ;;
147 | u) cleanup="true"
148 | ;;
149 | v) verbose="true"
150 | ;;
151 | ?) usage
152 | exit 2
153 | ;;
154 | esac
155 | done
156 |
157 | isCifs() {
158 | #TO:DO incase of multiple zone where cifs and nfs exists,
159 | #then check if the template file is from cifs using df -P filename
160 | #Currently only cifs is supported in hyperv zone.
161 | mount | grep "type cifs" > /dev/null
162 | echo $?
163 | }
164 |
165 | if [ "$tflag$nflag$fflag$sflag" != "1111" ]
166 | then
167 | usage
168 | exit 2
169 | fi
170 |
171 | mkdir -p $tmpltfs
172 |
173 | if [ ! -f $tmpltimg ]
174 | then
175 | printf "root disk file $tmpltimg doesn't exist\n"
176 | exit 3
177 | fi
178 |
179 | [ -n "$verbose" ] && is_compressed $tmpltimg
180 | tmpltimg2=$(uncompress $tmpltimg)
181 | rollback_if_needed $tmpltfs $? "failed to uncompress $tmpltimg\n"
182 |
183 | tmpltimg2=$(untar $tmpltimg2)
184 | rollback_if_needed $tmpltfs $? "tar archives not supported\n"
185 |
186 | if [ ${tmpltname%.vhd} != ${tmpltname} ]
187 | then
188 | if [ $(isCifs) -ne 0 ] ;
189 | then
190 | if which vhd-util &>/dev/null
191 | then
192 | vhd-util read -p -n ${tmpltimg2} > /dev/null
193 | rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
194 | vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null
195 | rollback_if_needed $tmpltfs $? "vhd remove $tmpltimg2 hidden failed\n"
196 | fi
197 | fi
198 | fi
199 |
200 | imgsize=$(ls -l $tmpltimg2| awk -F" " '{print $5}')
201 |
202 | create_from_file $tmpltfs $tmpltimg2 $tmpltname
203 |
204 | touch /$tmpltfs/template.properties
205 | rollback_if_needed $tmpltfs $? "Failed to create template.properties file"
206 | echo -n "" > /$tmpltfs/template.properties
207 |
208 | today=$(date '+%m_%d_%Y')
209 | echo "filename=$tmpltname" > /$tmpltfs/template.properties
210 | echo "description=$descr" >> /$tmpltfs/template.properties
211 | # we need to rethink this property as it might get changed after download due to decompression
212 | # option is to recalcutate it here
213 | echo "hvm=$hvm" >> /$tmpltfs/template.properties
214 | echo "size=$imgsize" >> /$tmpltfs/template.properties
215 |
216 | if [ "$cleanup" == "true" ]
217 | then
218 | rm -f $tmpltimg
219 | fi
220 |
221 | exit 0
222 |
--------------------------------------------------------------------------------
/files/govc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/files/govc
--------------------------------------------------------------------------------
/files/libvhd.so.1.0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/files/libvhd.so.1.0
--------------------------------------------------------------------------------
/files/result.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | import os
19 | import argparse
20 |
21 | import lxml.etree
22 | from operator import itemgetter
23 |
24 | def main():
25 | args = _generate_args()
26 | file_path_list = _generate_file_list(args)
27 |
28 | exit(parse_reports(file_path_list))
29 |
30 | def _generate_args():
31 | parser = argparse.ArgumentParser(
32 | description='Command line utility for reading xunit xml files'
33 | )
34 |
35 | parser.add_argument(
36 | 'path',
37 | metavar='/path/to/folder/containing/xunit-reports',
38 | type=str,
39 | help='A path to a folder containing xunit reports'
40 | )
41 | args = parser.parse_args()
42 | return vars(args)
43 |
44 | def _generate_file_list(args):
45 | path = args.pop('path')
46 | file_path_list = []
47 | if path.endswith('.xml') and os.path.isfile(path):
48 | file_path_list.append(path)
49 | for (root, dirnames, filenames) in os.walk(path):
50 | for filename in filenames:
51 | if filename.endswith('.xml'):
52 | file_path_list.append(os.path.join(root, filename))
53 |
54 | return file_path_list
55 |
56 | def parse_reports(file_path_list):
57 | print("Only failed tests shown:")
58 | print("Test | Result | Time (s) | Test File")
59 | print("--- | --- | --- | ---")
60 |
61 | exit_code = 0
62 |
63 | tests = []
64 | for file_path in file_path_list:
65 | filename = file_path[file_path.find('test_'):].replace('.xml', '')
66 | data = lxml.etree.iterparse(file_path, tag='testcase')
67 | for event, elem in data:
68 | name = ''
69 | status = 'Success'
70 | time = ''
71 | if 'name' in elem.attrib:
72 | name = elem.attrib['name']
73 | if 'time' in elem.attrib:
74 | time = str(elem.attrib['time'])
75 | for children in elem.getchildren():
76 | if 'skipped' == children.tag:
77 | status = 'Skipped'
78 | elif 'failure' == children.tag:
79 | exit_code = 1
80 | status = '`Failure`'
81 | elif 'error' == children.tag:
82 | exit_code = 1
83 | status = '`Error`'
84 | if status not in ['Success', 'Skipped']:
85 | tests.append([name, status, time, filename])
86 |
87 | for test in tests:
88 | print("%s | %s | %s | %s" % (test[0], test[1], test[2], test[3]))
89 | print("")
90 | return exit_code
91 |
92 | if __name__ == "__main__":
93 | main()
94 |
--------------------------------------------------------------------------------
/files/setup-systemvmtemplate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 |
19 |
20 | usage() {
21 | printf "\nUsage: %s:\n\t-m secondary storage mount point\n\t-f system vm template file\n\t-h hypervisor name: kvm|vmware|xenserver|hyperv|ovm3\n\t-s mgmt server secret key, if you specified any when running cloudstack-setup-database, default is password\n\t-u Url to system vm template\n\t-F clean up system templates of specified hypervisor\n\t-e Template suffix, e.g vhd, ova, qcow2\n\n" $(basename $0) >&2
22 | printf "\tor\n"
23 | printf "\nUsage: %s:\n\t-m secondary storage mount point\n\t-u http url for system vm template\n\t-h hypervisor name: kvm|vmware|xenserver|hyperv|ovm3\n\t-s mgmt server secret key\n\n" $(basename $0) >&2
24 | }
25 |
26 | # Usage: e.g. failed $? "this is an error"
27 | failed() {
28 | local returnval=$1
29 | local returnmsg=$2
30 |
31 | # check for an message, if there is no one dont print anything
32 | if [[ -z $returnmsg ]]; then
33 | :
34 | else
35 | echo -e $returnmsg
36 | fi
37 | if [[ $returnval -eq 0 ]]; then
38 | return 0
39 | elif [[ -n "(echo $returnmsg | grep "already")" ]]; then
40 | echo $returnmsg
41 | exit 0
42 | else
43 | echo "Installation failed"
44 | exit $returnval
45 | fi
46 | }
47 |
48 | #set -x
49 | mflag=
50 | fflag=
51 | ext="vhd"
52 | templateId=
53 | hyper=
54 | msKey=password
55 | DISKSPACE=2120000 #free disk space required in kilobytes
56 |
57 | # check if first parameter is not a dash (-) then print the usage block
58 | if [[ ! $@ =~ ^\-.+ ]]; then
59 | usage
60 | exit 0
61 | fi
62 |
63 | OPTERR=0
64 | while getopts 'm:h:f:u:Ft:e:Ms:o:r:d:p:'# OPTION
65 | do
66 | case $OPTION in
67 | m) mflag=1
68 | mntpoint="$OPTARG"
69 | ;;
70 | f) fflag=1
71 | tmpltimg="$OPTARG"
72 | ;;
73 | u) uflag=1
74 | url="$OPTARG"
75 | ;;
76 | F) Fflag=1
77 | ;;
78 | t) templateId="$OPTARG"
79 | ;;
80 | e) ext="$OPTARG"
81 | ;;
82 | h) hyper="$OPTARG"
83 | ;;
84 | s) sflag=1
85 | msKey="$OPTARG"
86 | ;;
87 | ?) usage
88 | exit 0
89 | ;;
90 | *) usage
91 | exit 0
92 | ;;
93 | esac
94 | done
95 |
96 | if [[ "$mflag$fflag" != "11" && "$mflag$uflag" != "11" ]]; then
97 | failed 2 "Please add a mount point and a system vm template file"
98 | fi
99 |
100 | if [[ -z "$hyper" ]]; then
101 | failed 2 "Please add a correct hypervisor name like: kvm|vmware|xenserver|hyperv|ovm3"
102 | fi
103 |
104 | if [[ ! -d $mntpoint ]]; then
105 | failed 2 "mount point $mntpoint doesn't exist\n"
106 | fi
107 |
108 | if [[ "$fflag" == "1" && ! -f $tmpltimg ]]; then
109 | failed 2 "template image file $tmpltimg doesn't exist"
110 | fi
111 |
112 | if [[ "$templateId" == "" ]]; then
113 | if [[ "$hyper" == "kvm" ]]; then
114 | ext="qcow2"
115 | templateId=3
116 | qemuimgcmd=$(which qemu-img)
117 | elif [[ "$hyper" == "xenserver" ]]; then
118 | ext="vhd"
119 | templateId=1
120 | elif [[ "$hyper" == "vmware" ]]; then
121 | ext="ova"
122 | templateId=8
123 | elif [[ "$hyper" == "lxc" ]]; then
124 | ext="qcow2"
125 | templateId=3
126 | elif [[ "$hyper" == "hyperv" ]]; then
127 | ext="vhd"
128 | templateId=9
129 | elif [[ "$hyper" == "ovm3" ]]; then
130 | ext="raw"
131 | templateId=12
132 | else
133 | failed 2 "Please add a correct hypervisor name like: kvm|vmware|xenserver|hyperv|ovm3"
134 | fi
135 | fi
136 |
137 | if [[ ! $templateId ]]; then
138 | failed 2 "Unable to get template Id from database"
139 | fi
140 |
141 | _uuid=$(uuidgen)
142 | localfile=$_uuid.$ext
143 |
144 | mntpoint=`echo "$mntpoint" | sed 's|/*$||'`
145 |
146 | destdir=$mntpoint/template/tmpl/1/$templateId/
147 |
148 | mkdir -p $destdir
149 | if [[ $? -ne 0 ]]; then
150 | failed 2 "Failed to write to mount point $mntpoint -- is it mounted?\n"
151 | fi
152 |
153 | if [[ "$Fflag" == "1" ]]; then
154 | rm -rf $destdir/*
155 | if [[ $? -ne 0 ]]; then
156 | failed 2 "Failed to clean up template directory $destdir -- check permissions?"
157 | fi
158 | fi
159 |
160 | if [[ -f $destdir/template.properties ]]; then
161 | failed 2 "Data already exists at destination $destdir -- use -F to force cleanup of old template\nIF YOU ARE ATTEMPTING AN UPGRADE, YOU MAY NEED TO SPECIFY A TEMPLATE ID USING THE -t FLAG"
162 | fi
163 |
164 | destfiles=$(find $destdir -name \*.$ext)
165 | if [[ "$destfiles" != "" ]]; then
166 | failed 2 "Data already exists at destination $destdir -- use -F to force cleanup of old template"
167 | fi
168 |
169 | tmplfile=$(dirname $0)/$localfile
170 |
171 | touch $tmplfile
172 | if [[ $? -ne 0 ]]; then
173 | failed 2 "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"
174 | fi
175 |
176 | destcap=$(df -P $destdir | awk '{print $4}' | tail -1 )
177 | [ $destcap -lt $DISKSPACE ] && echo "Insufficient free disk space for target folder $destdir: avail=${destcap}k req=${DISKSPACE}k" && failed 4
178 |
179 | localcap=$(df -P $(dirname $0) | awk '{print $4}' | tail -1 )
180 | [ $localcap -lt $DISKSPACE ] && echo "Insufficient free disk space for local temporary folder $(dirname $0): avail=${localcap}k req=${DISKSPACE}k" && failed 4
181 |
182 | if [[ "$uflag" == "1" ]]; then
183 | wget -O $tmplfile $url
184 | if [[ $? -ne 0 ]]; then
185 | failed 2 "Failed to fetch system vm template from $url"
186 | fi
187 | fi
188 |
189 | if [[ "$fflag" == "1" ]]; then
190 | cp $tmpltimg $tmplfile
191 | if [[ $? -ne 0 ]]; then
192 | failed 2 "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"
193 | fi
194 | fi
195 |
196 | installrslt=$($(dirname $0)/createtmplt.sh -s 2 -d 'SystemVM Template' -n $localfile -t $destdir/ -f $tmplfile -u -v)
197 |
198 | if [[ $? -ne 0 ]]; then
199 | failed 2 "Failed to install system vm template $tmpltimg to $destdir: $installrslt"
200 | fi
201 |
202 | if [ "$ext" == "ova" ]
203 | then
204 | tar xvf $destdir/$localfile -C $destdir &> /dev/null
205 | fi
206 |
207 | tmpltfile=$destdir/$localfile
208 | tmpltsize=$(ls -l $tmpltfile | awk -F" " '{print $5}')
209 | if [[ "$ext" == "qcow2" ]]; then
210 | vrtmpltsize=$($qemuimgcmd info $tmpltfile | grep -i 'virtual size' | sed -ne 's/.*(\([0-9]*\).*/\1/p' | xargs)
211 | else
212 | vrtmpltsize=$tmpltsize
213 | fi
214 |
215 | echo "$ext=true" >> $destdir/template.properties
216 | echo "id=$templateId" >> $destdir/template.properties
217 | echo "public=true" >> $destdir/template.properties
218 | echo "$ext.filename=$localfile" >> $destdir/template.properties
219 | echo "uniquename=routing-$templateId" >> $destdir/template.properties
220 | echo "$ext.virtualsize=$vrtmpltsize" >> $destdir/template.properties
221 | echo "virtualsize=$vrtmpltsize" >> $destdir/template.properties
222 | echo "$ext.size=$tmpltsize" >> $destdir/template.properties
223 |
224 | echo "Successfully installed system VM template $tmpltimg and template.properties to $destdir"
225 |
--------------------------------------------------------------------------------
/files/smoketests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 |
19 | TESTDIR="/marvin/tests/smoke"
20 | LOGDIR="/marvin/log"
21 |
22 | # Remove tests that can't run
23 | rm -fv $TESTDIR/{test_hostha_simulator.py,test_kubernetes_clusters.py,test_outofbandmanagement_nestedplugin.py,test_outofbandmanagement.py,test_hostha_kvm.py}
24 |
25 | mkdir -p $LOGDIR
26 |
27 | NUMTESTS=`find $TESTDIR/test_*.py | wc -l`
28 | run_start_time="$(date -u +%s)"
29 | counter=1
30 | PASSES=0
31 | FILES=$(ls $TESTDIR/test_*py | grep -v test_host_maintenance | grep -v test_hostha_kvm)
32 | if [ -f /$TESTDIR/test_host_maintenance.py ]; then
33 | FILES="$FILES $TESTDIR/test_host_maintenance.py"
34 | fi
35 | if [ -f $TESTDIR/test_hostha_kvm.py ]; then
36 | FILES="$FILES $TESTDIR/test_hostha_kvm.py"
37 | fi
38 |
39 | for file in $FILES; do
40 | echo "Starting test: $file"
41 | nosetests-3.4 --with-xunit --xunit-file=$LOGDIR/$(basename $file).xml --with-marvin --marvin-config=marvin.cfg -s -a tags=advanced $file
42 | done
43 |
44 |
--------------------------------------------------------------------------------
/files/sudoer.mbx:
--------------------------------------------------------------------------------
1 | Cmnd_Alias MBX = /usr/bin/mkdir, /bin/mkdir, /usr/bin/mkdir, /bin/mount, /usr/bin/umount, /bin/umount, /usr/bin/cp, /bin/cp, /usr/bin/chmod, /bin/chmod, /usr/bin/keytool, /bin/keytool, /usr/bin/virsh, /usr/sbin/ldconfig, /usr/sbin/sysctl, /usr/bin/rm -fr /export/testing/*, /export/monkeybox/files/setup-systemvmtemplate.sh
2 |
3 | Defaults:%sudo !requiretty
4 |
5 | %wheel ALL=(root) NOPASSWD:MBX
6 | %sudo ALL=(root) NOPASSWD:MBX
7 |
8 |
--------------------------------------------------------------------------------
/files/systemvm-map.json:
--------------------------------------------------------------------------------
1 | {
2 | "4.11": {
3 | "kvm": {
4 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-kvm.qcow2.bz2",
5 | "checksum": "d40bce40b2d5bb4ba73e56d1e95aeae5"
6 | },
7 | "xen": {
8 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-xen.vhd.bz2",
9 | "checksum": "1566dcbcc3806755d0012d1619bd4210"
10 | },
11 | "vmw": {
12 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-vmware.ova",
13 | "checksum": "d695376be20929d323adfaa5410c093f"
14 | }
15 | },
16 | "4.12": {
17 | "kvm": {
18 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-kvm.qcow2.bz2",
19 | "checksum": "d40bce40b2d5bb4ba73e56d1e95aeae5"
20 | },
21 | "xen": {
22 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-xen.vhd.bz2",
23 | "checksum": "1566dcbcc3806755d0012d1619bd4210"
24 | },
25 | "vmw": {
26 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-vmware.ova",
27 | "checksum": "d695376be20929d323adfaa5410c093f"
28 | }
29 | },
30 | "4.13": {
31 | "kvm": {
32 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-kvm.qcow2.bz2",
33 | "checksum": "d40bce40b2d5bb4ba73e56d1e95aeae5"
34 | },
35 | "xen": {
36 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-xen.vhd.bz2",
37 | "checksum": "1566dcbcc3806755d0012d1619bd4210"
38 | },
39 | "vmw": {
40 | "url": "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.3-vmware.ova",
41 | "checksum": "d695376be20929d323adfaa5410c093f"
42 | }
43 | },
44 | "4.14": {
45 | "kvm": {
46 | "url": "https://download.cloudstack.org/systemvm/4.14/systemvmtemplate-4.14.0-kvm.qcow2.bz2",
47 | "checksum": "4978e6e6140d167556f201496549a498"
48 | },
49 | "xen": {
50 | "url": "https://download.cloudstack.org/systemvm/4.14/systemvmtemplate-4.14.0-xen.vhd.bz2",
51 | "checksum": "2e3078de2ccce760d537e06fd9b4c7c7"
52 | },
53 | "vmw": {
54 | "url": "https://download.cloudstack.org/systemvm/4.14/systemvmtemplate-4.14.0-vmware.ova",
55 | "checksum": "33cad72f858aef11c95df486b0f21938"
56 | }
57 | },
58 | "4.15": {
59 | "kvm": {
60 | "url": "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2",
61 | "checksum": "0e9f9a7d0957c3e0a2088e41b2da2cec"
62 | },
63 | "xen": {
64 | "url": "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2",
65 | "checksum": "86373992740b1eca8aff8b08ebf3aea5"
66 | },
67 | "vmw": {
68 | "url": "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova",
69 | "checksum": "4006982765846d373eb3719b2fe4d720"
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/files/vhd-util:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shapeblue/mbx/099f8350deb37be97475d05e4a162a7c2672627e/files/vhd-util
--------------------------------------------------------------------------------
/files/xenfix.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 |
19 | service xapi stop
20 | sed -i "/INSTALLATION_UUID/c\INSTALLATION_UUID='$(uuidgen)'" /etc/xensource-inventory
21 | sed -i "/CONTROL_DOMAIN_UUID/c\CONTROL_DOMAIN_UUID='$(uuidgen)'" /etc/xensource-inventory
22 | rm -rf /var/xapi/state.db
23 | cert="/etc/xensource/xapi-ssl.pem"
24 | cert_backup="${cert}.`date -u +%Y%m%dT%TZ`"
25 | mv -f "${cert}" "${cert_backup}"
26 | /opt/xensource/libexec/generate_ssl_cert "${cert}" `hostname -f`
27 | service xapi start
28 | rm -f /etc/openvswitch/conf.db*
29 | sleep 5
30 | xe host-param-set uuid=$(xe host-list params=uuid|awk {'print $5'} | head -n 1) name-label=$(hostname)
31 | xe pool-enable-tls-verification || true
32 | echo yes | /opt/xensource/bin/xe-reset-networking --device=eth0 --mode=dhcp
33 |
--------------------------------------------------------------------------------
/marvin/examples/kvm.marvin.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "physical_networks": [
8 | {
9 | "broadcastdomainrange": "Zone",
10 | "vlan": "500-600",
11 | "name": "Adv-pnet",
12 | "traffictypes": [
13 | {
14 | "typ": "Guest"
15 | },
16 | {
17 | "typ": "Management"
18 | },
19 | {
20 | "typ": "Public"
21 | }
22 | ],
23 | "providers": [
24 | {
25 | "broadcastdomainrange": "ZONE",
26 | "name": "VirtualRouter"
27 | },
28 | {
29 | "broadcastdomainrange": "ZONE",
30 | "name": "VpcVirtualRouter"
31 | },
32 | {
33 | "broadcastdomainrange": "ZONE",
34 | "name": "InternalLbVm"
35 | }
36 | ],
37 | "isolationmethods": [
38 | "VLAN"
39 | ]
40 | }
41 | ],
42 | "ipranges": [
43 | {
44 | "startip": "172.20.5.10",
45 | "endip": "172.20.5.200",
46 | "netmask": "255.255.0.0",
47 | "vlan": "untagged",
48 | "gateway": "172.20.0.1"
49 | }
50 | ],
51 | "networktype": "Advanced",
52 | "pods": [
53 | {
54 | "name": "Pod",
55 | "startip": "172.20.6.10",
56 | "endip": "172.20.6.200",
57 | "netmask": "255.255.0.0",
58 | "gateway": "172.20.0.1",
59 | "clusters": [
60 | {
61 | "clustername": "Cluster",
62 | "hypervisor": "KVM",
63 | "hosts": [
64 | {
65 | "url": "http://172.20.0.114",
66 | "username": "root",
67 | "password": "P@ssword123"
68 | },
69 | {
70 | "url": "http://172.20.0.95",
71 | "username": "root",
72 | "password": "P@ssword123"
73 | }
74 | ],
75 | "clustertype": "CloudManaged",
76 | "primaryStorages": [
77 | {
78 | "url": "nfs://172.20.0.1/export/testing/415-qa/primary1",
79 | "name": "Primary1"
80 | },
81 | {
82 | "url": "nfs://172.20.0.1/export/testing/415-qa/primary2",
83 | "name": "Primary2"
84 | }
85 | ]
86 | }
87 | ]
88 | }
89 | ],
90 | "internaldns1": "172.20.0.1",
91 | "secondaryStorages": [
92 | {
93 | "url": "nfs://172.20.0.1/export/testing/415-qa/secondary",
94 | "provider" : "NFS"
95 | }
96 | ]
97 | }
98 | ],
99 | "dbSvr": {
100 | "dbSvr": "localhost",
101 | "passwd": "cloud",
102 | "db": "cloud",
103 | "port": 3306,
104 | "user": "cloud"
105 | },
106 | "logger":
107 | {
108 | "LogFolderPath": "/tmp/"
109 | },
110 | "globalConfig": [
111 | {
112 | "name": "network.gc.wait",
113 | "value": "30"
114 | },
115 | {
116 | "name": "storage.cleanup.interval",
117 | "value": "60"
118 | },
119 | {
120 | "name": "vm.op.wait.interval",
121 | "value": "5"
122 | },
123 | {
124 | "name": "default.page.size",
125 | "value": "500"
126 | },
127 | {
128 | "name": "network.gc.interval",
129 | "value": "30"
130 | },
131 | {
132 | "name": "workers",
133 | "value": "10"
134 | },
135 | {
136 | "name": "account.cleanup.interval",
137 | "value": "60"
138 | },
139 | {
140 | "name": "guest.domain.suffix",
141 | "value": "test.kvm"
142 | },
143 | {
144 | "name": "expunge.delay",
145 | "value": "60"
146 | },
147 | {
148 | "name": "vm.allocation.algorithm",
149 | "value": "random"
150 | },
151 | {
152 | "name": "expunge.interval",
153 | "value": "60"
154 | },
155 | {
156 | "name": "expunge.workers",
157 | "value": "3"
158 | },
159 | {
160 | "name": "check.pod.cidrs",
161 | "value": "true"
162 | },
163 | {
164 | "name": "secstorage.allowed.internal.sites",
165 | "value": "0.0.0.0/0"
166 | },
167 | {
168 | "name": "direct.agent.load.size",
169 | "value": "1000"
170 | },
171 | {
172 | "name": "enable.dynamic.scale.vm",
173 | "value": "true"
174 | },
175 | {
176 | "name": "ping.interval",
177 | "value": "20"
178 | },
179 | {
180 | "name": "ping.timeout",
181 | "value": "2.0"
182 | },
183 | {
184 | "name": "kvm.snapshot.enabled",
185 | "value": "true"
186 | },
187 | {
188 | "name": "vm.destroy.forcestop",
189 | "value": "true"
190 | },
191 | {
192 | "name": "management.network.cidr",
193 | "value": "172.20.0.0/16"
194 | },
195 | {
196 | "name": "vpc.max.networks",
197 | "value": "5"
198 | }
199 | ],
200 | "mgtSvr": [
201 | {
202 | "mgtSvrIp": "localhost",
203 | "passwd": "P@ssword123",
204 | "user": "root",
205 | "port": 8096,
206 | "hypervisor": "KVM",
207 | "useHttps": "False",
208 | "certCAPath": "NA",
209 | "certPath": "NA"
210 | }
211 | ]
212 | }
213 |
--------------------------------------------------------------------------------
/marvin/examples/vmware.marvin.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "physical_networks": [
8 | {
9 | "broadcastdomainrange": "Zone",
10 | "vlan": "100-200",
11 | "name": "PhyNet",
12 | "traffictypes": [
13 | {
14 | "typ": "Guest"
15 | },
16 | {
17 | "typ": "Management"
18 | },
19 | {
20 | "typ": "Public"
21 | }
22 | ],
23 | "providers": [
24 | {
25 | "broadcastdomainrange": "ZONE",
26 | "name": "VirtualRouter"
27 | },
28 | {
29 | "broadcastdomainrange": "ZONE",
30 | "name": "VpcVirtualRouter"
31 | },
32 | {
33 | "broadcastdomainrange": "ZONE",
34 | "name": "InternalLbVm"
35 | }
36 | ],
37 | "isolationmethods": [
38 | "VLAN"
39 | ]
40 | }
41 | ],
42 | "ipranges": [
43 | {
44 | "startip": "172.20.1.10",
45 | "endip": "172.20.1.200",
46 | "netmask": "255.255.0.0",
47 | "vlan": "untagged",
48 | "gateway": "172.20.0.1"
49 | }
50 | ],
51 | "networktype": "Advanced",
52 | "pods": [
53 | {
54 | "name": "Pod",
55 | "startip": "172.20.2.10",
56 | "endip": "172.20.2.200",
57 | "netmask": "255.255.0.0",
58 | "gateway": "172.20.0.1",
59 | "vmwaredc": {
60 | "username": "administrator@vsphere.local",
61 | "vcenter": "172.20.0.105",
62 | "password": "P@ssword123",
63 | "name": "DC"
64 | },
65 | "clusters": [
66 | {
67 | "clustername": "Cluster",
68 | "hypervisor": "VMware",
69 | "clustertype": "ExternalManaged",
70 | "username": "administrator@vsphere.local",
71 | "password": "P@ssword123",
72 | "url": "http://172.20.0.105/DC/Cluster",
73 | "clustertype": "ExternalManaged",
74 | "hosts": [
75 | {
76 | "url": "http://172.20.0.174",
77 | "username": "root",
78 | "password": "P@ssword123"
79 | }
80 | ],
81 | "primaryStorages": [
82 | {
83 | "url": "nfs://172.20.0.1/export/testing/415-vmw67/primary1",
84 | "name": "Primary1"
85 | },
86 | {
87 | "url": "nfs://172.20.0.1/export/testing/415-vmw67/primary2",
88 | "name": "Primary2"
89 | }
90 | ]
91 | }
92 | ]
93 | }
94 | ],
95 | "internaldns1": "172.20.0.1",
96 | "secondaryStorages": [
97 | {
98 | "url": "nfs://172.20.0.1/export/testing/415-vmw67/secondary",
99 | "provider" : "NFS"
100 | }
101 | ]
102 | }
103 | ],
104 | "dbSvr": {
105 | "dbSvr": "localhost",
106 | "passwd": "cloud",
107 | "db": "cloud",
108 | "port": 3306,
109 | "user": "cloud"
110 | },
111 | "logger":
112 | {
113 | "LogFolderPath": "/tmp/"
114 | },
115 | "globalConfig": [
116 | {
117 | "name": "network.gc.wait",
118 | "value": "30"
119 | },
120 | {
121 | "name": "storage.cleanup.interval",
122 | "value": "60"
123 | },
124 | {
125 | "name": "vm.op.wait.interval",
126 | "value": "5"
127 | },
128 | {
129 | "name": "default.page.size",
130 | "value": "500"
131 | },
132 | {
133 | "name": "network.gc.interval",
134 | "value": "30"
135 | },
136 | {
137 | "name": "workers",
138 | "value": "10"
139 | },
140 | {
141 | "name": "account.cleanup.interval",
142 | "value": "60"
143 | },
144 | {
145 | "name": "guest.domain.suffix",
146 | "value": "test.kvm"
147 | },
148 | {
149 | "name": "expunge.delay",
150 | "value": "60"
151 | },
152 | {
153 | "name": "vm.allocation.algorithm",
154 | "value": "random"
155 | },
156 | {
157 | "name": "expunge.interval",
158 | "value": "60"
159 | },
160 | {
161 | "name": "expunge.workers",
162 | "value": "3"
163 | },
164 | {
165 | "name": "check.pod.cidrs",
166 | "value": "true"
167 | },
168 | {
169 | "name": "secstorage.allowed.internal.sites",
170 | "value": "0.0.0.0/0"
171 | },
172 | {
173 | "name": "direct.agent.load.size",
174 | "value": "1000"
175 | },
176 | {
177 | "name": "enable.dynamic.scale.vm",
178 | "value": "true"
179 | },
180 | {
181 | "name": "ping.interval",
182 | "value": "20"
183 | },
184 | {
185 | "name": "ping.timeout",
186 | "value": "2.0"
187 | },
188 | {
189 | "name": "kvm.snapshot.enabled",
190 | "value": "true"
191 | },
192 | {
193 | "name": "vm.destroy.forcestop",
194 | "value": "true"
195 | },
196 | {
197 | "name": "management.network.cidr",
198 | "value": "172.20.0.0/16"
199 | },
200 | {
201 | "name": "vpc.max.networks",
202 | "value": "5"
203 | }
204 | ],
205 | "mgtSvr": [
206 | {
207 | "mgtSvrIp": "172.20.0.186",
208 | "user": "root",
209 | "passwd": "P@ssword123",
210 | "port": 8096,
211 | "hypervisor": "VMware",
212 | "useHttps": "False",
213 | "certCAPath": "NA",
214 | "certPath": "NA"
215 | }
216 | ]
217 | }
218 |
--------------------------------------------------------------------------------
/marvin/examples/xenserver.marvin.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "physical_networks": [
8 | {
9 | "broadcastdomainrange": "Zone",
10 | "vlan": "300-400",
11 | "name": "Adv-pnet",
12 | "traffictypes": [
13 | {
14 | "typ": "Guest"
15 | },
16 | {
17 | "typ": "Management"
18 | },
19 | {
20 | "typ": "Public"
21 | }
22 | ],
23 | "providers": [
24 | {
25 | "broadcastdomainrange": "ZONE",
26 | "name": "VirtualRouter"
27 | },
28 | {
29 | "broadcastdomainrange": "ZONE",
30 | "name": "VpcVirtualRouter"
31 | },
32 | {
33 | "broadcastdomainrange": "ZONE",
34 | "name": "InternalLbVm"
35 | }
36 | ],
37 | "isolationmethods": [
38 | "VLAN"
39 | ]
40 | }
41 | ],
42 | "ipranges": [
43 | {
44 | "startip": "172.20.3.10",
45 | "endip": "172.20.3.200",
46 | "netmask": "255.255.0.0",
47 | "vlan": "untagged",
48 | "gateway": "172.20.0.1"
49 | }
50 | ],
51 | "networktype": "Advanced",
52 | "pods": [
53 | {
54 | "name": "Pod",
55 | "startip": "172.20.4.10",
56 | "endip": "172.20.4.200",
57 | "netmask": "255.255.0.0",
58 | "gateway": "172.20.0.1",
59 | "clusters": [
60 | {
61 | "clustername": "Cluster",
62 | "hypervisor": "XenServer",
63 | "hosts": [
64 | {
65 | "url": "http://172.20.0.143",
66 | "username": "root",
67 | "password": "P@ssword123"
68 | }
69 | ],
70 | "clustertype": "CloudManaged",
71 | "primaryStorages": [
72 | {
73 | "url": "nfs://172.20.0.1/export/testing/415-qa/primary1",
74 | "name": "Primary1"
75 | },
76 | {
77 | "url": "nfs://172.20.0.1/export/testing/415-qa/primary2",
78 | "name": "Primary2"
79 | }
80 | ]
81 | }
82 | ]
83 | }
84 | ],
85 | "internaldns1": "172.20.0.1",
86 | "secondaryStorages": [
87 | {
88 | "url": "nfs://172.20.0.1/export/testing/415-qa/secondary",
89 | "provider" : "NFS"
90 | }
91 | ]
92 | }
93 | ],
94 | "dbSvr": {
95 | "dbSvr": "localhost",
96 | "passwd": "cloud",
97 | "db": "cloud",
98 | "port": 3306,
99 | "user": "cloud"
100 | },
101 | "logger":
102 | {
103 | "LogFolderPath": "/tmp/"
104 | },
105 | "globalConfig": [
106 | {
107 | "name": "network.gc.wait",
108 | "value": "60"
109 | },
110 | {
111 | "name": "storage.cleanup.interval",
112 | "value": "60"
113 | },
114 | {
115 | "name": "vm.op.wait.interval",
116 | "value": "5"
117 | },
118 | {
119 | "name": "default.page.size",
120 | "value": "500"
121 | },
122 | {
123 | "name": "network.gc.interval",
124 | "value": "60"
125 | },
126 | {
127 | "name": "workers",
128 | "value": "10"
129 | },
130 | {
131 | "name": "account.cleanup.interval",
132 | "value": "60"
133 | },
134 | {
135 | "name": "guest.domain.suffix",
136 | "value": "test.xs"
137 | },
138 | {
139 | "name": "expunge.delay",
140 | "value": "60"
141 | },
142 | {
143 | "name": "vm.allocation.algorithm",
144 | "value": "random"
145 | },
146 | {
147 | "name": "expunge.interval",
148 | "value": "60"
149 | },
150 | {
151 | "name": "expunge.workers",
152 | "value": "3"
153 | },
154 | {
155 | "name": "check.pod.cidrs",
156 | "value": "true"
157 | },
158 | {
159 | "name": "secstorage.allowed.internal.sites",
160 | "value": "0.0.0.0/0"
161 | },
162 | {
163 | "name": "direct.agent.load.size",
164 | "value": "1000"
165 | },
166 | {
167 | "name": "enable.dynamic.scale.vm",
168 | "value": "true"
169 | },
170 | {
171 | "name": "ping.interval",
172 | "value": "20"
173 | },
174 | {
175 | "name": "ping.timeout",
176 | "value": "2.0"
177 | },
178 | {
179 | "name": "vm.destroy.forcestop",
180 | "value": "true"
181 | },
182 | {
183 | "name": "management.network.cidr",
184 | "value": "172.20.0.0/16"
185 | },
186 | {
187 | "name": "vpc.max.networks",
188 | "value": "5"
189 | }
190 | ],
191 | "mgtSvr": [
192 | {
193 | "mgtSvrIp": "localhost",
194 | "passwd": "P@ssword123",
195 | "user": "root",
196 | "port": 8096,
197 | "hypervisor": "XenServer",
198 | "useHttps": "False",
199 | "certCAPath": "NA",
200 | "certPath": "NA"
201 | }
202 | ]
203 | }
204 |
--------------------------------------------------------------------------------
/marvin/kvm.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "localstorageenabled": "false",
8 | "securitygroupenabled": "false",
9 | "physical_networks": [
10 | {
11 | "broadcastdomainrange": "Zone",
12 | "vlan": "${vlan}",
13 | "name": "PhyNet",
14 | "traffictypes": [
15 | {
16 | "typ": "Guest"
17 | },
18 | {
19 | "typ": "Management"
20 | },
21 | {
22 | "typ": "Public"
23 | }
24 | ],
25 | "providers": [
26 | {
27 | "broadcastdomainrange": "ZONE",
28 | "name": "VirtualRouter"
29 | },
30 | {
31 | "broadcastdomainrange": "ZONE",
32 | "name": "VpcVirtualRouter"
33 | },
34 | {
35 | "broadcastdomainrange": "ZONE",
36 | "name": "InternalLbVm"
37 | }
38 | ],
39 | "isolationmethods": [
40 | "VLAN"
41 | ]
42 | }
43 | ],
44 | "ipranges": [
45 | {
46 | "startip": "${public_start}",
47 | "endip": "${public_end}",
48 | "netmask": "255.255.0.0",
49 | "vlan": "untagged",
50 | "gateway": "172.20.0.1"
51 | }
52 | ],
53 | "networktype": "Advanced",
54 | "pods": [
55 | {
56 | "name": "Pod",
57 | "startip": "${pod_start}",
58 | "endip": "${pod_end}",
59 | "netmask": "255.255.0.0",
60 | "gateway": "172.20.0.1",
61 | "clusters": [
62 | {
63 | "clustername": "Cluster",
64 | "hypervisor": "KVM",
65 | "hosts": [
66 | {
67 | "url": "http://${host1}",
68 | "username": "root",
69 | "password": "P@ssword123"
70 | },
71 | {
72 | "url": "http://${host2}",
73 | "username": "root",
74 | "password": "P@ssword123"
75 | }
76 | ],
77 | "clustertype": "CloudManaged",
78 | "primaryStorages": [
79 | {
80 | "url": "nfs://172.20.0.1${storage_path}/primary1",
81 | "name": "Primary1"
82 | },
83 | {
84 | "url": "nfs://172.20.0.1${storage_path}/primary2",
85 | "name": "Primary2"
86 | }
87 | ]
88 | }
89 | ]
90 | }
91 | ],
92 | "internaldns1": "172.20.0.1",
93 | "secondaryStorages": [
94 | {
95 | "url": "nfs://172.20.0.1${storage_path}/secondary",
96 | "provider" : "NFS"
97 | }
98 | ]
99 | }
100 | ],
101 | "dbSvr": {
102 | "dbSvr": "localhost",
103 | "passwd": "cloud",
104 | "db": "cloud",
105 | "port": 3306,
106 | "user": "cloud"
107 | },
108 | "logger":
109 | {
110 | "LogFolderPath": "/tmp/"
111 | },
112 | "globalConfig": [
113 | {
114 | "name": "network.gc.wait",
115 | "value": "30"
116 | },
117 | {
118 | "name": "storage.cleanup.interval",
119 | "value": "60"
120 | },
121 | {
122 | "name": "vm.op.wait.interval",
123 | "value": "5"
124 | },
125 | {
126 | "name": "default.page.size",
127 | "value": "500"
128 | },
129 | {
130 | "name": "network.gc.interval",
131 | "value": "30"
132 | },
133 | {
134 | "name": "workers",
135 | "value": "10"
136 | },
137 | {
138 | "name": "account.cleanup.interval",
139 | "value": "60"
140 | },
141 | {
142 | "name": "guest.domain.suffix",
143 | "value": "test.domain"
144 | },
145 | {
146 | "name": "expunge.delay",
147 | "value": "60"
148 | },
149 | {
150 | "name": "vm.allocation.algorithm",
151 | "value": "random"
152 | },
153 | {
154 | "name": "expunge.interval",
155 | "value": "60"
156 | },
157 | {
158 | "name": "expunge.workers",
159 | "value": "3"
160 | },
161 | {
162 | "name": "check.pod.cidrs",
163 | "value": "true"
164 | },
165 | {
166 | "name": "secstorage.allowed.internal.sites",
167 | "value": "0.0.0.0/0"
168 | },
169 | {
170 | "name": "direct.agent.load.size",
171 | "value": "1000"
172 | },
173 | {
174 | "name": "enable.dynamic.scale.vm",
175 | "value": "true"
176 | },
177 | {
178 | "name": "ping.interval",
179 | "value": "20"
180 | },
181 | {
182 | "name": "ping.timeout",
183 | "value": "2.0"
184 | },
185 | {
186 | "name": "kvm.snapshot.enabled",
187 | "value": "true"
188 | },
189 | {
190 | "name": "vm.destroy.forcestop",
191 | "value": "true"
192 | },
193 | {
194 | "name": "management.network.cidr",
195 | "value": "172.20.0.0/16"
196 | },
197 | {
198 | "name": "vpc.max.networks",
199 | "value": "5"
200 | }
201 | ],
202 | "mgtSvr": [
203 | {
204 | "mgtSvrIp": "localhost",
205 | "user": "root",
206 | "passwd": "P@ssword123",
207 | "port": 8096,
208 | "hypervisor": "KVM",
209 | "useHttps": "False",
210 | "certCAPath": "NA",
211 | "certPath": "NA"
212 | }
213 | ]
214 | }
215 |
--------------------------------------------------------------------------------
/marvin/vmw.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "localstorageenabled": "false",
8 | "securitygroupenabled": "false",
9 | "physical_networks": [
10 | {
11 | "broadcastdomainrange": "Zone",
12 | "vlan": "${vlan}",
13 | "name": "PhyNet",
14 | "traffictypes": [
15 | {
16 | "typ": "Guest"
17 | },
18 | {
19 | "typ": "Management"
20 | },
21 | {
22 | "typ": "Public"
23 | }
24 | ],
25 | "providers": [
26 | {
27 | "broadcastdomainrange": "ZONE",
28 | "name": "VirtualRouter"
29 | },
30 | {
31 | "broadcastdomainrange": "ZONE",
32 | "name": "VpcVirtualRouter"
33 | },
34 | {
35 | "broadcastdomainrange": "ZONE",
36 | "name": "InternalLbVm"
37 | }
38 | ],
39 | "isolationmethods": [
40 | "VLAN"
41 | ]
42 | }
43 | ],
44 | "ipranges": [
45 | {
46 | "startip": "${public_start}",
47 | "endip": "${public_end}",
48 | "netmask": "255.255.0.0",
49 | "vlan": "untagged",
50 | "gateway": "172.20.0.1"
51 | }
52 | ],
53 | "networktype": "Advanced",
54 | "pods": [
55 | {
56 | "name": "Pod",
57 | "startip": "${pod_start}",
58 | "endip": "${pod_end}",
59 | "netmask": "255.255.0.0",
60 | "gateway": "172.20.0.1",
61 | "vmwaredc": {
62 | "username": "administrator@vsphere.local",
63 | "vcenter": "${vcip}",
64 | "password": "P@ssword123",
65 | "name": "DC"
66 | },
67 | "clusters": [
68 | {
69 | "clustername": "Cluster",
70 | "hypervisor": "VMware",
71 | "clustertype": "ExternalManaged",
72 | "username": "administrator@vsphere.local",
73 | "password": "P@ssword123",
74 | "url": "http://${vcip}/DC/Cluster",
75 | "clustertype": "ExternalManaged",
76 | "hosts": [
77 | {
78 | "url": "http://${host1}",
79 | "username": "root",
80 | "password": "P@ssword123"
81 | },
82 | {
83 | "url": "http://${host2}",
84 | "username": "root",
85 | "password": "P@ssword123"
86 | }
87 | ],
88 | "primaryStorages": [
89 | {
90 | "url": "nfs://172.20.0.1${storage_path}/primary1",
91 | "name": "Primary1"
92 | },
93 | {
94 | "url": "nfs://172.20.0.1${storage_path}/primary2",
95 | "name": "Primary2"
96 | }
97 | ]
98 | }
99 | ]
100 | }
101 | ],
102 | "internaldns1": "172.20.0.1",
103 | "secondaryStorages": [
104 | {
105 | "url": "nfs://172.20.0.1${storage_path}/secondary",
106 | "provider" : "NFS"
107 | }
108 | ]
109 | }
110 | ],
111 | "dbSvr": {
112 | "dbSvr": "localhost",
113 | "passwd": "cloud",
114 | "db": "cloud",
115 | "port": 3306,
116 | "user": "cloud"
117 | },
118 | "logger":
119 | {
120 | "LogFolderPath": "/tmp/"
121 | },
122 | "globalConfig": [
123 | {
124 | "name": "network.gc.wait",
125 | "value": "30"
126 | },
127 | {
128 | "name": "storage.cleanup.interval",
129 | "value": "60"
130 | },
131 | {
132 | "name": "vm.op.wait.interval",
133 | "value": "5"
134 | },
135 | {
136 | "name": "default.page.size",
137 | "value": "500"
138 | },
139 | {
140 | "name": "network.gc.interval",
141 | "value": "30"
142 | },
143 | {
144 | "name": "workers",
145 | "value": "10"
146 | },
147 | {
148 | "name": "account.cleanup.interval",
149 | "value": "60"
150 | },
151 | {
152 | "name": "guest.domain.suffix",
153 | "value": "test.domain"
154 | },
155 | {
156 | "name": "expunge.delay",
157 | "value": "60"
158 | },
159 | {
160 | "name": "vm.allocation.algorithm",
161 | "value": "random"
162 | },
163 | {
164 | "name": "expunge.interval",
165 | "value": "60"
166 | },
167 | {
168 | "name": "expunge.workers",
169 | "value": "3"
170 | },
171 | {
172 | "name": "check.pod.cidrs",
173 | "value": "true"
174 | },
175 | {
176 | "name": "secstorage.allowed.internal.sites",
177 | "value": "0.0.0.0/0"
178 | },
179 | {
180 | "name": "direct.agent.load.size",
181 | "value": "1000"
182 | },
183 | {
184 | "name": "enable.dynamic.scale.vm",
185 | "value": "true"
186 | },
187 | {
188 | "name": "ping.interval",
189 | "value": "20"
190 | },
191 | {
192 | "name": "ping.timeout",
193 | "value": "2.0"
194 | },
195 | {
196 | "name": "kvm.snapshot.enabled",
197 | "value": "true"
198 | },
199 | {
200 | "name": "vm.destroy.forcestop",
201 | "value": "true"
202 | },
203 | {
204 | "name": "management.network.cidr",
205 | "value": "172.20.0.0/16"
206 | },
207 | {
208 | "name": "vpc.max.networks",
209 | "value": "5"
210 | }
211 | ],
212 | "mgtSvr": [
213 | {
214 | "mgtSvrIp": "localhost",
215 | "user": "root",
216 | "passwd": "P@ssword123",
217 | "port": 8096,
218 | "hypervisor": "VMware",
219 | "useHttps": "False",
220 | "certCAPath": "NA",
221 | "certPath": "NA"
222 | }
223 | ]
224 | }
225 |
--------------------------------------------------------------------------------
/marvin/xen.cfg:
--------------------------------------------------------------------------------
1 | {
2 | "zones": [
3 | {
4 | "name": "DC",
5 | "guestcidraddress": "10.1.1.0/24",
6 | "dns1": "8.8.8.8",
7 | "localstorageenabled": "false",
8 | "securitygroupenabled": "false",
9 | "physical_networks": [
10 | {
11 | "broadcastdomainrange": "Zone",
12 | "vlan": "${vlan}",
13 | "name": "PhyNet",
14 | "traffictypes": [
15 | {
16 | "typ": "Guest"
17 | },
18 | {
19 | "typ": "Management"
20 | },
21 | {
22 | "typ": "Public"
23 | }
24 | ],
25 | "providers": [
26 | {
27 | "broadcastdomainrange": "ZONE",
28 | "name": "VirtualRouter"
29 | },
30 | {
31 | "broadcastdomainrange": "ZONE",
32 | "name": "VpcVirtualRouter"
33 | },
34 | {
35 | "broadcastdomainrange": "ZONE",
36 | "name": "InternalLbVm"
37 | }
38 | ],
39 | "isolationmethods": [
40 | "VLAN"
41 | ]
42 | }
43 | ],
44 | "ipranges": [
45 | {
46 | "startip": "${public_start}",
47 | "endip": "${public_end}",
48 | "netmask": "255.255.0.0",
49 | "vlan": "untagged",
50 | "gateway": "172.20.0.1"
51 | }
52 | ],
53 | "networktype": "Advanced",
54 | "pods": [
55 | {
56 | "name": "Pod",
57 | "startip": "${pod_start}",
58 | "endip": "${pod_end}",
59 | "netmask": "255.255.0.0",
60 | "gateway": "172.20.0.1",
61 | "clusters": [
62 | {
63 | "clustername": "Cluster",
64 | "hypervisor": "XenServer",
65 | "hosts": [
66 | {
67 | "url": "http://${host1}",
68 | "username": "root",
69 | "password": "P@ssword123"
70 | }
71 | ],
72 | "clustertype": "CloudManaged",
73 | "primaryStorages": [
74 | {
75 | "url": "nfs://172.20.0.1${storage_path}/primary1",
76 | "name": "Primary1"
77 | },
78 | {
79 | "url": "nfs://172.20.0.1${storage_path}/primary2",
80 | "name": "Primary2"
81 | }
82 | ]
83 | }
84 | ]
85 | }
86 | ],
87 | "internaldns1": "172.20.0.1",
88 | "secondaryStorages": [
89 | {
90 | "url": "nfs://172.20.0.1${storage_path}/secondary",
91 | "provider" : "NFS"
92 | }
93 | ]
94 | }
95 | ],
96 | "dbSvr": {
97 | "dbSvr": "localhost",
98 | "passwd": "cloud",
99 | "db": "cloud",
100 | "port": 3306,
101 | "user": "cloud"
102 | },
103 | "logger":
104 | {
105 | "LogFolderPath": "/tmp/"
106 | },
107 | "globalConfig": [
108 | {
109 | "name": "network.gc.wait",
110 | "value": "30"
111 | },
112 | {
113 | "name": "storage.cleanup.interval",
114 | "value": "60"
115 | },
116 | {
117 | "name": "vm.op.wait.interval",
118 | "value": "5"
119 | },
120 | {
121 | "name": "default.page.size",
122 | "value": "500"
123 | },
124 | {
125 | "name": "network.gc.interval",
126 | "value": "30"
127 | },
128 | {
129 | "name": "workers",
130 | "value": "10"
131 | },
132 | {
133 | "name": "account.cleanup.interval",
134 | "value": "60"
135 | },
136 | {
137 | "name": "guest.domain.suffix",
138 | "value": "test.domain"
139 | },
140 | {
141 | "name": "expunge.delay",
142 | "value": "60"
143 | },
144 | {
145 | "name": "vm.allocation.algorithm",
146 | "value": "random"
147 | },
148 | {
149 | "name": "expunge.interval",
150 | "value": "60"
151 | },
152 | {
153 | "name": "expunge.workers",
154 | "value": "3"
155 | },
156 | {
157 | "name": "check.pod.cidrs",
158 | "value": "true"
159 | },
160 | {
161 | "name": "secstorage.allowed.internal.sites",
162 | "value": "0.0.0.0/0"
163 | },
164 | {
165 | "name": "direct.agent.load.size",
166 | "value": "1000"
167 | },
168 | {
169 | "name": "enable.dynamic.scale.vm",
170 | "value": "true"
171 | },
172 | {
173 | "name": "ping.interval",
174 | "value": "20"
175 | },
176 | {
177 | "name": "ping.timeout",
178 | "value": "2.0"
179 | },
180 | {
181 | "name": "kvm.snapshot.enabled",
182 | "value": "true"
183 | },
184 | {
185 | "name": "vm.destroy.forcestop",
186 | "value": "true"
187 | },
188 | {
189 | "name": "management.network.cidr",
190 | "value": "172.20.0.0/16"
191 | },
192 | {
193 | "name": "vpc.max.networks",
194 | "value": "5"
195 | }
196 | ],
197 | "mgtSvr": [
198 | {
199 | "mgtSvrIp": "localhost",
200 | "user": "root",
201 | "passwd": "P@ssword123",
202 | "port": 8096,
203 | "hypervisor": "XenServer",
204 | "useHttps": "False",
205 | "certCAPath": "NA",
206 | "certPath": "NA"
207 | }
208 | ]
209 | }
210 |
--------------------------------------------------------------------------------
/mbx:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | set -e
19 |
20 | ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
21 | mkdir -p $ROOT/boxes
22 | touch $ROOT/boxes/boxes.list
23 | export LIBVIRT_DEFAULT_URI="qemu:///system"
24 | echo MonkeyBox 🐵 v0.4
25 |
26 | usage() {
27 | echo "Available commands are:"
28 | echo " init: initialises monkeynet and mbx templates"
29 | echo " package: builds packages from a git repo and sha/tag/branch"
30 | echo " list: lists available environments"
31 | echo " deploy: creates QA env with two monkeybox VMs and creates marvin cfg file"
32 | echo " launch: launches QA env zone using environment's marvin cfg file"
33 | echo " test: start marvin tests"
34 | echo " dev: creates dev env with a single monkeybox VM and creates marvin cfg file"
35 | echo " agentscp: updates KVM agent in dev environment using scp and restarts it"
36 | echo " ssh: ssh into a mbx VM"
37 | echo " stop: stop all env VMs"
38 | echo " start: start all env VMs"
39 | echo " destroy: destroy environment"
40 | }
41 |
42 | init() {
43 | if virsh net-list --all --name | grep -q monkeynet;
44 | then
45 | echo "'monkeynet' network is already defined, skipped re-initialisation";
46 | else
47 | virsh net-destroy monkeynet 2>/dev/null || true
48 | virsh net-undefine monkeynet 2>/dev/null || true
49 | virsh net-define $ROOT/monkeynet.xml
50 | virsh net-autostart monkeynet
51 | virsh net-start monkeynet
52 | fi
53 | echo "Setting up mbx sudoers file. Please enter sudoer password if you're prompted."
54 | sudo cp $ROOT/files/sudoer.mbx /etc/sudoers.d/mbx
55 | for template in $(virsh list --all | awk '{print $2}' | grep mbxt-); do
56 | echo "Forgetting template: $template"
57 | virsh undefine $template >/dev/null 2>/dev/null || true
58 | done
59 | echo "Updating templates"
60 | for template in $(cat $ROOT/templates/md5sum.txt | awk '{print $2}' | sed 's/.qcow2//g'); do
61 | echo "Updating template: $template"
62 | wget -nc https://download.cloudstack.org/templates/mbx/$template.qcow2 -O $ROOT/templates/$template.qcow2 || true
63 | virsh define $ROOT/templates/xmls/mbxt-$template.xml >/dev/null
64 | done
65 | echo "Running md5 checksum checks on templates (this may take some time...)"
66 | (cd $ROOT/templates && md5sum --check md5sum.txt)
67 | sudo cp $ROOT/files/libvhd.so.1.0 /usr/lib/
68 | sudo ldconfig
69 | sudo cp $ROOT/files/vhd-util /usr/bin/
70 | }
71 |
72 | list() {
73 | echo
74 | for env in $(cat $ROOT/boxes/boxes.list); do
75 | echo -e "Name: \033[4m$env\033[0m"
76 | for vm in $(cat $ROOT/boxes/$env/list); do
77 | ip=$(getent hosts $vm | awk '{ print $1 }')
78 | url=""
79 | if [[ $vm == *"mgmt"* ]]; then
80 | url="http://$ip:8080/client"
81 | fi
82 | echo -e "$vm\t$ip\t$url"
83 | if [[ $vm == *vmw-host1* ]]; then
84 | vcip=$(sshpass -p 'P@ssword123' ssh -o "ConnectTimeout=1" -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" root@$vm vim-cmd "vmsvc/get.guest 1 | grep ipAddress | head -1 | sed 's/.*ipAddress = \"//g' | sed 's/\".*//g'" 2> /dev/null) || true
85 | echo -e "$env-vcsvr\t$vcip\thttps://$vcip/"
86 | fi
87 | done
88 | echo
89 | options+=($env)
90 | done
91 | if [ ${#options[@]} -eq 0 ]; then
92 | echo -e "No mbx environments found\n"
93 | fi
94 | echo "Following mbx templates are available:"
95 | virsh list --all | grep mbxt- | awk '{print $2}'
96 | }
97 |
98 | package() {
99 | if [[ "$1" == "-h" ]]; then
100 | echo "Usage: mbx package