Python脚本与RHN Satellite的API接口

时间:2013-01-22 21:53:14

标签: python rhel xmlrpclib satellite

我正在尝试创建一个与RHN Satellite的API接口的python脚本。下面的代码调度远程命令,以便针对指定的服务器(var id)立即运行。问题是Satellite服务器在我指定后2小时正好调度命令。我找不到发生这种情况的地方。 Satellite服务器和客户端都是RHEL6。这是我的代码:

#!/bin/python
import xmlrpclib
from datetime import date, datetime, time, timedelta
from sys import argv
import socket
import os

SATELLITE_URL = "https://URL"
SATELLITE_LOGIN = "username"
SATELLITE_PASSWORD = "password"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
id = [] #Satellite server ID
script = "#!/bin/sh \n yum update -y"


def schedule_script():

    earliest_occurrence = xmlrpclib.DateTime()
    print earliest_occurrence
    client.system.scheduleScriptRun(key, id, "root", "root", 300, script, earliest_occurrence)

schedule_script()

client.auth.logout(key)

当我打印变量“earliest_occurrence”时,它会打印当前时间。当我在Satellite服务器上执行“日期”时,它会打印正确的时间。

非常感谢任何帮助。谢谢!

0 个答案:

没有答案