Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F26091372
D4085.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D4085.diff
View Options
diff --git a/utils/migrate-ssh-keys.py b/utils/migrate-ssh-keys.py
deleted file mode 100755
--- a/utils/migrate-ssh-keys.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env python3
-
-# -------------------------------------------------------------
-# rOPS — migrate SSH keys from file to Salt state
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: Nasqueron
-# Description: Read a dictionary, and for each key, find in
-# a specified folder a data file. Add data from
-# this file to the dictionary. Output in YAML.
-# License: BSD-2-Clause
-# -------------------------------------------------------------
-
-# -------------------------------------------------------------
-# Table of contents
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-#
-# :: Configuration
-# :: YAML style
-# :: Update code
-# :: Run task
-#
-# -------------------------------------------------------------
-
-
-import os
-import yaml
-
-
-# -------------------------------------------------------------
-# Configuration
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-# Where is located the dictionary to update?
-state_file = "pillar/core/users.sls"
-state_key = "shellusers"
-
-# Where are located the data fileS?
-data_path = "roles/shellserver/users/files/ssh_keys/"
-
-# What property should get the data and be added if missing in the dict?
-state_data_property = "ssh_keys"
-
-
-# -------------------------------------------------------------
-# YAML style
-#
-# Allows indented lists in dump
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-class SaltStyleDumper(yaml.Dumper):
- def increase_indent(self, flow=False, indentless=False):
- return super(SaltStyleDumper, self).increase_indent(flow, False)
-
-
-# -------------------------------------------------------------
-# Update code
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-def do_update():
- state = read_state()
- update_state(state)
- print(dump_state(state))
-
-
-def read_state():
- fd = open(state_file, "r")
- states = yaml.safe_load(fd.read())
- fd.close()
-
- return states[state_key]
-
-
-def update_state(state):
- for key in state:
- if state_data_property not in state[key]:
- state[key][state_data_property] = read_data(key)
-
-
-def read_data(key):
- path = data_path + key
-
- if not os.path.exists(path):
- return []
-
- return [line.strip() for line in open(path, "r") if is_value_line(line)]
-
-
-def is_value_line(line):
- if line.startswith("#"):
- return False
-
- if line.strip() == "":
- return False
-
- return True
-
-
-def dump_state(state):
- return yaml.dump(
- {state_key: state}, default_flow_style=False, Dumper=SaltStyleDumper, width=1000
- )
-
-
-# -------------------------------------------------------------
-# Run task
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-do_update()
diff --git a/utils/reformat.py b/utils/reformat.py
deleted file mode 100755
--- a/utils/reformat.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python3
-
-# -------------------------------------------------------------
-# Salt — Reformat Salt states and source code files
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: Nasqueron
-# License: BSD-2-Clause
-# Description: This script detects multi-lines patterns
-# and rewrite them to apply the new style.
-#
-# Before: \n BLOCK_START [...] BLOCK_START
-# After: \n BLOCK_START [...] BLOCK_END
-# -------------------------------------------------------------
-
-import sys
-
-BLOCK_START = "# -------------------------------------------------------------\n"
-BLOCK_END = "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
-
-
-def usage():
- print(f"usage: {sys.argv[0]} <file to reformat>", file=sys.stderr)
-
-
-class Reformater:
- def __init__(self, file):
- self.file = file
- self.pattern_detection_counter = 0
-
- def reformat_inline(self):
- buffer = []
- with open(self.file, "r+") as fd:
- for line in fd:
- buffer.append(self.reformat_line(line))
-
- fd.seek(0)
- fd.truncate()
- fd.writelines(buffer)
-
- def reformat_line(self, line):
- if self.pattern_detection_counter == 0 and line == "\n":
- self.pattern_detection_counter += 1
- elif self.pattern_detection_counter == 1 and line == BLOCK_START:
- self.pattern_detection_counter += 1
- elif self.pattern_detection_counter == 2:
- if line == BLOCK_END:
- # We're probably in a header block or a correct one, so skip
- self.pattern_detection_counter = 0
- elif line == BLOCK_START:
- # We've got a winner
- self.pattern_detection_counter = 0
- return BLOCK_END
- elif not line.startswith("#"):
- # Let's go on, it's a multiline comments block
- self.pattern_detection_counter = 0
- else:
- self.pattern_detection_counter = 0
-
- return line
-
-
-if __name__ == "__main__":
- if len(sys.argv) < 2:
- usage()
- sys.exit(1)
-
- file_to_reformat = sys.argv[1]
- Reformater(file_to_reformat).reformat_inline()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 21, 02:51 (22 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3644643
Default Alt Text
D4085.diff (5 KB)
Attached To
Mode
D4085: Prune unused migration scripts
Attached
Detach File
Event Timeline
Log In to Comment