Merge lp:~chad.smith/charms/precise/landscape-client/lsclient-origin-param into lp:~charmers/charms/precise/landscape-client/trunk

Proposed by Chad Smith
Status: Merged
Approved by: Mark Mims
Approved revision: 27
Merged at revision: 21
Proposed branch: lp:~chad.smith/charms/precise/landscape-client/lsclient-origin-param
Merge into: lp:~charmers/charms/precise/landscape-client/trunk
Diff against target: 158 lines (+86/-8)
5 files modified
README (+3/-3)
config.yaml (+10/-2)
hooks/common.py (+6/-1)
hooks/install (+66/-1)
revision (+1/-1)
To merge this branch: bzr merge lp:~chad.smith/charms/precise/landscape-client/lsclient-origin-param
Reviewer Review Type Date Requested Status
Mark Mims (community) Approve
David Britton (community) Approve
Review via email: mp+150623@code.launchpad.net

Description of the change

The branch updates landscape-client charm to allow passing an "origin" parameter to designate a different repository from which to pull landscape-client & landscape-common debs. If unspecified, the origin parameter defaults to "distro" which will not alter PPAs or apt-sources on the juju unit and just deploy the distribution's stock landscape-client deb.

Here are the changes I put in to add an origin param that takes any of the following formats:
#PPAs
ppa:blah/blah

# APT SOURCE LINES
deb http://archive.ubuntu.com/ubuntu precise main

# private repo with or without keys
https://landscape-person:<email address hidden>/landscape/lds-trunk/ubuntu|HEXKEY

To post a comment you must log in.
Revision history for this message
David Britton (dpb) wrote :

[1] Let's get rid of the grub-pc workaround. I don't think we want that in the official charm.

[2] Can we change the sources file to something like "landscape-client-origin.list"?

[3] Add in ;; to the default (*) case. Just for sanity sake.

[4] Move the rm into add_apt_source, just to keep it with like code, also change to simply rm -f $SOURCES_FILE, which will always succeed (then you can take it out of the if block)

[5] Change interactions in the case statement with the souces_file to '>' from '>>' to make it clear that the file is being recreated each time

[6] Probably want to specially handle the case of ORIGIN not set. like, a sentinel in add_apt_source or something like that.

[7] Remove stray ntp installation.

Revision history for this message
David Britton (dpb) wrote :

Looks great, just clean up small things. I think the logic in it is good. +1

review: Approve
24. By Chad Smith

resolve dbp's review comments [1-5] & 7
add_apt_source sentinal is already handled if $ORIGIN default case statement

Revision history for this message
David Britton (dpb) wrote :

Chad, also I found another problem:

If you use this charm with old clients (like what is in precise), it will not work with a password on the account. We need to try either specifying both password and key if either/or is specified (if the config file can handle it), or specify the right one based on client version.

review: Needs Fixing
25. By Chad Smith

backwards compatibility writing registration_password and registration_key into config for precise ls-client

Revision history for this message
David Britton (dpb) wrote :

Glad the easier solution works. Looks good, +1

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

Validated as working w/ precise distro landscape-client and our PPA of landscape-client from trunk.

26. By Chad Smith

merge in upstream meta-data for landscape-client

27. By Chad Smith

bump revision beyond new upstream

Revision history for this message
Mark Mims (mark-mims) wrote :

love to see the origin bits consolidated with charm-helpers... i.e., please add the signed-keys bits into charm-helpers sometime and use that for this charm

