Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Creates and returns a Nimbus optional file

Argument:
custom_tasks -- A list of tuples were the first item is the file to edit
                and the second is the string to place there. In these
                tuples, the first element is the content, and the second
                is the location

Example:
ws_optional_factory([("YOURKEY", "/root/.ssh/authorized_keys")])(more...)

        def ws_optional_factory(custom_tasks=None, credential=None):
    """
    Creates and returns a Nimbus optional file

    Argument:
    custom_tasks -- A list of tuples were the first item is the file to edit
                    and the second is the string to place there. In these
                    tuples, the first element is the content, and the second
                    is the location

    Example:
    ws_optional_factory([("YOURKEY", "/root/.ssh/authorized_keys")])

    returns None if input is invalid
    """

    # Create the XML doc
    doc = xml.dom.minidom.Document()

    ##
    ## Create XML document heirarchy
    ##

    # Create the OptionalParameters (root) element
    op = doc.createElement("OptionalParameters")

    # Add the Workspace deployment element (first, to be root)
    doc.appendChild(op)

    # Add each filewrite element
    for task in custom_tasks:

        # Verify that the path is absolute
        if not task[1][0] or task[1][0] != "/":
            return None

        filewrite = doc.createElement("filewrite")
        op.appendChild(filewrite)

        content_el = doc.createElement("content")
        filewrite.appendChild(content_el)
        content = doc.createTextNode(task[0])
        content_el.appendChild(content)

        pathOnVM_el = doc.createElement("pathOnVM")
        filewrite.appendChild(pathOnVM_el)
        pathOnVM = doc.createTextNode(task[1])
        pathOnVM_el.appendChild(pathOnVM)

    if credential:
        credentialToCopy_el = doc.createElement("credentialToCopy")
        op.appendChild(credentialToCopy_el)
        credentialToCopy = doc.createTextNode(credential)
        credentialToCopy_el.appendChild(credentialToCopy)


    ##
    ## Create output file. Write xml. Close file.
    ##

    (xml_out, file_name) = tempfile.mkstemp()

    os.write(xml_out, doc.toxml(encoding="utf-8"))
    os.close(xml_out)

    # Return the filename of the created metadata file
    return file_name
        


src/c/l/cloud-scheduler-1.6/cloudscheduler/nimbuscluster.py   cloud-scheduler(Download)
            else:
                _job_proxy = None
            vm_optional = nimbus_xml.ws_optional_factory(custom_tasks=customization, credential=_job_proxy)
        else:
            vm_optional = None

src/c/l/cloud-scheduler-HEAD/cloudscheduler/nimbuscluster.py   cloud-scheduler(Download)
            else:
                _job_proxy = None
            vm_optional = nimbus_xml.ws_optional_factory(custom_tasks=customization, credential=_job_proxy)
        else:
            vm_optional = None