Merge lp:~harlowja/cloud-init/cloud-init-render-tool into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: lp:~harlowja/cloud-init/cloud-init-render-tool
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 106 lines (+90/-1)
2 files modified
setup.py (+1/-1)
tools/net-convert.py (+89/-0)
To merge this branch: bzr merge lp:~harlowja/cloud-init/cloud-init-render-tool
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
cloud-init Commiters Pending
Review via email: mp+297816@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

I like this, its useful.

The distro has some affect (at least right now) on the rendering. so it seems we should expose the distro there somehow.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:1244
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~harlowja/cloud-init/cloud-init-render-tool/+merge/297816/+edit-commit-message

https://server-team-jenkins.canonical.com/job/cloud-init-ci/42/
Executed test runs:
    None: https://server-team-jenkins.canonical.com/job/lp-vote-on-merge/16/console

Click here to trigger a rebuild:
https://server-team-jenkins.canonical.com/job/cloud-init-ci/42/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Hello,
Thank you for taking the time to contribute to cloud-init. Cloud-init has moved its revision control system to git. As a result, we are marking all bzr merge proposals as 'rejected'. If you would like to re-submit this proposal for review, please do so by following the current HACKING documentation at http://cloudinit.readthedocs.io/en/latest/topics/hacking.html .

I'm going to mark this as 'merged', because I think it is actually
upstream at
https://git.launchpad.net/cloud-init/commit/?id=79236a629f1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2016-06-14 21:56:51 +0000
3+++ setup.py 2016-06-18 00:17:45 +0000
4@@ -211,7 +211,7 @@
5 cmdclass=cmdclass,
6 entry_points={
7 'console_scripts': [
8- 'cloud-init = cloudinit.cmd.main:main'
9+ 'cloud-init = cloudinit.cmd.main:main',
10 ],
11 }
12 )
13
14=== added file 'tools/net-convert.py'
15--- tools/net-convert.py 1970-01-01 00:00:00 +0000
16+++ tools/net-convert.py 2016-06-18 00:17:45 +0000
17@@ -0,0 +1,89 @@
18+#!/usr/bin/python
19+# vi: ts=4 expandtab
20+#
21+# Copyright (C) 2012 Canonical Ltd.
22+# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
23+# Copyright (C) 2012 Yahoo! Inc.
24+#
25+# Author: Scott Moser <scott.moser@canonical.com>
26+# Author: Juerg Haefliger <juerg.haefliger@hp.com>
27+# Author: Joshua Harlow <harlowja@yahoo-inc.com>
28+#
29+# This program is free software: you can redistribute it and/or modify
30+# it under the terms of the GNU General Public License version 3, as
31+# published by the Free Software Foundation.
32+#
33+# This program is distributed in the hope that it will be useful,
34+# but WITHOUT ANY WARRANTY; without even the implied warranty of
35+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36+# GNU General Public License for more details.
37+#
38+# You should have received a copy of the GNU General Public License
39+# along with this program. If not, see <http://www.gnu.org/licenses/>.
40+
41+import argparse
42+import json
43+import os
44+
45+from cloudinit.sources.helpers import openstack
46+
47+from cloudinit.net import eni
48+from cloudinit.net import network_state
49+from cloudinit.net import sysconfig
50+
51+
52+def main():
53+ parser = argparse.ArgumentParser()
54+ parser.add_argument("--network-data", "-p", type=open,
55+ metavar="PATH", required=True)
56+ parser.add_argument("--kind", "-k",
57+ choices=['eni', 'network_data.json'],
58+ required=True)
59+ parser.add_argument("-d", "--directory",
60+ metavar="PATH",
61+ help="directory to place output in",
62+ required=True)
63+ parser.add_argument("-m", "--mac",
64+ metavar="name,mac",
65+ action='append',
66+ help="interface name to mac mapping")
67+ parser.add_argument("--output-kind", "-ok",
68+ choices=['eni', 'sysconfig'],
69+ required=True)
70+ args = parser.parse_args()
71+
72+ if not os.path.isdir(args.directory):
73+ os.makedirs(args.directory)
74+
75+ if args.mac:
76+ known_macs = {}
77+ for item in args.mac:
78+ iface_name, iface_mac = item.split(",", 1)
79+ known_macs[iface_mac] = iface_name
80+ else:
81+ known_macs = None
82+
83+ net_data = args.network_data.read()
84+ if args.kind == "eni":
85+ pre_ns = eni.convert_eni_data(net_data)
86+ ns = network_state.parse_net_config_data(pre_ns)
87+ else:
88+ pre_ns = openstack.convert_net_json(
89+ json.loads(net_data), known_macs=known_macs)
90+ ns = network_state.parse_net_config_data(pre_ns)
91+
92+ if not ns:
93+ raise RuntimeError("No valid network_state object created from"
94+ "input data")
95+
96+ if args.output_kind == "eni":
97+ r_cls = eni.Renderer
98+ else:
99+ r_cls = sysconfig.Renderer
100+
101+ r = r_cls()
102+ r.render_network_state(args.directory, ns)
103+
104+
105+if __name__ == '__main__':
106+ main()