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

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Creates and returns a Nimbus deployment request file

Arguments:
vm_duration    -- time in minutes for VM to be deployed
vm_targetstate -- state VM should be in after it is deployed
vm_mem         -- memory in megabytes that deployed VM will have
vm_storage     -- memory in megabytes that deployed VM will have TODO: Make this optional
vm_nodes       -- Number of VMs to request
vm_cores       -- optional. number of cores for deployed VM
(more...)

        def ws_deployment_factory(vm_duration, vm_targetstate, vm_mem, vm_storage, vm_nodes, vm_cores=1):
    """
    Creates and returns a Nimbus deployment request file

    Arguments:
    vm_duration    -- time in minutes for VM to be deployed
    vm_targetstate -- state VM should be in after it is deployed
    vm_mem         -- memory in megabytes that deployed VM will have
    vm_storage     -- memory in megabytes that deployed VM will have TODO: Make this optional
    vm_nodes       -- Number of VMs to request
    vm_cores       -- optional. number of cores for deployed VM

    returns text file with XML deployment request
    """

    # Namespace variables for populating the xml file
    root_nmspc = "http://www.globus.org/2008/06/workspace/negotiable"
    jsdl_nmspc = "http://schemas.ggf.org/jsdl/2005/11/jsdl"
    xsi_nmspc  = "http://www.w3.org/2001/XMLSchema-instance"

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

    ##
    ## Create XML document heirarchy
    ##

    # TODO: Clean this up and give some sample XML to clarify this

    # Create the WorkspaceDeployment (root) element
    wsd_el = doc.createElementNS(root_nmspc, "WorkspaceDeployment")

    # Define namespaces in the root element
    wsd_el.setAttribute("xmlns", root_nmspc )
    wsd_el.setAttribute("xmlns:jsdl", jsdl_nmspc)
    wsd_el.setAttribute("xmlns:xsi", xsi_nmspc)

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

    #-lvl 1
    deploymenttime_el = doc.createElementNS(root_nmspc, "DeploymentTime")
    wsd_el.appendChild(deploymenttime_el)
    #--lvl2
    minduration_el = doc.createElementNS(root_nmspc, "minDuration")
    deploymenttime_el.appendChild(minduration_el)

    #-lvl 1
    initialstate_el = doc.createElementNS(root_nmspc, "InitialState")
    wsd_el.appendChild(initialstate_el)

    #-lvl 1
    rsrcallocation_el = doc.createElementNS(root_nmspc, "ResourceAllocation")
    wsd_el.appendChild(rsrcallocation_el)
    #--lvl 2
    memory_el = doc.createElementNS(jsdl_nmspc, "jsdl:IndividualPhysicalMemory")
    rsrcallocation_el.appendChild(memory_el)
    #---lvl 3
    exactmem_el = doc.createElementNS(jsdl_nmspc, "jsdl:Exact")
    memory_el.appendChild(exactmem_el)
    #--lvl 2
    ncpu_el = doc.createElementNS(jsdl_nmspc, "jsdl:IndividualCPUCount")
    rsrcallocation_el.appendChild(ncpu_el)
    #---lvl 3
    exactncpu_el = doc.createElementNS(jsdl_nmspc, "jsdl:Exact")
    ncpu_el.appendChild(exactncpu_el)
    exactncpu_txt = doc.createTextNode(str(vm_cores))
    exactncpu_el.appendChild(exactncpu_txt)

    if vm_storage and vm_storage > 0:
        #--lvl 2
        storage_el = doc.createElementNS(root_nmspc, "Storage")
        rsrcallocation_el.appendChild(storage_el)
        #---lvl 3
        entry_el = doc.createElementNS(root_nmspc, "entry")
        storage_el.appendChild(entry_el)
        #----lvl 4
        partitionname_el = doc.createElementNS(root_nmspc, "partitionName")
        entry_el.appendChild(partitionname_el)
        #----lvl 4
        diskspace_el = doc.createElementNS(jsdl_nmspc, "jsdl:IndividualDiskSpace")
        entry_el.appendChild(diskspace_el)
        #-----lvl 5
        exactdisk_el = doc.createElementNS(jsdl_nmspc, "jsdl:Exact")
        diskspace_el.appendChild(exactdisk_el)

    #-lvl 1
    nodenumber_el = doc.createElementNS(root_nmspc, "NodeNumber")
    wsd_el.appendChild(nodenumber_el)

    #-lvl 1
    shutdown_el = doc.createElementNS(root_nmspc, "ShutdownMechanism")
    wsd_el.appendChild(shutdown_el)

    ##
    ## Set field values
    ##

    minduration_txt = doc.createTextNode(format_duration_time(vm_duration))
    minduration_el.appendChild(minduration_txt)

    initialstate_txt = doc.createTextNode(vm_targetstate)
    initialstate_el.appendChild(initialstate_txt)

    exactmem_txt = doc.createTextNode(str(vm_mem))
    exactmem_el.appendChild(exactmem_txt)
    if vm_storage and vm_storage > 0:
        partitionname_txt = doc.createTextNode(PARTITION_NAME)
        partitionname_el.appendChild(partitionname_txt)

        exactdisk_txt = doc.createTextNode(format_storage(vm_storage))
        exactdisk_el.appendChild(exactdisk_txt)

    nodenumber_txt = doc.createTextNode(str(vm_nodes))
    nodenumber_el.appendChild(nodenumber_txt)

    shutdown_txt = doc.createTextNode(SHUTDOWN_MECH)
    shutdown_el.appendChild(shutdown_txt)

    ##
    ## 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)
        # Create a deployment request file
        if not self.temp_lease_storage:
            vm_deploymentrequest = nimbus_xml.ws_deployment_factory(vm_duration = self.vm_lifetime, \
                vm_targetstate = self.VM_TARGETSTATE, vm_mem = vm_mem, vm_storage = vm_storage, vm_nodes = self.VM_NODES, vm_cores=vm_cores)
        else:
            vm_deploymentrequest = nimbus_xml.ws_deployment_factory(vm_duration = self.vm_lifetime, \

src/c/l/cloud-scheduler-HEAD/cloudscheduler/nimbuscluster.py   cloud-scheduler(Download)
        # Create a deployment request file
        if not self.temp_lease_storage:
            vm_deploymentrequest = nimbus_xml.ws_deployment_factory(vm_duration = self.vm_lifetime, \
                vm_targetstate = self.VM_TARGETSTATE, vm_mem = vm_mem, vm_storage = vm_storage, vm_nodes = self.VM_NODES, vm_cores=vm_cores)
        else:
            vm_deploymentrequest = nimbus_xml.ws_deployment_factory(vm_duration = self.vm_lifetime, \