Merge lp:~thomnico/orange-box/mirroring into lp:orange-box

Proposed by Nicolas Thomas
Status: Approved
Approved by: Scott Croft
Approved revision: 527
Proposed branch: lp:~thomnico/orange-box/mirroring
Merge into: lp:orange-box
Diff against target: 2111 lines (+431/-684)
27 files modified
debian/changelog (+64/-11)
debian/control (+6/-4)
debian/install (+3/-0)
debian/links (+1/-1)
debian/postinst (+0/-310)
debian/postrm (+0/-23)
debian/preinst (+0/-136)
debian/source/format (+1/-1)
etc/apache2/sites-available/archive.conf (+1/-0)
etc/apt/orange-box-mirror.list (+36/-14)
etc/bind/named.conf.wildcard-archive (+6/-0)
etc/bind/zones.wildcard-archive (+20/-0)
etc/orangebox-mirror.state (+1/-0)
usr/bin/orange-box-add-node (+6/-3)
usr/bin/orange-box-add-physical-nodes (+7/-2)
usr/bin/orange-box-add-virtual-nodes (+24/-12)
usr/bin/orange-box-amt-monitor (+3/-1)
usr/bin/orange-box-apm-power-fix (+0/-38)
usr/bin/orange-box-bootstrap-juju (+5/-1)
usr/bin/orange-box-create-package-mirror (+14/-1)
usr/bin/orange-box-demo-cleanup (+3/-1)
usr/bin/orange-box-hacks (+32/-0)
usr/bin/orange-box-mirror (+165/-0)
usr/bin/orange-box-purge-everything (+1/-0)
usr/bin/orange-box-run (+21/-18)
usr/bin/orange-box-setup-nat (+0/-99)
usr/bin/orange-box-status-all-nodes (+11/-8)
To merge this branch: bzr merge lp:~thomnico/orange-box/mirroring
Reviewer Review Type Date Requested Status
Orange Box Pending
Review via email: mp+246782@code.launchpad.net
To post a comment you must log in.
lp:~thomnico/orange-box/mirroring updated
524. By Nicolas Thomas

releasing 1.90-0mirror

525. By Nicolas Thomas

Clean up

modified:
  usr/bin/orange-box-mirror

526. By Nicolas Thomas

Fix the place where the state of mirroring is placed.

added:
  etc/orangebox-mirror.state
modified:
  usr/bin/orange-box-mirror

527. By Nicolas Thomas

Commit merged from trunk
modified:
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-create-package-mirror
pending merges:
  Dustin Kirkland 2015-01-21 * etc/apt/orange-box-mirror.list, usr/bin/orange-box-create-package-

528. By Nicolas Thomas

Add missing deb-src and update mirror to ensure correct permissions.

modified:
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-mirror

529. By Nicolas Thomas

Merged with latest dev (newnet branch)

* Change source/format for bzr-buildpackage to work
* Fix issue with the ssh checking for power management of VMs
*
*
* Add biosdevname cmd in scripts
* Add a check/heal for VMs powermanagement ssh keys
*
[ Nicolas Thomas ]
* Remove synccharmstore etc..
* Adapt a number of changes to network setup etc..
* Assume ob number in preinst and check in postinst in case network is not up
* preinst bridgeutils

[ Takenori Matsumoto ]
* usr/bin/orange-box-setup-nat:
  - Fix net.ipv4.conf.all.accept_redirects
* usr/bin/orange-box-add-virtual-node
  - Fix Add maas's ssh key into /home/ubuntu/.ssh/authorized_keys so that MAAS can control power via virsh
[ Takenori Matsumoto ]
* Re-write pachtes based on PPA (orange-box_1.89-0ubuntu1~trusty.debian.tar.xz, orange-box_1.89.orig.tar.gz) rather than trunk codes
[ takenori ]
* usr/bin/orange-box-add-virtual-nodes:
* usr/bin/orange-box-add-virtual-nodes:
* usr/bin/orange-box-add-virtual-nodes:
* :
[ Dustin Kirkland ]
[ takenori ]
* :

removed:
  debian/postinst
  debian/postrm
  debian/preinst
  usr/bin/orange-box-apm-power-fix
  usr/bin/orange-box-setup-nat
added:
  debian/install
  debian/postinst
  debian/postrm
  debian/preinst
  usr/bin/orange-box-hacks
  usr/bin/orange-box-setup-nat
modified:
  debian/changelog
  debian/control
  debian/links
  debian/source/format
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-add-node
  usr/bin/orange-box-add-physical-nodes
  usr/bin/orange-box-add-virtual-nodes
  usr/bin/orange-box-amt-monitor
  usr/bin/orange-box-bootstrap-juju
  usr/bin/orange-box-create-package-mirror
  usr/bin/orange-box-demo-cleanup
  usr/bin/orange-box-purge-everything
  usr/bin/orange-box-run
  usr/bin/orange-box-status-all-nodes
pending merges:
  Nicolas Thomas 2015-06-15 updates on ssh maas to ubuntu automation
    Nicolas Thomas 2015-06-15 releasing 2.9~ppa2
    Nicolas Thomas 2015-06-15 Update source/format so zbr-buildpackages works
    Nicolas Thomas 2015-06-15 releasing 2.9~ppa1
    Nicolas Thomas 2015-06-15 releasing 2.8~ppa1
    Nicolas Thomas 2015-06-15 * Add biosdevname cmd in scripts
    Nicolas Thomas 2015-06-11 releasing 2.8ubuntu1~trusty
    Nicolas Thomas 2015-06-11 releasing 2.8~ppa0
    Nicolas Thomas 2015-06-11 Fix the maas ssh keygen creation or copy
    Nicolas Thomas 2015-06-11 Fix the creation of the etc/orange-box.conf file
    Nicolas Thomas 2015-06-11 * Assume ob number in preinst and check in postinst in case network is not up
    Nicolas Thomas 2015-06-11 Move MAAS / nmap to predepend as they are used in preinst and that block dpkg -i when developing
    Nicolas Thomas 2015-06-11 * Adapt a number of changes to network setup etc..
    Nicolas Thomas 2015-06-11 Remove synccharmstore etc..
    Nicolas Thomas 2015-06-11 Aligned with Takenori modif made out of bzr.
    Nicolas Thomas 2015-06-09 * Testing tomnico ppa
    Nicolas Thomas 2015-06-09 :
    Nicolas Thomas 2015-06-09 * usr/bin/orange-box-setup-nat:
    Nicolas Thomas 2015-04-27 * remove debian/postrm, debian/preinst remove:
    Nicolas Thomas 2015-04-27 debian/postrm, debian/preinst remove:
    Nicolas Thomas 2015-04-27 * Creating a branch to start the new orangebox setup new stuff.
    Darryl Weaver 2015-02-07 Added workaround for bug: https://bugs.launchpad.net/maas/+bug/1367482

Unmerged revisions

529. By Nicolas Thomas

Merged with latest dev (newnet branch)

* Change source/format for bzr-buildpackage to work
* Fix issue with the ssh checking for power management of VMs
*
*
* Add biosdevname cmd in scripts
* Add a check/heal for VMs powermanagement ssh keys
*
[ Nicolas Thomas ]
* Remove synccharmstore etc..
* Adapt a number of changes to network setup etc..
* Assume ob number in preinst and check in postinst in case network is not up
* preinst bridgeutils

[ Takenori Matsumoto ]
* usr/bin/orange-box-setup-nat:
  - Fix net.ipv4.conf.all.accept_redirects
* usr/bin/orange-box-add-virtual-node
  - Fix Add maas's ssh key into /home/ubuntu/.ssh/authorized_keys so that MAAS can control power via virsh
[ Takenori Matsumoto ]
* Re-write pachtes based on PPA (orange-box_1.89-0ubuntu1~trusty.debian.tar.xz, orange-box_1.89.orig.tar.gz) rather than trunk codes
[ takenori ]
* usr/bin/orange-box-add-virtual-nodes:
* usr/bin/orange-box-add-virtual-nodes:
* usr/bin/orange-box-add-virtual-nodes:
* :
[ Dustin Kirkland ]
[ takenori ]
* :

removed:
  debian/postinst
  debian/postrm
  debian/preinst
  usr/bin/orange-box-apm-power-fix
  usr/bin/orange-box-setup-nat
added:
  debian/install
  debian/postinst
  debian/postrm
  debian/preinst
  usr/bin/orange-box-hacks
  usr/bin/orange-box-setup-nat
modified:
  debian/changelog
  debian/control
  debian/links
  debian/source/format
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-add-node
  usr/bin/orange-box-add-physical-nodes
  usr/bin/orange-box-add-virtual-nodes
  usr/bin/orange-box-amt-monitor
  usr/bin/orange-box-bootstrap-juju
  usr/bin/orange-box-create-package-mirror
  usr/bin/orange-box-demo-cleanup
  usr/bin/orange-box-purge-everything
  usr/bin/orange-box-run
  usr/bin/orange-box-status-all-nodes
pending merges:
  Nicolas Thomas 2015-06-15 updates on ssh maas to ubuntu automation
    Nicolas Thomas 2015-06-15 releasing 2.9~ppa2
    Nicolas Thomas 2015-06-15 Update source/format so zbr-buildpackages works
    Nicolas Thomas 2015-06-15 releasing 2.9~ppa1
    Nicolas Thomas 2015-06-15 releasing 2.8~ppa1
    Nicolas Thomas 2015-06-15 * Add biosdevname cmd in scripts
    Nicolas Thomas 2015-06-11 releasing 2.8ubuntu1~trusty
    Nicolas Thomas 2015-06-11 releasing 2.8~ppa0
    Nicolas Thomas 2015-06-11 Fix the maas ssh keygen creation or copy
    Nicolas Thomas 2015-06-11 Fix the creation of the etc/orange-box.conf file
    Nicolas Thomas 2015-06-11 * Assume ob number in preinst and check in postinst in case network is not up
    Nicolas Thomas 2015-06-11 Move MAAS / nmap to predepend as they are used in preinst and that block dpkg -i when developing
    Nicolas Thomas 2015-06-11 * Adapt a number of changes to network setup etc..
    Nicolas Thomas 2015-06-11 Remove synccharmstore etc..
    Nicolas Thomas 2015-06-11 Aligned with Takenori modif made out of bzr.
    Nicolas Thomas 2015-06-09 * Testing tomnico ppa
    Nicolas Thomas 2015-06-09 :
    Nicolas Thomas 2015-06-09 * usr/bin/orange-box-setup-nat:
    Nicolas Thomas 2015-04-27 * remove debian/postrm, debian/preinst remove:
    Nicolas Thomas 2015-04-27 debian/postrm, debian/preinst remove:
    Nicolas Thomas 2015-04-27 * Creating a branch to start the new orangebox setup new stuff.
    Darryl Weaver 2015-02-07 Added workaround for bug: https://bugs.launchpad.net/maas/+bug/1367482

528. By Nicolas Thomas

Add missing deb-src and update mirror to ensure correct permissions.

modified:
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-mirror

527. By Nicolas Thomas

Commit merged from trunk
modified:
  etc/apt/orange-box-mirror.list
  usr/bin/orange-box-create-package-mirror
pending merges:
  Dustin Kirkland 2015-01-21 * etc/apt/orange-box-mirror.list, usr/bin/orange-box-create-package-

526. By Nicolas Thomas

Fix the place where the state of mirroring is placed.

added:
  etc/orangebox-mirror.state
modified:
  usr/bin/orange-box-mirror

525. By Nicolas Thomas

Clean up

modified:
  usr/bin/orange-box-mirror

524. By Nicolas Thomas

releasing 1.90-0mirror

523. By Nicolas Thomas

Adding files to allow a full mirroring of archives and local usage by modifying dns.
Resulting in an almost off-line environement if using only packages.

added:
  etc/bind/
  etc/bind/named.conf.wildcard-archive
  etc/bind/zones.wildcard-archive
  usr/bin/orange-box-mirror
