Пример #1
0
def getFWInfo(ibmc, root_uri, system_uri, manager_uri):
    LOG_FILE = "/etc/ansible/ansible_ibmc/log/getFwinfo.log"
    REPORT_FILE = "/etc/ansible/ansible_ibmc/report/getFwinfoReport.log"
    log, report = ansibleGetLoger(LOG_FILE, REPORT_FILE, "getFwinfo")
    rets = {'result': True, 'msg': ''}
    ret = spApiGetFwInfo(ibmc, root_uri, manager_uri)
    if ret["result"] == True:
        if ret["fwInfo"] == [] or ret["fwInfo"] == None:
            rets['result'] = False
            rets['msg'] = "get fwInfo failed "
            return rets
        msg = ''
        try:
            for eachFw in ret["fwInfo"]:
                msg = msg + "===============================================\n"
                msg = msg + "DeviceName:" + eachFw["DeviceName"] + "\n"
                msg = msg + "Manufacturer:" + eachFw["Controllers"][0][
                    "Manufacturer"] + "\n"
                msg = msg + "Model:" + eachFw["Controllers"][0]["Model"] + "\n"
                msg = msg + "FirmwareVersion:" + eachFw["Controllers"][0][
                    "FirmwareVersion"] + "\n"
        except Exception, err:
            log.error(ibmc['ip'] + "parse fwInfo exceptiom :" + str(err))
        FWInfoDic = {"fwinfo": ret["fwInfo"]}
        fileName = str(ibmc['ip']) + "fwInfo.json"
        jsonfile = None
        try:
            jsonfile = open('/etc/ansible/ansible_ibmc/report/' + fileName,
                            "w")
            if jsonfile is not None:
                json.dump(FWInfoDic, jsonfile, indent=4)
        except Exception, e:
            log.error(ibmc['ip'] + " write json exception :" + str(e))
import commands
import base64
import platform
import subprocess
import string
import ConfigParser
from datetime import datetime
sys.path.append("/etc/ansible/ansible_ibmc/module")
from redfishApi import *
sys.path.append("/etc/ansible/ansible_ibmc/scripts")
from powerManage import *
from cfgBmc import *
from commonLoger import ansibleGetLoger
LOG_FILE = "/etc/ansible/ansible_ibmc/log/spRedfishAPI.log"
REPORT_FILE = "/etc/ansible/ansible_ibmc/report/spRedfishAPI.log"
log,report=ansibleGetLoger(LOG_FILE,REPORT_FILE,"spRedfishAPI")

def spAPISetSpService(ibmc,root_uri,manager_uri,spEnable,restarTimeout = 30,deployTimeout=7200,deployStatus=True):
    uri = root_uri + manager_uri + "/SPService"
    Etag = getEtag(ibmc,uri)
    token = getToken() 
    headers = {'content-type': 'application/json','X-Auth-Token':token,'If-Match':Etag}
    playload = {"SPStartEnabled": spEnable ,\
                 "SysRestartDelaySeconds": restarTimeout,\
                 "SPTimeout": deployTimeout,\
                 "SPFinished":deployStatus }    
    ret = {'result':True,'msg': ''}
    try:
        r = request('PATCH',resource=uri,headers=headers,data=playload,tmout=10,ip=ibmc['ip'])
        print "rrrr",r
        result = r.status_code
import time
import commands
import base64
import platform
import string
import logging, logging.handlers
from datetime import datetime

sys.path.append("/etc/ansible/ansible_ibmc/scripts")
from powerManage import *
REQUEST_Ok = 200
global token
from commonLoger import ansibleGetLoger
LOG_FILE = "/etc/ansible/ansible_ibmc/log/getRaidInfo.log"
REPORT_FILE = "/etc/ansible/ansible_ibmc/report/getRaidInfoReport.log"
log, report = ansibleGetLoger(LOG_FILE, REPORT_FILE, "getRaidInfo")


def ApiGetStorages(ibmc, root_uri, system_uri):
    ret = {
        "result": True,
        'msg': "ApiGetStorages successfully!",
        "storgesInfo": {}
    }
    uri = root_uri + system_uri + "/Storages"
    log.info("uri=" + str(uri))
    token = getToken()
    headers = {'X-Auth-Token': token}
    r = request('GET',
                resource=uri,
                headers=headers,
Пример #4
0
import time
import commands
import string
import ConfigParser
from datetime import datetime

sys.path.append("/etc/ansible/ansible_ibmc/module")
from redfishApi import *

sys.path.append("/etc/ansible/ansible_ibmc/scripts")
from cfgBmc import *
from commonLoger import ansibleGetLoger

LOG_FILE = "/etc/ansible/ansible_ibmc/log/accountManage.log"
REPORT_FILE = "/etc/ansible/ansible_ibmc/report/accountManage.log"
log, report = ansibleGetLoger(LOG_FILE, REPORT_FILE, "accountManage")


def getAccountsId(ibmc, root_uri, username):
    uri = root_uri + "/AccountService/Accounts"
    token = getToken()
    headers = {'content-type': 'application/json', 'X-Auth-Token': token}
    playload = {}
    try:
        r = request('GET',
                    resource=uri,
                    headers=headers,
                    data=playload,
                    tmout=10)
    except Exception, e:
        log.error(ibmc['ip'] + " -- " +
Пример #5
0
import base64
import platform
import subprocess
import string
import ConfigParser
from datetime import datetime
sys.path.append("/etc/ansible/ansible_ibmc/module")
from redfishApi import *
sys.path.append("/etc/ansible/ansible_ibmc/scripts")
from powerManage import *
from cfgBmc import *
from commonLoger import ansibleGetLoger
from spRedfishAPI import *
LOG_FILE = "/etc/ansible/ansible_ibmc/log/upgradFwBySp.log"
REPORT_FILE = "/etc/ansible/ansible_ibmc/report/upgradFwBySpReport.log"
log, report = ansibleGetLoger(LOG_FILE, REPORT_FILE, "upgradFwBySp")
CHECK_INTERVAL = 6
#total time= 6s *20
WAIT_TRANFILE_TIME = 20
#total time= 6s *100
WATT_UPGRADE_RES = 100
#totall 300s
WAIT_SPSTART = 3
KEEP_CONNECT_INTERVAL = 100


def getConfig(configPath):
    list = []
    file = None
    try:
        file = open(configPath)