https://bugs.launchpad.net/charm-tools/+bug/1154339

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2013-01-18 04:12:34 +0000
3+++ README 2013-03-07 20:24:20 +0000
4@@ -13,7 +13,7 @@
5
6 landscape-client:
7 account-name: <account_name_here>
8- registration-password: <registration_key_here>
9+ registration-key: <registration_key_here>
10 computer-title: <computer_title_here>
11 tags: <csv_tag_list>
12
13@@ -24,7 +24,7 @@
14
15 landscape-client:
16 account-name: standalone
17- registration-password: 128-qosk-7382
18+ registration-key: 128-qosk-7382
19 computer-title: Dev Laptop 09
20 tags: laptop,precise,developer
21 ping-url = http://landscape.example.com/ping
22@@ -49,7 +49,7 @@
23 of Landscape. In the dedicated version of Landscape (LDS), this will
24 always be "standalone"
25
26-registration-password:
27+registration-key:
28 The account registration key, found in the Landscape account GUI.
29
30 computer-title:
31
32=== modified file 'config.yaml'
33--- config.yaml 2013-01-18 09:45:23 +0000
34+++ config.yaml 2013-03-07 20:24:20 +0000
35@@ -1,4 +1,12 @@
36 options:
37+ origin:
38+ description: |
39+ Origin of ppa or private deb repository from which to install
40+ landscape-client. May be one of the following:
41+ distro (default), ppa:somecustom/ppa or a full APT url source
42+ entry with optional key. For example:
43+ deb https://asf@private-ppa.launchpad.net/myrepo precise main|YOURAPTKEY"
44+ type: string
45 data-path:
46 description: |
47 The directory to store data files in (default:
48@@ -42,9 +50,9 @@
49 description: |
50 The account this computer belongs to.
51 type: string
52- registration-password:
53+ registration-key:
54 description: |
55- The account-wide password used for registering clients.
56+ The account-wide key used for registering clients.
57 type: string
58 exchange-interval:
59 description: |
60
61=== modified file 'hooks/common.py'
62--- hooks/common.py 2013-02-01 11:55:50 +0000
63+++ hooks/common.py 2013-03-07 20:24:20 +0000
64@@ -20,7 +20,12 @@
65 client_config = Configuration()
66 client_config.reload()
67 for key, value in service_config.items():
68- setattr(client_config, key.replace("-", "_"), value)
69+ if key != "origin":
70+ setattr(client_config, key.replace("-", "_"), value)
71+ if key == "registration-key":
72+ # Use registration_password additionally for
73+ # backwards compatibility with landscape-client in precise.
74+ setattr(client_config, "registration_password", value)
75 client_config.write()
76 return try_to_register()
77
78
79=== modified file 'hooks/install'
80--- hooks/install 2012-05-02 21:33:06 +0000
81+++ hooks/install 2013-03-07 20:24:20 +0000
82@@ -1,3 +1,68 @@
83 #!/bin/bash
84
85-apt-get install -y landscape-client
86+set -e
87+
88+# Where to get our debs from
89+ORIGIN=`config-get origin`
90+
91+SOURCES_FILE=/etc/apt/sources.list.d/landscape-client-origin.list
92+CODENAME=$(cat /etc/lsb-release | grep CODENAME | sed 's/.*=//')
93+
94+add_apt_source() {
95+ # Allow sources of the formats:
96+ # https/blah/blah|KEYKEYKEY
97+ # deb https/blah/blah precise main|KEYKEYKEY
98+ # ppa:landscape/trunk
99+ if [ "$1" == "distro" ]; then
100+ # do nothing extra
101+ return
102+ fi
103+ src=`echo $1| awk -F '|' '{print $1}'`
104+ key=`echo $1| awk -F '|' '{print $2}'`
105+
106+ rm -f $SOURCES_FILE
107+
108+ case "$src" in
109+ ppa:*)
110+ apt-add-repository -y $src
111+ return
112+ ;;
113+ deb*)
114+ # Blindly take a apt source line
115+ if [ ! -z "$key" ]; then
116+ apt-key adv --keyserver keyserver.ubuntu.com --recv-key $key
117+ fi
118+ echo "$src" > $SOURCES_FILE
119+ chmod go+r $SOURCES_FILE
120+ return
121+ ;;
122+ http*)
123+ # take a url and make it a valid APT source for the current release
124+ if [ ! -z "$key" ]; then
125+ apt-key adv --keyserver keyserver.ubuntu.com --recv-key $key
126+ fi
127+ echo "deb $src $CODENAME main" > $SOURCES_FILE
128+ chmod go+r $SOURCES_FILE
129+ return
130+ ;;
131+ *)
132+ echo "Invalid repository origin specified: '" $src "'"
133+ ;;
134+ esac
135+}
136+
137+function apt_get() {
138+ DEBIAN_FRONTEND=noninteractive apt-get \
139+ --allow-unauthenticated -y \
140+ -o Dpkg::Options::='--force-confold' $*;
141+}
142+
143+
144+# Workaround for: https://bugs.launchpad.net/juju/+bug/993034
145+echo 'Acquire::https { Proxy "false"; };' >> /etc/apt/apt.conf.d/02juju-apt-proxy
146+
147+apt_get install apt-transport-https wget
148+
149+add_apt_source "$ORIGIN"
150+apt_get update
151+apt_get install landscape-client
152
153=== modified file 'revision'
154--- revision 2013-02-15 09:56:21 +0000
155+++ revision 2013-03-07 20:24:20 +0000
156@@ -1,1 +1,1 @@
157-8
158+9

Subscribers

People subscribed via source and target branches