summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/sunhpc/commands/__init__.py12
-rw-r--r--lib/sunhpc/commands/set/grub/__init__.py57
2 files changed, 63 insertions, 6 deletions
diff --git a/lib/sunhpc/commands/__init__.py b/lib/sunhpc/commands/__init__.py
index ef7fdca..75b7692 100644
--- a/lib/sunhpc/commands/__init__.py
+++ b/lib/sunhpc/commands/__init__.py
@@ -653,7 +653,7 @@ class Command(object):
#print("\033[92m[+]\033[0m \033[96m%s\033[0m" % (msg))
print("\033[92m[+]\033[0m %s" % (msg))
- def message(self, msg, tag='[+]', end=''):
+ def message(self, tag='[+]', msg=' ', end=' '):
header = '\033[92m%s\033[0m' % tag
ender = '\033[95m%s\033[0m' % end
msger = '\033[31m%s\033[0m' % msg
@@ -856,7 +856,7 @@ class Command(object):
w, r ,e = (p.stdin, p.stdout, p.stderr)
currLength = 0
prevLength = 0
- spinChars = '-\|/'
+ spinChars = r'-\|/'
spinIndex = 0
while 1:
line = e.readline().decode()
@@ -1269,7 +1269,7 @@ class Command(object):
pdict = {}
plist = []
nparams = 0
- flagpattern=re.compile("^[a-zA-z0-9\-_+]+=")
+ flagpattern=re.compile(r"^[a-zA-z0-9\-_+]+=")
for arg in args:
tokens = arg.split()
if tokens[0] == 'select':
@@ -1543,7 +1543,7 @@ class DocStringHandler(
s += '*[%s]*' % name
else:
s += '*{%s}*' % name
- txt = txt.replace('*', '\*')
+ txt = txt.replace('*', '\\*')
s += '\n%s\n' % txt.replace('\t', ' ')
if self.section['param']:
s += '\n**Parameters:**\n\n'
@@ -1553,12 +1553,12 @@ class DocStringHandler(
s += '*[%s=%s]*' % (name, type)
else:
s += '*{%s=%s}*' % (name, type)
- txt = txt.replace('*', '\*')
+ txt = txt.replace('*', '\\*')
s += '\n%s\n' % txt.replace('\t', ' ')
if self.section['example']:
s += '\n**Examples:**\n'
for (cmd, txt) in self.section['example']:
- txt = txt.replace('*', '\*')
+ txt = txt.replace("*", "\\*")
s += '%s::\n\n' % txt.replace('\t',' ')
s += ' %s sunhpc %s\n' % (prompt, cmd)
if self.section['related']:
diff --git a/lib/sunhpc/commands/set/grub/__init__.py b/lib/sunhpc/commands/set/grub/__init__.py
new file mode 100644
index 0000000..95bf378
--- /dev/null
+++ b/lib/sunhpc/commands/set/grub/__init__.py
@@ -0,0 +1,57 @@
+#coding:utf-8
+
+import os
+import sys
+import sunhpc
+class command(sunhpc.commands.HostArgumentProcessor,
+ sunhpc.commands.set.command):
+ pass
+
+class Command(command):
+ """
+ Grub2 boot configure
+ <param type='strings' name='default'>
+ Set the default boot options
+ </param>
+
+ <example cmd='grub default=1'>
+ Set the default boot options index 1
+ </example>
+ """
+
+ def run(self, params, args):
+ (default, ) = self.fillParams([
+ ('default', None),
+ ])
+
+ if default:
+ try:
+ default_number = int(default)
+ #self.msg('Please modify it manually by using the command: grubby --set-defautl-index=%s' % default)
+ info = self.message('[*]', 'Please modify it manually by using the command:', 'grubby --set-default-index=%s' % default)
+ print (info)
+ sys.exit(0)
+ except ValueError:
+ self.msg('The "default" parameters must be the numbers.', 'a')
+
+
+ current_kernel = os.popen('uname -r').read().strip()
+ self.msg('--> Current kernel: %s' % current_kernel)
+
+ default_kernel = os.popen('grubby --default-kernel').read().strip()
+ self.msg('--> Default kernel: %s' % default_kernel)
+
+ kernel_index = os.popen('grubby --default-index').read().strip()
+ self.msg('--> Default kernel index: %s' % kernel_index)
+
+ kernel_list = os.popen('grubby --info=ALL').readlines()
+ self.msg('')
+ self.msg('-------- All Kernel List begin----------')
+ for i in kernel_list:
+ self.msg(i.strip())
+ self.msg('-------- All Kernel List ender----------')
+ self.msg('')
+
+ self.msg('Using index number, you can change the default boot kernel.e,g.. sunhpc set grub default=1', 'i')
+
+RollName = "base"