blob: 853a48bc721ace2f695ffcd15858cacf5cfa742b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#coding:utf-8
import sunhpc.commands
class Command(sunhpc.commands.set.host.command):
"""
Set the number of CPUs for a list of hosts.
<arg type='string' name='host' repeat='1'>
One or more host names.
</arg>
<arg type='string' name='cpus'>
The number of CPUs to assign to each host.
</arg>
<param optional='1' type='string' name='cpus'>
Can be used in place of the cpus argument.
</param>
<example cmd='set host cpus compute-0-0 2'>
Sets the CPU value to 2 for compute-0-0.
</example>
<example cmd='set host cpus compute-0-0 compute-0-1 4'>
Sets the CPU value to 4 for compute-0-0 and compute-0-1.
</example>
<example cmd='set host cpus compute-0-0 compute-0-1 cpus=4'>
Same as above.
</example>
"""
def run(self, params, args):
(args, cpus) = self.fillPositionalArgs(('cpus',))
if not len(args):
self.abort('must supply host')
if not cpus:
self.abort('must supply cpus')
for host in self.getHostnames(args):
self.db.execute("""update nodes set cpus=%d where
name='%s'""" % (int(cpus), host))
RollName = "base"
|