Skip to content

Commit

Permalink
cloud-init: Fix netmask conversion issue
Browse files Browse the repository at this point in the history
If cloud config file has netmask as follows:
address: 150.0.0.5
netmask: 255.255.255.0 (dotted netmask)

Then cloud-init should convert this into CIDR
as follows:
address: 150.0.0.5/24

Change-Id: I4aa6ae02cbe0539b7dede667a09f66c7598c9045
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/6868
Tested-by: michellew <[email protected]>
Reviewed-by: Dweep Advani <[email protected]>
  • Loading branch information
akaher committed Mar 21, 2019
1 parent bdb6499 commit 6c09916
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion SPECS/cloud-init/cloud-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Name: cloud-init
Version: 0.7.9
Release: 14%{?dist}
Release: 15%{?dist}
Summary: Cloud instance init scripts
Group: System Environment/Base
License: GPLv3
Expand Down Expand Up @@ -138,6 +138,8 @@ rm -rf $RPM_BUILD_ROOT


%changelog
* Thu Mar 14 2019 Ajay Kaher <[email protected]> 0.7.9-15
- Fix netmask conversion from dotted to cidr
* Wed Feb 28 2018 Anish Swaminathan <[email protected]> 0.7.9-14
- Add support for systemd constructs for azure DS
* Mon Oct 16 2017 Vinay Kulkarni <[email protected]> 0.7.9-13
Expand Down
9 changes: 5 additions & 4 deletions SPECS/cloud-init/photon-distro.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/cloudinit/distros/photon.py
--- cloud-init-0.7.9/cloudinit/distros/photon.py 1969-12-31 16:00:00.000000000 -0800
+++ cloud-init-0.7.9-new/cloudinit/distros/photon.py 2017-05-15 05:13:49.156848344 -0700
@@ -0,0 +1,319 @@
--- cloud-init-0.7.9/cloudinit/distros/photon.py 1970-01-01 05:30:00.000000000 +0530
+++ cloud-init-0.7.9-new/cloudinit/distros/photon.py 2019-03-15 02:04:38.050451527 +0530
@@ -0,0 +1,320 @@
+# vi: ts=4 expandtab
+#
+# Copyright (C) 2017 VMware Inc.
Expand All @@ -16,6 +16,7 @@ diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/clo
+from cloudinit import util
+from cloudinit.distros import net_util
+from cloudinit.distros.parsers.hostname import HostnameConf
+from cloudinit.net.network_state import mask2cidr
+
+from cloudinit.settings import PER_INSTANCE
+
Expand Down Expand Up @@ -80,7 +81,7 @@ diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/clo
+ if info.get('address'):
+ net_cfg['Address'] = "%s" % (info.get('address'))
+ if info.get('netmask'):
+ net_cfg['Address'] += "/%s" % (info.get('netmask'))
+ net_cfg['Address'] += "/%s" % (mask2cidr(info.get('netmask')))
+ if info.get('gateway'):
+ net_cfg['Gateway'] = info.get('gateway')
+ if info.get('dns-nameservers'):
Expand Down

0 comments on commit 6c09916

Please sign in to comment.