modified:
  etc/apache2/sites-available/archive.conf
  etc/apt/orange-box-mirror.list

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-01-21 22:04:42 +0000
3+++ debian/changelog 2015-06-15 14:59:02 +0000
4@@ -1,20 +1,73 @@
5-orange-box (1.90) unreleased; urgency=medium
6-
7- * etc/apt/orange-box-mirror.list, usr/bin/orange-box-create-package-
8- mirror:
9- - we're not currently using postmirror.sh, so set to /bin/true
10-
11- -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 09 Jan 2015 11:13:51 -0600
12-
13-orange-box (1.89-0ubuntu1) vivid; urgency=medium
14-
15+orange-box (2.9ubuntu1~trusty) trusty; urgency=medium
16+
17+ * Change source/format for bzr-buildpackage to work
18+ * Fix issue with the ssh checking for power management of VMs
19+ *
20+ *
21+
22+ -- Nicolas Thomas <nicolas.thomas@canonical.com> Mon, 15 Jun 2015 13:32:06 +0200
23+
24+orange-box (2.9-0ubuntu1) trusty; urgency=medium
25+
26+ * Add biosdevname cmd in scripts
27+ * Add a check/heal for VMs powermanagement ssh keys
28+ *
29+
30+ -- Nicolas Thomas <nicolas.thomas@canonical.com> Mon, 15 Jun 2015 10:40:23 +0200
31+
32+orange-box (2.8ubuntu1~trusty-0ubuntu1) trusty; urgency=medium
33+
34+ [ Nicolas Thomas ]
35+ * Remove synccharmstore etc..
36+ * Adapt a number of changes to network setup etc..
37+ * Assume ob number in preinst and check in postinst in case network is not up
38+ * preinst bridgeutils
39+
40+ -- Nicolas Thomas <nicolas.thomas@canonical.com> Thu, 11 Jun 2015 20:59:08 +0200
41+
42+orange-box (2.7) trusty; urgency=medium
43+
44+ [ Takenori Matsumoto ]
45+ * usr/bin/orange-box-setup-nat:
46+ - Fix net.ipv4.conf.all.accept_redirects
47+ * usr/bin/orange-box-add-virtual-node
48+ - Fix Add maas's ssh key into /home/ubuntu/.ssh/authorized_keys so that MAAS can control power via virsh
49+
50+ -- Takenori Matsumoto <takenori.matsumoto@canonical.com> Fri, 02 May 2015 14:13:51 -0600
51+
52+orange-box (2.6) trusty; urgency=medium
53+
54+ [ Takenori Matsumoto ]
55+ * Re-write pachtes based on PPA (orange-box_1.89-0ubuntu1~trusty.debian.tar.xz, orange-box_1.89.orig.tar.gz) rather than trunk codes
56+
57+ [ takenori ]
58+ * usr/bin/orange-box-add-virtual-nodes:
59+ * usr/bin/orange-box-add-virtual-nodes:
60+ * usr/bin/orange-box-add-virtual-nodes:
61+ * :
62+
63+ -- Takenori Matsumoto <takenori.matsumoto@canonical.com> Fri, 02 May 2015 01:13:51 -0600
64+
65+orange-box (1.90-0mirror-0ubuntu1) utopic; urgency=medium
66+
67+ [ Nicolas Thomas ]
68+ * Adding support for mirror
69+
70+ -- thomas <nicolas.thomas@canonical.com> Sat, 17 Jan 2015 00:31:37 +0100
71+
72+orange-box (1.89-0ubuntu1~trusty) trusty; urgency=medium
73+
74+ [ Dustin Kirkland ]
75 * usr/bin/orange-box-bootstrap-juju:
76 - go back to --upload-tools, please keep this!
77 * usr/bin/orange-box-add-virtual-nodes:
78 - use ~maas rather than hard coding to /home/maas
79 + note that maas 1.7 has created a home directory in /var/lib/maas
80
81- -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 09 Jan 2015 11:13:49 -0600
82+ [ takenori ]
83+ * :
84+
85+ -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 29 Oct 2014 09:58:53 -0500
86
87 orange-box (1.88-0ubuntu1) unstable; urgency=medium
88
89
90=== modified file 'debian/control'
91--- debian/control 2014-09-24 12:15:15 +0000
92+++ debian/control 2015-06-15 14:59:02 +0000
93@@ -9,7 +9,11 @@
94 Package: orange-box
95 Architecture: all
96 Pre-Depends:
97- run-one,
98+ run-one,
99+ maas,
100+ maas-cluster-controller,
101+ nmap,
102+ bridge-utils,
103 Depends: ${misc:Depends},
104 amtterm,
105 apache2,
106@@ -27,10 +31,7 @@
107 libglib2.0-bin,
108 libvirt-bin,
109 openssh-server,
110- maas,
111- maas-cluster-controller,
112 network-manager,
113- nmap,
114 pastebinit,
115 qemu-kvm,
116 remmina,
117@@ -43,6 +44,7 @@
118 vlan,
119 wsmancli,
120 x11vnc,
121+ biosdevname,
122 Recommends:
123 landscape-client,
124 python-keystone,
125
126=== added file 'debian/install'
127--- debian/install 1970-01-01 00:00:00 +0000
128+++ debian/install 2015-06-15 14:59:02 +0000
129@@ -0,0 +1,3 @@
130+etc/
131+home/
132+usr/
133
134=== modified file 'debian/links'
135--- debian/links 2014-05-08 23:10:25 +0000
136+++ debian/links 2015-06-15 14:59:02 +0000
137@@ -1,1 +1,1 @@
138-/usr/bin/orange-box-setup-nat /etc/network/if-up.d/orange-box-setup-nat
139+
140
141=== added file 'debian/postinst'
142--- debian/postinst 1970-01-01 00:00:00 +0000
143+++ debian/postinst 2015-06-15 14:59:02 +0000
144@@ -0,0 +1,331 @@
145+#!/bin/bash
146+
147+set -e
148+set -x
149+
150+PKG="orange-box"
151+RETRY=120
152+
153+. /usr/lib/orange-box/inc/common
154+. /etc/orange-box.conf
155+
156+check_orangebox_number() {
157+## be sure to wake AMT first give some time and ping again.
158+nmap -p 16992 -oG - 172.27.${orangebox_number}.11-20 > /dev/null
159+sleep 12
160+nmap -p 16992 -oG - 172.27.${orangebox_number}.11-20 > /dev/null
161+NUMAMTS=`nmap -p 16992 -oG - 172.27.${orangebox_number}.11-20 |grep open |wc -l`
162+[[ $NUMAMTS < 3 ]] && (echo "AMT or hostname not set correctly"; rm -f /etc/orange-box.conf;exit 2)
163+true
164+}
165+
166+
167+router_ip=172.27.${orangebox_number}.1
168+static_low=172.27.`expr ${orangebox_number} + 2`.1
169+static_high=172.27.`expr ${orangebox_number} + 2`.254
170+dhcp_low=172.27.`expr ${orangebox_number} + 1`.1
171+dhcp_high=172.27.`expr ${orangebox_number} + 1`.254
172+br0_broadcast=172.27.`expr ${orangebox_number} + 3`.255
173+
174+setup_maas_admin() {
175+ # Configure the MAAS admin user
176+ # Sadly, there's no way to test if the user has been created already,
177+ # so ignore errors for idempotence
178+ maas-region-admin createadmin --username admin --email maas-admin@example.com --password="admin" 2>/dev/null || true
179+ . /etc/maas/maas_cluster.conf
180+ APIKEY=$(maas-region-admin apikey --username admin | tail -n1)
181+ maas login admin $MAAS_URL $APIKEY
182+}
183+
184+setup_maas_networking() {
185+ count=0
186+ while ! maas admin node-group-interfaces list $CLUSTER_UUID >/dev/null 2>&1; do
187+ count=$((count+1))
188+ sleep 1
189+ if [ $count -gt $RETRY ]; then
190+ error "[maas admin node-group-interfaces list] failed [$RETRY] times"
191+ fi
192+ done
193+ internal_interface=$(route -n | grep "^172\.27\.${orangebox_number}\." | sed -e "s/.* //")
194+ # Support MAAS 1.5, and 1.6
195+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
196+ if dpkg --compare-versions $maas_ver lt 1.6; then
197+ maas admin node-group-interface update $CLUSTER_UUID $internal_interface ip_range_low=$static_low ip_range_high=$static_high management=2 broadcast_ip=$br0_broadcast router_ip=$router_ip
198+
199+ else
200+ sh -x /var/lib/dpkg/info/maas-dns.postinst configure
201+ run-one-until-success maas admin node-group-interface update $CLUSTER_UUID $internal_interface ip_range_low=$dhcp_low ip_range_high=$dhcp_high static_ip_range_low=$static_low static_ip_range_high=$static_high management=2 broadcast_ip=$br0_broadcast router_ip=$router_ip
202+
203+ fi
204+ # Setup nat
205+ # Ensure we have an external connection
206+ orange-box-test-uplink
207+ orange-box-setup-nat
208+ # Redirect to MAAS web interface
209+ cat >/var/www/html/index.html <<EOF
210+<meta http-equiv="refresh" content="0; url=/MAAS">
211+EOF
212+}
213+
214+setup_dns() {
215+ # Set MAAS upstream DNS
216+ maas admin maas set-config name=upstream_dns value=172.27.252.1
217+ sed -i -e "/^nameserver ${router_ip}$/d" /etc/resolvconf/resolv.conf.d/head
218+ echo "nameserver ${router_ip}" >> /etc/resolvconf/resolv.conf.d/head
219+ resolvconf -u
220+ sed -e 's/dnssec-validation auto;/dnssec-enable no;dnssec-validation no;/g' -i /etc/bind/named.conf.options
221+}
222+
223+setup_squid() {
224+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
225+ if dpkg --compare-versions $maas_ver lt 1.6; then
226+ # This is now a transparent proxy
227+ if [ -d "/etc/squid-deb-proxy" ]; then
228+ echo > /etc/squid-deb-proxy/squid-deb-proxy.conf
229+ fi
230+ cat /usr/lib/orange-box/inc/squid.conf > /etc/squid3/squid.conf
231+ # Enable squid3, disable squid-deb-proxy
232+ update-rc.d -f squid-deb-proxy remove || true
233+ invoke-rc.d squid-deb-proxy stop || true
234+ # Create directories, if necessary
235+ squid3 -z -N || true
236+ ensure_running squid3
237+ fi
238+ true
239+}
240+
241+setup_local_mirror() {
242+ # Set up the local mirror
243+ a2ensite archive
244+ a2ensite ubuntu-cloud
245+ a2dissite 000-default
246+ mkdir -p /srv/mirrors/archive.ubuntu.com
247+ echo '<meta http-equiv="refresh" content="0; url=MAAS/">' > /srv/mirrors/archive.ubuntu.com/index.html
248+ invoke-rc.d apache2 stop || true
249+ invoke-rc.d apache2 start
250+}
251+
252+setup_boot_resources() {
253+ # Importing boot resources
254+ # This might take a long time.
255+ # MAAS won't work very well until this is done, so we're going to block
256+ # until this completes.
257+ orange-box-test-uplink
258+ # Support MAAS 1.5, and newer
259+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
260+ if dpkg --compare-versions $maas_ver lt 1.6; then
261+ cat /usr/lib/orange-box/inc/bootresources_1.5.yaml > /etc/maas/bootresources.yaml
262+ run-this-one maas-import-pxe-files --config-file /etc/maas/bootresources.yaml
263+ else
264+ maas admin boot-resources import
265+ while [ $(maas admin boot-images read $CLUSTER_UUID | wc -l) -lt 10 ]; do
266+ # Waiting for images to download
267+ sleep 10
268+ done
269+ # add precise to the list but don't wait it is not necessary now.
270+ # usual failure is already there..
271+ maas admin boot-source-selections create 1 os="ubuntu" release="precise" arches="amd64" subarches="*" labels="*" || true
272+ maas admin boot-resources import
273+ fi
274+}
275+
276+setup_desktop() {
277+ sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.background picture-uri file:///usr/share/orange-box/orange-box-background.png
278+ sudo -u ubuntu dbus-launch gsettings set com.canonical.Unity.Launcher favorites "['firefox.desktop', 'byobu.desktop', 'remmina.desktop']"
279+ sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.session idle-delay 999999
280+ sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
281+ sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled false
282+ if [ -e /etc/lightdm/lightdm.conf ]; then
283+ sed -i -e "/autologin-user=/d" /etc/lightdm/users.conf
284+ echo "autologin-user=ubuntu" >> /etc/lightdm/users.conf
285+ fi
286+ echo "enabled=0" > /etc/default/apport
287+ invoke-rc.d apport stop || true
288+}
289+
290+setup_ssh_keys() {
291+ # Disable remote password authentication, since our username/password
292+ # combo is very well known
293+ if ! grep -qs "^PasswordAuthentication no" /etc/ssh/sshd_config 2>/dev/null; then
294+ echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
295+ invoke-rc.d ssh stop || true
296+ invoke-rc.d ssh start
297+ fi
298+ if [ ! -e /home/ubuntu/.ssh/id_rsa ]; then
299+ su -l ubuntu -c "ssh-keygen -N '' -f /home/ubuntu/.ssh/id_rsa"
300+ fi
301+ maas admin sshkeys new key="$(cat /home/ubuntu/.ssh/id_rsa.pub)" || true
302+ if ! grep -qs "^Host.*maas$" /home/ubuntu/.ssh/config; then
303+ cat <<EOF >>/home/ubuntu/.ssh/config
304+
305+Host *.maas
306+UserKnownHostsFile /dev/null
307+StrictHostKeyChecking no
308+CheckHostIP no
309+
310+EOF
311+ fi
312+ chmod 600 /home/ubuntu/.ssh/config
313+ chown -R ubuntu:ubuntu /home/ubuntu/.ssh/config
314+
315+}
316+
317+setup_juju() {
318+ mkdir -p /home/ubuntu/.juju
319+ cat >/home/ubuntu/.juju/environments.yaml <<EOF
320+default: maas
321+environments:
322+ maas:
323+ type: maas
324+ maas-server: 'http://${router_ip}/MAAS/'
325+ maas-oauth: '$APIKEY'
326+ default-series: trusty
327+ #enable-os-upgrade: false
328+ authorized-keys-path: /home/ubuntu/.ssh/id_rsa.pub
329+ admin-secret: 'admin'
330+ logging-config: '<root>=DEBUG'
331+ lxc-clone: true
332+EOF
333+ rm -rf /home/ubuntu/.juju-plugins
334+ git clone https://github.com/juju/plugins /home/ubuntu/.juju-plugins
335+ sudo chown -R ubuntu:ubuntu /home/ubuntu/
336+ echo "PATH=\$PATH:/home/ubuntu/.juju-plugins:/home/ubuntu/Examples/bin" >> /home/ubuntu/.bashrc
337+ #Required for local charm deployments to work.
338+ sed -i -e '/^export JUJU_REPOSITORY=/d' /home/ubuntu/.bashrc
339+}
340+
341+ensure_running() {
342+ job="$1"
343+ count=1
344+ while true; do
345+ if (service $job status | grep -qs "running"); then
346+ break
347+ fi
348+ invoke-rc.d $job start
349+ sleep 1
350+ count=$((count+1))
351+ if [ $count -gt $RETRY ]; then
352+ error "[$job] refused to start [$RETRY] times"
353+ fi
354+ done
355+}
356+
357+ensure_running_maas() {
358+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
359+ if dpkg --compare-versions $maas_ver lt 1.6; then
360+ ensure_running maas-region-celery
361+ ensure_running maas-cluster-celery
362+ ensure_running maas-txlongpoll
363+ ensure_running maas-pserv
364+ ensure_running maas-dhcp-server
365+ ensure_running squid3
366+ else
367+ ensure_running apache2
368+ ensure_running maas-clusterd
369+ ensure_running maas-dhcpd
370+ ensure_running maas-proxy
371+ fi
372+ invoke-rc.d tgt stop || true
373+ invoke-rc.d tgt start
374+ ensure_running tgt
375+}
376+
377+setup_all_nodes() {
378+ # Ensure that pxe and dhcp are running
379+ ensure_running_maas
380+ maas admin node-groups import-boot-images
381+ orange-box-add-physical-nodes
382+ orange-box-add-virtual-nodes
383+}
384+
385+apply_patches() {
386+ # This is a DISGUSTING HACK that needs to go away
387+ # as soon as MAAS ships these fixes
388+ cd /
389+ cat /usr/lib/orange-box/patches/acquire_languages_none.patch | patch -p0 -N || true
390+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
391+ if dpkg --compare-versions $maas_ver lt 1.6; then
392+ cat /usr/lib/orange-box/patches/arp_ip_order.patch | patch -p0 -N || true
393+ cat /usr/lib/orange-box/patches/try_amt_harder.patch | patch -p0 -N || true
394+ rm -f /usr/lib/python2.7/dist-packages/provisioningserver/utils/__init__.pyc
395+ invoke-rc.d maas-cluster-celery stop || true
396+ invoke-rc.d maas-cluster-celery start
397+ fi
398+ cd -
399+}
400+
401+setup_landscape() {
402+ # The master node will be managed by Landscape
403+ # TODO: this is currently hardcoded to our own landscape account
404+ if which landscape-config; then
405+ case "$(hostname)" in
406+ OrangeBox*|orangebox*)
407+ landscape-config -a canonical-orange -t "$(hostname)__$(dmidecode -s baseboard-serial-number)" -p ubuntu-aubergine --script-users=ALL --silent --include-manager-plugins=ScriptExecution || true
408+ ;;
409+ esac
410+ fi
411+}
412+
413+setup_examples() {
414+ mkdir -p /home/ubuntu
415+ if [ -d /home/ubuntu/Examples/.bzr ]; then
416+ bzr pull >/dev/null 2>&1 || true
417+ elif [ -d /home/ubuntu/Examples ]; then
418+ mv -f /home/ubuntu/Examples /home/ubuntu/.Examples
419+ bzr branch lp:orange-box-examples /home/ubuntu/Examples >/dev/null 2>&1 || true
420+ else
421+ bzr branch lp:orange-box-examples /home/ubuntu/Examples >/dev/null 2>&1 || true
422+ fi
423+ chown -R ubuntu:ubuntu /home/ubuntu
424+}
425+
426+case "$1" in
427+ configure)
428+ check_orangebox_number
429+ setup_desktop
430+ ###apply_patches
431+ setup_maas_admin
432+ setup_dns
433+ if [ -n "$2" ]; then
434+ echo
435+ echo "INFO: Skipping importing boot resources, since this is a package upgrade"
436+ echo "INFO: If you want to update boot resources, run:"
437+ echo "INFO: sudo maas-import-pxe-files"
438+ echo "INFO: sudo maas admin node-groups import-boot-images"
439+ echo
440+ else
441+ setup_boot_resources
442+ fi
443+ setup_maas_networking
444+ maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
445+ if dpkg --compare-versions $maas_ver lt 1.6; then
446+ setup_squid
447+ fi
448+ setup_local_mirror
449+ setup_ssh_keys
450+ setup_juju
451+ if [ -n "$2" ]; then
452+ echo
453+ echo "INFO: Skipping adding all nodes, since this is a package upgrade"
454+ echo "INFO: If you want to delete and add all nodes again, run:"
455+ echo "INFO: sudo orange-box-add-physical-nodes"
456+ echo "INFO: sudo orange-box-add-virtual-nodes"
457+ echo
458+ else
459+ # Only add all nodes and configure landscape on initial install, not upgrades
460+ setup_landscape
461+ setup_all_nodes
462+ fi
463+# setup_examples
464+ ;;
465+ abort-upgrade|abort-remove|abort-deconfigure)
466+ ;;
467+ *)
468+ echo "postinst called with unknown argument \`$1'" >&2
469+ exit 1
470+ ;;
471+esac
472+
473+#DEBHELPER#
474+
475+exit 0
476
477=== removed file 'debian/postinst'
478--- debian/postinst 2014-11-27 23:56:37 +0000
479+++ debian/postinst 1970-01-01 00:00:00 +0000
480@@ -1,310 +0,0 @@
481-#!/bin/sh
482-
483-set -e
484-set -x
485-
486-PKG="orange-box"
487-RETRY=120
488-
489-. /usr/lib/orange-box/inc/common
490-
491-setup_maas_admin() {
492- # Configure the MAAS admin user
493- # Sadly, there's no way to test if the user has been created already,
494- # so ignore errors for idempotence
495- maas-region-admin createadmin --username admin --email maas-admin@example.com --password="admin" 2>/dev/null || true
496- . /etc/maas/maas_cluster.conf
497- APIKEY=$(maas-region-admin apikey --username admin | tail -n1)
498- maas login admin $MAAS_URL $APIKEY
499-}
500-
501-setup_maas_networking() {
502- count=0
503- while ! maas admin node-group-interfaces list $CLUSTER_UUID >/dev/null 2>&1; do
504- count=$((count+1))
505- sleep 1
506- if [ $count -gt $RETRY ]; then
507- error "[maas admin node-group-interfaces list] failed [$RETRY] times"
508- fi
509- done
510- internal_interface=$(route -n | grep "^10\.14\." | sed -e "s/.* //")
511- # Support MAAS 1.5, and 1.6
512- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
513- if dpkg --compare-versions $maas_ver lt 1.6; then
514- maas admin node-group-interface update $CLUSTER_UUID $internal_interface ip_range_low=10.14.100.1 ip_range_high=10.14.199.254 management=2 broadcast_ip=10.14.255.255 router_ip=10.14.4.1
515- else
516- sh -x /var/lib/dpkg/info/maas-dns.postinst configure
517- run-one-until-success maas admin node-group-interface update $CLUSTER_UUID $internal_interface ip_range_low=10.14.50.1 ip_range_high=10.14.99.254 static_ip_range_low=10.14.100.1 static_ip_range_high=10.14.199.254 management=2 broadcast_ip=10.14.255.255 router_ip=10.14.4.1
518- fi
519- # Setup nat
520- # Ensure we have an external connection
521- orange-box-test-uplink
522- orange-box-setup-nat
523- # Redirect to MAAS web interface
524- cat >/var/www/html/index.html <<EOF
525-<meta http-equiv="refresh" content="0; url=/MAAS">
526-EOF
527-}
528-
529-setup_dns() {
530- # Set MAAS upstream DNS
531- external_interface=$(ip route ls | grep ^default | awk '{print $5}')
532- dns=$(nmcli d list iface $external_interface | grep -m 1 "^IP4.DNS" | awk '{ print $2 }')
533- maas admin maas set-config name=upstream_dns value=$dns
534- sed -i -e "/^nameserver 10.14.4.1$/d" /etc/resolvconf/resolv.conf.d/head
535- echo "nameserver 10.14.4.1" >> /etc/resolvconf/resolv.conf.d/head
536- resolvconf -u
537- sed -e 's/dnssec-validation auto;/dnssec-enable no;dnssec-validation no;/g' -i /etc/bind/named.conf.options
538-}
539-
540-setup_squid() {
541- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
542- if dpkg --compare-versions $maas_ver lt 1.6; then
543- # This is now a transparent proxy
544- if [ -d "/etc/squid-deb-proxy" ]; then
545- echo > /etc/squid-deb-proxy/squid-deb-proxy.conf
546- fi
547- cat /usr/lib/orange-box/inc/squid.conf > /etc/squid3/squid.conf
548- # Disable squid3, enable squid-deb-proxy
549- update-rc.d -f squid-deb-proxy remove || true
550- invoke-rc.d squid-deb-proxy stop || true
551- # Create directories, if necessary
552- squid3 -z -N || true
553- ensure_running squid3
554- fi
555- true
556-}
557-
558-setup_local_mirror() {
559- # Set up the local mirror
560- a2ensite archive
561- a2ensite ubuntu-cloud
562- a2dissite 000-default
563- mkdir -p /srv/mirrors/archive.ubuntu.com
564- echo '<meta http-equiv="refresh" content="0; url=MAAS/">' > /srv/mirrors/archive.ubuntu.com/index.html
565- invoke-rc.d apache2 stop || true
566- invoke-rc.d apache2 start
567- # Sync the charm store to /srv/charmstore
568- # Note: This is going to take a LONG time
569- orange-box-sync-charmstore &
570-}
571-
572-setup_boot_resources() {
573- # Importing boot resources
574- # This might take a long time.
575- # MAAS won't work very well until this is done, so we're going to block
576- # until this completes.
577- orange-box-test-uplink
578- # Support MAAS 1.5, and newer
579- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
580- if dpkg --compare-versions $maas_ver lt 1.6; then
581- cat /usr/lib/orange-box/inc/bootresources_1.5.yaml > /etc/maas/bootresources.yaml
582- run-this-one maas-import-pxe-files --config-file /etc/maas/bootresources.yaml
583- else
584- maas admin boot-resources import
585- while [ $(maas admin boot-images read $CLUSTER_UUID | wc -l) -lt 10 ]; do
586- # Waiting for images to download
587- sleep 10
588- done
589- fi
590-}
591-
592-setup_desktop() {
593- sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.background picture-uri file:///usr/share/orange-box/orange-box-background.png
594- sudo -u ubuntu dbus-launch gsettings set com.canonical.Unity.Launcher favorites "['firefox.desktop', 'byobu.desktop', 'remmina.desktop']"
595- sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.session idle-delay 999999
596- sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
597- sudo -u ubuntu dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled false
598- if [ -e /etc/lightdm/lightdm.conf ]; then
599- sed -i -e "/autologin-user=/d" /etc/lightdm/users.conf
600- echo "autologin-user=ubuntu" >> /etc/lightdm/users.conf
601- fi
602- echo "enabled=0" > /etc/default/apport
603- invoke-rc.d apport stop || true
604-}
605-
606-setup_ssh_keys() {
607- # Disable remote password authentication, since our username/password
608- # combo is very well known
609- if ! grep -qs "^PasswordAuthentication no" /etc/ssh/sshd_config 2>/dev/null; then
610- echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
611- invoke-rc.d ssh stop || true
612- invoke-rc.d ssh start
613- fi
614- if [ ! -e /home/ubuntu/.ssh/id_rsa ]; then
615- su -l ubuntu -c "ssh-keygen -N '' -f /home/ubuntu/.ssh/id_rsa"
616- fi
617- maas admin sshkeys new key="$(cat /home/ubuntu/.ssh/id_rsa.pub)" || true
618- if ! grep -qs "^Host.*maas$" /home/ubuntu/.ssh/config; then
619- cat <<EOF >>/home/ubuntu/.ssh/config
620-
621-Host *.maas
622-UserKnownHostsFile /dev/null
623-StrictHostKeyChecking no
624-CheckHostIP no
625-
626-EOF
627- fi
628- chmod 600 /home/ubuntu/.ssh/config
629- chown -R ubuntu:ubuntu /home/ubuntu/.ssh/config
630-}
631-
632-setup_juju() {
633- mkdir -p /home/ubuntu/.juju
634- cat >/home/ubuntu/.juju/environments.yaml <<EOF
635-default: maas
636-environments:
637- maas:
638- type: maas
639- maas-server: 'http://10.14.4.1/MAAS/'
640- maas-oauth: '$APIKEY'
641- default-series: trusty
642- #enable-os-upgrade: false
643- authorized-keys-path: /home/ubuntu/.ssh/id_rsa.pub
644- admin-secret: 'admin'
645- logging-config: '<root>=DEBUG'
646- lxc-clone: true
647-EOF
648- rm -rf /home/ubuntu/.juju-plugins
649- git clone https://github.com/juju/plugins /home/ubuntu/.juju-plugins
650- sudo chown -R ubuntu:ubuntu /home/ubuntu/
651- echo "PATH=\$PATH:/home/ubuntu/.juju-plugins:/home/ubuntu/Examples/bin" >> /home/ubuntu/.bashrc
652- #Required for local charm deployments to work.
653- sed -i -e '/^export JUJU_REPOSITORY=/d' /home/ubuntu/.bashrc
654- echo "export JUJU_REPOSITORY=/srv/charmstore" >> /home/ubuntu/.bashrc
655-}
656-
657-ensure_running() {
658- job="$1"
659- count=1
660- while true; do
661- if (service $job status | grep -qs "running"); then
662- break
663- fi
664- invoke-rc.d $job start
665- sleep 1
666- count=$((count+1))
667- if [ $count -gt $RETRY ]; then
668- error "[$job] refused to start [$RETRY] times"
669- fi
670- done
671-}
672-
673-ensure_running_maas() {
674- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
675- if dpkg --compare-versions $maas_ver lt 1.6; then
676- ensure_running maas-region-celery
677- ensure_running maas-cluster-celery
678- ensure_running maas-txlongpoll
679- ensure_running maas-pserv
680- ensure_running maas-dhcp-server
681- ensure_running squid3
682- else
683- ensure_running apache2
684- ensure_running maas-clusterd
685- ensure_running maas-dhcpd
686- ensure_running maas-proxy
687- fi
688- invoke-rc.d tgt stop || true
689- invoke-rc.d tgt start
690- ensure_running tgt
691-}
692-
693-setup_all_nodes() {
694- # Ensure that pxe and dhcp are running
695- ensure_running_maas
696- maas admin node-groups import-boot-images
697- orange-box-add-physical-nodes
698- orange-box-add-virtual-nodes
699-}
700-
701-apply_patches() {
702- # This is a DISGUSTING HACK that needs to go away
703- # as soon as MAAS ships these fixes
704- cd /
705- cat /usr/lib/orange-box/patches/acquire_languages_none.patch | patch -p0 -N || true
706- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
707- if dpkg --compare-versions $maas_ver lt 1.6; then
708- cat /usr/lib/orange-box/patches/arp_ip_order.patch | patch -p0 -N || true
709- cat /usr/lib/orange-box/patches/try_amt_harder.patch | patch -p0 -N || true
710- rm -f /usr/lib/python2.7/dist-packages/provisioningserver/utils/__init__.pyc
711- invoke-rc.d maas-cluster-celery stop || true
712- invoke-rc.d maas-cluster-celery start
713- fi
714- cd -
715-}
716-
717-setup_landscape() {
718- # The master node will be managed by Landscape
719- # TODO: this is currently hardcoded to our own landscape account
720- if which landscape-config; then
721- case "$(hostname)" in
722- OrangeBox*|orangebox*)
723- landscape-config -a canonical-orange -t "$(hostname)__$(dmidecode -s baseboard-serial-number)" -p ubuntu-aubergine --script-users=ALL --silent --include-manager-plugins=ScriptExecution || true
724- ;;
725- esac
726- fi
727-}
728-
729-setup_examples() {
730- mkdir -p /home/ubuntu
731- if [ -d /home/ubuntu/Examples/.bzr ]; then
732- bzr pull >/dev/null 2>&1 || true
733- elif [ -d /home/ubuntu/Examples ]; then
734- mv -f /home/ubuntu/Examples /home/ubuntu/.Examples
735- bzr branch lp:orange-box-examples /home/ubuntu/Examples >/dev/null 2>&1 || true
736- else
737- bzr branch lp:orange-box-examples /home/ubuntu/Examples >/dev/null 2>&1 || true
738- fi
739- chown -R ubuntu:ubuntu /home/ubuntu
740-}
741-
742-case "$1" in
743- configure)
744- setup_desktop
745- apply_patches
746- setup_maas_admin
747- setup_dns
748- if [ -n "$2" ]; then
749- echo
750- echo "INFO: Skipping importing boot resources, since this is a package upgrade"
751- echo "INFO: If you want to update boot resources, run:"
752- echo "INFO: sudo maas-import-pxe-files"
753- echo "INFO: sudo maas admin node-groups import-boot-images"
754- echo
755- else
756- setup_boot_resources
757- fi
758- setup_maas_networking
759- maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
760- if dpkg --compare-versions $maas_ver lt 1.6; then
761- setup_squid
762- fi
763- setup_local_mirror
764- setup_ssh_keys
765- setup_juju
766- if [ -n "$2" ]; then
767- echo
768- echo "INFO: Skipping adding all nodes, since this is a package upgrade"
769- echo "INFO: If you want to delete and add all nodes again, run:"
770- echo "INFO: sudo orange-box-add-physical-nodes"
771- echo "INFO: sudo orange-box-add-virtual-nodes"
772- echo
773- else
774- # Only add all nodes and configure landscape on initial install, not upgrades
775- setup_landscape
776- setup_all_nodes
777- fi
778- setup_examples
779- ;;
780- abort-upgrade|abort-remove|abort-deconfigure)
781- ;;
782- *)
783- echo "postinst called with unknown argument \`$1'" >&2
784- exit 1
785- ;;
786-esac
787-
788-#DEBHELPER#
789-
790-exit 0
791
792=== added file 'debian/postrm'
793--- debian/postrm 1970-01-01 00:00:00 +0000
794+++ debian/postrm 2015-06-15 14:59:02 +0000
795@@ -0,0 +1,23 @@
796+#!/bin/sh
797+
798+set -e
799+
800+webserver="apache2"
801+
802+case "$1" in
803+ remove)
804+ for i in archive ubuntu-cloud; do
805+ if [ -e "/etc/apache2/sites-enabled/${i}.conf" ]; then
806+ a2dissite $i
807+ fi
808+ done
809+ invoke-rc.d $webserver reload
810+ rm -f /var/log/orange-box-mirror.log
811+ rm -rf /etc/maas
812+ rm -rf /var/lib/orange-box
813+ ;;
814+esac
815+
816+#DEBHELPER#
817+
818+exit 0
819
820=== removed file 'debian/postrm'
821--- debian/postrm 2014-07-17 04:12:46 +0000
822+++ debian/postrm 1970-01-01 00:00:00 +0000
823@@ -1,23 +0,0 @@
824-#!/bin/sh
825-
826-set -e
827-
828-webserver="apache2"
829-
830-case "$1" in
831- remove)
832- for i in archive ubuntu-cloud; do
833- if [ -e "/etc/apache2/sites-enabled/${i}.conf" ]; then
834- a2dissite $i
835- fi
836- done
837- invoke-rc.d $webserver reload
838- rm -f /var/log/orange-box-mirror.log
839- rm -rf /etc/maas
840- rm -rf /var/lib/orange-box
841- ;;
842-esac
843-
844-#DEBHELPER#
845-
846-exit 0
847
848=== added file 'debian/preinst'
849--- debian/preinst 1970-01-01 00:00:00 +0000
850+++ debian/preinst 2015-06-15 14:59:02 +0000
851@@ -0,0 +1,166 @@
852+#!/bin/sh
853+set -e
854+set -x
855+
856+get_orangebox_number() {
857+## assume hostname as been set correctly .. will be checked in postinst
858+OBNum=`hostname | cut -c 10- -`
859+echo $OBNum
860+echo "orangebox_number=$OBNum" > /etc/orange-box.conf
861+}
862+
863+### According to OB networking re-design
864+orangebox_number=`get_orangebox_number`
865+default_maas_ip=172.27.${orangebox_number}.1
866+gateway_ip=172.27.252.1
867+external_ip=172.27.252.${orangebox_number}
868+internal_ip=172.27.${orangebox_number}.1
869+br0_broadcast=172.27.`expr ${orangebox_number} + 3`.255
870+
871+#unnecessary comment
872+
873+preflight_checks() {
874+ if [ "$(id -u ubuntu)" != "1000" ]; then
875+ echo "ERROR: Read the docs; a proper OrangeBox setup requires the default user to be [ubuntu]" 1>&2
876+ exit 1
877+ fi
878+ #ensure em1 is the correct name
879+ biosdevname -i eth1 || (echo "biosdevname should have been run already assume it does"; true)
880+ # TODO: Check that the AMTs are on static IPs
881+ # TODO: Check dual hard drives, which one is which
882+ # TODO: Ensure we have two interfaces, one internal, one external
883+}
884+
885+setup_debconf() {
886+ echo "debconf maas/default-maas-url string $default_maas_ip" | debconf-set-selections -
887+ echo "debconf maas-cluster-controller/maas-url string http://${default_maas_ip}/MAAS" | debconf-set-selections -
888+ echo "debconf maas/installation-note boolean true" | debconf-set-selections -
889+ echo "debconf iptables-persistent/autosave_done boolean true" | debconf-set-selections -
890+ echo "debconf iptables-persistent/autosave_v4 boolean true" | debconf-set-selections -
891+ echo "debconf iptables-persistent/autosave_v6 boolean true" | debconf-set-selections -
892+}
893+
894+setup_networking() {
895+ modprobe 8021q || true
896+ sed -i -e "/8021q/d" /etc/modules || true
897+ echo "8021q" >> /etc/modules
898+ # Set up the two network interfaces
899+ external_interface=$(ip route ls | grep ^default | awk '{print $5}')
900+ # TODO: ip addr ls
901+ for interface in $(ifconfig -a -s | grep -v ^Iface | awk '{print $1}'); do
902+ case "$interface" in
903+ lo|br*|wlan*|vnet*)
904+ continue
905+ ;;
906+ $external_interface)
907+ continue
908+ ;;
909+ *)
910+ internal_interface="$interface"
911+ break
912+ ;;
913+ esac
914+ done
915+ # Set a sane default
916+ [ -z "$internal_interface" ] && internal_interface=eth0
917+ # TODO: use ip
918+ default_mac=$(ifconfig "$internal_interface" | grep "^$internal_interface" | sed -e "s/.*HWaddr //")
919+ # Tell NetworkManager to piss off
920+ sed -i -e "/^unmanaged-devices=mac:$default_mac$/d" /etc/NetworkManager/NetworkManager.conf
921+ cat >>/etc/NetworkManager/NetworkManager.conf <<EOF
922+[keyfile]
923+unmanaged-devices=mac:$default_mac
924+EOF
925+ invoke-rc.d network-manager stop || true
926+ invoke-rc.d network-manager start
927+ cat >/etc/network/interfaces <<EOF
928+auto lo
929+iface lo inet loopback
930+
931+auto $external_interface
932+iface $external_interface inet static
933+ address ${external_ip}
934+ netmask 255.255.252.0
935+ broadcast 172.27.255.255
936+ gateway ${gateway_ip}
937+ dns-nameservers ${gateway_ip}
938+
939+auto $internal_interface
940+iface $internal_interface inet manual
941+
942+
943+auto br0
944+iface br0 inet static
945+ address ${internal_ip}
946+ netmask 255.255.252.0
947+ broadcast $br0_broadcast
948+ bridge_ports $internal_interface
949+ bridge_stp off
950+ bridge_fd 0
951+ bridge_maxwait 0
952+
953+# VLAN 2, Uplink network
954+iface ${internal_interface}.2 inet dhcp
955+vlan-raw-device $internal_interface
956+
957+# Network management alias
958+iface br0:1 inet static
959+address 10.90.90.91
960+netmask 255.255.255.0
961+broadcast 10.90.90.255
962+
963+EOF
964+ ifdown --force $internal_interface || true
965+ ifdown --force br0 || true
966+ ifup $internal_interface
967+ ifup br0
968+ ### Same for $external_interface
969+ ifdown --force $external_interface || true
970+ ifup $external_interface
971+
972+ # Wait a moment for the network to normalize
973+ echo "INFO: Ensure networking has settled"
974+ run-one-until-success ping -c 10 maas.ubuntu.com
975+}
976+
977+setup_external_drive() {
978+ # External drive must be:
979+ # a) partitioned into 1 big partition
980+ # b) ext4 formatted
981+ # Find root disk
982+ root_disk=$(mount | grep " on / " | awk '{print $1}' | sed -e "s/[0-9]\+$//")
983+ # Find biggest non-root disk
984+ ext_disk=$(fdisk -l | grep "^Disk /" | grep -v $root_disk | sort -k4 -n -r | awk '{print $2}' | awk -F: '{print $1}')
985+ partition="${ext_disk}1"
986+ if [ -b "$ext_disk" ]; then
987+ if [ ! -b "$partition" ]; then
988+ # Create the partition, if it doesn't exist already
989+ echo "n
990+p
991+1
992+
993+
994+w
995+"|fdisk "$ext_disk"
996+ mkfs.ext4 "$partition"
997+ fi
998+ sed -i -e "/ \/srv/d" /etc/fstab
999+ # Add the fstab entry
1000+ uuid=$(blkid -s UUID -o value "$partition")
1001+ echo "UUID=$uuid /srv ext4 defaults 1 1" >> /etc/fstab
1002+ fi
1003+ umount $partition || true
1004+ mount -a
1005+ chown root:root /srv
1006+ chmod 755 /srv
1007+}
1008+
1009+
1010+preflight_checks
1011+setup_external_drive
1012+setup_debconf
1013+setup_networking
1014+
1015+#DEBHELPER#
1016+
1017+exit 0
1018
1019=== removed file 'debian/preinst'
1020--- debian/preinst 2014-08-25 14:32:16 +0000
1021+++ debian/preinst 1970-01-01 00:00:00 +0000
1022@@ -1,136 +0,0 @@
1023-#!/bin/sh
1024-set -e
1025-set -x
1026-
1027-#unnecessary comment
1028-
1029-preflight_checks() {
1030- if [ "$(id -u ubuntu)" != "1000" ]; then
1031- echo "ERROR: Read the docs; a proper OrangeBox setup requires the default user to be [ubuntu]" 1>&2
1032- exit 1
1033- fi
1034- # TODO: Check that the AMTs are on static IPs
1035- # TODO: Check dual hard drives, which one is which
1036- # TODO: Ensure we have two interfaces, one internal, one external
1037-}
1038-
1039-setup_debconf() {
1040- echo "debconf maas/default-maas-url string 10.14.4.1" | debconf-set-selections -
1041- echo "debconf maas-cluster-controller/maas-url string http://10.14.4.1/MAAS" | debconf-set-selections -
1042- echo "debconf maas/installation-note boolean true" | debconf-set-selections -
1043- echo "debconf iptables-persistent/autosave_done boolean true" | debconf-set-selections -
1044- echo "debconf iptables-persistent/autosave_v4 boolean true" | debconf-set-selections -
1045- echo "debconf iptables-persistent/autosave_v6 boolean true" | debconf-set-selections -
1046-}
1047-
1048-setup_networking() {
1049- modprobe 8021q || true
1050- sed -i -e "/8021q/d" /etc/modules || true
1051- echo "8021q" >> /etc/modules
1052- # Set up the two network interfaces
1053- external_interface=$(ip route ls | grep ^default | awk '{print $5}')
1054- # TODO: ip addr ls
1055- for interface in $(ifconfig -a -s | grep -v ^Iface | awk '{print $1}'); do
1056- case "$interface" in
1057- lo|br*|wlan*)
1058- continue
1059- ;;
1060- $external_interface)
1061- continue
1062- ;;
1063- *)
1064- internal_interface="$interface"
1065- break
1066- ;;
1067- esac
1068- done
1069- # Set a sane default
1070- [ -z "$internal_interface" ] && internal_interface=eth0
1071- # TODO: use ip
1072- default_mac=$(ifconfig "$internal_interface" | grep "^$internal_interface" | sed -e "s/.*HWaddr //")
1073- # Tell NetworkManager to piss off
1074- sed -i -e "/^unmanaged-devices=mac:$default_mac$/d" /etc/NetworkManager/NetworkManager.conf
1075- cat >>/etc/NetworkManager/NetworkManager.conf <<EOF
1076-[keyfile]
1077-unmanaged-devices=mac:$default_mac
1078-EOF
1079- invoke-rc.d network-manager stop || true
1080- invoke-rc.d network-manager start
1081- cat >/etc/network/interfaces <<EOF
1082-auto lo
1083-iface lo inet loopback
1084-
1085-auto $internal_interface
1086-iface $internal_interface inet manual
1087-
1088-auto br0
1089-iface br0 inet static
1090- address 10.14.4.1
1091- netmask 255.255.0.0
1092- broadcast 10.14.255.255
1093- bridge_ports $internal_interface
1094- bridge_stp off
1095- bridge_fd 0
1096- bridge_maxwait 0
1097-
1098-# VLAN 2, Uplink network
1099-iface eth0.2 inet dhcp
1100-vlan-raw-device eth0
1101-
1102-# Network management alias
1103-iface br0:1 inet static
1104-address 10.90.90.91
1105-netmask 255.255.255.0
1106-broadcast 10.90.90.255
1107-
1108-EOF
1109- ifdown --force $internal_interface || true
1110- ifdown --force br0 || true
1111- ifup $internal_interface
1112- ifup br0
1113- # Wait a moment for the network to normalize
1114- echo "INFO: Ensure networking has settled"
1115- run-one-until-success ping -c 10 maas.ubuntu.com
1116-}
1117-
1118-setup_external_drive() {
1119- # External drive must be:
1120- # a) partitioned into 1 big partition
1121- # b) ext4 formatted
1122- # Find root disk
1123- root_disk=$(mount | grep " on / " | awk '{print $1}' | sed -e "s/[0-9]\+$//")
1124- # Find biggest non-root disk
1125- ext_disk=$(fdisk -l | grep "^Disk /" | grep -v $root_disk | sort -k4 -n -r | awk '{print $2}' | awk -F: '{print $1}')
1126- partition="${ext_disk}1"
1127- if [ -b "$ext_disk" ]; then
1128- if [ ! -b "$partition" ]; then
1129- # Create the partition, if it doesn't exist already
1130- echo "n
1131-p
1132-1
1133-
1134-
1135-w
1136-"|fdisk "$ext_disk"
1137- mkfs.ext4 "$partition"
1138- fi
1139- sed -i -e "/ \/srv/d" /etc/fstab
1140- # Add the fstab entry
1141- uuid=$(blkid -s UUID -o value "$partition")
1142- echo "UUID=$uuid /srv ext4 defaults 1 1" >> /etc/fstab
1143- fi
1144- umount $partition || true
1145- mount -a
1146- chown root:root /srv
1147- chmod 755 /srv
1148-}
1149-
1150-
1151-preflight_checks
1152-setup_external_drive
1153-setup_debconf
1154-setup_networking
1155-
1156-#DEBHELPER#
1157-
1158-exit 0
1159
1160=== modified file 'debian/source/format'
1161--- debian/source/format 2014-04-04 19:40:10 +0000
1162+++ debian/source/format 2015-06-15 14:59:02 +0000
1163@@ -1,1 +1,1 @@
1164-3.0 (quilt)
1165+3.0 (native)
1166
1167=== modified file 'etc/apache2/sites-available/archive.conf'
1168--- etc/apache2/sites-available/archive.conf 2014-04-11 05:16:52 +0000
1169+++ etc/apache2/sites-available/archive.conf 2015-06-15 14:59:02 +0000
1170@@ -1,5 +1,6 @@
1171 <VirtualHost *:80>
1172 ServerName archive.ubuntu.com
1173+ ServerAlias *.archive.ubuntu.com
1174 ServerAdmin webmaster@localhost
1175 DocumentRoot /srv/mirrors/archive.ubuntu.com/
1176 ErrorLog ${APACHE_LOG_DIR}/error.log
1177
1178=== modified file 'etc/apt/orange-box-mirror.list'
1179--- etc/apt/orange-box-mirror.list 2015-01-21 22:04:42 +0000
1180+++ etc/apt/orange-box-mirror.list 2015-06-15 14:59:02 +0000
1181@@ -8,36 +8,58 @@
1182 set var_path $base_path/var
1183 set cleanscript /bin/true
1184 set defaultarch amd64
1185-set postmirror_script /bin/true
1186-# set run_postmirror 0
1187+set postmirror_script $var_path/postmirror.sh
1188+set run_postmirror 1
1189 set nthreads 20
1190 set _tilde 0
1191 #
1192 ############# end config ##############
1193
1194 ## Trusty
1195-deb http://orange-box.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
1196-deb http://orange-box.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
1197-deb http://orange-box.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
1198-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
1199-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
1200-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
1201+deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
1202+deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
1203+deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
1204+deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
1205+deb-i386 http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
1206+deb-i386 http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
1207+deb-i386 http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
1208+
1209+
1210+deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
1211+deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
1212+deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
1213+deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
1214+
1215
1216 ## precise
1217-deb http://orange-box.archive.ubuntu.com/ubuntu precise main restricted universe multiverse
1218-deb http://orange-box.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
1219-deb http://orange-box.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
1220-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu precise main restricted universe multiverse
1221-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
1222-deb-i386 http://orange-box.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
1223+deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
1224+deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
1225+deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
1226+deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
1227+
1228+deb-i386 http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
1229+deb-i386 http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
1230+deb-i386 http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
1231+deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
1232+deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
1233+deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
1234+
1235+##http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main Sources
1236
1237 ## Cloud-archive
1238 deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main
1239 deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main
1240 deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/icehouse main
1241+deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/juno main
1242 deb-i386 http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main
1243 deb-i386 http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main
1244 deb-i386 http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/icehouse main
1245+deb-i386 http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/juno main
1246+deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main
1247+deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main
1248+deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/icehouse main
1249+deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/juno main
1250+
1251
1252 clean http://archive.ubuntu.com/ubuntu
1253 clean http://ubuntu-cloud.archive.canonical.com/ubuntu
1254
1255=== added directory 'etc/bind'
1256=== added file 'etc/bind/named.conf.wildcard-archive'
1257--- etc/bind/named.conf.wildcard-archive 1970-01-01 00:00:00 +0000
1258+++ etc/bind/named.conf.wildcard-archive 2015-06-15 14:59:02 +0000
1259@@ -0,0 +1,6 @@
1260+# Zone declarations.
1261+zone "archive.ubuntu.com" {
1262+ type master;
1263+ file "/etc/bind/zones.wildcard-archive";
1264+};
1265+
1266
1267=== added file 'etc/bind/zones.wildcard-archive'
1268--- etc/bind/zones.wildcard-archive 1970-01-01 00:00:00 +0000
1269+++ etc/bind/zones.wildcard-archive 2015-06-15 14:59:02 +0000
1270@@ -0,0 +1,20 @@
1271+$TTL 300
1272+@ IN SOA archive.ubuntu.com ubuntu.com (
1273+ 999 ; serial
1274+ 600 ; Refresh
1275+ 1800 ; Retry
1276+ 604800 ; Expire
1277+ 300 ; TTL
1278+ )
1279+
1280+ IN NS archive.ubuntu.com
1281+
1282+
1283+
1284+
1285+ns IN CNAME archive.ubuntu.com
1286+archive.ubuntu.com. IN A 10.14.4.1
1287+archive.ubuntu.com IN A 10.14.4.1
1288+ubuntu-cloud.archive.canonical.com. IN A 10.14.4.1
1289+* IN A 10.14.4.1
1290+
1291
1292=== added file 'etc/orangebox-mirror.state'
1293--- etc/orangebox-mirror.state 1970-01-01 00:00:00 +0000
1294+++ etc/orangebox-mirror.state 2015-06-15 14:59:02 +0000
1295@@ -0,0 +1,1 @@
1296+INIT
1297\ No newline at end of file
1298
1299=== modified file 'usr/bin/orange-box-add-node'
1300--- usr/bin/orange-box-add-node 2014-10-27 20:54:45 +0000
1301+++ usr/bin/orange-box-add-node 2015-06-15 14:59:02 +0000
1302@@ -23,6 +23,9 @@
1303 set -e
1304 set -x
1305
1306+## According to OB network re-design
1307+. /etc/orange-box.conf
1308+
1309 ip_to_mac() {
1310 local ip="$1"
1311 arp -n | sort | grep -m1 "^$ip\s" | awk '{print $3}'
1312@@ -31,7 +34,7 @@
1313 node_name() {
1314 local num="${1##*.}"
1315 num=$((num-10))
1316- echo "node${num}"
1317+ echo "node${num}ob${orangebox_number}"
1318 }
1319
1320 hostname_to_system_id() {
1321@@ -60,7 +63,7 @@
1322 maas admin zone read zone2 || maas admin zones create name=zone2 description="Physical machines on right side of Orange Box"
1323
1324 #Create maas-br0 network if it does not already exist
1325-maas admin network read maas-br0 || maas admin networks create name=maas-br0 ip=10.14.0.0 netmask=255.255.0.0 default_gateway=10.14.4.1 dns_servers=10.14.4.1 description="Auto created when running orange-box-add-node"
1326+maas admin network read maas-br0 || maas admin networks create name=maas-br0 ip=172.27.${orangebox_number}.0 netmask=255.255.252.0 default_gateway=172.27.${orangebox_number}.1 dns_servers=172.27.${orangebox_number}.1 description="Auto created when running orange-box-add-node"
1327
1328 # Loop over the list of ip addresses listening on 16992
1329 for ip in $@; do
1330@@ -73,7 +76,7 @@
1331 zone="zone2"
1332 fi
1333 info "$ip --> $hostname --> $mac"
1334- if [ -z "$ip" ] || [ "$ip" = "10.14.4.1" ]; then
1335+ if [ -z "$ip" ] || [ "$ip" = "172.27.${orangebox_number}.1" ]; then
1336 continue
1337 fi
1338 # Remove it, if it's already here
1339
1340=== modified file 'usr/bin/orange-box-add-physical-nodes'
1341--- usr/bin/orange-box-add-physical-nodes 2014-07-11 18:27:46 +0000
1342+++ usr/bin/orange-box-add-physical-nodes 2015-06-15 14:59:02 +0000
1343@@ -25,11 +25,16 @@
1344
1345 oauth_login
1346
1347+## According to OB network re-design
1348+. /etc/orange-box.conf
1349+
1350+
1351+
1352 # Search for nodes listening on AMT's 16992
1353 info "Searching for all nodes on the local network listening on 16992; this will take 60 seconds...."
1354-ips=$(time for i in $(seq 1 10); do nmap -p 16992 -oG - 10.14.4.1/24 | grep 16992/open | awk '{print $2}' ; done | sort -u -r)
1355+ips=$(time for i in $(seq 1 10); do nmap -p 16992 -oG - 172.27.${orangebox_number}.1/22 | grep 16992/open | awk '{print $2}' ; done | sort -u -r)
1356 if [ -z "$ips" ]; then
1357- error "nmap did not find any nodes listening on [16992] on the [10.14.4.1/24] network"
1358+ error "nmap did not find any nodes listening on [16992] on the [172.27.${orangebox_number}.1/22] network"
1359 fi
1360 info "Found: [$ips]"
1361
1362
1363=== modified file 'usr/bin/orange-box-add-virtual-nodes'
1364--- usr/bin/orange-box-add-virtual-nodes 2015-02-07 16:07:08 +0000
1365+++ usr/bin/orange-box-add-virtual-nodes 2015-06-15 14:59:02 +0000
1366@@ -18,6 +18,13 @@
1367 # You should have received a copy of the GNU General Public License
1368 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1369
1370+##
1371+##
1372+. /etc/orange-box.conf
1373+
1374+external_ip="172.27.252.${orangebox_number}"
1375+internal_ip="172.27.${orangebox_number}.1"
1376+internal_network="172.27.${orangebox_number}.0"
1377
1378 if [ "$(id -u)" != "0" ]; then
1379 echo "Must be run with sudo or by root"
1380@@ -29,13 +36,20 @@
1381
1382 virsh net-info default && virsh net-destroy default && virsh net-undefine default
1383
1384-[ -d ~maas ] || install -d /var/lib/maas --owner maas --group maas
1385+[ -d /var/lib/maas ] || install -d /var/lib/maas --owner maas --group maas
1386 chsh maas -s /bin/bash
1387-[ -d ~maas/.ssh ] || echo -e "\n\n\n" | sudo -u maas ssh-keygen -N "" -t rsa -f ~maas/.ssh/id_rsa
1388-grep 'maas@' /home/ubuntu/.ssh/authorized_keys || cat ~maas/.ssh/id_rsa.pub | tee -a /home/ubuntu/.ssh/authorized_keys
1389-printf "%s,%s %s %s\n" "node0.maas" "10.14.4.1" $(awk '{print $1 " " $2}' /etc/ssh/ssh_host_ecdsa_key.pub) | tee -a ~maas/.ssh/known_hosts
1390+[ -d /var/lib/maas/.ssh ] || mkdir /var/lib/maas/.ssh && chown maas:maas /var/lib/maas/.ssh
1391+[ -f /var/lib/maas/.ssh/id_rsa ] || echo -e "\n\n\n" | sudo -u maas ssh-keygen -N "" -t rsa -f /var/lib/maas/.ssh/id_rsa
1392+[ -f /var/lib/maas/.ssh/known_hosts ] || sudo -u maas ssh-keyscan 172.27.${orangebox_number}.1 |sudo -u maas tee -a /var/lib/maas/.ssh/known_hosts > /dev/null
1393+#check virtual power access/if it fails and there is a key then remove it#
1394+sudo -u maas ssh ubuntu@172.27.${orangebox_number}.1 uname || sudo -u maas ssh-keyscan 172.27.${orangebox_number}.1 |sudo -u maas tee -a /var/lib/maas/.ssh/known_hosts > /dev/null
1395+sudo -u maas virsh -c qemu+ssh://ubuntu@172.27.${orangebox_number}.1/system list > /dev/null || sed -i '/ maas@/d' /home/ubuntu/.ssh/authorized_keys
1396+#If there is no key /new install or just removed add it"
1397+grep 'maas@' /home/ubuntu/.ssh/authorized_keys || cat /var/lib/maas/.ssh/id_rsa.pub | tee -a /home/ubuntu/.ssh/authorized_keys
1398+printf "%s,%s %s %s\n" "node0.maas" "$internal_ip" $(awk '{print $1 " " $2}' /etc/ssh/ssh_host_ecdsa_key.pub) | tee -a /var/lib/maas/.ssh/known_hosts
1399 chown -R ubuntu:ubuntu /home/ubuntu
1400
1401+
1402 maas admin tags new name=virtual || true
1403 maas admin tags new name=bootstrap || true
1404 maas admin tags new name=neutron || true
1405@@ -53,25 +67,23 @@
1406 maas admin zone read zone0 || maas admin zones create name=zone0 description="Virtual machines on node0"
1407
1408 #Create maas-br0 network if it does not already exist
1409-maas admin network read maas-br0 || maas admin networks create name=maas-br0 ip=10.14.0.0 netmask=255.255.0.0 default_gateway=10.14.4.1 dns_servers=10.14.4.1 description="Auto created when running orange-box-add-virtual-nodes"
1410+### For APAC Roadshow
1411+maas admin network read maas-br0 || maas admin networks create name=maas-br0 ip=${internal_network} netmask=255.255.252.0 default_gateway=${internal_ip} dns_servers=${internal_ip} description="Auto created when running orange-box-add-virtual-nodes"
1412+
1413
1414 for i in $(seq 0 2 | sort -r); do
1415- hostname="node0vm${i}.maas"
1416+ hostname="node0vm${i}ob${orangebox_number}.maas"
1417 virsh destroy $hostname || true
1418 virsh undefine $hostname || true
1419 echo "INFO: Installing virtual machine"
1420- virt-install --debug --name $hostname --ram 4096 --disk=path=/var/lib/orange-box/${hostname}-1.img,size=20 --disk=path=/var/lib/orange-box/${hostname}-2.img,size=2 --vcpus=2 --os-type=linux --pxe --network=bridge=br0,model=virtio --network=bridge=br0,model=rtl8139 --boot network --video=cirrus --graphics vnc|| true
1421+ virt-install --debug --name $hostname --ram 4096 --disk=path=/var/lib/orange-box/${hostname}-1.img,size=20 --disk=path=/var/lib/orange-box/${hostname}-2.img,size=2 --vcpus=2 --os-type=linux --pxe --network=bridge=br0 --network=bridge=br0 --boot network --video=cirrus --graphics vnc|| true
1422 virsh console $hostname || true
1423- #Workaround for bug: https://bugs.launchpad.net/maas/+bug/1367482
1424- virsh dumpxml $hostname > /tmp/${hostname}.xml
1425- sed -i -e "s#<model type='rtl8139'/>#<model type='rtl8139'/> <rom file=''/>#" /tmp/${hostname}.xml
1426- virsh define /tmp/${hostname}.xml
1427 virsh autostart $hostname
1428 mac=$(virsh dumpxml $hostname | python -c 'import sys, lxml.etree; print list(lxml.etree.parse(sys.stdin).iter("mac"))[0].get("address")')
1429 mac2=$(virsh dumpxml $hostname | python -c 'import sys, lxml.etree; print list(lxml.etree.parse(sys.stdin).iter("mac"))[0].get("address")')
1430 system_id=$(maas admin nodes list mac_address=$mac | grep system_id | cut -d'"' -f4)
1431 if [ -n "$system_id" ]; then
1432- maas admin node update $system_id hostname=$hostname power_type=virsh power_parameters_power_address=qemu+ssh://ubuntu@10.14.4.1/system power_parameters_power_id=$hostname
1433+ maas admin node update $system_id hostname=$hostname power_type=virsh power_parameters_power_address=qemu+ssh://ubuntu@${internal_ip}/system power_parameters_power_id=$hostname
1434 maas admin tag update-nodes "virtual" add=$system_id
1435 case $i in
1436 0)
1437
1438=== modified file 'usr/bin/orange-box-amt-monitor'
1439--- usr/bin/orange-box-amt-monitor 2014-04-16 22:26:52 +0000
1440+++ usr/bin/orange-box-amt-monitor 2015-06-15 14:59:02 +0000
1441@@ -1,3 +1,5 @@
1442 #!/bin/sh
1443
1444-watch -n 10 "sudo nmap -p 16992 -oG - 10.14.4.1/24 | grep 16992/open | sort"
1445+. /etc/orange-box.conf
1446+watch -n 10 "sudo nmap -p 16992 -oG - 172.27.${orangebox_number}.0/22 | grep 16992/open | sort"
1447+
1448
1449=== removed file 'usr/bin/orange-box-apm-power-fix'
1450--- usr/bin/orange-box-apm-power-fix 2014-10-31 09:19:40 +0000
1451+++ usr/bin/orange-box-apm-power-fix 1970-01-01 00:00:00 +0000
1452@@ -1,38 +0,0 @@
1453-#!/bin/sh
1454-#
1455-# orange-box-apm-power-fix - fix for issue with orange-box-apm-power
1456-# Copyright (C) 2014 Canonical Ltd.
1457-#
1458-# Authors: Darryl Weaver <darryl.weaver@canonical.com>
1459-#
1460-# This program is free software: you can redistribute it and/or modify
1461-# it under the terms of the GNU General Public License as published by
1462-# the Free Software Foundation, version 3 of the License.
1463-#
1464-# This program is distributed in the hope that it will be useful,
1465-# but WITHOUT ANY WARRANTY; without even the implied warranty of
1466-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1467-# GNU General Public License for more details.
1468-#
1469-# You should have received a copy of the GNU General Public License
1470-# along with this program. If not, see <http://www.gnu.org/licenses/>.
1471-
1472-set -x
1473-
1474-if [ ! -f /var/lib/maas/boot-resources/current/syslinux/poweroff-APM.com ]
1475-then
1476-cd /srv/data
1477-wget https://launchpadlibrarian.net/187530745/acpioff.c32
1478-cd /var/lib/maas/boot-resources/current/syslinux
1479-sudo mv poweroff.com poweroff-APM.com
1480-sudo mv /srv/data/acpioff.c32 poweroff.c32
1481-fi
1482-
1483-#fixing the AMT template
1484-cd /srv/data
1485-wget https://launchpadlibrarian.net/187911231/not-permitted.patch
1486-cd /etc/maas/templates/power
1487-patch < /srv/data/not-permitted.patch
1488-
1489-exit
1490-
1491
1492=== modified file 'usr/bin/orange-box-bootstrap-juju'
1493--- usr/bin/orange-box-bootstrap-juju 2015-01-07 23:15:31 +0000
1494+++ usr/bin/orange-box-bootstrap-juju 2015-06-15 14:59:02 +0000
1495@@ -24,8 +24,12 @@
1496 timeout 1m run-one-until-success nc -w 10 -zvv $@ 2>&1
1497 }
1498
1499+## According to OB network re-disign
1500+. /etc/orange-box.conf
1501+
1502 juju status && echo "Existing deployment found, exiting." && exit 0
1503-juju bootstrap --to node0vm0.maas --show-log --upload-tools
1504+###juju bootstrap --to node0ob${orangebox_number}vm0.maas --show-log --upload-tools
1505+juju bootstrap --to node0vm0ob${orangebox_number}.maas --show-log --upload-tools
1506 juju set-constraints "tags="
1507 juju deploy --to 0 --repository=/srv/charmstore/ local:trusty/juju-gui
1508 juju expose juju-gui
1509
1510=== modified file 'usr/bin/orange-box-create-package-mirror'
1511--- usr/bin/orange-box-create-package-mirror 2015-01-21 22:04:42 +0000
1512+++ usr/bin/orange-box-create-package-mirror 2015-06-15 14:59:02 +0000
1513@@ -27,7 +27,9 @@
1514 fi
1515
1516 home=$PWD
1517-IP=10.14.4.1
1518+. /etc/orange-box.conf
1519+
1520+IP=172.27.${orangebox_number}.1
1521
1522 function run_mirror {
1523 echo "apt-mirror /etc/apt/orange-box-mirror.list >>/var/log/orange-box-mirror.log 2>&1"
1524@@ -95,6 +97,17 @@
1525 echo Making mirror directories ...
1526 mkdir -p /srv/mirrors /srv/skel /srv/var
1527
1528+echo Creating postmirror.sh script ...
1529+# This created a blank file, for some reason :/
1530+echo << 'EOF' > /srv/var/postmirror.sh
1531+#!/bin/sh
1532+/srv/var/clean.sh
1533+EOF
1534+
1535+echo Making postmirror.sh executable ...
1536+chmod +x /srv/var/postmirror.sh
1537+echo Done. && echo
1538+
1539 echo Setting up the web dirs for mirroring ...
1540 ln -s /srv/mirrors/archive.ubuntu.com/ubuntu /var/www/html/archive.ubuntu.com
1541 ln -s /srv/mirrors/ubuntu-cloud.archive.canonical.com/ubuntu /var/www/html/ubuntu-cloud.archive.canonical.com
1542
1543=== modified file 'usr/bin/orange-box-demo-cleanup'
1544--- usr/bin/orange-box-demo-cleanup 2014-10-23 22:18:49 +0000
1545+++ usr/bin/orange-box-demo-cleanup 2015-06-15 14:59:02 +0000
1546@@ -20,6 +20,8 @@
1547
1548 ENVIRONMENT=`juju env`
1549
1550+. /etc/orange-box.conf
1551+
1552 #Destroy juju environment
1553 juju destroy-environment $ENVIRONMENT
1554 #make sure AMTs are all powered off
1555@@ -27,6 +29,6 @@
1556 if dpkg --compare-versions $maas_ver lt 1.6; then
1557 export AMT_PASSWORD=Password1+
1558 for i in $(seq 11 19); do
1559- yes | amttool 10.14.4.$i powerdown >/dev/null 2>&1
1560+ yes | amttool 172.27.${orangebox_number}.$i powerdown >/dev/null 2>&1
1561 done
1562 fi
1563
1564=== added file 'usr/bin/orange-box-hacks'
1565--- usr/bin/orange-box-hacks 1970-01-01 00:00:00 +0000
1566+++ usr/bin/orange-box-hacks 2015-06-15 14:59:02 +0000
1567@@ -0,0 +1,32 @@
1568+#!/bin/sh
1569+
1570+okay() {
1571+ echo "OK: $@"
1572+}
1573+
1574+error() {
1575+ echo "ERROR: $@"
1576+}
1577+
1578+# Check powerstate in AMT
1579+for i in $(seq 1 9); do
1580+ amtoutput=$(yes | amttool 10.14.4.1${i} info)
1581+ if [ "$amthostname" = "node${i}amt" ]; then
1582+ okay "[node${i}]: AMT is responsive"
1583+ else
1584+ error "[node${i}]: AMT is not responsive"
1585+ fi
1586+ amtpowerstate=$(echo "$amtoutput" | grep "^Powerstate:" | awk '{print $2}')
1587+ if [ -n "$amtpowerstate" ]; then
1588+ okay "[node${i}]: AMT powerstate [$amtpowerstate]"
1589+ else
1590+ error "[node${i}]: AMT powerstate unknown [$amtpowerstate]"
1591+ fi
1592+ uptime=$(ssh node$i.maas "uptime" 2>/dev/null)
1593+ if [ -n "$uptime" ]; then
1594+ okay "[node${i}]: SSH to node successful; uptime=[$uptime]"
1595+ else
1596+ error "[node${i}]: SSH to node unsuccessful; uptime=[$uptime]"
1597+ fi
1598+ echo
1599+done
1600
1601=== added file 'usr/bin/orange-box-mirror'
1602--- usr/bin/orange-box-mirror 1970-01-01 00:00:00 +0000
1603+++ usr/bin/orange-box-mirror 2015-06-15 14:59:02 +0000
1604@@ -0,0 +1,165 @@
1605+#!/bin/bash
1606+#
1607+# orange-box-mirror
1608+# Copyright (C) 2014 Canonical Ltd.
1609+#
1610+# Authors: Nicolas Thomas <nicolas.thomas@canonical.com>
1611+#
1612+# This program is free software: you can redistribute it and/or modify
1613+# it under the terms of the GNU General Public License as published by
1614+# the Free Software Foundation, version 3 of the License.
1615+#
1616+# This program is distributed in the hope that it will be useful,
1617+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1618+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1619+# GNU General Public License for more details.
1620+#
1621+# You should have received a copy of the GNU General Public License
1622+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1623+
1624+set -e
1625+
1626+STATE=`cat /etc/orangebox-mirror.state`
1627+
1628+# looking for inconsistency / self healing
1629+dig +short xyz.archive.ubuntu.com | grep 10.14.4.1 > /dev/null && CHECKEDSTATE=ENABLED || CHECKEDSTATE=DISABLED
1630+if [[ $STATE != $CHECKEDSTATE ]]
1631+then
1632+ if [[ $STATE == MIRRORING ]]
1633+ then
1634+ echo "WAS MIRRORING"
1635+ # IF nobody use the log then it is not mirroring
1636+ if ( sudo fuser /var/log/orange-box-mirror.log )
1637+ then
1638+ CHECKEDSTATE=MIRRORING
1639+ else
1640+ dig +short xyz.archive.ubuntu.com | grep 10.14.4.1 && CHECKEDSTATE=ENABLED || CHECKEDSTATE=DISABLED
1641+ fi
1642+ fi
1643+ STATE=$CHECKEDSTATE
1644+ echo $CHECKEDSTATE > /etc/orangebox-mirror.state
1645+ echo "Some script end up in error or been screwed healing"
1646+fi
1647+
1648+is-root()
1649+{
1650+ if [ "$(id -u)" != "0" ]; then
1651+ echo "Must be run with sudo or by root"
1652+ exit 77
1653+ fi
1654+}
1655+
1656+control_c()
1657+# run if user hits control-c
1658+{
1659+ echo -en "\n*** Ouch! Exiting ***\n"
1660+ [[ $STATE = MIRRORING ]] && echo "DISABLED" > /etc/orangebox-mirror.state
1661+ exit $?
1662+}
1663+
1664+# trap keyboard interrupt (control-c)
1665+trap control_c SIGINT
1666+
1667+
1668+usage()
1669+{
1670+cat << EOF
1671+
1672+orange-box-mirror - control usage and sync of local to OrangeBox mirrors
1673+
1674+USAGE: <action>
1675+
1676+ The options must be passed as follows:
1677+ <action>
1678+ enable - enable dns modification to point to local
1679+ disable - disable usage of the local mirror
1680+ sync - synchronize the mirror with archive disabling it during sync
1681+ status - describe current state
1682+
1683+ Note: actions requires root privileges use sudo
1684+
1685+EOF
1686+exit 0
1687+}
1688+
1689+enable-dns-usage()
1690+{
1691+[[ $STATE = MIRRORING ]] && { echo "wait for mirroring to end"; exit 2; }
1692+[[ $STATE = ENABLED ]] && { echo "Already enabled"; exit 0; }
1693+is-root
1694+# make sure no duplicates:
1695+TMPFILE=`mktemp`
1696+grep -v "named.conf.wildcard-archive" /etc/bind/named.conf > $TMPFILE || echo "was already off continue"
1697+mv $TMPFILE /etc/bind/named.conf
1698+chown bind:bind /etc/bind/named.conf
1699+echo 'include "/etc/bind/named.conf.wildcard-archive";' >> /etc/bind/named.conf
1700+service bind9 restart
1701+echo "ENABLED" > /etc/orangebox-mirror.state
1702+}
1703+
1704+disable-dns-usage()
1705+{
1706+[[ $STATE = MIRRORING ]] && { echo "Mirroring in progress usage disabled"; exit 0; }
1707+[[ $STATE = DISABLED ]] && { echo "Already disabled"; exit 0; }
1708+is-root
1709+TMPFILE=`mktemp`
1710+grep -v "named.conf.wildcard-archive" /etc/bind/named.conf > $TMPFILE || echo "was already off continue"
1711+mv $TMPFILE /etc/bind/named.conf
1712+chown bind:bind /etc/bind/named.conf
1713+service bind9 restart
1714+echo "DISABLED" > /etc/orangebox-mirror.state
1715+}
1716+
1717+sync-mirror()
1718+{
1719+[[ $STATE = MIRRORING ]] && { echo "already mirroring" ;exit 2; }
1720+PREVIOUSSTATE=$STATE
1721+#trick to not rewrite disabling
1722+STATE="ENABLED"
1723+disable-dns-usage
1724+echo "MIRRORING" > /etc/orangebox-mirror.state
1725+cat > /srv/var/postmirror.sh<<EOF
1726+wget -nH --cut-dirs 4 -r --no-parent -P /srv/mirrors/archive.ubuntu.com/ubuntu/dists/trusty-updates/main/ http://archive.ubuntu.com/ubuntu/dists/trusty/main/uefi/grub2-amd64/
1727+
1728+EOF
1729+chmod 755 /srv/var/postmirror.sh
1730+run-one apt-mirror /etc/apt/orange-box-mirror.list |tee -a /var/log/orange-box-mirror.log
1731+chmod -R g+rx,o+rx /srv/mirrors/*.com
1732+echo "SYNCED" > /etc/orangebox-mirror.state
1733+STATE=SYNCED
1734+case $PREVIOUSSTATE in
1735+ ENABLED)
1736+ enable-dns-usage
1737+ ;;
1738+ DISABLED)
1739+ disable-dns-usage
1740+ ;;
1741+esac
1742+}
1743+
1744+status()
1745+{
1746+echo "This OrangeBox state is "$STATE
1747+}
1748+
1749+[ $# -lt 1 ] && usage
1750+
1751+ACTION=$1
1752+
1753+case $ACTION in
1754+ enable)
1755+ enable-dns-usage
1756+ ;;
1757+ disable)
1758+ disable-dns-usage
1759+ ;;
1760+ sync)
1761+ sync-mirror
1762+ ;;
1763+ status)
1764+ status
1765+ ;;
1766+ *)
1767+ usage
1768+ ;;
1769+esac
1770
1771=== modified file 'usr/bin/orange-box-purge-everything'
1772--- usr/bin/orange-box-purge-everything 2014-10-08 11:51:07 +0000
1773+++ usr/bin/orange-box-purge-everything 2015-06-15 14:59:02 +0000
1774@@ -21,6 +21,7 @@
1775
1776 sudo apt-get purge $(dpkg -l | egrep "orange-box|maas|squid" | awk '{print $2}') bind9
1777 rm -rf /srv/boot-resources/* /etc/bind /root/.maascli.db
1778+rm -rf /home/ubuntu/.juju/environments/
1779 echo
1780 echo "=== IT IS HIGHLY RECOMMENDED THAT YOU REBOOT NOW! ==="
1781 echo
1782
1783=== modified file 'usr/bin/orange-box-run'
1784--- usr/bin/orange-box-run 2014-06-11 01:00:16 +0000
1785+++ usr/bin/orange-box-run 2015-06-15 14:59:02 +0000
1786@@ -24,22 +24,25 @@
1787 cmd="tail -f /var/log/cloud-init-output.log | ccze -A"
1788 fi
1789
1790-tmux new-window -n all-nodes "ssh node1.maas $cmd" \; \
1791- split-window -v "ssh node2.maas $cmd" \; \
1792- select-layout tiled \; \
1793- split-window -h "ssh node2.maas $cmd" \; \
1794- select-layout tiled \; \
1795- split-window -v "ssh node3.maas $cmd" \; \
1796- select-layout tiled \; \
1797- split-window -h "ssh node4.maas $cmd" \; \
1798- select-layout tiled \; \
1799- split-window -v "ssh node5.maas $cmd" \; \
1800- select-layout tiled \; \
1801- split-window -h "ssh node6.maas $cmd" \; \
1802- select-layout tiled \; \
1803- split-window -v "ssh node7.maas $cmd" \; \
1804- select-layout tiled \; \
1805- split-window -h "ssh node8.maas $cmd" \; \
1806- select-layout tiled \; \
1807- split-window -v "ssh node9.maas $cmd" \; \
1808+## According to OB network re-design
1809+. /etc/orange-box.conf
1810+
1811+tmux new-window -n all-nodes "ssh node1ob${orangebox_number}.maas $cmd" \; \
1812+ split-window -v "ssh node2ob${orangebox_number}.maas $cmd" \; \
1813+ select-layout tiled \; \
1814+ split-window -h "ssh node2ob${orangebox_number}.maas $cmd" \; \
1815+ select-layout tiled \; \
1816+ split-window -v "ssh node3ob${orangebox_number}.maas $cmd" \; \
1817+ select-layout tiled \; \
1818+ split-window -h "ssh node4ob${orangebox_number}.maas $cmd" \; \
1819+ select-layout tiled \; \
1820+ split-window -v "ssh node5ob${orangebox_number}.maas $cmd" \; \
1821+ select-layout tiled \; \
1822+ split-window -h "ssh node6ob${orangebox_number}.maas $cmd" \; \
1823+ select-layout tiled \; \
1824+ split-window -v "ssh node7ob${orangebox_number}.maas $cmd" \; \
1825+ select-layout tiled \; \
1826+ split-window -h "ssh node8ob${orangebox_number}.maas $cmd" \; \
1827+ select-layout tiled \; \
1828+ split-window -v "ssh node9ob${orangebox_number}.maas $cmd" \; \
1829 select-layout tiled
1830
1831=== added file 'usr/bin/orange-box-setup-nat'
1832--- usr/bin/orange-box-setup-nat 1970-01-01 00:00:00 +0000
1833+++ usr/bin/orange-box-setup-nat 2015-06-15 14:59:02 +0000
1834@@ -0,0 +1,127 @@
1835+#!/bin/bash
1836+#
1837+# orange-box-setup-nat - Setup NAT for external network access by nodes
1838+# Copyright (C) 2014 Canonical Ltd.
1839+#
1840+# Authors: Ronald McCollam <ronald.mccollam@canonical.com>
1841+# Dustin Kirkland <kirkland@canonical.com>
1842+#
1843+# This program is free software: you can redistribute it and/or modify
1844+# it under the terms of the GNU General Public License as published by
1845+# the Free Software Foundation, version 3 of the License.
1846+#
1847+# This program is distributed in the hope that it will be useful,
1848+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1849+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1850+# GNU General Public License for more details.
1851+#
1852+# You should have received a copy of the GNU General Public License
1853+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1854+
1855+set -x
1856+
1857+if [ "$(id -u)" != "0" ]; then
1858+ echo "Must be run with sudo or by root"
1859+ exit 77
1860+fi
1861+
1862+# Don't bother to restart sshd when lo is configured.
1863+if [ "$IFACE" = lo ]; then
1864+ exit 0
1865+fi
1866+
1867+# According to OB network re-design
1868+. /etc/orange-box.conf
1869+
1870+
1871+##internal=$(route -n | grep "^10\.14\." | sed -e "s/.* //")
1872+internal=$(route -n | grep "^172\.27\.${orangebox_number}\." | sed -e "s/.* //")
1873+external=$(ip route ls | grep ^default | awk '{print $5}')
1874+
1875+if [ -z "$internal" ] || [ -z "$external" ]; then
1876+ echo "usage: $0 [INTERNAL_INTERFACE] [EXTERNAL_INTERFACE]" 1>&2
1877+ exit 1
1878+fi
1879+
1880+set -e
1881+
1882+# Update MAAS upstream DNS
1883+maas admin maas set-config name=upstream_dns value=172.27.252.1 || true
1884+
1885+# Intel Centrino Advanced-N 6235 and Ubuntu don't work well with Wireless-N
1886+if lspci -v 2>/dev/null | grep -qs "Centrino Advanced-N 6235" 2>/dev/null; then
1887+ sed -i -e "/options iwlwifi 11n_disable=1/d" /etc/modprobe.d/iwlwifi.conf
1888+ echo "options iwlwifi 11n_disable=1" >> /etc/modprobe.d/iwlwifi.conf
1889+fi
1890+
1891+# Configure NAT and IP forwarding, giving slave NUCs external network access
1892+# through the master.
1893+
1894+# Enable IP forwarding and save for next boot
1895+echo 1 > /proc/sys/net/ipv4/ip_forward
1896+echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/10-maas-ip-forward.conf
1897+echo "net.ipv4.conf.all.accept_redirects=1 >> /etc/sysctl.d/10-maas-ip-forward.conf"
1898+echo "net.ipv6.conf.all.accept_redirects=1 >> /etc/sysctl.d/10-maas-ip-forward.conf"
1899+echo "net.ipv4.conf.all.send_redirects=1 >> /etc/sysctl.d/10-maas-ip-forward.conf"
1900+sysctl --system
1901+
1902+#Create the static ip tables for multi OBs.
1903+cat > /etc/rc.local <<EOF
1904+#!/bin/sh -e
1905+#
1906+# rc.local
1907+#
1908+# This script is executed at the end of each multiuser runlevel.
1909+# Make sure that the script will "exit 0" on success or any other
1910+# value on error.
1911+#
1912+# In order to enable or disable this script just change the execution
1913+# bits.
1914+#
1915+# By default this script does nothing.
1916+
1917+EOF
1918+for obn in `seq 4 4 80`
1919+do
1920+ [[ $obn == ${orangebox_number} ]] ||echo " ip route add 172.27.$obn.0/22 via 172.27.252.$obn " >> /etc/rc.local
1921+done
1922+echo "exit 0" >> /etc/rc.local
1923+
1924+# Note that this script assumes no existing iptables rules. If you do have
1925+# any, they will be deleted.
1926+iptables --flush
1927+iptables --table nat --flush
1928+iptables --delete-chain
1929+iptables --table nat --delete-chain
1930+
1931+# Firewalling this machine
1932+# Allow incoming SSH
1933+iptables -A INPUT -i $external -p tcp --dport 22 -j ACCEPT
1934+iptables -A INPUT -i $external -m state --state ESTABLISHED,RELATED -j ACCEPT
1935+###iptables -A INPUT -i $external -j DROP
1936+
1937+# Some things use the MAAS proxy - some things don't. So turn on NAT.
1938+echo "Setting up ip forwarding"
1939+iptables -t nat -A POSTROUTING -o $external -j MASQUERADE
1940+iptables -A FORWARD -i $external -o $internal -m state --state RELATED,ESTABLISHED -j ACCEPT
1941+iptables -A FORWARD -i $internal -o $external -j ACCEPT
1942+# The following line sets up a transparent proxy
1943+iptables -A PREROUTING -t nat -i br0 -p tcp -m multiport --dports 80 -j REDIRECT --to-port 3128
1944+
1945+iptables-save > /etc/iptables/rules.v4
1946+
1947+# 14.10 deprecates the iptables-persistent service in favor of netfilter-persistent
1948+service iptables-persistent restart || service netfilter-persistent restart
1949+
1950+# It seems we need to restart squid3 after making these network changes
1951+maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
1952+if dpkg --compare-versions $maas_ver lt 1.6; then
1953+# We now run squid3, and NOT squid-deb-proxy
1954+ update-rc.d -f squid-deb-proxy remove || true
1955+ service squid-deb-proxy stop || true
1956+ service squid3 stop || true
1957+ service squid3 start
1958+else
1959+ service maas-proxy stop || true
1960+ service maas-proxy start || true
1961+fi
1962
1963=== removed file 'usr/bin/orange-box-setup-nat'
1964--- usr/bin/orange-box-setup-nat 2014-10-08 11:51:07 +0000
1965+++ usr/bin/orange-box-setup-nat 1970-01-01 00:00:00 +0000
1966@@ -1,99 +0,0 @@
1967-#!/bin/bash
1968-#
1969-# orange-box-setup-nat - Setup NAT for external network access by nodes
1970-# Copyright (C) 2014 Canonical Ltd.
1971-#
1972-# Authors: Ronald McCollam <ronald.mccollam@canonical.com>
1973-# Dustin Kirkland <kirkland@canonical.com>
1974-#
1975-# This program is free software: you can redistribute it and/or modify
1976-# it under the terms of the GNU General Public License as published by
1977-# the Free Software Foundation, version 3 of the License.
1978-#
1979-# This program is distributed in the hope that it will be useful,
1980-# but WITHOUT ANY WARRANTY; without even the implied warranty of
1981-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1982-# GNU General Public License for more details.
1983-#
1984-# You should have received a copy of the GNU General Public License
1985-# along with this program. If not, see <http://www.gnu.org/licenses/>.
1986-
1987-set -x
1988-
1989-if [ "$(id -u)" != "0" ]; then
1990- echo "Must be run with sudo or by root"
1991- exit 77
1992-fi
1993-
1994-# Don't bother to restart sshd when lo is configured.
1995-if [ "$IFACE" = lo ]; then
1996- exit 0
1997-fi
1998-
1999-internal=$(route -n | grep "^10\.14\." | sed -e "s/.* //")
2000-external=$(ip route ls | grep ^default | awk '{print $5}')
2001-
2002-
2003-if [ -z "$internal" ] || [ -z "$external" ]; then
2004- echo "usage: $0 [INTERNAL_INTERFACE] [EXTERNAL_INTERFACE]" 1>&2
2005- exit 1
2006-fi
2007-
2008-set -e
2009-
2010-# Update MAAS upstream DNS
2011-dns=$(nmcli d list iface $external | grep -m 1 "^IP4.DNS" | awk '{ print $2 }')
2012-maas admin maas set-config name=upstream_dns value=$dns || true
2013-
2014-# Intel Centrino Advanced-N 6235 and Ubuntu don't work well with Wireless-N
2015-if lspci -v 2>/dev/null | grep -qs "Centrino Advanced-N 6235" 2>/dev/null; then
2016- sed -i -e "/options iwlwifi 11n_disable=1/d" /etc/modprobe.d/iwlwifi.conf
2017- echo "options iwlwifi 11n_disable=1" >> /etc/modprobe.d/iwlwifi.conf
2018-fi
2019-
2020-# Configure NAT and IP forwarding, giving slave NUCs external network access
2021-# through the master.
2022-
2023-# Enable IP forwarding and save for next boot
2024-echo 1 > /proc/sys/net/ipv4/ip_forward
2025-echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/10-maas-ip-forward.conf
2026-sysctl --system
2027-
2028-# Note that this script assumes no existing iptables rules. If you do have
2029-# any, they will be deleted.
2030-iptables --flush
2031-iptables --table nat --flush
2032-iptables --delete-chain
2033-iptables --table nat --delete-chain
2034-
2035-# Firewalling this machine
2036-# Allow incoming SSH
2037-iptables -A INPUT -i $external -p tcp --dport 22 -j ACCEPT
2038-iptables -A INPUT -i $external -m state --state ESTABLISHED,RELATED -j ACCEPT
2039-iptables -A INPUT -i $external -j DROP
2040-
2041-# Some things use the MAAS proxy - some things don't. So turn on NAT.
2042-echo "Setting up ip forwarding"
2043-iptables -t nat -A POSTROUTING -o $external -j MASQUERADE
2044-iptables -A FORWARD -i $external -o $internal -m state --state RELATED,ESTABLISHED -j ACCEPT
2045-iptables -A FORWARD -i $internal -o $external -j ACCEPT
2046-# The following line sets up a transparent proxy
2047-iptables -A PREROUTING -t nat -i br0 -p tcp -m multiport --dports 80 -j REDIRECT --to-port 3128
2048-
2049-iptables-save > /etc/iptables/rules.v4
2050-
2051-# 14.10 deprecates the iptables-persistent service in favor of netfilter-persistent
2052-service iptables-persistent restart || service netfilter-persistent restart
2053-
2054-# It seems we need to restart squid3 after making these network changes
2055-maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
2056-if dpkg --compare-versions $maas_ver lt 1.6; then
2057-# We now run squid3, and NOT squid-deb-proxy
2058- update-rc.d -f squid-deb-proxy remove || true
2059- service squid-deb-proxy stop || true
2060- service squid3 stop || true
2061- service squid3 start
2062-else
2063- service maas-proxy stop || true
2064- service maas-proxy start || true
2065-fi
2066
2067=== modified file 'usr/bin/orange-box-status-all-nodes'
2068--- usr/bin/orange-box-status-all-nodes 2014-10-20 11:58:14 +0000
2069+++ usr/bin/orange-box-status-all-nodes 2015-06-15 14:59:02 +0000
2070@@ -22,6 +22,9 @@
2071 export AMT_PASSWORD=Password1+
2072 ERRORS=0
2073
2074+## According to OB network re-design
2075+. /etc/orange-box.conf
2076+
2077 okay() {
2078 echo "OK: $@"
2079 }
2080@@ -35,23 +38,23 @@
2081 status_all_nodes() {
2082 # Check all VM nodes
2083 for i in $(seq 0 2); do
2084- if virsh list --all | grep node0vm${i} | grep running >/dev/null 2>&1; then
2085- okay "[node0vm${i}]: Is running"
2086- uptime=$(ssh node0vm${i}.maas "uptime" 2>/dev/null)
2087+ if virsh list --all | grep node0ob${orangebox_number}vm${i} | grep running >/dev/null 2>&1; then
2088+ okay "[node0ob${orangebox_number}vm${i}]: Is running"
2089+ uptime=$(ssh node0ob${orangebox_number}vm${i}.maas "uptime" 2>/dev/null)
2090 if [ -n "$uptime" ]; then
2091- okay "[node0vm${i}]: SSH to node successful; uptime=[$uptime]"
2092+ okay "[node0ob${orangebox_number}vm${i}]: SSH to node successful; uptime=[$uptime]"
2093 else
2094- error "[node0vm${i}]: SSH to node unsuccessful; uptime=[$uptime]"
2095+ error "[node0ob${orangebox_number}vm${i}]: SSH to node unsuccessful; uptime=[$uptime]"
2096 fi
2097 else
2098- error "[node0vm${i}]: Is not running"
2099+ error "[node0ob${orangebox_number}vm${i}]: Is not running"
2100 fi
2101 done
2102 # Check all AMT nodes
2103 for i in $(seq 1 9); do
2104- hostname="node${i}.maas"
2105+ hostname="node${i}ob${orangebox_number}.maas"
2106 # (1) Ping AMT IP Addresses
2107- amt_ip="10.14.4.1$i"
2108+ amt_ip="172.27.${orangebox_number}.1$i"
2109 if ping -c 1 -q $amt_ip >/dev/null 2>&1; then
2110 okay "[$hostname]: AMT responding to ping [$amt_ip]"
2111 else

Subscribers

People subscribed via source and target branches