Exemplo n.º 1
0
def getExpirationDate(license_props):
    """
    Iterates through a property list and returns the expirationDate
    """
    if license_props:
        df = DateFormat.getInstance()
        for p in license_props:
            if p.getKey() == "expirationDate":
                val = p.getValue()
                if val.getClass().getName() == "java.util.GregorianCalendar":
                    return df.format(val.getTime())
    return None
Exemplo n.º 2
0
def printHostHardwareSummary(si):
    host = InventoryNavigator(si.getRootFolder()).searchManagedEntities("HostSystem")
    df = DateFormat.getInstance()
    for h in host:
        hinfo = h.getHardware()
        print "Hypervisor Name: " + h.getName()
        print hinfo.getSystemInfo().getVendor(),
        print hinfo.getSystemInfo().getModel()
        print "Bios: ", hinfo.getBiosInfo().getBiosVersion(),
        print df.format(hinfo.getBiosInfo().getReleaseDate().getTime())
        print "Overall Status: ", 
        print h.getOverallStatus().toString().capitalize()
        print "CPU Info: ", hinfo.getCpuPkg()[0].getDescription()
        print "\tCPU's: ", hinfo.getCpuInfo().getNumCpuPackages()
        print "\tCores: ", hinfo.getCpuInfo().getNumCpuCores()
        print "Memory Info: %.2f GB" % (hinfo.getMemorySize() * pow(10.0, -9))
Exemplo n.º 3
0
def dumpPropertyList(pList):
    """
    Iterates through a property list and prints the key/value pairs
    Primarily for debugging
    """
    FORMAT = "%16s %s"
    for p in pList:
        k = p.getKey()
        if p.getValue().__class__ is unicode or \
                p.getValue().__class__ is long:
            v = p.getValue()

        elif p.getValue().getClass().getName() == "com.vmware.vim25.KeyValue":
            v = p.getValue().getValue()
        elif p.getValue().getClass().getName() == "java.util.GregorianCalendar":
            df = DateFormat.getInstance()
            v = df.format(p.getValue().getTime())
        else:
            v = "Val: UNABLE TO PRINT; " + p.getValue().getClass().getName()

        print FORMAT % (k.capitalize()+":", v)
Exemplo n.º 4
0
import com.ibm.custom.WordHelper as WordHelper
import java.util.Calendar as Calendar
import java.text.DateFormat as DateFormat
import java.util.List as List
import java.util.Arrays as Arrays

df = DateFormat.getInstance()
rp = WordHelper("./samplet.dotx")  #Create Helper Object
doc = rp.getDocument()  #Sample method to get Document object

#Replace Keywords:
rp.replaceText("##LetterNum##", "123/456/789")
rp.replaceText("##CurrentDate##", df.format(Calendar.getInstance().getTime()))
rp.replaceText("##CustomerName##", "IBM")
rp.replaceText("##TicketID##", "ABC123")
rp.replaceText("##ResolveDate##", df.format(Calendar.getInstance().getTime()))
rp.replaceText("##SolutionDetails##", "Restart Server\n Recreate User\n")
rp.replaceText("##Resolver##", "John Doe")

#Update Tables - template table first row must match the header
tbheads = Arrays.asList("Circuit ID", "Speed", "Location")
tbdata = Arrays.asList(Arrays.asList("CI100", "100 Mbps", "Singapore"),
                       Arrays.asList("CI210", "1 Gbps", "Kuala Lumpur"),
                       Arrays.asList("CI320", "10 Gbps", "Bangkok"))
rp.updateTable(tbheads, tbdata)

#Save the result
rp.saveAs("./jython_output.doc")