summaryrefslogtreecommitdiff
path: root/cloudinit/transforms/cc_disable_ec2_metadata.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/transforms/cc_disable_ec2_metadata.py')
-rw-r--r--cloudinit/transforms/cc_disable_ec2_metadata.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/cloudinit/transforms/cc_disable_ec2_metadata.py b/cloudinit/transforms/cc_disable_ec2_metadata.py
index 6b31ea8e..4d2a7f55 100644
--- a/cloudinit/transforms/cc_disable_ec2_metadata.py
+++ b/cloudinit/transforms/cc_disable_ec2_metadata.py
@@ -17,14 +17,16 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import cloudinit.util as util
-import subprocess
-from cloudinit.CloudConfig import per_always
-frequency = per_always
+from cloudinit import util
+
+from cloudinit.settings import PER_ALWAYS
+
+frequency = PER_ALWAYS
+
+reject_cmd = ['route', 'add', '-host', '169.254.169.254', 'reject']
def handle(_name, cfg, _cloud, _log, _args):
if util.get_cfg_option_bool(cfg, "disable_ec2_metadata", False):
- fwall = "route add -host 169.254.169.254 reject"
- subprocess.call(fwall.split(' '))
+ util.subp(reject_cmd)