diff --git a/adaptor/pcm_slurm/cgo_shenwei/slurm.go b/adaptor/pcm_slurm/cgo_shenwei/slurm.go deleted file mode 100644 index dbaef2e6..00000000 --- a/adaptor/pcm_slurm/cgo_shenwei/slurm.go +++ /dev/null @@ -1,3 +0,0 @@ -package slurm - -//todo diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/extra/cancel_job.go b/adaptor/pcm_slurm/cgo_tianhe/example/extra/cancel_job.go deleted file mode 100644 index d98b6c67..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/extra/cancel_job.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/extra" - "fmt" -) -import "os" -import "strconv" - -func main() { - - if len(os.Args) < 2 { - fmt.Printf("Please specify Job ID\n") - return - } - id, _ := strconv.Atoi(os.Args[1]) - fmt.Printf("try to cancel %d\n", id) - err := extra.Cancel_job(uint32(id)) - if err != nil { - fmt.Printf(err.Error()) - - } -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/extra/get_job_account_info.go b/adaptor/pcm_slurm/cgo_tianhe/example/extra/get_job_account_info.go deleted file mode 100644 index 1fdc1b62..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/extra/get_job_account_info.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/extra" - "fmt" -) -import "os" -import "strconv" - -func main() { - - if len(os.Args) < 2 { - fmt.Printf("Please specify Job ID\n") - return - } - id, _ := strconv.Atoi(os.Args[1]) - - jobs, err := extra.Get_job_info_accounting(uint32(id)) - if err != nil { - fmt.Printf(err.Error()) - return - } - fmt.Printf("JobId\tuser\taccount\tstate\t\tJobName\n") - for i := range jobs { - fmt.Printf("%d\t%s\t%s\t%s\t%s\n", jobs[i].JobId, jobs[i].User, jobs[i].Account, jobs[i].State, jobs[i].JobName) - - } -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_all_jobs.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_all_jobs.go deleted file mode 100644 index 860a23a9..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_all_jobs.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - "fmt" -) - -func main() { - job_list := job_info.Get_all_jobs() - fmt.Printf("Found %d jobs \n", job_list.Record_count) - /* a little bit nicer */ - fmt.Printf("Id\tName\t\tPartion\tUser\tRuntime\tStatus\t\t(Reason)\tNodes\tPriority\n") - fmt.Printf("________________________________________________________________________________________________\n") - for i := range job_list.Job_list { - job := job_list.Job_list[i] - fmt.Printf("%d\t%s\t%s\t %s\t%s\t%s\t%s\t%d\n", - job.Job_id, job.Name, job.Partition, job_info.Get_job_runtime(job).String(), job.Job_stateS, - job_info.Reason_to_string(job.State_reason), job.Nodes, job.Priority) - } - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_all_nodes.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_all_nodes.go deleted file mode 100644 index ff579bb8..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_all_nodes.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/nodeinfo" - "fmt" -) - -func main() { - node_list := node_info.Get_all_nodes() - fmt.Printf("Found %d nodes \n", node_list.Record_count) - for i := range node_list.Node_list { - node := node_list.Node_list[i] - fmt.Println("Node_hostname: " + node.Node_hostname) - fmt.Println("State: " + node_info.State_to_string(node.Node_state)) - fmt.Println("Arch: " + node.Arch) - fmt.Println("Boards: " + string(node.Boards)) - fmt.Println("Boot_time: " + string(node.Boot_time)) - fmt.Println("Cores: " + string(node.Cores)) - fmt.Println("Cpu_load: " + string(node.Cpu_load)) - fmt.Println("Cpus: " + string(node.Cpus)) - fmt.Println("Features: " + node.Features) - fmt.Println("Gres: " + node.Gres) - fmt.Println("Node_addr: " + node.Node_addr) - fmt.Println("Node_hostname: " + node.Node_hostname) - fmt.Println("Os: " + node.Os) - fmt.Println("Real_memory: " + string(node.Real_memory)) - fmt.Println("Reason_time: " + string(node.Reason_time)) - fmt.Println("Node_state: " + string(node.Node_state)) - fmt.Println("Reason_uid: " + string(node.Reason_uid)) - fmt.Println("Slurmd_start_time: " + string(node.Slurmd_start_time)) - fmt.Println("Sockets: " + string(node.Sockets)) - fmt.Println("Threads: " + string(node.Threads)) - fmt.Println("Tmp_disk: " + string(node.Tmp_disk)) - fmt.Println("Weight: " + string(node.Weight)) - } - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_info.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_info.go deleted file mode 100644 index 13665642..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_info.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - "fmt" -) - -func main() { - - version := int(0) - var config slurm.Ctl_conf - version = slurm.Version() - fmt.Printf("Version is %s\n", slurm.VersionString(version)) - config = slurm.GetConfig() - slurm.Print_Ctl_conf(config) - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_job_by_id.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_job_by_id.go deleted file mode 100644 index 705f624a..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_job_by_id.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - "fmt" - "os" - "strconv" -) - -func main() { - - if len(os.Args) < 2 { - fmt.Printf("Please specify Job ID\n") - return - } - id, _ := strconv.Atoi(os.Args[1]) - job_list := job_info.Get_job(uint32(id)) - if job_list.Error_code != 0 { - msg := slurm.GetErrorString(job_list.Error_code) - fmt.Printf("Error: %s\n", msg) - return - - } - for i := range job_list.Job_list { - job_info.Print_Job_info(job_list.Job_list[i]) - } - fmt.Printf("Id\tName\t\tPartion\tUser\tRuntime\tStatus\t\t(Reason)\tNodes\tPriority\n") - fmt.Printf("________________________________________________________________________________________________\n") - for i := range job_list.Job_list { - job := job_list.Job_list[i] - fmt.Printf("%d\t%s\t%s %s\t%s\t%s\t%s\t%d\n", - job.Job_id, job.Name, job.Partition, job_info.Get_job_runtime(job).String(), job.Job_stateS, - job_info.Reason_to_string(job.State_reason), job.Nodes, job.Priority) - } - - end_time := job_info.Get_job_endtime(uint32(id)) - fmt.Printf("End-Time: %s\n", end_time) - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_node_info.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_node_info.go deleted file mode 100644 index 18803cbb..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_node_info.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/nodeinfo" - "fmt" -) - -func main() { - /* name := os.Args[1] - fmt.Println(string(name))*/ - node_list := node_info.Get_node_info("localhost") - fmt.Println(string(node_list.Record_count)) - for i := range node_list.Node_list { - node := node_list.Node_list[i] - fmt.Println("Node_hostname: " + node.Node_hostname) - fmt.Println("State: " + node_info.State_to_string(node.Node_state)) - fmt.Println("Arch: " + node.Arch) - fmt.Println("Boards: " + string(node.Boards)) - fmt.Println("Boot_time: " + string(node.Boot_time)) - fmt.Println("Cores: " + string(node.Cores)) - fmt.Println("Cpu_load: " + string(node.Cpu_load)) - fmt.Println("Cpus: " + string(node.Cpus)) - fmt.Println("Features: " + node.Features) - fmt.Println("Gres: " + node.Gres) - fmt.Println("Node_addr: " + node.Node_addr) - fmt.Println("Node_hostname: " + node.Node_hostname) - fmt.Println("Os: " + node.Os) - fmt.Println("Real_memory: " + string(node.Real_memory)) - fmt.Println("Reason_time: " + string(node.Reason_time)) - fmt.Println("Node_state: " + string(node.Node_state)) - fmt.Println("Reason_uid: " + string(node.Reason_uid)) - fmt.Println("Slurmd_start_time: " + string(node.Slurmd_start_time)) - fmt.Println("Sockets: " + string(node.Sockets)) - fmt.Println("Threads: " + string(node.Threads)) - fmt.Println("Tmp_disk: " + string(node.Tmp_disk)) - fmt.Println("Weight: " + string(node.Weight)) - } - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_partitions.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_partitions.go deleted file mode 100644 index 84799e8b..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_partitions.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/partitioninfo" - "fmt" -) - -func main() { - partition_list := partition_info.Get_partitions() - fmt.Printf("Found %d partions \n", partition_list.Record_count) - - for i := range partition_list.Partition_list { - partition := partition_list.Partition_list[i] - fmt.Printf("%s\t %s\t %d\t %d\n", partition.Name, partition.Nodes, partition.Max_time, partition.Node_inx) - fmt.Println("partitionName: " + partition.Name) - fmt.Println("partitionNodes: " + partition.Nodes) - fmt.Println(partition.Max_time) - fmt.Println(partition.Node_inx) - } - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_user_info.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_user_info.go deleted file mode 100644 index 54933d64..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_user_info.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -// -//import ( -// user_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user" -// "fmt" -//) -// -//func main() { -// -// fmt.Printf("Found user") -// -// userList := user_info.Get_all_users() -// fmt.Printf("Found %d user \n", userList.WithoutDefaults) -// -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/get_user_jobs.go b/adaptor/pcm_slurm/cgo_tianhe/example/get_user_jobs.go deleted file mode 100644 index 6f8cd06b..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/get_user_jobs.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - "fmt" - "os" -) - -func main() { - - if len(os.Args) < 2 { - fmt.Printf("Please specify username\n") - return - } - name := os.Args[1] - job_list := job_info.Get_user_jobs(name) - if job_list.Error_code != 0 { - msg := slurm.GetErrorString(job_list.Error_code) - fmt.Printf("Error: %s\n", msg) - return - - } - fmt.Printf("Id\tName\t\tPartion\tUser\tRuntime\tStatus\t\t(Reason)\tNodes\tPriority\n") - fmt.Printf("________________________________________________________________________________________________\n") - for i := range job_list.Job_list { - job := job_list.Job_list[i] - fmt.Printf("%d\t%s\t%s %s\t%s\t%s\t%s\t%d\n", - job.Job_id, job.Name, job.Partition, job_info.Get_job_runtime(job).String(), job.Job_stateS, - job_info.Reason_to_string(job.State_reason), job.Nodes, job.Priority) - } - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/Readme.md b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/Readme.md deleted file mode 100644 index 571a4675..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/Readme.md +++ /dev/null @@ -1,109 +0,0 @@ -# Submission of jobs -This folder shows in a few more examples of how jobs can be submitted in Slurm. Some examples use containers. -Attention: The parameters for job names and partitions probably have to be adjusted! - -# Simple Jobs - -## submit_job.go -In this example, a simple bash-Jobs is submitted. The used partition is *long* (adapt probably). -``` -job_desc.Partition="long" -``` - -The job sets two environment variables and executes a -``` -hostname -env | grep SLUM -``` -On a single node of the cluster (single task job). -The application does not wait until the hob is completed, but dirctly returns. -The (std) output is written to -out-jobid.txt, the std- error to err-jobid.txt - -``` -job_desc.Std_out = ("./out-%j.txt") -job_desc.Std_err = ("./err-%j.txt") -```` - - -## update_job.go -This example allows to update the qos and the partition a job is running on. This can help to move the job to another queue with another partition. -Note to users: In theory, the API allows the update of the number of nodes and the tasks per node. However, since this is only allowed by root or a slurm admin, we do not include an example here. -Synthax -``` -./update_job JobId qos partition -``` -(Note: This requires that the Job with the Id JobID is already submitted and in a pending state) - - -# Container jobs - -The following examples all submit a job that starts singulrity containers. -These containers, if they do not exist, are created. However, problems can arise if the user does not have sudo permissions.. - -## The containers - -The first container is an MPI container. This is used by and `submit_mpi_containier.go` and `submit_mpi_and_update.go`. The definition is stored in `mpi_container.def` - It can also be created with the command - -``` -sudo singularity build mpi_container.img mpi_container.def -``` - -The program mpi_pingppong (source code enclosed: `mpi_pingpong.c` ) is built into the container. It performs a ping-pong test between two processes. - -This container uses the hybrid model, which assumes that MPI is installed on the cluter (to start the job) and installs it in the container itself. Works with OpenMPI. - -The second container is an openmp container, including a sample OpenMP programm openmp_example (source code: ` openmp_example.c`). -It can also be created with the command: - -``` -sudo singularity build openmp_container.img openmp_container.def -``` - -This container is used bei `submit_openmp_container.go`. - - -## submit_mpi_containier.go -Submits a mpi-container job to the cluster. It runs to Processes on two nodes -``` -job_desc.Min_nodes =uint32(2) -job_desc.Num_tasks = uint32(2) -``` -The application blocks, until the job is completed. The (std) output is written to -jobid-out.txt, the std- error to jobId-err.txt -``` -job_desc.Std_out = ("./%j-out.txt") -job_desc.Std_err = ("./%j-err.txt") -``` -## submit_omp_container.go -Submits two openMP jobs to the cluster and wait, until they are completed. -Both jobs allocate *one process* for the job, but *two CPUs per task/process* (for multi-threading). -``` -job_desc.Num_tasks = uint32(1) -job_desc.Cpus_per_task = uint16(2) - -``` -The first job reads the environment variable ` SLURM_JOB_CPUS_PER_NODE` and sets the number of openMP threads to exactly the number of cpus that are available per task/process. -``` -job_desc.Script+= "export OMP_NUM_THREADS=$SLURM_JOB_CPUS_PER_NODE\n" -``` -The second job sets the number of threads to 4 (which is oversuscribing because more threads are started than processes) and executes the same job. -``` -job_desc.Script+= "export OMP_NUM_THREADS=4\n" -``` - -The program waits until both jobs are completed. The results are written to the two outputs files, similiar to `submit_mpi_container.go` - -### submit_mpi_and_update.go -This application is dooing the same as `submit_mpi_container.go` -``` -ops.Qos = "shortjobs" -ops.Partition = "short" -``` - -This situation, can, for example, be created my submitting longer, other jobs bevore in the background (depending on the partion size) and than start this application: - -``` -./submit_mpi_containier & ./submit_mpi_containier & ./submit_mpi_and_update -``` diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_container.def b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_container.def deleted file mode 100644 index 0453082e..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_container.def +++ /dev/null @@ -1,37 +0,0 @@ -Bootstrap: docker -From: ubuntu:latest - -%files - mpi_pingpong.c /opt - -%environment - export OMPI_DIR=/home0/opt/openmpi - export SINGULARITY_OMPI_DIR=$OMPI_DIR - export SINGULARITYENV_APPEND_PATH=$OMPI_DIR/bin - export SINGULAIRTYENV_APPEND_LD_LIBRARY_PATH=$OMPI_DIR/lib - -%post - echo "Installing required packages..." - apt-get update && apt-get install -y wget git bash gcc gfortran g++ make file - - echo "Installing Open MPI" - export OMPI_DIR=/home0/opt/openmpi - export OMPI_VERSION=4.0.3 - export OMPI_URL="https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-$OMPI_VERSION.tar.bz2" - mkdir -p /tmp/ompi - mkdir -p /opt - chmod a+w /opt/ - chmod a+r /opt/ - ls -la /tmp/ompi - # Download - cd /tmp/ompi && wget -O openmpi-$OMPI_VERSION.tar.bz2 $OMPI_URL && tar -xjf openmpi-$OMPI_VERSION.tar.bz2 - ls -la - # Compile and install - cd /tmp/ompi/openmpi-$OMPI_VERSION && ./configure --prefix=$OMPI_DIR && make install - # Set env variables so we can compile our application - export PATH=$OMPI_DIR/bin:$PATH - export LD_LIBRARY_PATH=$OMPI_DIR/lib:$LD_LIBRARY_PATH - export MANPATH=$OMPI_DIR/share/man:$MANPATH - # rm -r tmp/mpi - echo "Compiling the MPI application..." - cd /opt && mpicc -o mpi_pingpong mpi_pingpong.c diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_pingpong.c b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_pingpong.c deleted file mode 100644 index bdaa3f1a..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/mpi_pingpong.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#define MAX_ITER 1000 -int main (int argc, char **argv) { - int rc; - int size; - int myrank; - size_t max_send = 1<<22; - char *send_buf = (char*)malloc(sizeof(char)*max_send); - char *recv_buf = (char*)malloc(sizeof(char)*max_send); - size_t send_size; - clock_t start, end; - rc = MPI_Init (&argc, &argv); - if (rc != MPI_SUCCESS) { - fprintf (stderr, "MPI_Init() failed"); - return EXIT_FAILURE; - } - - rc = MPI_Comm_size (MPI_COMM_WORLD, &size); - if (rc != MPI_SUCCESS) { - fprintf (stderr, "MPI_Comm_size() failed"); - goto exit_with_error; - } - - if(size!= 2) { - - fprintf(stderr, "This process requieres exact two processes\n"); - } - rc = MPI_Comm_rank (MPI_COMM_WORLD, &myrank); - if (rc != MPI_SUCCESS) { - fprintf (stderr, "MPI_Comm_rank() failed"); - goto exit_with_error; - } - if(myrank==0) - fprintf (stdout, "Size\t Time(ms)\n"); - - for(send_size=1 ; send_size<= max_send; send_size*=2){ - for (int i = 0; i -#include - -int main() { - #pragma omp parallel - { - int id = omp_get_thread_num(); - int data = id; - int total = omp_get_num_threads(); - printf("Greetings from thread %d out of %d with Data %d\n", id, total, data); - } - printf("parallel for ends.\n"); - return 0; -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_job.go b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_job.go deleted file mode 100644 index 90530f22..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_job.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - submit_job "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob" -) -import "os/user" -import "os" -import "strconv" -import "fmt" - -func main() { - job_desc := submit_job.Job_descriptor{} - job_desc.Script = "#! /bin/bash\n hostname \n env | grep SLURM " - dir, _ := os.Getwd() - - user, _ := user.Current() - userid, _ := strconv.Atoi(user.Uid) - job_desc.User_id = uint32(userid) - groupid, _ := strconv.Atoi(user.Gid) - - job_desc.Group_id = uint32(groupid) - job_desc.Name = "test_job" - job_desc.Partition = "debug" - job_desc.Time_limit = uint32(2) - job_desc.Min_nodes = uint32(1) - job_desc.Std_out = ("./out-%j.txt") - job_desc.Std_err = ("./err-%j.txt") - job_desc.Work_dir = dir - job_desc.Environment = []string{"SLURM_GO_JOB=TRUE", "SLURM_CONTAINER_JOB=FALSE"} - answer := submit_job.Submit_job(&job_desc) - if answer.Error_code != 0 { - msg := slurm.GetErrorString(answer.Error_code) - fmt.Printf("Error: %s\n", msg) - return - } - fmt.Printf("Submitted Job %d\n", answer.Job_id) -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_and_update.go b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_and_update.go deleted file mode 100644 index 9bc2ef31..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_and_update.go +++ /dev/null @@ -1,122 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - job_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - submit_job "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob" -) -import "os" -import "strconv" -import "fmt" -import "os/exec" -import "path/filepath" -import "time" -import "os/user" - -func fileExists(filename string) bool { - info, err := os.Stat(filename) - if os.IsNotExist(err) { - return false - } - return !info.IsDir() -} -func build_container(file_name, container_name string) { - - cmd := exec.Command("sudo", "/usr/local/bin/singularity", "build", container_name, file_name) - fmt.Print("Now build new container") - fmt.Printf("%s\n", cmd.String()) - stdoutStderr, err := cmd.CombinedOutput() - if err != nil { - fmt.Printf("error in creating container %s \n", err) - // return - } - fmt.Printf("%s\n", stdoutStderr) -} - -func main() { - job_desc := submit_job.Job_descriptor{} - - dir, _ := os.Getwd() - container := filepath.Join(dir, "mpi_container.img") - definition := filepath.Join(dir, "mpi_container.def") - if !fileExists(container) { - build_container(definition, container) - } - - if !fileExists(container) { - return - } - /* use Cmd to create our script */ - - job_desc.Script = "#!/bin/bash\n export PATH=$PATH:/usr/local/bin\n srun hostname \n" - cmd := exec.Command("/home0/opt/openmpi/bin/mpirun", "-mca btl_tcp_if_include eth1", "/usr/local/bin/singularity", "exec", container, "/opt/mpi_pingpong") - job_desc.Script += cmd.String() - fmt.Printf("cmd %s\n", job_desc.Script) - user, _ := user.Current() - userid, _ := strconv.Atoi(user.Uid) - job_desc.User_id = uint32(userid) - groupid, _ := strconv.Atoi(user.Gid) - - job_desc.Group_id = uint32(groupid) - job_desc.Name = "flex_mpi_job" - job_desc.Partition = "long" - job_desc.Time_limit = uint32(60) - job_desc.Ntasks_per_node = uint16(1) - job_desc.Num_tasks = uint32(2) - job_desc.Std_out = ("./%j-out.txt") - job_desc.Std_err = ("./%j-err.txt") - job_desc.Work_dir = dir - - time.Sleep(3 * time.Second) - answer := submit_job.Submit_job(&job_desc) - if answer.Error_code != 0 { - msg := slurm.GetErrorString(answer.Error_code) - fmt.Printf("Error: %s\n", msg) - return - } - fmt.Printf("Submitted Job %d\n", answer.Job_id) - - time.Sleep(5 * time.Second) - - job_list := job_info.Get_job(answer.Job_id) - if job_list.Error_code != 0 { - msg := slurm.GetErrorString(job_list.Error_code) - fmt.Printf("Error: %s\n", msg) - return - - } - job := job_list.Job_list[0] - - fmt.Printf("job %d is %s\n", answer.Job_id, job.Job_stateS) - state := job.Job_stateS - if state == "Pending" { - fmt.Printf("Move job %d to another partition \n", answer.Job_id) - var ops submit_job.Update_job_options - - ops.Qos = "shortjobs" - ops.Partition = "short" - err2 := submit_job.Update_job(ops, uint32(answer.Job_id)) - if err2 != uint32(0) { - fmt.Printf("error %s \n", slurm.GetErrorString(err2)) - } - } - - for state == "Pending" || state == "Running" { - time.Sleep(2 * time.Second) - job_list = job_info.Get_job(answer.Job_id) - if job_list.Error_code != 0 { - msg := slurm.GetErrorString(job_list.Error_code) - fmt.Printf("Error: %s\n", msg) - return - - } - job = job_list.Job_list[0] - - state = job.Job_stateS - - fmt.Printf("job %d is %s\n", answer.Job_id, job.Job_stateS) - - } - - fmt.Printf("Total runtime Job %d %s\n", job.Job_id, job_info.Get_job_runtime(job).String()) -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_containier.go b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_containier.go deleted file mode 100644 index 9cfed38c..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_mpi_containier.go +++ /dev/null @@ -1,111 +0,0 @@ -package main - -// -//import ( -// "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" -// job_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" -// submit_job "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob" -// "fmt" -// "os" -// "os/exec" -// "os/user" -// "path/filepath" -// "strconv" -// "time" -//) -// -//func fileExists(filename string) bool { -// info, err := os.Stat(filename) -// if os.IsNotExist(err) { -// return false -// } -// return !info.IsDir() -//} -//func build_container(file_name, container_name string) { -// -// cmd := exec.Command("sudo", "/usr/local/bin/singularity", "build", container_name, file_name) -// fmt.Print("Now build new container") -// fmt.Printf("%s\n", cmd.String()) -// stdoutStderr, err := cmd.CombinedOutput() -// if err != nil { -// fmt.Printf("error in creating container %s \n", err) -// -// fmt.Printf("%s\n", stdoutStderr) -// // return -// } -// fmt.Printf("%s\n", stdoutStderr) -//} -// -//func main() { -// job_desc := submit_job.Job_descriptor{} -// -// dir, _ := os.Getwd() -// container := filepath.Join(dir, "mpi_container.img") -// definition := filepath.Join(dir, "mpi_container.def") -// if !fileExists(container) { -// build_container(definition, container) -// } -// -// if !fileExists(container) { -// return -// } -// /* use Cmd to create our script */ -// -// job_desc.Script = "#!/bin/bash\n export PATH=$PATH:/usr/local/bin\n hostname \n" -// cmd := exec.Command("/home0/opt/openmpi/bin/mpirun", "-mca btl_tcp_if_include eth1", "/usr/local/bin/singularity", "exec", container, "/opt/mpi_pingpong") -// job_desc.Script += cmd.String() -// fmt.Printf("cmd %s\n", job_desc.Script) -// user, _ := user.Current() -// userid, _ := strconv.Atoi(user.Uid) -// job_desc.User_id = uint32(userid) -// groupid, _ := strconv.Atoi(user.Gid) -// -// job_desc.Group_id = uint32(groupid) -// job_desc.Name = "mpi_job" -// job_desc.Partition = "long" -// job_desc.Time_limit = uint32(60) -// job_desc.Min_nodes = uint32(2) -// job_desc.Num_tasks = uint32(2) -// job_desc.Std_out = ("./%j-out.txt") -// job_desc.Std_err = ("./%j-err.txt") -// job_desc.Work_dir = dir -// -// answer := submit_job.Submit_job(&job_desc) -// if answer.Error_code != 0 { -// msg := slurm.GetErrorString(answer.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// } -// fmt.Printf("Submitted Job %d\n", answer.Job_id) -// -// job_list := job_info.Get_job(answer.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job := job_list.Job_list[0] -// -// fmt.Printf("job %d is %s\n", answer.Job_id, job.Job_stateS) -// state := job.Job_stateS -// for state == "Pending" || state == "Running" { -// time.Sleep(2 * time.Second) -// job_list = job_info.Get_job(answer.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job = job_list.Job_list[0] -// -// state = job.Job_stateS -// -// fmt.Printf("job %d is %s\n", answer.Job_id, job.Job_stateS) -// -// } -// -// fmt.Printf("Total runtime Job %d: %s\n", job.Job_id, job_info.Get_job_runtime(job).String()) -// -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_openmp_container.go b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_openmp_container.go deleted file mode 100644 index 235bf46d..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/submit_openmp_container.go +++ /dev/null @@ -1,159 +0,0 @@ -package main - -// -//import ( -// "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" -// job_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" -// submit_job "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob" -// "fmt" -// "os" -// "os/exec" -// "os/user" -// "path/filepath" -// "strconv" -// "time" -//) -// -//func fileExists(filename string) bool { -// info, err := os.Stat(filename) -// if os.IsNotExist(err) { -// return false -// } -// return !info.IsDir() -//} -//func build_container(file_name, container_name string) { -// -// cmd := exec.Command("sudo", "/usr/local/bin/singularity", "build", container_name, file_name) -// fmt.Print("Now build new container") -// fmt.Printf("%s\n", cmd.String()) -// stdoutStderr, err := cmd.CombinedOutput() -// if err != nil { -// fmt.Printf("error in creating container %s \n", err) -// -// fmt.Printf("%s\n", stdoutStderr) -// // return -// } -// fmt.Printf("%s\n", stdoutStderr) -//} -// -//func main() { -// job_desc := submit_job.Job_descriptor{} -// -// dir, _ := os.Getwd() -// container := filepath.Join(dir, "openmp_container.img") -// definition := filepath.Join(dir, "openmp_container.def") -// if !fileExists(container) { -// build_container(definition, container) -// } -// -// if !fileExists(container) { -// return -// } -// /* use Cmd to create our script */ -// -// job_desc.Script = "#!/bin/bash\n export PATH=$PATH:/usr/local/bin\n hostname \n" -// job_desc.Script += "export OMP_NUM_THREADS=$SLURM_JOB_CPUS_PER_NODE\n" -// cmd := exec.Command("/usr/local/bin/singularity", "exec", container, "/opt/openmp_example") -// -// job_desc.Script += cmd.String() -// fmt.Printf("cmd %s\n", job_desc.Script) -// user, _ := user.Current() -// userid, _ := strconv.Atoi(user.Uid) -// job_desc.User_id = uint32(userid) -// groupid, _ := strconv.Atoi(user.Gid) -// -// job_desc.Group_id = uint32(groupid) -// job_desc.Name = "test_job" -// job_desc.Partition = "long" -// job_desc.Time_limit = uint32(60) -// job_desc.Min_nodes = uint32(1) -// job_desc.Num_tasks = uint32(1) -// -// job_desc.Cpus_per_task = uint16(2) -// job_desc.Std_out = ("./%j-out.txt") -// job_desc.Std_err = ("./%j-err.txt") -// job_desc.Work_dir = dir -// -// answer := submit_job.Submit_job(&job_desc) -// if answer.Error_code != 0 { -// msg := slurm.GetErrorString(answer.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// } -// fmt.Printf("Submitted Job %d\n", answer.Job_id) -// -// /*Now, we submit the same jon again, ut with some oversubsciption */ -// job_desc.Script = "#!/bin/bash\n export PATH=$PATH:/usr/local/bin\n hostname \n" -// job_desc.Script += "export OMP_NUM_THREADS=4\n" -// -// job_desc.Script += cmd.String() -// fmt.Printf("cmd %s\n", job_desc.Script) -// answer2 := submit_job.Submit_job(&job_desc) -// if answer2.Error_code != 0 { -// msg := slurm.GetErrorString(answer.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// } -// fmt.Printf("Submitted Job %d\n", answer2.Job_id) -// -// job_list := job_info.Get_job(answer.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job := job_list.Job_list[0] -// -// fmt.Printf("job is %s\n", job.Job_stateS) -// state := job.Job_stateS -// for state == "Pending" || state == "Running" { -// time.Sleep(2 * time.Second) -// job_list = job_info.Get_job(answer.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job = job_list.Job_list[0] -// -// state = job.Job_stateS -// -// fmt.Printf("job is %s\n", job.Job_stateS) -// -// } -// -// fmt.Printf("Total runtime first job %s\n", job_info.Get_job_runtime(job).String()) -// /*wait for second job */ -// job_list = job_info.Get_job(answer2.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job = job_list.Job_list[0] -// -// fmt.Printf("job is %s\n", job.Job_stateS) -// state = job.Job_stateS -// for state == "Pending" || state == "Running" { -// time.Sleep(2 * time.Second) -// job_list = job_info.Get_job(answer2.Job_id) -// if job_list.Error_code != 0 { -// msg := slurm.GetErrorString(job_list.Error_code) -// fmt.Printf("Error: %s\n", msg) -// return -// -// } -// job = job_list.Job_list[0] -// -// state = job.Job_stateS -// -// fmt.Printf("job is %s\n", job.Job_stateS) -// -// } -// -// fmt.Printf("Total runtime second job %s\n", job_info.Get_job_runtime(job).String()) -// -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/update_job.go b/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/update_job.go deleted file mode 100644 index 7cbe85e2..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/example/submit_example/update_job.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - submit_job "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob" -) -import "os" -import "strconv" -import "fmt" - -func main() { - if len(os.Args) < 4 { - fmt.Printf("Synthax specify JobID, qos and partition \n") - return - } - var ops submit_job.Update_job_options - id, err := strconv.Atoi(os.Args[1]) - if err != nil { - fmt.Printf("Invalid job id (no int) %s\n", os.Args[1]) - return - } - - ops.Qos = os.Args[2] - ops.Partition = os.Args[3] - - err2 := submit_job.Update_job(ops, uint32(id)) - if err2 != uint32(0) { - fmt.Printf("error %s \n", slurm.GetErrorString(err2)) - } -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/service/common.go b/adaptor/pcm_slurm/cgo_tianhe/service/common.go deleted file mode 100644 index 6bfbfd60..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/service/common.go +++ /dev/null @@ -1,16 +0,0 @@ -package slurm - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#include -#include -*/ -import "C" - -func GetErrorString(errno uint32) string { - msg := C.GoString(C.slurm_strerror(C.int(errno))) - return msg -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/service/converter.go b/adaptor/pcm_slurm/cgo_tianhe/service/converter.go deleted file mode 100644 index f0b7b127..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/service/converter.go +++ /dev/null @@ -1,227 +0,0 @@ -package slurm - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#include -#include - -inline uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int32_t int32_ptr(int32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -*/ -import "C" - -func Job_info_convert_c_to_go(c_struct *C.struct_job_info) Job_info { - var go_struct Job_info - - go_struct.account = C.GoString(c_struct.account) - go_struct.alloc_node = C.GoString(c_struct.alloc_node) - go_struct.alloc_sid = uint32(c_struct.alloc_sid) - go_struct.array_job_id = uint32(c_struct.array_job_id) - go_struct.array_task_id = uint16(c_struct.array_task_id) - go_struct.assoc_id = uint32(c_struct.assoc_id) - go_struct.batch_flag = uint16(c_struct.batch_flag) - go_struct.batch_host = C.GoString(c_struct.batch_host) - go_struct.boards_per_node = uint16(c_struct.boards_per_node) - go_struct.batch_script = C.GoString(c_struct.batch_script) - go_struct.command = C.GoString(c_struct.command) - go_struct.comment = C.GoString(c_struct.comment) - go_struct.contiguous = uint16(c_struct.contiguous) - go_struct.cores_per_socket = uint16(c_struct.cores_per_socket) - go_struct.cpus_per_task = uint16(c_struct.cpus_per_task) - go_struct.dependency = C.GoString(c_struct.dependency) - go_struct.derived_ec = uint32(c_struct.derived_ec) - go_struct.eligible_time = int64(c_struct.eligible_time) - go_struct.end_time = int64(c_struct.end_time) - go_struct.exc_nodes = C.GoString(c_struct.exc_nodes) - go_struct.exc_node_inx = int32(C.int32_ptr(c_struct.exc_node_inx)) - go_struct.exit_code = uint32(c_struct.exit_code) - go_struct.features = C.GoString(c_struct.features) - go_struct.group_id = uint32(c_struct.group_id) - go_struct.gres = C.GoString(c_struct.gres) - go_struct.job_id = uint32(c_struct.job_id) - go_struct.job_state = uint16(c_struct.job_state) - go_struct.licenses = C.GoString(c_struct.licenses) - go_struct.max_cpus = uint32(c_struct.max_cpus) - go_struct.max_nodes = uint32(c_struct.max_nodes) - go_struct.name = C.GoString(c_struct.name) - go_struct.network = C.GoString(c_struct.network) - go_struct.nodes = C.GoString(c_struct.nodes) - go_struct.nice = uint16(c_struct.nice) - go_struct.node_inx = int32(C.int32_ptr(c_struct.node_inx)) - go_struct.ntasks_per_core = uint16(c_struct.ntasks_per_core) - go_struct.ntasks_per_node = uint16(c_struct.ntasks_per_node) - go_struct.ntasks_per_socket = uint16(c_struct.ntasks_per_socket) - go_struct.ntasks_per_board = uint16(c_struct.ntasks_per_board) - go_struct.num_cpus = uint32(c_struct.num_cpus) - go_struct.num_nodes = uint32(c_struct.num_nodes) - go_struct.partition = C.GoString(c_struct.partition) - go_struct.pn_min_memory = uint32(c_struct.pn_min_memory) - go_struct.pn_min_cpus = uint16(c_struct.pn_min_cpus) - go_struct.pn_min_tmp_disk = uint32(c_struct.pn_min_tmp_disk) - go_struct.preempt_time = int64(c_struct.preempt_time) - go_struct.pre_sus_time = int64(c_struct.pre_sus_time) - go_struct.priority = uint32(c_struct.priority) - go_struct.profile = uint32(c_struct.profile) - go_struct.qos = C.GoString(c_struct.qos) - go_struct.req_nodes = C.GoString(c_struct.req_nodes) - go_struct.req_node_inx = int32(C.int32_ptr(c_struct.req_node_inx)) - go_struct.req_switch = uint32(c_struct.req_switch) - go_struct.requeue = uint16(c_struct.requeue) - go_struct.resize_time = int64(c_struct.resize_time) - go_struct.restart_cnt = uint16(c_struct.restart_cnt) - go_struct.resv_name = C.GoString(c_struct.resv_name) - go_struct.shared = uint16(c_struct.shared) - go_struct.show_flags = uint16(c_struct.show_flags) - go_struct.sockets_per_board = uint16(c_struct.sockets_per_board) - go_struct.sockets_per_node = uint16(c_struct.sockets_per_node) - go_struct.start_time = int64(c_struct.start_time) - go_struct.state_desc = C.GoString(c_struct.state_desc) - go_struct.state_reason = uint16(c_struct.state_reason) - go_struct.submit_time = int64(c_struct.submit_time) - go_struct.suspend_time = int64(c_struct.suspend_time) - go_struct.time_limit = uint32(c_struct.time_limit) - go_struct.time_min = uint32(c_struct.time_min) - go_struct.threads_per_core = uint16(c_struct.threads_per_core) - go_struct.user_id = uint32(c_struct.user_id) - go_struct.wait4switch = uint32(c_struct.wait4switch) - go_struct.wckey = C.GoString(c_struct.wckey) - go_struct.work_dir = C.GoString(c_struct.work_dir) - - return go_struct -} - -func Job_descriptor_convert_c_to_go(c_struct *C.struct_job_descriptor) Job_descriptor { - var go_struct Job_descriptor - - go_struct.Account = C.GoString(c_struct.account) - go_struct.Acctg_freq = C.GoString(c_struct.acctg_freq) - go_struct.Alloc_node = C.GoString(c_struct.alloc_node) - go_struct.Alloc_resp_port = uint16(c_struct.alloc_resp_port) - go_struct.Alloc_sid = uint32(c_struct.alloc_sid) - go_struct.Argc = uint32(c_struct.argc) - go_struct.Array_inx = C.GoString(c_struct.array_inx) - go_struct.Begin_time = int64(c_struct.begin_time) - go_struct.Ckpt_interval = uint16(c_struct.ckpt_interval) - go_struct.Ckpt_dir = C.GoString(c_struct.ckpt_dir) - go_struct.Comment = C.GoString(c_struct.comment) - go_struct.Contiguous = uint16(c_struct.contiguous) - go_struct.Cpu_bind = C.GoString(c_struct.cpu_bind) - go_struct.Cpu_bind_type = uint16(c_struct.cpu_bind_type) - go_struct.Dependency = C.GoString(c_struct.dependency) - go_struct.End_time = int64(c_struct.end_time) - go_struct.Env_size = uint32(c_struct.env_size) - go_struct.Exc_nodes = C.GoString(c_struct.exc_nodes) - go_struct.Features = C.GoString(c_struct.features) - go_struct.Group_id = uint32(c_struct.group_id) - go_struct.Immediate = uint16(c_struct.immediate) - go_struct.Job_id = uint32(c_struct.job_id) - go_struct.Kill_on_node_fail = uint16(c_struct.kill_on_node_fail) - go_struct.Licenses = C.GoString(c_struct.licenses) - go_struct.Mail_type = uint16(c_struct.mail_type) - go_struct.Mail_user = C.GoString(c_struct.mail_user) - go_struct.Mem_bind = C.GoString(c_struct.mem_bind) - go_struct.Mem_bind_type = uint16(c_struct.mem_bind_type) - go_struct.Name = C.GoString(c_struct.name) - go_struct.Network = C.GoString(c_struct.network) - go_struct.Nice = uint16(c_struct.nice) - go_struct.Num_tasks = uint32(c_struct.num_tasks) - go_struct.Open_mode = uint8(c_struct.open_mode) - go_struct.Other_port = uint16(c_struct.other_port) - go_struct.Overcommit = uint8(c_struct.overcommit) - go_struct.Partition = C.GoString(c_struct.partition) - go_struct.Plane_size = uint16(c_struct.plane_size) - go_struct.Priority = uint32(c_struct.priority) - go_struct.Profile = uint32(c_struct.profile) - go_struct.Qos = C.GoString(c_struct.qos) - go_struct.Reboot = uint16(c_struct.reboot) - go_struct.Resp_host = C.GoString(c_struct.resp_host) - go_struct.Req_nodes = C.GoString(c_struct.req_nodes) - go_struct.Requeue = uint16(c_struct.requeue) - go_struct.Reservation = C.GoString(c_struct.reservation) - go_struct.Script = C.GoString(c_struct.script) - go_struct.Shared = uint16(c_struct.shared) - go_struct.Spank_job_env_size = uint32(c_struct.spank_job_env_size) - go_struct.Task_dist = uint16(c_struct.task_dist) - go_struct.Time_limit = uint32(c_struct.time_limit) - go_struct.Time_min = uint32(c_struct.time_min) - go_struct.User_id = uint32(c_struct.user_id) - go_struct.Wait_all_nodes = uint16(c_struct.wait_all_nodes) - go_struct.Warn_signal = uint16(c_struct.warn_signal) - go_struct.Warn_time = uint16(c_struct.warn_time) - go_struct.Work_dir = C.GoString(c_struct.work_dir) - go_struct.Cpus_per_task = uint16(c_struct.cpus_per_task) - go_struct.Min_cpus = uint32(c_struct.min_cpus) - go_struct.Max_cpus = uint32(c_struct.max_cpus) - go_struct.Min_nodes = uint32(c_struct.min_nodes) - go_struct.Max_nodes = uint32(c_struct.max_nodes) - go_struct.Boards_per_node = uint16(c_struct.boards_per_node) - go_struct.Sockets_per_board = uint16(c_struct.sockets_per_board) - go_struct.Sockets_per_node = uint16(c_struct.sockets_per_node) - go_struct.Cores_per_socket = uint16(c_struct.cores_per_socket) - go_struct.Threads_per_core = uint16(c_struct.threads_per_core) - go_struct.Ntasks_per_node = uint16(c_struct.ntasks_per_node) - go_struct.Ntasks_per_socket = uint16(c_struct.ntasks_per_socket) - go_struct.Ntasks_per_core = uint16(c_struct.ntasks_per_core) - go_struct.Ntasks_per_board = uint16(c_struct.ntasks_per_board) - go_struct.Pn_min_cpus = uint16(c_struct.pn_min_cpus) - go_struct.Pn_min_memory = uint32(c_struct.pn_min_memory) - go_struct.Pn_min_tmp_disk = uint32(c_struct.pn_min_tmp_disk) - go_struct.Req_switch = uint32(c_struct.req_switch) - go_struct.Std_err = C.GoString(c_struct.std_err) - go_struct.Std_in = C.GoString(c_struct.std_in) - go_struct.Std_out = C.GoString(c_struct.std_out) - go_struct.Wait4switch = uint32(c_struct.wait4switch) - go_struct.Wckey = C.GoString(c_struct.wckey) - - return go_struct -} - -func submit_response_msg_convert_c_to_go(c_struct *C.struct_submit_response_msg) Submit_response_msg { - var go_struct Submit_response_msg - - go_struct.Job_id = uint32(c_struct.job_id) - go_struct.Step_id = uint32(c_struct.step_id) - go_struct.Error_code = uint32(c_struct.error_code) - return go_struct -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/service/job_info.go b/adaptor/pcm_slurm/cgo_tianhe/service/job_info.go deleted file mode 100644 index 900caeea..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/service/job_info.go +++ /dev/null @@ -1,94 +0,0 @@ -package slurm - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#include -#include - - struct job_info_msg *get_job_info(){ - - struct job_info_msg* job_buffer; - if(slurm_load_jobs ((time_t) NULL, - &job_buffer, SHOW_ALL)) { - return NULL; - } - - return job_buffer; - } - -struct job_info* job_from_list(struct job_info_msg *list, int i){ - return &list->job_array[i]; -} - - struct job_info_msg *get_single_job_info(uint32_t id){ - struct job_info_msg* job_buffer; - if( slurm_load_job (&job_buffer, id, SHOW_DETAIL)) { - return NULL; - } - return job_buffer; - } - - //static time_t last_update_time = (time_t) NULL; - //int error_code; - //job_info_msg_t * job_info_msg_ptr = NULL; - // - //error_code = slurm_load_jobs (last_update_time, &job_info_msg_ptr, 1); - //if (error_code) { - // slurm_perror ("slurm_load_jobs"); - // return (error_code); - //} - // - //slurm_print_job_info_msg ( stdout, job_info_msg_ptr, 1 ) ; - // - //slurm_free_job_info_msg ( job_info_msg_ptr ) ; - -*/ -import "C" - -func Get_all_jobs() Job_info_msg { - var go_job_buffer Job_info_msg - c_job_buffer := C.get_job_info() - if c_job_buffer == nil { - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Job_list = nil - return go_job_buffer - } - - go_job_buffer.Last_update = int64(c_job_buffer.last_update) - go_job_buffer.Record_count = uint32(c_job_buffer.record_count) - go_job_buffer.Job_list = make([]Job_info, c_job_buffer.record_count, c_job_buffer.record_count) - for i := uint32(0); i < go_job_buffer.Record_count; i++ { - job := C.job_from_list(c_job_buffer, C.int(i)) - go_job := Job_info_convert_c_to_go(job) - go_job_buffer.Job_list[i] = go_job - } - C.slurm_free_job_info_msg(c_job_buffer) - - return go_job_buffer -} - -func Get_job(id uint32) Job_info_msg { - var go_job_buffer Job_info_msg - c_job_buffer := C.get_single_job_info(C.uint32_t(id)) - if c_job_buffer == nil { - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Job_list = nil - return go_job_buffer - } - go_job_buffer.Last_update = int64(c_job_buffer.last_update) - go_job_buffer.Record_count = uint32(c_job_buffer.record_count) - go_job_buffer.Job_list = make([]Job_info, c_job_buffer.record_count, c_job_buffer.record_count) - for i := uint32(0); i < go_job_buffer.Record_count; i++ { - job := C.job_from_list(c_job_buffer, C.int(i)) - go_job := Job_info_convert_c_to_go(job) - go_job_buffer.Job_list[i] = go_job - } - C.slurm_free_job_info_msg(c_job_buffer) - - return go_job_buffer -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/service/job_submit.go b/adaptor/pcm_slurm/cgo_tianhe/service/job_submit.go deleted file mode 100644 index 35230022..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/service/job_submit.go +++ /dev/null @@ -1,367 +0,0 @@ -package slurm - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#include -#include - -struct submit_response_msg *submit_job(struct job_descriptor *desc) -{ - - struct submit_response_msg *resp_msg; - if (slurm_submit_batch_job(desc, - &resp_msg)) { - return NULL; - } - return resp_msg; - -} - -void free_submit_response_msg(struct submit_response_msg *msg) -{ - slurm_free_submit_response_response_msg(msg); -} -*/ -import "C" -import ( - "fmt" - "unsafe" -) - -func Submit_job(go_struct *Job_descriptor) Submit_response_msg { - - var c_struct C.struct_job_descriptor - - C.slurm_init_job_desc_msg(&c_struct) - if go_struct.Account != "" { - account_s := C.CString(go_struct.Account) - defer C.free(unsafe.Pointer(account_s)) - c_struct.account = account_s - } - if go_struct.Acctg_freq != "" { - acctg_freq_s := C.CString(go_struct.Acctg_freq) - defer C.free(unsafe.Pointer(acctg_freq_s)) - c_struct.acctg_freq = acctg_freq_s - } - if go_struct.Alloc_node != "" { - alloc_node_s := C.CString(go_struct.Alloc_node) - defer C.free(unsafe.Pointer(alloc_node_s)) - c_struct.alloc_node = alloc_node_s - } - if go_struct.Alloc_resp_port != 0 { - c_struct.alloc_resp_port = C.uint16_t(go_struct.Alloc_resp_port) - } - if go_struct.Alloc_sid != 0 { - c_struct.alloc_sid = C.uint32_t(go_struct.Alloc_sid) - } - if len(go_struct.Argv) > 0 { - c_struct.argc = C.uint32_t(len(go_struct.Argv)) - cArray := C.malloc(C.size_t(C.size_t(len(go_struct.Argv)) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - for i := 0; i < len(go_struct.Argv); i++ { - a[i] = C.CString(go_struct.Argv[i]) - } - c_struct.argv = (**C.char)(cArray) - fmt.Printf("test\n") - } - - if go_struct.Array_inx != "" { - array_inx_s := C.CString(go_struct.Array_inx) - defer C.free(unsafe.Pointer(array_inx_s)) - c_struct.array_inx = array_inx_s - } - if go_struct.Begin_time != 0 { - c_struct.begin_time = C.int64_t(go_struct.Begin_time) - } - if go_struct.Ckpt_interval != 0 { - c_struct.ckpt_interval = C.uint16_t(go_struct.Ckpt_interval) - } - if go_struct.Ckpt_dir != "" { - ckpt_dir_s := C.CString(go_struct.Ckpt_dir) - defer C.free(unsafe.Pointer(ckpt_dir_s)) - c_struct.ckpt_dir = ckpt_dir_s - } - if go_struct.Comment != "" { - comment_s := C.CString(go_struct.Comment) - defer C.free(unsafe.Pointer(comment_s)) - c_struct.comment = comment_s - } - if go_struct.Contiguous != 0 { - c_struct.contiguous = C.uint16_t(go_struct.Contiguous) - } - if go_struct.Cpu_bind != "" { - cpu_bind_s := C.CString(go_struct.Cpu_bind) - defer C.free(unsafe.Pointer(cpu_bind_s)) - c_struct.cpu_bind = cpu_bind_s - } - if go_struct.Cpu_bind_type != 0 { - c_struct.cpu_bind_type = C.uint16_t(go_struct.Cpu_bind_type) - } - if go_struct.Dependency != "" { - dependency_s := C.CString(go_struct.Dependency) - defer C.free(unsafe.Pointer(dependency_s)) - c_struct.dependency = dependency_s - } - if go_struct.End_time != 0 { - c_struct.end_time = C.int64_t(go_struct.End_time) - } - if len(go_struct.Environment) > 0 { - c_struct.env_size = C.uint32_t(len(go_struct.Environment)) - cArray := C.malloc(C.size_t(C.size_t(len(go_struct.Environment)) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - for i := 0; i < len(go_struct.Environment); i++ { - a[i] = C.CString(go_struct.Environment[i]) - defer C.free(unsafe.Pointer(a[i])) - } - c_struct.environment = (**C.char)(cArray) - } else { - c_struct.env_size = 1 - cArray := C.malloc(C.size_t(C.size_t(1) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - a[0] = C.CString("SLURM_GO_JOB=TRUE") - defer C.free(unsafe.Pointer(a[0])) - c_struct.environment = (**C.char)(cArray) - - } - if go_struct.Exc_nodes != "" { - exc_nodes_s := C.CString(go_struct.Exc_nodes) - defer C.free(unsafe.Pointer(exc_nodes_s)) - c_struct.exc_nodes = exc_nodes_s - } - if go_struct.Features != "" { - features_s := C.CString(go_struct.Features) - defer C.free(unsafe.Pointer(features_s)) - c_struct.features = features_s - } - if go_struct.Group_id != 0 { - c_struct.group_id = C.uint32_t(go_struct.Group_id) - } - if go_struct.Immediate != 0 { - c_struct.immediate = C.uint16_t(go_struct.Immediate) - } - if go_struct.Job_id != 0 { - c_struct.job_id = C.uint32_t(go_struct.Job_id) - } - if go_struct.Kill_on_node_fail != 0 { - c_struct.kill_on_node_fail = C.uint16_t(go_struct.Kill_on_node_fail) - } - if go_struct.Licenses != "" { - licenses_s := C.CString(go_struct.Licenses) - defer C.free(unsafe.Pointer(licenses_s)) - c_struct.licenses = licenses_s - } - if go_struct.Mail_type != 0 { - c_struct.mail_type = C.uint16_t(go_struct.Mail_type) - } - if go_struct.Mail_user != "" { - mail_user_s := C.CString(go_struct.Mail_user) - defer C.free(unsafe.Pointer(mail_user_s)) - c_struct.mail_user = mail_user_s - } - if go_struct.Mem_bind != "" { - mem_bind_s := C.CString(go_struct.Mem_bind) - defer C.free(unsafe.Pointer(mem_bind_s)) - c_struct.mem_bind = mem_bind_s - } - if go_struct.Mem_bind_type != 0 { - c_struct.mem_bind_type = C.uint16_t(go_struct.Mem_bind_type) - } - if go_struct.Name != "" { - name_s := C.CString(go_struct.Name) - defer C.free(unsafe.Pointer(name_s)) - c_struct.name = name_s - } - if go_struct.Network != "" { - network_s := C.CString(go_struct.Network) - defer C.free(unsafe.Pointer(network_s)) - c_struct.network = network_s - } - if go_struct.Nice != 0 { - c_struct.nice = C.uint16_t(go_struct.Nice) - } - if go_struct.Num_tasks != 0 { - c_struct.num_tasks = C.uint32_t(go_struct.Num_tasks) - } - if go_struct.Open_mode != 0 { - c_struct.open_mode = C.uint8_t(go_struct.Open_mode) - } - if go_struct.Other_port != 0 { - c_struct.other_port = C.uint16_t(go_struct.Other_port) - } - if go_struct.Overcommit != 0 { - c_struct.overcommit = C.uint8_t(go_struct.Overcommit) - } - if go_struct.Partition != "" { - partition_s := C.CString(go_struct.Partition) - defer C.free(unsafe.Pointer(partition_s)) - c_struct.partition = partition_s - } - if go_struct.Plane_size != 0 { - c_struct.plane_size = C.uint16_t(go_struct.Plane_size) - } - if go_struct.Priority != 0 { - c_struct.priority = C.uint32_t(go_struct.Priority) - } - if go_struct.Profile != 0 { - c_struct.profile = C.uint32_t(go_struct.Profile) - } - if go_struct.Qos != "" { - qos_s := C.CString(go_struct.Qos) - defer C.free(unsafe.Pointer(qos_s)) - c_struct.qos = qos_s - } - if go_struct.Reboot != 0 { - c_struct.reboot = C.uint16_t(go_struct.Reboot) - } - if go_struct.Resp_host != "" { - resp_host_s := C.CString(go_struct.Resp_host) - defer C.free(unsafe.Pointer(resp_host_s)) - c_struct.resp_host = resp_host_s - } - if go_struct.Req_nodes != "" { - req_nodes_s := C.CString(go_struct.Req_nodes) - defer C.free(unsafe.Pointer(req_nodes_s)) - c_struct.req_nodes = req_nodes_s - } - if go_struct.Requeue != 0 { - c_struct.requeue = C.uint16_t(go_struct.Requeue) - } - if go_struct.Reservation != "" { - reservation_s := C.CString(go_struct.Reservation) - defer C.free(unsafe.Pointer(reservation_s)) - c_struct.reservation = reservation_s - } - if go_struct.Script != "" { - script_s := C.CString(go_struct.Script) - defer C.free(unsafe.Pointer(script_s)) - c_struct.script = script_s - } - if go_struct.Shared != 0 { - c_struct.shared = C.uint16_t(go_struct.Shared) - } - if go_struct.Spank_job_env_size != 0 { - c_struct.spank_job_env_size = C.uint32_t(go_struct.Spank_job_env_size) - } - if go_struct.Task_dist != 0 { - c_struct.task_dist = C.uint16_t(go_struct.Task_dist) - } - if go_struct.Time_limit != 0 { - c_struct.time_limit = C.uint32_t(go_struct.Time_limit) - } - if go_struct.Time_min != 0 { - c_struct.time_min = C.uint32_t(go_struct.Time_min) - } - //if go_struct.User_id != 0 { - // c_struct.user_id = C.uint32_t(go_struct.User_id) - //} - c_struct.user_id = C.uint32_t(go_struct.User_id) - if go_struct.Wait_all_nodes != 0 { - c_struct.wait_all_nodes = C.uint16_t(go_struct.Wait_all_nodes) - } - if go_struct.Warn_signal != 0 { - c_struct.warn_signal = C.uint16_t(go_struct.Warn_signal) - } - if go_struct.Warn_time != 0 { - c_struct.warn_time = C.uint16_t(go_struct.Warn_time) - } - if go_struct.Work_dir != "" { - work_dir_s := C.CString(go_struct.Work_dir) - defer C.free(unsafe.Pointer(work_dir_s)) - c_struct.work_dir = work_dir_s - } - if go_struct.Cpus_per_task != 0 { - c_struct.cpus_per_task = C.uint16_t(go_struct.Cpus_per_task) - } - if go_struct.Min_cpus != 0 { - c_struct.min_cpus = C.uint32_t(go_struct.Min_cpus) - } - if go_struct.Max_cpus != 0 { - c_struct.max_cpus = C.uint32_t(go_struct.Max_cpus) - } - if go_struct.Min_nodes != 0 { - c_struct.min_nodes = C.uint32_t(go_struct.Min_nodes) - } - if go_struct.Max_nodes != 0 { - c_struct.max_nodes = C.uint32_t(go_struct.Max_nodes) - } - if go_struct.Boards_per_node != 0 { - c_struct.boards_per_node = C.uint16_t(go_struct.Boards_per_node) - } - if go_struct.Sockets_per_board != 0 { - c_struct.sockets_per_board = C.uint16_t(go_struct.Sockets_per_board) - } - if go_struct.Sockets_per_node != 0 { - c_struct.sockets_per_node = C.uint16_t(go_struct.Sockets_per_node) - } - if go_struct.Cores_per_socket != 0 { - c_struct.cores_per_socket = C.uint16_t(go_struct.Cores_per_socket) - } - if go_struct.Threads_per_core != 0 { - c_struct.threads_per_core = C.uint16_t(go_struct.Threads_per_core) - } - if go_struct.Ntasks_per_node != 0 { - c_struct.ntasks_per_node = C.uint16_t(go_struct.Ntasks_per_node) - } - if go_struct.Ntasks_per_socket != 0 { - c_struct.ntasks_per_socket = C.uint16_t(go_struct.Ntasks_per_socket) - } - if go_struct.Ntasks_per_core != 0 { - c_struct.ntasks_per_core = C.uint16_t(go_struct.Ntasks_per_core) - } - if go_struct.Ntasks_per_board != 0 { - c_struct.ntasks_per_board = C.uint16_t(go_struct.Ntasks_per_board) - } - if go_struct.Pn_min_cpus != 0 { - c_struct.pn_min_cpus = C.uint16_t(go_struct.Pn_min_cpus) - } - if go_struct.Pn_min_memory != 0 { - c_struct.pn_min_memory = C.uint32_t(go_struct.Pn_min_memory) - } - if go_struct.Pn_min_tmp_disk != 0 { - c_struct.pn_min_tmp_disk = C.uint32_t(go_struct.Pn_min_tmp_disk) - } - if go_struct.Req_switch != 0 { - c_struct.req_switch = C.uint32_t(go_struct.Req_switch) - } - if go_struct.Std_err != "" { - std_err_s := C.CString(go_struct.Std_err) - defer C.free(unsafe.Pointer(std_err_s)) - c_struct.std_err = std_err_s - } - if go_struct.Std_in != "" { - std_in_s := C.CString(go_struct.Std_in) - defer C.free(unsafe.Pointer(std_in_s)) - c_struct.std_in = std_in_s - } - if go_struct.Std_out != "" { - std_out_s := C.CString(go_struct.Std_out) - defer C.free(unsafe.Pointer(std_out_s)) - c_struct.std_out = std_out_s - } - - if go_struct.Wait4switch != 0 { - c_struct.wait4switch = C.uint32_t(go_struct.Wait4switch) - } - if go_struct.Wckey != "" { - wckey_s := C.CString(go_struct.Wckey) - defer C.free(unsafe.Pointer(wckey_s)) - c_struct.wckey = wckey_s - } - - c_msg := C.submit_job(&c_struct) - - defer C.free_submit_response_msg(c_msg) - if c_msg == nil { - go_msg := Submit_response_msg{} - go_msg.Job_id = 1<<31 - 1 - go_msg.Error_code = uint32(C.slurm_get_errno()) - return go_msg - } - go_msg := submit_response_msg_convert_c_to_go(c_msg) - - return go_msg - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/service/type.go b/adaptor/pcm_slurm/cgo_tianhe/service/type.go deleted file mode 100644 index 1fe4f177..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/service/type.go +++ /dev/null @@ -1,254 +0,0 @@ -package slurm - -type Job_descriptor struct { - Account string /* charge to specified account */ - Acctg_freq string /* accounting polling intervals (seconds) */ - Alloc_node string /* node making resource allocation request - * NOTE: Normally set by slurm_submit* or - * slurm_allocate* function */ - Alloc_resp_port uint16 /* port to send allocation confirmation to */ - Alloc_sid uint32 /* local sid making resource allocation request - * NOTE: Normally set by slurm_submit* or - * slurm_allocate* function - * NOTE: Also used for update flags, see - * ALLOC_SID_* flags */ - Argc uint32 /* number of arguments to the script */ - Argv []string /* arguments to the script */ - Array_inx string /* job array index values */ - //void *array_bitmap; /* NOTE: Set by slurmctld */ - Begin_time int64 /* delay initiation until this time */ - Ckpt_interval uint16 /* periodically checkpoint this job */ - Ckpt_dir string /* directory to store checkpoint images */ - Comment string /* arbitrary comment (used by Moab scheduler) */ - Contiguous uint16 /* 1 if job requires contiguous nodes, - * 0 otherwise,default=0 */ - Cpu_bind string /* binding map for map/mask_cpu */ - Cpu_bind_type uint16 /* see cpu_bind_type_t */ - Dependency string /* synchronize job execution with other jobs */ - End_time int64 /* time by which job must complete, used for - * job update only now, possible deadline - * scheduling in the future */ - Environment []string /* environment variables to set for job, - * name=value pairs, one per line */ - Env_size uint32 /* element count in environment */ - Exc_nodes string /* comma separated list of nodes excluded - * from job's allocation, default NONE */ - Features string /* comma separated list of required features, - * default NONE */ - Gres string /* comma separated list of required generic - * resources, default NONE */ - Group_id uint32 /* group to assume, if run as root. */ - Immediate uint16 /* 1 if allocate to run or fail immediately, - * 0 if to be queued awaiting resources */ - Job_id uint32 /* job ID, default set by SLURM */ - Kill_on_node_fail uint16 /* 1 if node failure to kill job, - * 0 otherwise,default=1 */ - Licenses string /* licenses required by the job */ - Mail_type uint16 /* see MAIL_JOB_ definitions above */ - Mail_user string /* user to receive notification */ - Mem_bind string /* binding map for map/mask_cpu */ - Mem_bind_type uint16 /* see mem_bind_type_t */ - Name string /* name of the job, default "" */ - Network string /* network use spec */ - Nice uint16 /* requested priority change, - * NICE_OFFSET == no change */ - Num_tasks uint32 /* number of tasks to be started, - * for batch only */ - Open_mode uint8 /* out/err open mode truncate or append, - * see OPEN_MODE_* */ - Other_port uint16 /* port to send various notification msg to */ - Overcommit uint8 /* over subscribe resources, for batch only */ - Partition string /* name of requested partition, - * default in SLURM config */ - Plane_size uint16 /* plane size when task_dist = - SLURM_DIST_PLANE */ - Priority uint32 /* relative priority of the job, - * explicitly set only for user root, - * 0 == held (don't initiate) */ - Profile uint32 /* Level of acct_gather_profile {all | none} */ - Qos string /* Quality of Service */ - Resp_host string /* NOTE: Set by slurmctld */ - Req_nodes string /* comma separated list of required nodes - * default NONE */ - Requeue uint16 /* enable or disable job requeue option */ - Reservation string /* name of reservation to use */ - Script string /* the actual job script, default NONE */ - Shared uint16 /* 1 if job can share nodes with other jobs, - * 0 if job needs exclusive access to the node, - * or NO_VAL to accept the system default. - * SHARED_FORCE to eliminate user control. */ - //char **spank_job_env; environment variables for job prolog/epilog - // * scripts as set by SPANK plugins - Spank_job_env_size uint32 /* element count in spank_env */ - Task_dist uint16 /* see enum task_dist_state */ - Time_limit uint32 /* maximum run time in minutes, default is - * partition limit */ - Time_min uint32 /* minimum run time in minutes, default is - * time_limit */ - User_id uint32 /* set only if different from current UID, - * can only be explicitly set by user root */ - Wait_all_nodes uint16 /* 0 to start job immediately after allocation - * 1 to start job after all nodes booted - * or NO_VAL to use system default */ - Warn_signal uint16 /* signal to send when approaching end time */ - Warn_time uint16 /* time before end to send signal (seconds) */ - Work_dir string /* pathname of working directory */ - - /* job constraints: */ - Cpus_per_task uint16 /* number of processors required for - * each task */ - Min_cpus uint32 /* minimum number of processors required, - * default=0 */ - Max_cpus uint32 /* maximum number of processors required, - * default=0 */ - Min_nodes uint32 /* minimum number of nodes required by job, - * default=0 */ - Max_nodes uint32 /* maximum number of nodes usable by job, - * default=0 */ - Boards_per_node uint16 /* boards per node required by job */ - Sockets_per_board uint16 /* sockets per board required by job */ - Sockets_per_node uint16 /* sockets per node required by job */ - Cores_per_socket uint16 /* cores per socket required by job */ - Threads_per_core uint16 /* threads per core required by job */ - Ntasks_per_node uint16 /* number of tasks to invoke on each node */ - Ntasks_per_socket uint16 /* number of tasks to invoke on - * each socket */ - Ntasks_per_core uint16 /* number of tasks to invoke on each core */ - Ntasks_per_board uint16 /* number of tasks to invoke on each board */ - Pn_min_cpus uint16 /* minimum # CPUs per node, default=0 */ - Pn_min_memory uint32 /* minimum real memory per node OR - * real memory per CPU | MEM_PER_CPU, - * default=0 (no limit) */ - Pn_min_tmp_disk uint32 /* minimum tmp disk per node, - * default=0 */ - - /* - * The following parameters are only meaningful on a Blue Gene - * system at present. Some will be of value on other system. Don't remove these - * they are needed for LCRM and others that can't talk to the opaque data type - * select_jobinfo. - */ - //uint16_t geometry[HIGHEST_DIMENSIONS]; node count in various - // * dimensions, e.g. X, Y, and Z - //uint16_t conn_type[HIGHEST_DIMENSIONS]; see enum connection_type - Reboot uint16 /* force node reboot before startup */ - Rotate uint16 /* permit geometry rotation if set */ - //char *blrtsimage; /* BlrtsImage for block */ - //char *linuximage; /* LinuxImage for block */ - //char *mloaderimage; /* MloaderImage for block */ - //char *ramdiskimage; /* RamDiskImage for block */ - - /* End of Blue Gene specific values */ - Req_switch uint32 /* Minimum number of switches */ - //dynamic_plugin_data_t *select_jobinfo; /* opaque data type, - // * SLURM internal use only */ - Std_err string /* pathname of stderr */ - Std_in string /* pathname of stdin */ - Std_out string /* pathname of stdout */ - Wait4switch uint32 /* Maximum time to wait for minimum switches */ - Wckey string /* wckey for job */ -} - -type Submit_response_msg struct { - Job_id uint32 - Step_id uint32 - Error_code uint32 -} - -type Job_info struct { - account string /* charge to specified account */ - alloc_node string /* local node making resource alloc */ - alloc_sid uint32 /* local sid making resource alloc */ - array_job_id uint32 /* job_id of a job array or 0 if N/A */ - array_task_id uint16 /* task_id of a job array */ - assoc_id uint32 /* association id for job */ - batch_flag uint16 /* 1 if batch: queued job with script */ - batch_host string /* name of host running batch script */ - batch_script string /* contents of batch script */ - command string /* command to be executed, built from submitted - * job's argv and NULL for salloc command */ - comment string /* arbitrary comment (used by Moab scheduler) */ - contiguous uint16 /* 1 if job requires contiguous nodes */ - cpus_per_task uint16 /* number of processors required for - * each task */ - dependency string /* synchronize job execution with other jobs */ - derived_ec uint32 /* highest exit code of all job steps */ - eligible_time int64 /* time job is eligible for running */ - end_time int64 /* time of termination, actual or expected */ - exc_nodes string /* comma separated list of excluded nodes */ - exc_node_inx int32 /* excluded list index pairs into node_table: - * start_range_1, end_range_1, - * start_range_2, .., -1 */ - exit_code uint32 /* exit code for job (status from wait call) */ - features string /* comma separated list of required features */ - gres string /* comma separated list of generic resources */ - group_id uint32 /* group job sumitted as */ - job_id uint32 /* job ID */ - job_state uint16 /* state of the job, see enum job_states */ - licenses string /* licenses required by the job */ - max_cpus uint32 /* maximum number of cpus usable by job */ - max_nodes uint32 /* maximum number of nodes usable by job */ - boards_per_node uint16 /* boards per node required by job */ - sockets_per_board uint16 /* sockets per board required by job */ - sockets_per_node uint16 /* sockets per node required by job */ - cores_per_socket uint16 /* cores per socket required by job */ - threads_per_core uint16 /* threads per core required by job */ - name string /* name of the job */ - network string /* network specification */ - nodes string /* list of nodes allocated to job */ - nice uint16 /* requested priority change */ - node_inx int32 /* list index pairs into node_table for *nodes: - * start_range_1, end_range_1, - * start_range_2, .., -1 */ - ntasks_per_core uint16 /* number of tasks to invoke on each core */ - ntasks_per_node uint16 /* number of tasks to invoke on each node */ - ntasks_per_socket uint16 /* number of tasks to invoke on each socket*/ - ntasks_per_board uint16 /* number of tasks to invoke on each board */ - - num_nodes uint32 /* minimum number of nodes required by job */ - num_cpus uint32 /* minimum number of cpus required by job */ - partition string /* name of assigned partition */ - pn_min_memory uint32 /* minimum real memory per node, default=0 */ - pn_min_cpus uint16 /* minimum # CPUs per node, default=0 */ - pn_min_tmp_disk uint32 /* minimum tmp disk per node, default=0 */ - pre_sus_time int64 /* time job ran prior to last suspend */ - priority uint32 /* relative priority of the job, - * 0=held, 1=required nodes DOWN/DRAINED */ - profile uint32 /* Level of acct_gather_profile {all | none} */ - qos string /* Quality of Service */ - req_nodes string /* comma separated list of required nodes */ - req_node_inx int32 /* required list index pairs into node_table: - * start_range_1, end_range_1, - * start_range_2, .., -1 */ - req_switch uint32 /* Minimum number of switches */ - requeue uint16 /* enable or disable job requeue option */ - resize_time int64 /* time of latest size change */ - restart_cnt uint16 /* count of job restarts */ - resv_name string /* reservation name */ - /*dynamic_plugin_data_t *select_jobinfo;*/ /* opaque data type, - * process using - * slurm_get_select_jobinfo() - */ - /*job_resources_t *job_resrcs;*/ /* opaque data type, job resources */ - shared uint16 /* 1 if job can share nodes with other jobs */ - show_flags uint16 /* conveys level of details requested */ - start_time int64 /* time execution begins, actual or expected */ - state_desc string /* optional details for state_reason */ - state_reason uint16 /* reason job still pending or failed, see - * slurm.h:enum job_state_reason */ - submit_time int64 /* time of job submission */ - suspend_time int64 /* time job last suspended or resumed */ - time_limit uint32 /* maximum run time in minutes or INFINITE */ - time_min uint32 /* minimum run time in minutes or INFINITE */ - user_id uint32 /* user the job runs as */ - preempt_time int64 /* preemption signal time */ - wait4switch uint32 /* Maximum time to wait for minimum switches */ - wckey string /* wckey for job */ - work_dir string /* pathname of working directory */ -} - -type Job_info_msg struct { - Last_update int64 - Record_count uint32 - Job_list []Job_info -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/extra/slurm_extra.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/extra/slurm_extra.go deleted file mode 100644 index ab9ac2cc..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/extra/slurm_extra.go +++ /dev/null @@ -1,118 +0,0 @@ -/*These are some extra functions to work with slurm in go -** They are seperated, since they don't use the slurm-API -** but wrap arround the SLURM comand line tools */ -package extra - -import ( - "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm" - job_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - "errors" - "fmt" - "os" - "os/exec" - "path/filepath" - "strconv" - "strings" -) - -var slurm_path string - -func find_slurm_path() { - var err error - var path string - path = os.Getenv("SLURM_PATH") - if path == " " { - path, err = exec.LookPath("sinfo") - if err != nil { - fmt.Printf("could not find slurm executables\n Either add slum-bins to your PATH or define SLURM_PATH\n") - } else { - slurm_path = strings.TrimSuffix(path, "bin/sinfo") - } - } else { - test_path := filepath.Join(path, "bin/sinfo") - _, err := os.Stat(test_path) - if os.IsNotExist(err) { - fmt.Printf("Slurm executable sinfo does no exist at %s\n", test_path) - } else { - slurm_path = path - - } - } -} - -func Cancel_job(JobId uint32) error { - find_slurm_path() - if slurm_path == "" { - return errors.New("Cannot find slurm executable") - } - job_list := job_info.Get_job(JobId) - if job_list.Error_code != 0 { - msg := slurm.GetErrorString(job_list.Error_code) - fmt.Printf(msg) - return errors.New(msg) - } - path := filepath.Join(slurm_path, "bin", "scancel") - cmd := exec.Command(path, strconv.FormatInt(int64(JobId), 10)) - fmt.Print(cmd.String()) - out, err := cmd.CombinedOutput() - if err != nil { - msg := string(out) + err.Error() - return errors.New(msg) - } - return nil -} - -type Acc_Job_info struct { - JobId uint32 - User string - Account string - State string - JobName string -} - -var sacct_format_string string - -func parse_sacct_output(input string) []Acc_Job_info { - var job_list []Acc_Job_info - lines := strings.Split(string(input), "\n") - fmt.Printf("len %d\n", len(lines)-1) - for l := range lines { - var job_info Acc_Job_info - elements := strings.Split(lines[l], "|") - if len(elements) < 5 { - break //Well, this is not clean, but keep it like this for Now - } - id, ierr := strconv.Atoi(elements[0]) - - if ierr != nil { - break //we have no useable entry here but something like 323.batch . Ignore these for now - } - job_info.JobId = uint32(id) - job_info.User = elements[1] - job_info.Account = elements[2] - job_info.State = elements[3] - job_info.JobName = elements[4] - job_list = append(job_list, job_info) - } - return job_list -} - -func Get_job_info_accounting(JobId uint32) ([]Acc_Job_info, error) { - - sacct_format_string = "JobId,user,account,state,JobName" - find_slurm_path() - if slurm_path == "" { - return nil, errors.New("Cannot find slurm executable") - } - path := filepath.Join(slurm_path, "bin", "sacct") - cmd := exec.Command(path, "-j", strconv.FormatInt(int64(JobId), 10), "--format", sacct_format_string, "-p", "-n") - //fmt.Printf(cmd.String()) - out, err := cmd.CombinedOutput() - if err != nil { - msg := string(out) + err.Error() - return nil, errors.New(msg) - } - list := parse_sacct_output(string(out)) - - return list, nil -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo/slurm_job_info.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo/slurm_job_info.go deleted file mode 100644 index 116935ac..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo/slurm_job_info.go +++ /dev/null @@ -1,480 +0,0 @@ -package job_info - -/* -#cgo LDFLAGS: -lslurm -#include -#include - -inline uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int32_t int32_ptr(int32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} - struct job_info_msg *get_job_info(){ - struct job_info_msg* job_buffer; - if(slurm_load_jobs ((time_t) NULL, - &job_buffer, SHOW_ALL)) { - return NULL; - } - return job_buffer; - } - struct job_info_msg *get_single_job_info(uint32_t id){ - struct job_info_msg* job_buffer; - if( slurm_load_job (&job_buffer, id, SHOW_DETAIL)) { - return NULL; - } - return job_buffer; - } - - struct job_info* job_from_list(struct job_info_msg *list, int i){ - return &list->job_array[i]; -} - void free_job_buffer(void* buffer){ - - slurm_free_job_info_msg ((struct job_info_msg*)buffer); -} - -struct job_info_msg *get_user_job_info(uint32_t id){ - - struct job_info_msg* job_buffer; - if( slurm_load_job_user(&job_buffer, id, SHOW_DETAIL)) - return NULL; - return job_buffer; - -} - -int64_t get_job_endtime(int32_t jobid){ - time_t end_time; - - if(slurm_get_end_time (jobid, &end_time)) - return -1; - else - return end_time; - - -} - -int char_len(char* c) { - uint i = 0; - while(c[i]!='\0') i++; - return i; - } - - -*/ -import "C" - -import "fmt" -import "os/user" -import "strconv" -import "time" - -func Reason_to_string(state uint16) string { - switch s := C.uint16_t(state); s { - case C.WAIT_NO_REASON: - return "wait no reason" - } - return "unkown reason" - -} -func state_to_string(state uint32) string { - switch s := C.uint32_t(state); s { - case C.JOB_PENDING: - return "Pending" /* queued waiting for initiation */ - case C.JOB_RUNNING: - return "Running" /* allocated resources and executing */ - case C.JOB_SUSPENDED: - return "Suspended" /* allocated resources, execution suspended */ - case C.JOB_COMPLETE: - return "Complete" /* completed execution successfully */ - case C.JOB_CANCELLED: - return "Cancelled" /* cancelled by user */ - case C.JOB_FAILED: - return "Failed" /* completed execution unsuccessfully */ - case C.JOB_TIMEOUT: - return "Timeout" /* terminated on reaching time limit */ - case C.JOB_NODE_FAIL: - return "Node Fail" /* terminated on node failure */ - case C.JOB_PREEMPTED: - return "Preempted" /* terminated due to preemption */ - } - - return "Unknow status" /* not a real state, last entry in table */ -} - -type Job_info struct { - Account string - Alloc_node string - Alloc_sid uint32 - //array_bitmap void; - Array_job_id uint32 - Array_task_id uint32 - Assoc_id uint32 - Batch_flag uint16 - Batch_host string - Boards_per_node uint16 - Command string - Comment string - Contiguous uint16 - Cores_per_socket uint16 - Cpus_per_task uint16 - Dependency string - Derived_ec uint32 - Eligible_time int64 - End_time int64 - Exc_nodes string - Exc_node_inx int32 - Exit_code uint32 - Features string - //gres_detail_str char**; - Group_id uint32 - Job_id uint32 - Job_state uint32 - Job_stateS string - Licenses string - Max_cpus uint32 - Max_nodes uint32 - Name string - Network string - Nodes string - Nice uint32 - Node_inx int32 - Ntasks_per_core uint16 - Ntasks_per_node uint16 - Ntasks_per_socket uint16 - Ntasks_per_board uint16 - Num_cpus uint32 - Num_nodes uint32 - Partition string - Pn_min_memory uint64 - Pn_min_cpus uint16 - Pn_min_tmp_disk uint32 - Preempt_time int64 - Pre_sus_time int64 - Priority uint32 - Profile uint32 - Qos string - Req_nodes string - Req_node_inx int32 - Req_switch uint32 - Requeue uint16 - Resize_time int64 - Restart_cnt uint16 - Resv_name string - Shared uint16 - Show_flags uint16 - Sockets_per_board uint16 - Sockets_per_node uint16 - Start_time int64 - State_desc string - State_reason uint16 - Submit_time int64 - Suspend_time int64 - Time_limit uint32 - Time_min uint32 - Threads_per_core uint16 - User_id uint32 - //accurate void; - Wait4switch uint32 - Wckey string - Work_dir string -} - -func Job_info_convert_c_to_go(c_struct *C.struct_job_info) Job_info { - var go_struct Job_info - - go_struct.Account = C.GoString(c_struct.account) - go_struct.Alloc_node = C.GoString(c_struct.alloc_node) - go_struct.Alloc_sid = uint32(c_struct.alloc_sid) - go_struct.Array_job_id = uint32(c_struct.array_job_id) - go_struct.Array_task_id = uint32(c_struct.array_task_id) - go_struct.Assoc_id = uint32(c_struct.assoc_id) - go_struct.Batch_flag = uint16(c_struct.batch_flag) - go_struct.Batch_host = C.GoString(c_struct.batch_host) - go_struct.Boards_per_node = uint16(c_struct.boards_per_node) - go_struct.Command = C.GoString(c_struct.command) - go_struct.Comment = C.GoString(c_struct.comment) - go_struct.Contiguous = uint16(c_struct.contiguous) - go_struct.Cores_per_socket = uint16(c_struct.cores_per_socket) - go_struct.Cpus_per_task = uint16(c_struct.cpus_per_task) - go_struct.Dependency = C.GoString(c_struct.dependency) - go_struct.Derived_ec = uint32(c_struct.derived_ec) - go_struct.Eligible_time = int64(c_struct.eligible_time) - go_struct.End_time = int64(c_struct.end_time) - go_struct.Exc_nodes = C.GoString(c_struct.exc_nodes) - go_struct.Exc_node_inx = int32(C.int32_ptr(c_struct.exc_node_inx)) - go_struct.Exit_code = uint32(c_struct.exit_code) - go_struct.Features = C.GoString(c_struct.features) - go_struct.Group_id = uint32(c_struct.group_id) - go_struct.Job_id = uint32(c_struct.job_id) - go_struct.Job_state = uint32(c_struct.job_state) - go_struct.Job_stateS = state_to_string(uint32(c_struct.job_state)) - go_struct.Licenses = C.GoString(c_struct.licenses) - go_struct.Max_cpus = uint32(c_struct.max_cpus) - go_struct.Max_nodes = uint32(c_struct.max_nodes) - go_struct.Name = C.GoString(c_struct.name) - go_struct.Network = C.GoString(c_struct.network) - go_struct.Nodes = C.GoString(c_struct.nodes) - go_struct.Nice = uint32(c_struct.nice) - go_struct.Node_inx = int32(C.int32_ptr(c_struct.node_inx)) - go_struct.Ntasks_per_core = uint16(c_struct.ntasks_per_core) - go_struct.Ntasks_per_node = uint16(c_struct.ntasks_per_node) - go_struct.Ntasks_per_socket = uint16(c_struct.ntasks_per_socket) - go_struct.Ntasks_per_board = uint16(c_struct.ntasks_per_board) - go_struct.Num_cpus = uint32(c_struct.num_cpus) - go_struct.Num_nodes = uint32(c_struct.num_nodes) - go_struct.Partition = C.GoString(c_struct.partition) - go_struct.Pn_min_memory = uint64(c_struct.pn_min_memory) - go_struct.Pn_min_cpus = uint16(c_struct.pn_min_cpus) - go_struct.Pn_min_tmp_disk = uint32(c_struct.pn_min_tmp_disk) - go_struct.Preempt_time = int64(c_struct.preempt_time) - go_struct.Pre_sus_time = int64(c_struct.pre_sus_time) - go_struct.Priority = uint32(c_struct.priority) - go_struct.Profile = uint32(c_struct.profile) - go_struct.Qos = C.GoString(c_struct.qos) - go_struct.Req_nodes = C.GoString(c_struct.req_nodes) - go_struct.Req_node_inx = int32(C.int32_ptr(c_struct.req_node_inx)) - go_struct.Req_switch = uint32(c_struct.req_switch) - go_struct.Requeue = uint16(c_struct.requeue) - go_struct.Resize_time = int64(c_struct.resize_time) - go_struct.Restart_cnt = uint16(c_struct.restart_cnt) - go_struct.Resv_name = C.GoString(c_struct.resv_name) - go_struct.Shared = uint16(c_struct.shared) - go_struct.Show_flags = uint16(c_struct.show_flags) - go_struct.Sockets_per_board = uint16(c_struct.sockets_per_board) - go_struct.Sockets_per_node = uint16(c_struct.sockets_per_node) - go_struct.Start_time = int64(c_struct.start_time) - go_struct.State_desc = C.GoString(c_struct.state_desc) - go_struct.State_reason = uint16(c_struct.state_reason) - go_struct.Submit_time = int64(c_struct.submit_time) - go_struct.Suspend_time = int64(c_struct.suspend_time) - go_struct.Time_limit = uint32(c_struct.time_limit) - go_struct.Time_min = uint32(c_struct.time_min) - go_struct.Threads_per_core = uint16(c_struct.threads_per_core) - go_struct.User_id = uint32(c_struct.user_id) - go_struct.Wait4switch = uint32(c_struct.wait4switch) - go_struct.Wckey = C.GoString(c_struct.wckey) - go_struct.Work_dir = C.GoString(c_struct.work_dir) - return go_struct -} - -func Print_Job_info(go_struct Job_info) { - fmt.Printf("%s:\t %s\n", "account", go_struct.Account) - fmt.Printf("%s:\t %s\n", "alloc node", go_struct.Alloc_node) - fmt.Printf("%s:\t %d\n", "alloc sid", go_struct.Alloc_sid) - fmt.Printf("%s:\t %d\n", "array job id", go_struct.Array_job_id) - fmt.Printf("%s:\t %d\n", "array task id", go_struct.Array_task_id) - fmt.Printf("%s:\t %d\n", "assoc id", go_struct.Assoc_id) - fmt.Printf("%s:\t %d\n", "batch flag", go_struct.Batch_flag) - fmt.Printf("%s:\t %s\n", "batch host", go_struct.Batch_host) - fmt.Printf("%s:\t %d\n", "boards per node", go_struct.Boards_per_node) - fmt.Printf("%s:\t %s\n", "command", go_struct.Command) - fmt.Printf("%s:\t %s\n", "comment", go_struct.Comment) - fmt.Printf("%s:\t %d\n", "contiguous", go_struct.Contiguous) - fmt.Printf("%s:\t %d\n", "cores per socket", go_struct.Cores_per_socket) - fmt.Printf("%s:\t %d\n", "cpus per task", go_struct.Cpus_per_task) - fmt.Printf("%s:\t %s\n", "dependency", go_struct.Dependency) - fmt.Printf("%s:\t %d\n", "derived ec", go_struct.Derived_ec) - fmt.Printf("%s:\t %d\n", "eligible time", go_struct.Eligible_time) - fmt.Printf("%s:\t %d\n", "end time", go_struct.End_time) - fmt.Printf("%s:\t %s\n", "exc nodes", go_struct.Exc_nodes) - fmt.Printf("%s:\t %d\n", "exc node inx", go_struct.Exc_node_inx) - fmt.Printf("%s:\t %d\n", "exit code", go_struct.Exit_code) - fmt.Printf("%s:\t %s\n", "features", go_struct.Features) - fmt.Printf("%s:\t %d\n", "group id", go_struct.Group_id) - fmt.Printf("%s:\t %d\n", "job id", go_struct.Job_id) - fmt.Printf("%s:\t %d\n", "job state", go_struct.Job_state) - fmt.Printf("%s:\t %s\n", "licenses", go_struct.Licenses) - fmt.Printf("%s:\t %d\n", "max cpus", go_struct.Max_cpus) - fmt.Printf("%s:\t %d\n", "max nodes", go_struct.Max_nodes) - fmt.Printf("%s:\t %s\n", "name", go_struct.Name) - fmt.Printf("%s:\t %s\n", "network", go_struct.Network) - fmt.Printf("%s:\t %s\n", "nodes", go_struct.Nodes) - fmt.Printf("%s:\t %d\n", "nice", go_struct.Nice) - fmt.Printf("%s:\t %d\n", "node inx", go_struct.Node_inx) - fmt.Printf("%s:\t %d\n", "ntasks per core", go_struct.Ntasks_per_core) - fmt.Printf("%s:\t %d\n", "ntasks per node", go_struct.Ntasks_per_node) - fmt.Printf("%s:\t %d\n", "ntasks per socket", go_struct.Ntasks_per_socket) - fmt.Printf("%s:\t %d\n", "ntasks per board", go_struct.Ntasks_per_board) - fmt.Printf("%s:\t %d\n", "num cpus", go_struct.Num_cpus) - fmt.Printf("%s:\t %d\n", "num nodes", go_struct.Num_nodes) - fmt.Printf("%s:\t %s\n", "partition", go_struct.Partition) - fmt.Printf("%s:\t %d\n", "pn min memory", go_struct.Pn_min_memory) - fmt.Printf("%s:\t %d\n", "pn min cpus", go_struct.Pn_min_cpus) - fmt.Printf("%s:\t %d\n", "pn min tmp disk", go_struct.Pn_min_tmp_disk) - fmt.Printf("%s:\t %d\n", "preempt time", go_struct.Preempt_time) - fmt.Printf("%s:\t %d\n", "pre sus time", go_struct.Pre_sus_time) - fmt.Printf("%s:\t %d\n", "priority", go_struct.Priority) - fmt.Printf("%s:\t %d\n", "profile", go_struct.Profile) - fmt.Printf("%s:\t %s\n", "qos", go_struct.Qos) - fmt.Printf("%s:\t %s\n", "req nodes", go_struct.Req_nodes) - fmt.Printf("%s:\t %d\n", "req node inx", go_struct.Req_node_inx) - fmt.Printf("%s:\t %d\n", "req switch", go_struct.Req_switch) - fmt.Printf("%s:\t %d\n", "requeue", go_struct.Requeue) - fmt.Printf("%s:\t %d\n", "resize time", go_struct.Resize_time) - fmt.Printf("%s:\t %d\n", "restart cnt", go_struct.Restart_cnt) - fmt.Printf("%s:\t %s\n", "resv name", go_struct.Resv_name) - fmt.Printf("%s:\t %d\n", "shared", go_struct.Shared) - fmt.Printf("%s:\t %d\n", "show flags", go_struct.Show_flags) - fmt.Printf("%s:\t %d\n", "sockets per board", go_struct.Sockets_per_board) - fmt.Printf("%s:\t %d\n", "sockets per node", go_struct.Sockets_per_node) - fmt.Printf("%s:\t %d\n", "start time", go_struct.Start_time) - fmt.Printf("%s:\t %s\n", "state desc", go_struct.State_desc) - fmt.Printf("%s:\t %d\n", "state reason", go_struct.State_reason) - fmt.Printf("%s:\t %d\n", "submit time", go_struct.Submit_time) - fmt.Printf("%s:\t %d\n", "suspend time", go_struct.Suspend_time) - fmt.Printf("%s:\t %d\n", "time limit", go_struct.Time_limit) - fmt.Printf("%s:\t %d\n", "time min", go_struct.Time_min) - fmt.Printf("%s:\t %d\n", "threads per core", go_struct.Threads_per_core) - fmt.Printf("%s:\t %d\n", "user id", go_struct.User_id) - fmt.Printf("%s:\t %d\n", "wait4switch", go_struct.Wait4switch) - fmt.Printf("%s:\t %s\n", "wckey", go_struct.Wckey) - fmt.Printf("%s:\t %s\n", "work dir", go_struct.Work_dir) -} - -type Job_info_msg struct { - Last_update int64 - Record_count uint32 - Error_code uint32 - Job_list []Job_info -} - -func Get_job_runtime(job Job_info) time.Duration { - - start_time := time.Unix(job.Start_time, 0) - current_time := time.Now() - diff := current_time.Sub(start_time).Round(time.Second) - if int64(diff) < 0 { - return 0 - } - end_time := time.Unix(job.End_time, 0) - diff2 := current_time.Sub(end_time) - if int64(diff2) < 0 { - return diff - } - return end_time.Sub(start_time) -} - -func Get_job_endtime(id uint32) time.Time { - c_time := C.get_job_endtime(C.int32_t(id)) - return time.Unix(int64(c_time), 0) - -} - -func Get_all_jobs() Job_info_msg { - var go_job_buffer Job_info_msg - c_job_buffer := C.get_job_info() - if c_job_buffer == nil { - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Error_code = uint32(C.slurm_get_errno()) - return go_job_buffer - } - - go_job_buffer.Last_update = int64(c_job_buffer.last_update) - go_job_buffer.Record_count = uint32(c_job_buffer.record_count) - go_job_buffer.Job_list = make([]Job_info, c_job_buffer.record_count, c_job_buffer.record_count) - for i := uint32(0); i < go_job_buffer.Record_count; i++ { - job := C.job_from_list(c_job_buffer, C.int(i)) - go_job := Job_info_convert_c_to_go(job) - go_job_buffer.Job_list[i] = go_job - } - C.slurm_free_job_info_msg(c_job_buffer) - - return go_job_buffer -} - -func Get_job(id uint32) Job_info_msg { - var go_job_buffer Job_info_msg - c_job_buffer := C.get_single_job_info(C.uint32_t(id)) - if c_job_buffer == nil { - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Error_code = uint32(C.slurm_get_errno()) - return go_job_buffer - } - go_job_buffer.Last_update = int64(c_job_buffer.last_update) - go_job_buffer.Record_count = uint32(c_job_buffer.record_count) - go_job_buffer.Job_list = make([]Job_info, c_job_buffer.record_count, c_job_buffer.record_count) - for i := uint32(0); i < go_job_buffer.Record_count; i++ { - job := C.job_from_list(c_job_buffer, C.int(i)) - go_job := Job_info_convert_c_to_go(job) - go_job_buffer.Job_list[i] = go_job - } - C.slurm_free_job_info_msg(c_job_buffer) - - return go_job_buffer -} - -func Get_user_jobs(name string) Job_info_msg { - - var go_job_buffer Job_info_msg - user, err := user.Lookup(name) - - if err != nil { - fmt.Printf("Error %s\n", err.Error()) - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Error_code = C.ESLURMD_UID_NOT_FOUND - - return go_job_buffer - - } - - userid, _ := strconv.Atoi(user.Uid) - c_job_buffer := C.get_user_job_info(C.uint32_t(userid)) - - if c_job_buffer == nil { - go_job_buffer.Last_update = int64(0) - go_job_buffer.Record_count = uint32(0) - go_job_buffer.Error_code = uint32(C.slurm_get_errno()) - return go_job_buffer - } - go_job_buffer.Last_update = int64(c_job_buffer.last_update) - go_job_buffer.Record_count = uint32(c_job_buffer.record_count) - go_job_buffer.Job_list = make([]Job_info, c_job_buffer.record_count, c_job_buffer.record_count) - for i := uint32(0); i < go_job_buffer.Record_count; i++ { - job := C.job_from_list(c_job_buffer, C.int(i)) - go_job := Job_info_convert_c_to_go(job) - go_job_buffer.Job_list[i] = go_job - } - C.slurm_free_job_info_msg(c_job_buffer) - - return go_job_buffer - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/nodeinfo/slurm_node_info.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/nodeinfo/slurm_node_info.go deleted file mode 100644 index a25797b2..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/nodeinfo/slurm_node_info.go +++ /dev/null @@ -1,232 +0,0 @@ -package node_info - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -inline uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int32_t int32_ptr(int32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} - struct node_info_msg *get_node_info(){ - struct node_info_msg* node_buffer; - if(slurm_load_node ((time_t) NULL, - &node_buffer, SHOW_ALL)) - return NULL; - return node_buffer; - } - struct node_info_msg *get_single_node_info(char* name){ - struct node_info_msg* node_buffer; - if( slurm_load_node_single (&node_buffer, name, SHOW_DETAIL)) - return NULL; - return node_buffer; - } - - struct node_info* node_from_list(struct node_info_msg *list, int i){ - return &list->node_array[i]; -} - void free_node_buffer(void* buffer){ - - slurm_free_node_info_msg ((struct node_info_msg*)buffer); - } - - -*/ -import "C" - -import "fmt" -import "unsafe" - -type Node_info struct { - Arch string - Boards uint16 - Boot_time int64 - Cores uint16 - Cpu_load uint32 - Cpus uint16 - Features string - Gres string - Name string - Node_addr string - Node_hostname string - Node_state uint32 - Os string - Real_memory uint64 - Reason string - Reason_time int64 - Reason_uid uint32 - Slurmd_start_time int64 - Sockets uint16 - Threads uint16 - Tmp_disk uint32 - Weight uint32 -} - -func Node_info_convert_c_to_go(c_struct *C.struct_node_info) Node_info { - var go_struct Node_info - - go_struct.Arch = C.GoString(c_struct.arch) - go_struct.Boards = uint16(c_struct.boards) - go_struct.Boot_time = int64(c_struct.boot_time) - go_struct.Cores = uint16(c_struct.cores) - go_struct.Cpu_load = uint32(c_struct.cpu_load) - go_struct.Cpus = uint16(c_struct.cpus) - go_struct.Features = C.GoString(c_struct.features) - go_struct.Gres = C.GoString(c_struct.gres) - go_struct.Name = C.GoString(c_struct.name) - go_struct.Node_addr = C.GoString(c_struct.node_addr) - go_struct.Node_hostname = C.GoString(c_struct.node_hostname) - go_struct.Node_state = uint32(c_struct.node_state) - go_struct.Os = C.GoString(c_struct.os) - go_struct.Real_memory = uint64(c_struct.real_memory) - go_struct.Reason = C.GoString(c_struct.reason) - go_struct.Reason_time = int64(c_struct.reason_time) - go_struct.Reason_uid = uint32(c_struct.reason_uid) - go_struct.Slurmd_start_time = int64(c_struct.slurmd_start_time) - go_struct.Sockets = uint16(c_struct.sockets) - go_struct.Threads = uint16(c_struct.threads) - go_struct.Tmp_disk = uint32(c_struct.tmp_disk) - go_struct.Weight = uint32(c_struct.weight) - return go_struct -} - -func State_to_string(state uint32) string { - - switch s := C.uint16_t(state); s { - case C.NODE_STATE_UNKNOWN: - return "node state unknown" - case C.NODE_STATE_DOWN: - return "node state down" - case C.NODE_STATE_IDLE: - return "node state idle" - case C.NODE_STATE_ALLOCATED: - return "node state allocated" - case C.NODE_STATE_ERROR: - return "node state error" - case C.NODE_STATE_MIXED: - return "node state mixed" - case C.NODE_STATE_FUTURE: - return "node state future" - case C.NODE_STATE_END: - return "node state end" - } - return "Unkown state" -} - -func Print_node_info(go_struct Node_info) { - fmt.Printf("%s:\t %s\n", "arch", go_struct.Arch) - fmt.Printf("%s:\t %d\n", "boards", go_struct.Boards) - fmt.Printf("%s:\t %d\n", "boot time", go_struct.Boot_time) - fmt.Printf("%s:\t %d\n", "cores", go_struct.Cores) - fmt.Printf("%s:\t %d\n", "cpu load", go_struct.Cpu_load) - fmt.Printf("%s:\t %d\n", "cpus", go_struct.Cpus) - fmt.Printf("%s:\t %s\n", "features", go_struct.Features) - fmt.Printf("%s:\t %s\n", "gres", go_struct.Gres) - fmt.Printf("%s:\t %s\n", "name", go_struct.Name) - fmt.Printf("%s:\t %s\n", "node addr", go_struct.Node_addr) - fmt.Printf("%s:\t %s\n", "node hostname", go_struct.Node_hostname) - fmt.Printf("%s:\t %d\n", "node state", go_struct.Node_state) - fmt.Printf("%s:\t %s\n", "os", go_struct.Os) - fmt.Printf("%s:\t %d\n", "real memory", go_struct.Real_memory) - fmt.Printf("%s:\t %s\n", "reason", go_struct.Reason) - fmt.Printf("%s:\t %d\n", "reason time", go_struct.Reason_time) - fmt.Printf("%s:\t %d\n", "reason uid", go_struct.Reason_uid) - fmt.Printf("%s:\t %d\n", "slurmd start time", go_struct.Slurmd_start_time) - fmt.Printf("%s:\t %d\n", "sockets", go_struct.Sockets) - fmt.Printf("%s:\t %d\n", "threads", go_struct.Threads) - fmt.Printf("%s:\t %d\n", "tmp disk", go_struct.Tmp_disk) - fmt.Printf("%s:\t %d\n", "weight", go_struct.Weight) -} - -type Node_info_msg struct { - Last_update int64 - Record_count uint32 - Error_code uint32 - Node_list []Node_info -} - -func Get_all_nodes() Node_info_msg { - var go_node_buffer Node_info_msg - c_node_buffer := C.get_node_info() - if c_node_buffer == nil { - go_node_buffer.Last_update = int64(0) - go_node_buffer.Record_count = uint32(0) - go_node_buffer.Error_code = uint32(C.slurm_get_errno()) - return go_node_buffer - } - go_node_buffer.Last_update = int64(c_node_buffer.last_update) - go_node_buffer.Record_count = uint32(c_node_buffer.record_count) - go_node_buffer.Node_list = make([]Node_info, c_node_buffer.record_count, c_node_buffer.record_count) - for i := uint32(0); i < go_node_buffer.Record_count; i++ { - node := C.node_from_list(c_node_buffer, C.int(i)) - go_node := Node_info_convert_c_to_go(node) - go_node_buffer.Node_list[i] = go_node - } - C.slurm_free_node_info_msg(c_node_buffer) - - return go_node_buffer -} - -func Get_node_info(name string) Node_info_msg { - - var go_node_buffer Node_info_msg - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) - c_node_buffer := C.get_single_node_info(c_name) - if c_node_buffer == nil { - go_node_buffer.Last_update = int64(0) - go_node_buffer.Record_count = uint32(0) - go_node_buffer.Error_code = uint32(C.slurm_get_errno()) - - return go_node_buffer - } - go_node_buffer.Last_update = int64(c_node_buffer.last_update) - go_node_buffer.Record_count = uint32(c_node_buffer.record_count) - go_node_buffer.Node_list = make([]Node_info, c_node_buffer.record_count, c_node_buffer.record_count) - for i := uint32(0); i < go_node_buffer.Record_count; i++ { - node := C.node_from_list(c_node_buffer, C.int(i)) - go_node := Node_info_convert_c_to_go(node) - go_node_buffer.Node_list[i] = go_node - } - C.slurm_free_node_info_msg(c_node_buffer) - - return go_node_buffer - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/partitioninfo/slurm_partition_info.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/partitioninfo/slurm_partition_info.go deleted file mode 100644 index 713cb785..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/partitioninfo/slurm_partition_info.go +++ /dev/null @@ -1,183 +0,0 @@ -package partition_info - -/* -#cgo LDFLAGS: -lslurm -#include -#include - - -uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -int32_t int32_ptr(int32_t* pointer, int off) { - if (NULL == pointer) { - return -1;} - pointer+=off; - return *pointer; -} -uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} - - struct partition_info_msg *get_partition_info(){ - struct partition_info_msg* partition_buffer; - if( slurm_load_partitions ((time_t) NULL, - &partition_buffer, SHOW_ALL)) - return NULL; - return partition_buffer; - } - struct partition_info* partition_from_list(struct partition_info_msg *list, int i){ - return &list->partition_array[i]; -} - void free_partition_buffer(void* buffer){ - - slurm_free_partition_info_msg ((struct partition_info_msg*)buffer); - } - int find_node_inx(int32_t* node){ - int ret = 0; - while(*node != -1) { node++; ret++;}; - return ret; -} - - -*/ -import "C" - -import "fmt" - -type Partition_info struct { - Allow_alloc_nodes string - Allow_groups string - Alternate string - Cr_type uint16 - Def_mem_per_cpu uint64 - Default_time uint32 - Flags uint16 - Grace_time uint32 - Max_cpus_per_node uint32 - Max_mem_per_cpu uint64 - Max_nodes uint32 - Max_share uint16 - Max_time uint32 - Min_nodes uint32 - Name string - Node_inx []int32 - Nodes string - Preempt_mode uint16 - State_up uint16 - Total_cpus uint32 - Total_nodes uint32 -} - -func Partition_info_convert_c_to_go(c_struct *C.struct_partition_info) Partition_info { - var go_struct Partition_info - - go_struct.Allow_alloc_nodes = C.GoString(c_struct.allow_alloc_nodes) - go_struct.Allow_groups = C.GoString(c_struct.allow_groups) - go_struct.Alternate = C.GoString(c_struct.alternate) - go_struct.Cr_type = uint16(c_struct.cr_type) - go_struct.Def_mem_per_cpu = uint64(c_struct.def_mem_per_cpu) - go_struct.Default_time = uint32(c_struct.default_time) - go_struct.Flags = uint16(c_struct.flags) - go_struct.Grace_time = uint32(c_struct.grace_time) - go_struct.Max_cpus_per_node = uint32(c_struct.max_cpus_per_node) - go_struct.Max_mem_per_cpu = uint64(c_struct.max_mem_per_cpu) - go_struct.Max_nodes = uint32(c_struct.max_nodes) - go_struct.Max_share = uint16(c_struct.max_share) - go_struct.Max_time = uint32(c_struct.max_time) - go_struct.Min_nodes = uint32(c_struct.min_nodes) - go_struct.Name = C.GoString(c_struct.name) - t := C.find_node_inx(c_struct.node_inx) - - fmt.Printf("%d", t) - go_struct.Node_inx = make([]int32, t, t) - for i := int32(0); i < int32(t); i++ { - go_struct.Node_inx[i] = int32(C.int32_ptr(c_struct.node_inx, C.int(i))) - - } - go_struct.Nodes = C.GoString(c_struct.nodes) - go_struct.Preempt_mode = uint16(c_struct.preempt_mode) - go_struct.State_up = uint16(c_struct.state_up) - go_struct.Total_cpus = uint32(c_struct.total_cpus) - go_struct.Total_nodes = uint32(c_struct.total_nodes) - return go_struct -} -func Print_Partition_info(go_struct Partition_info) { - fmt.Printf("%s:\t %s\n", "allow alloc nodes", go_struct.Allow_alloc_nodes) - fmt.Printf("%s:\t %s\n", "allow groups", go_struct.Allow_groups) - fmt.Printf("%s:\t %s\n", "alternate", go_struct.Alternate) - fmt.Printf("%s:\t %d\n", "cr type", go_struct.Cr_type) - fmt.Printf("%s:\t %d\n", "def mem per cpu", go_struct.Def_mem_per_cpu) - fmt.Printf("%s:\t %d\n", "default time", go_struct.Default_time) - fmt.Printf("%s:\t %d\n", "flags", go_struct.Flags) - fmt.Printf("%s:\t %d\n", "grace time", go_struct.Grace_time) - fmt.Printf("%s:\t %d\n", "max cpus per node", go_struct.Max_cpus_per_node) - fmt.Printf("%s:\t %d\n", "max mem per cpu", go_struct.Max_mem_per_cpu) - fmt.Printf("%s:\t %d\n", "max nodes", go_struct.Max_nodes) - fmt.Printf("%s:\t %d\n", "max share", go_struct.Max_share) - fmt.Printf("%s:\t %d\n", "max time", go_struct.Max_time) - fmt.Printf("%s:\t %d\n", "min nodes", go_struct.Min_nodes) - fmt.Printf("%s:\t %s\n", "name", go_struct.Name) - fmt.Printf("%s:\t %d\n", "node inx", go_struct.Node_inx) - fmt.Printf("%s:\t %s\n", "nodes", go_struct.Nodes) - fmt.Printf("%s:\t %d\n", "preempt mode", go_struct.Preempt_mode) - fmt.Printf("%s:\t %d\n", "state up", go_struct.State_up) - fmt.Printf("%s:\t %d\n", "total cpus", go_struct.Total_cpus) - fmt.Printf("%s:\t %d\n", "total nodes", go_struct.Total_nodes) -} - -type Partition_info_msg struct { - Last_update int64 - Record_count uint32 - Partition_list []Partition_info -} - -func Get_partitions() Partition_info_msg { - var go_partition_buffer Partition_info_msg - c_partition_buffer := C.get_partition_info() - if c_partition_buffer == nil { - go_partition_buffer.Last_update = int64(0) - go_partition_buffer.Record_count = uint32(0) - return go_partition_buffer - } - go_partition_buffer.Last_update = int64(c_partition_buffer.last_update) - go_partition_buffer.Record_count = uint32(c_partition_buffer.record_count) - go_partition_buffer.Partition_list = make([]Partition_info, c_partition_buffer.record_count, c_partition_buffer.record_count) - for i := uint32(0); i < go_partition_buffer.Record_count; i++ { - partition := C.partition_from_list(c_partition_buffer, C.int(i)) - go_partition := Partition_info_convert_c_to_go(partition) - go_partition_buffer.Partition_list[i] = go_partition - } - C.slurm_free_partition_info_msg(c_partition_buffer) - - return go_partition_buffer -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/qos/get_qos_info.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/qos/get_qos_info.go deleted file mode 100644 index 8b115d47..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/qos/get_qos_info.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -/* -#cgo LDFLAGS: -lslurmdb - -#include -#include -#include - -slurmdb_qos_rec_t Get_qos() { - - slurmdb_qos_cond_t *qos_cond = NULL; - void *conn = slurmdb_connection_get(); - List asdlist = slurmdb_qos_get(conn, qos_cond); - uint16_t size = slurm_list_count(asdlist); - slurmdb_qos_rec_t QosArray[size]; - - slurmdb_qos_rec_t *rec = NULL; - ListIterator itr = slurm_list_iterator_create(asdlist); - - int i = 0; - while ((rec = slurm_list_next(itr))) { - QosArray[i] = *rec; - i++; - } - slurm_list_destroy(asdlist); - return *QosArray; -} -*/ -import "C" -import "fmt" - -func main() { - a := C.Get_qos() - fmt.Println("name: ", C.GoString(a.name)) -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/slurm.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/slurm.go deleted file mode 100644 index 9c74545a..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/slurm.go +++ /dev/null @@ -1,574 +0,0 @@ -package slurm - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#ifndef ptr_convert -#define ptr_convert - -struct slurm_ctl_conf* get_config(uint64_t time){ - slurm_ctl_conf_t * config = NULL; - slurm_load_ctl_conf ((time_t) time, &config); - return config; - -} - -inline uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int32_t int32_ptr(int32_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -inline int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return -1;} - return *pointer; -} -#endif -*/ -import "C" - -import "fmt" - -type Ctl_conf struct { - Last_update int64 - Accounting_storage_tres string - Accounting_storage_enforce uint16 - Accounting_storage_backup_host string - Accounting_storage_host string - Accounting_storage_loc string - Accounting_storage_pass string - Accounting_storage_port uint32 - Accounting_storage_type string - Accounting_storage_user string - Acctng_store_job_comment uint16 - //acct_gather_conf void; - Acct_gather_energy_type string - Acct_gather_profile_type string - Acct_gather_filesystem_type string - Acct_gather_node_freq uint16 - Authtype string - Batch_start_timeout uint16 - Boot_time int64 - //cgroup_conf void; - Checkpoint_type string - Cluster_name string - Complete_wait uint16 - Debug_flags uint64 - Def_mem_per_cpu uint64 - Disable_root_jobs uint16 - Enforce_part_limits uint16 - Epilog string - Epilog_msg_time uint32 - Epilog_slurmctld string - Ext_sensors_type string - Ext_sensors_freq uint16 - //ext_sensors_conf void; - Fast_schedule uint16 - First_job_id uint32 - Get_env_timeout uint16 - Gres_plugins string - Hash_val uint32 - Health_check_interval uint16 - Health_check_node_state uint16 - Health_check_program string - Inactive_limit uint16 - Job_acct_gather_freq string - Job_acct_gather_type string - Job_ckpt_dir string - Job_comp_host string - Job_comp_loc string - Job_comp_pass string - Job_comp_port uint32 - Job_comp_type string - Job_comp_user string - Job_credential_private_key string - Job_credential_public_certificate string - Job_file_append uint16 - Job_requeue uint16 - Job_submit_plugins string - Keep_alive_time uint16 - Kill_on_bad_exit uint16 - Kill_wait uint16 - Launch_type string - Licenses string - Licenses_used string - Mail_prog string - Max_array_sz uint32 - Max_job_cnt uint32 - Max_job_id uint32 - Max_mem_per_cpu uint64 - Max_step_cnt uint32 - Max_tasks_per_node uint16 - Min_job_age uint32 - Mpi_default string - Mpi_params string - Msg_timeout uint16 - Next_job_id uint32 - //node_features_conf void; - Node_prefix string - Over_time_limit uint16 - Plugindir string - Plugstack string - Preempt_mode uint16 - Preempt_type string - Priority_decay_hl uint32 - Priority_calc_period uint32 - Priority_favor_small uint16 - Priority_flags uint16 - Priority_max_age uint32 - Priority_reset_period uint16 - Priority_type string - Priority_weight_age uint32 - Priority_weight_fs uint32 - Priority_weight_js uint32 - Priority_weight_part uint32 - Priority_weight_qos uint32 - Private_data uint16 - Proctrack_type string - Prolog string - Prolog_slurmctld string - Propagate_prio_process uint16 - Propagate_rlimits string - Propagate_rlimits_except string - Reboot_program string - Reconfig_flags uint16 - Resume_program string - Resume_rate uint16 - Resume_timeout uint16 - Resv_epilog string - Resv_over_run uint16 - Resv_prolog string - Ret2service uint16 - Salloc_default_command string - Sched_logfile string - Sched_log_level uint16 - Sched_params string - Sched_time_slice uint16 - Schedtype string - Select_type string - //select_conf_key_pairs void; - Select_type_param uint16 - Slurm_conf string - Slurm_user_id uint32 - Slurm_user_name string - Slurmd_user_id uint32 - Slurmd_user_name string - Slurmctld_debug uint16 - Slurmctld_logfile string - Slurmctld_pidfile string - Slurmctld_plugstack string - //slurmctld_plugstack_conf void; - Slurmctld_port uint32 - Slurmctld_port_count uint16 - Slurmctld_timeout uint16 - Slurmd_debug uint16 - Slurmd_logfile string - Slurmd_pidfile string - Slurmd_port uint32 - Slurmd_spooldir string - Slurmd_timeout uint16 - Srun_epilog string - Srun_prolog string - State_save_location string - Suspend_exc_nodes string - Suspend_exc_parts string - Suspend_program string - Suspend_rate uint16 - Suspend_time uint32 - Suspend_timeout uint16 - Switch_type string - Task_epilog string - Task_plugin string - Task_plugin_param uint32 - Task_prolog string - Tmp_fs string - Topology_plugin string - Track_wckey uint16 - Tree_width uint16 - Unkillable_program string - Unkillable_timeout uint16 - Use_pam uint16 - Version string - Vsize_factor uint16 - Wait_time uint16 -} - -func Ctl_conf_convert_c_to_go(c_struct *C.struct_slurm_ctl_conf) Ctl_conf { - var go_struct Ctl_conf - - go_struct.Last_update = int64(c_struct.last_update) - go_struct.Accounting_storage_enforce = uint16(c_struct.accounting_storage_enforce) - go_struct.Accounting_storage_backup_host = C.GoString(c_struct.accounting_storage_backup_host) - go_struct.Accounting_storage_host = C.GoString(c_struct.accounting_storage_host) - go_struct.Accounting_storage_loc = C.GoString(c_struct.accounting_storage_loc) - go_struct.Accounting_storage_pass = C.GoString(c_struct.accounting_storage_pass) - go_struct.Accounting_storage_port = uint32(c_struct.accounting_storage_port) - go_struct.Accounting_storage_type = C.GoString(c_struct.accounting_storage_type) - go_struct.Accounting_storage_user = C.GoString(c_struct.accounting_storage_user) - go_struct.Acctng_store_job_comment = uint16(c_struct.acctng_store_job_comment) - go_struct.Acct_gather_energy_type = C.GoString(c_struct.acct_gather_energy_type) - go_struct.Acct_gather_profile_type = C.GoString(c_struct.acct_gather_profile_type) - go_struct.Acct_gather_filesystem_type = C.GoString(c_struct.acct_gather_filesystem_type) - go_struct.Acct_gather_node_freq = uint16(c_struct.acct_gather_node_freq) - go_struct.Authtype = C.GoString(c_struct.authtype) - go_struct.Batch_start_timeout = uint16(c_struct.batch_start_timeout) - go_struct.Boot_time = int64(c_struct.boot_time) - go_struct.Checkpoint_type = C.GoString(c_struct.checkpoint_type) - go_struct.Cluster_name = C.GoString(c_struct.cluster_name) - go_struct.Complete_wait = uint16(c_struct.complete_wait) - go_struct.Debug_flags = uint64(c_struct.debug_flags) - go_struct.Def_mem_per_cpu = uint64(c_struct.def_mem_per_cpu) - go_struct.Disable_root_jobs = uint16(c_struct.disable_root_jobs) - go_struct.Enforce_part_limits = uint16(c_struct.enforce_part_limits) - go_struct.Epilog = C.GoString(c_struct.epilog) - go_struct.Epilog_msg_time = uint32(c_struct.epilog_msg_time) - go_struct.Epilog_slurmctld = C.GoString(c_struct.epilog_slurmctld) - go_struct.Ext_sensors_type = C.GoString(c_struct.ext_sensors_type) - go_struct.Ext_sensors_freq = uint16(c_struct.ext_sensors_freq) - go_struct.Fast_schedule = uint16(c_struct.fast_schedule) - go_struct.First_job_id = uint32(c_struct.first_job_id) - go_struct.Get_env_timeout = uint16(c_struct.get_env_timeout) - go_struct.Gres_plugins = C.GoString(c_struct.gres_plugins) - go_struct.Hash_val = uint32(c_struct.hash_val) - go_struct.Health_check_interval = uint16(c_struct.health_check_interval) - go_struct.Health_check_node_state = uint16(c_struct.health_check_node_state) - go_struct.Health_check_program = C.GoString(c_struct.health_check_program) - go_struct.Inactive_limit = uint16(c_struct.inactive_limit) - go_struct.Job_acct_gather_freq = C.GoString(c_struct.job_acct_gather_freq) - go_struct.Job_acct_gather_type = C.GoString(c_struct.job_acct_gather_type) - go_struct.Job_ckpt_dir = C.GoString(c_struct.job_ckpt_dir) - go_struct.Job_comp_host = C.GoString(c_struct.job_comp_host) - go_struct.Job_comp_loc = C.GoString(c_struct.job_comp_loc) - go_struct.Job_comp_pass = C.GoString(c_struct.job_comp_pass) - go_struct.Job_comp_port = uint32(c_struct.job_comp_port) - go_struct.Job_comp_type = C.GoString(c_struct.job_comp_type) - go_struct.Job_comp_user = C.GoString(c_struct.job_comp_user) - go_struct.Job_credential_private_key = C.GoString(c_struct.job_credential_private_key) - go_struct.Job_credential_public_certificate = C.GoString(c_struct.job_credential_public_certificate) - go_struct.Job_file_append = uint16(c_struct.job_file_append) - go_struct.Job_requeue = uint16(c_struct.job_requeue) - go_struct.Job_submit_plugins = C.GoString(c_struct.job_submit_plugins) - go_struct.Keep_alive_time = uint16(c_struct.keep_alive_time) - go_struct.Kill_on_bad_exit = uint16(c_struct.kill_on_bad_exit) - go_struct.Kill_wait = uint16(c_struct.kill_wait) - go_struct.Launch_type = C.GoString(c_struct.launch_type) - go_struct.Licenses = C.GoString(c_struct.licenses) - go_struct.Licenses_used = C.GoString(c_struct.licenses_used) - go_struct.Mail_prog = C.GoString(c_struct.mail_prog) - go_struct.Max_array_sz = uint32(c_struct.max_array_sz) - go_struct.Max_job_cnt = uint32(c_struct.max_job_cnt) - go_struct.Max_job_id = uint32(c_struct.max_job_id) - go_struct.Max_mem_per_cpu = uint64(c_struct.max_mem_per_cpu) - go_struct.Max_step_cnt = uint32(c_struct.max_step_cnt) - go_struct.Max_tasks_per_node = uint16(c_struct.max_tasks_per_node) - go_struct.Min_job_age = uint32(c_struct.min_job_age) - go_struct.Mpi_default = C.GoString(c_struct.mpi_default) - go_struct.Mpi_params = C.GoString(c_struct.mpi_params) - go_struct.Msg_timeout = uint16(c_struct.msg_timeout) - go_struct.Next_job_id = uint32(c_struct.next_job_id) - go_struct.Node_prefix = C.GoString(c_struct.node_prefix) - go_struct.Over_time_limit = uint16(c_struct.over_time_limit) - go_struct.Plugindir = C.GoString(c_struct.plugindir) - go_struct.Plugstack = C.GoString(c_struct.plugstack) - go_struct.Preempt_mode = uint16(c_struct.preempt_mode) - go_struct.Preempt_type = C.GoString(c_struct.preempt_type) - go_struct.Priority_decay_hl = uint32(c_struct.priority_decay_hl) - go_struct.Priority_calc_period = uint32(c_struct.priority_calc_period) - go_struct.Priority_favor_small = uint16(c_struct.priority_favor_small) - go_struct.Priority_flags = uint16(c_struct.priority_flags) - go_struct.Priority_max_age = uint32(c_struct.priority_max_age) - go_struct.Priority_reset_period = uint16(c_struct.priority_reset_period) - go_struct.Priority_type = C.GoString(c_struct.priority_type) - go_struct.Priority_weight_age = uint32(c_struct.priority_weight_age) - go_struct.Priority_weight_fs = uint32(c_struct.priority_weight_fs) - go_struct.Priority_weight_js = uint32(c_struct.priority_weight_js) - go_struct.Priority_weight_part = uint32(c_struct.priority_weight_part) - go_struct.Priority_weight_qos = uint32(c_struct.priority_weight_qos) - go_struct.Private_data = uint16(c_struct.private_data) - go_struct.Proctrack_type = C.GoString(c_struct.proctrack_type) - go_struct.Prolog = C.GoString(c_struct.prolog) - go_struct.Prolog_slurmctld = C.GoString(c_struct.prolog_slurmctld) - go_struct.Propagate_prio_process = uint16(c_struct.propagate_prio_process) - go_struct.Propagate_rlimits = C.GoString(c_struct.propagate_rlimits) - go_struct.Propagate_rlimits_except = C.GoString(c_struct.propagate_rlimits_except) - go_struct.Reboot_program = C.GoString(c_struct.reboot_program) - go_struct.Reconfig_flags = uint16(c_struct.reconfig_flags) - go_struct.Resume_program = C.GoString(c_struct.resume_program) - go_struct.Resume_rate = uint16(c_struct.resume_rate) - go_struct.Resume_timeout = uint16(c_struct.resume_timeout) - go_struct.Resv_epilog = C.GoString(c_struct.resv_epilog) - go_struct.Resv_over_run = uint16(c_struct.resv_over_run) - go_struct.Resv_prolog = C.GoString(c_struct.resv_prolog) - go_struct.Ret2service = uint16(c_struct.ret2service) - go_struct.Salloc_default_command = C.GoString(c_struct.salloc_default_command) - go_struct.Sched_logfile = C.GoString(c_struct.sched_logfile) - go_struct.Sched_log_level = uint16(c_struct.sched_log_level) - go_struct.Sched_params = C.GoString(c_struct.sched_params) - go_struct.Sched_time_slice = uint16(c_struct.sched_time_slice) - go_struct.Schedtype = C.GoString(c_struct.schedtype) - go_struct.Select_type = C.GoString(c_struct.select_type) - go_struct.Select_type_param = uint16(c_struct.select_type_param) - go_struct.Slurm_conf = C.GoString(c_struct.slurm_conf) - go_struct.Slurm_user_id = uint32(c_struct.slurm_user_id) - go_struct.Slurm_user_name = C.GoString(c_struct.slurm_user_name) - go_struct.Slurmd_user_id = uint32(c_struct.slurmd_user_id) - go_struct.Slurmd_user_name = C.GoString(c_struct.slurmd_user_name) - go_struct.Slurmctld_debug = uint16(c_struct.slurmctld_debug) - go_struct.Slurmctld_logfile = C.GoString(c_struct.slurmctld_logfile) - go_struct.Slurmctld_pidfile = C.GoString(c_struct.slurmctld_pidfile) - go_struct.Slurmctld_plugstack = C.GoString(c_struct.slurmctld_plugstack) - go_struct.Slurmctld_port = uint32(c_struct.slurmctld_port) - go_struct.Slurmctld_port_count = uint16(c_struct.slurmctld_port_count) - go_struct.Slurmctld_timeout = uint16(c_struct.slurmctld_timeout) - go_struct.Slurmd_debug = uint16(c_struct.slurmd_debug) - go_struct.Slurmd_logfile = C.GoString(c_struct.slurmd_logfile) - go_struct.Slurmd_pidfile = C.GoString(c_struct.slurmd_pidfile) - go_struct.Slurmd_port = uint32(c_struct.slurmd_port) - go_struct.Slurmd_spooldir = C.GoString(c_struct.slurmd_spooldir) - go_struct.Slurmd_timeout = uint16(c_struct.slurmd_timeout) - go_struct.Srun_epilog = C.GoString(c_struct.srun_epilog) - go_struct.Srun_prolog = C.GoString(c_struct.srun_prolog) - go_struct.State_save_location = C.GoString(c_struct.state_save_location) - go_struct.Suspend_exc_nodes = C.GoString(c_struct.suspend_exc_nodes) - go_struct.Suspend_exc_parts = C.GoString(c_struct.suspend_exc_parts) - go_struct.Suspend_program = C.GoString(c_struct.suspend_program) - go_struct.Suspend_rate = uint16(c_struct.suspend_rate) - go_struct.Suspend_time = uint32(c_struct.suspend_time) - go_struct.Suspend_timeout = uint16(c_struct.suspend_timeout) - go_struct.Switch_type = C.GoString(c_struct.switch_type) - go_struct.Task_epilog = C.GoString(c_struct.task_epilog) - go_struct.Task_plugin = C.GoString(c_struct.task_plugin) - go_struct.Task_plugin_param = uint32(c_struct.task_plugin_param) - go_struct.Task_prolog = C.GoString(c_struct.task_prolog) - go_struct.Tmp_fs = C.GoString(c_struct.tmp_fs) - go_struct.Topology_plugin = C.GoString(c_struct.topology_plugin) - go_struct.Track_wckey = uint16(c_struct.track_wckey) - go_struct.Tree_width = uint16(c_struct.tree_width) - go_struct.Unkillable_program = C.GoString(c_struct.unkillable_program) - go_struct.Unkillable_timeout = uint16(c_struct.unkillable_timeout) - go_struct.Use_pam = uint16(c_struct.use_pam) - go_struct.Version = C.GoString(c_struct.version) - go_struct.Vsize_factor = uint16(c_struct.vsize_factor) - go_struct.Wait_time = uint16(c_struct.wait_time) - return go_struct -} - -func Print_Ctl_conf(go_struct Ctl_conf) { - fmt.Printf("%s:\t %d\n", "last update", go_struct.Last_update) - fmt.Printf("%s:\t %s\n", "accounting storage tres", go_struct.Accounting_storage_tres) - fmt.Printf("%s:\t %d\n", "accounting storage enforce", go_struct.Accounting_storage_enforce) - fmt.Printf("%s:\t %s\n", "accounting storage backup host", go_struct.Accounting_storage_backup_host) - fmt.Printf("%s:\t %s\n", "accounting storage host", go_struct.Accounting_storage_host) - fmt.Printf("%s:\t %s\n", "accounting storage loc", go_struct.Accounting_storage_loc) - fmt.Printf("%s:\t %s\n", "accounting storage pass", go_struct.Accounting_storage_pass) - fmt.Printf("%s:\t %d\n", "accounting storage port", go_struct.Accounting_storage_port) - fmt.Printf("%s:\t %s\n", "accounting storage type", go_struct.Accounting_storage_type) - fmt.Printf("%s:\t %s\n", "accounting storage user", go_struct.Accounting_storage_user) - fmt.Printf("%s:\t %d\n", "acctng store job comment", go_struct.Acctng_store_job_comment) - fmt.Printf("%s:\t %s\n", "acct gather energy type", go_struct.Acct_gather_energy_type) - fmt.Printf("%s:\t %s\n", "acct gather profile type", go_struct.Acct_gather_profile_type) - fmt.Printf("%s:\t %s\n", "acct gather filesystem type", go_struct.Acct_gather_filesystem_type) - fmt.Printf("%s:\t %d\n", "acct gather node freq", go_struct.Acct_gather_node_freq) - fmt.Printf("%s:\t %s\n", "authtype", go_struct.Authtype) - fmt.Printf("%s:\t %d\n", "batch start timeout", go_struct.Batch_start_timeout) - fmt.Printf("%s:\t %d\n", "boot time", go_struct.Boot_time) - fmt.Printf("%s:\t %s\n", "checkpoint type", go_struct.Checkpoint_type) - fmt.Printf("%s:\t %s\n", "user name", go_struct.Cluster_name) - fmt.Printf("%s:\t %d\n", "complete wait", go_struct.Complete_wait) - fmt.Printf("%s:\t %d\n", "debug flags", go_struct.Debug_flags) - fmt.Printf("%s:\t %d\n", "def mem per cpu", go_struct.Def_mem_per_cpu) - fmt.Printf("%s:\t %d\n", "disable root jobs", go_struct.Disable_root_jobs) - fmt.Printf("%s:\t %d\n", "enforce part limits", go_struct.Enforce_part_limits) - fmt.Printf("%s:\t %s\n", "epilog", go_struct.Epilog) - fmt.Printf("%s:\t %d\n", "epilog msg time", go_struct.Epilog_msg_time) - fmt.Printf("%s:\t %s\n", "epilog slurmctld", go_struct.Epilog_slurmctld) - fmt.Printf("%s:\t %s\n", "ext sensors type", go_struct.Ext_sensors_type) - fmt.Printf("%s:\t %d\n", "ext sensors freq", go_struct.Ext_sensors_freq) - fmt.Printf("%s:\t %d\n", "fast schedule", go_struct.Fast_schedule) - fmt.Printf("%s:\t %d\n", "first job id", go_struct.First_job_id) - fmt.Printf("%s:\t %d\n", "get env timeout", go_struct.Get_env_timeout) - fmt.Printf("%s:\t %s\n", "gres plugins", go_struct.Gres_plugins) - fmt.Printf("%s:\t %d\n", "hash val", go_struct.Hash_val) - fmt.Printf("%s:\t %d\n", "health check interval", go_struct.Health_check_interval) - fmt.Printf("%s:\t %d\n", "health check node state", go_struct.Health_check_node_state) - fmt.Printf("%s:\t %s\n", "health check program", go_struct.Health_check_program) - fmt.Printf("%s:\t %d\n", "inactive limit", go_struct.Inactive_limit) - fmt.Printf("%s:\t %s\n", "job acct gather freq", go_struct.Job_acct_gather_freq) - fmt.Printf("%s:\t %s\n", "job acct gather type", go_struct.Job_acct_gather_type) - fmt.Printf("%s:\t %s\n", "job ckpt dir", go_struct.Job_ckpt_dir) - fmt.Printf("%s:\t %s\n", "job comp host", go_struct.Job_comp_host) - fmt.Printf("%s:\t %s\n", "job comp loc", go_struct.Job_comp_loc) - fmt.Printf("%s:\t %s\n", "job comp pass", go_struct.Job_comp_pass) - fmt.Printf("%s:\t %d\n", "job comp port", go_struct.Job_comp_port) - fmt.Printf("%s:\t %s\n", "job comp type", go_struct.Job_comp_type) - fmt.Printf("%s:\t %s\n", "job comp user", go_struct.Job_comp_user) - fmt.Printf("%s:\t %s\n", "job credential private key", go_struct.Job_credential_private_key) - fmt.Printf("%s:\t %s\n", "job credential public certificate", go_struct.Job_credential_public_certificate) - fmt.Printf("%s:\t %d\n", "job file append", go_struct.Job_file_append) - fmt.Printf("%s:\t %d\n", "job requeue", go_struct.Job_requeue) - fmt.Printf("%s:\t %s\n", "job submit plugins", go_struct.Job_submit_plugins) - fmt.Printf("%s:\t %d\n", "keep alive time", go_struct.Keep_alive_time) - fmt.Printf("%s:\t %d\n", "kill on bad exit", go_struct.Kill_on_bad_exit) - fmt.Printf("%s:\t %d\n", "kill wait", go_struct.Kill_wait) - fmt.Printf("%s:\t %s\n", "launch type", go_struct.Launch_type) - fmt.Printf("%s:\t %s\n", "licenses", go_struct.Licenses) - fmt.Printf("%s:\t %s\n", "licenses used", go_struct.Licenses_used) - fmt.Printf("%s:\t %s\n", "mail prog", go_struct.Mail_prog) - fmt.Printf("%s:\t %d\n", "max array sz", go_struct.Max_array_sz) - fmt.Printf("%s:\t %d\n", "max job cnt", go_struct.Max_job_cnt) - fmt.Printf("%s:\t %d\n", "max job id", go_struct.Max_job_id) - fmt.Printf("%s:\t %d\n", "max mem per cpu", go_struct.Max_mem_per_cpu) - fmt.Printf("%s:\t %d\n", "max step cnt", go_struct.Max_step_cnt) - fmt.Printf("%s:\t %d\n", "max tasks per node", go_struct.Max_tasks_per_node) - fmt.Printf("%s:\t %d\n", "min job age", go_struct.Min_job_age) - fmt.Printf("%s:\t %s\n", "mpi default", go_struct.Mpi_default) - fmt.Printf("%s:\t %s\n", "mpi params", go_struct.Mpi_params) - fmt.Printf("%s:\t %d\n", "msg timeout", go_struct.Msg_timeout) - fmt.Printf("%s:\t %d\n", "next job id", go_struct.Next_job_id) - fmt.Printf("%s:\t %s\n", "node prefix", go_struct.Node_prefix) - fmt.Printf("%s:\t %d\n", "over time limit", go_struct.Over_time_limit) - fmt.Printf("%s:\t %s\n", "plugindir", go_struct.Plugindir) - fmt.Printf("%s:\t %s\n", "plugstack", go_struct.Plugstack) - fmt.Printf("%s:\t %d\n", "preempt mode", go_struct.Preempt_mode) - fmt.Printf("%s:\t %s\n", "preempt type", go_struct.Preempt_type) - fmt.Printf("%s:\t %d\n", "priority decay hl", go_struct.Priority_decay_hl) - fmt.Printf("%s:\t %d\n", "priority calc period", go_struct.Priority_calc_period) - fmt.Printf("%s:\t %d\n", "priority favor small", go_struct.Priority_favor_small) - fmt.Printf("%s:\t %d\n", "priority flags", go_struct.Priority_flags) - fmt.Printf("%s:\t %d\n", "priority max age", go_struct.Priority_max_age) - fmt.Printf("%s:\t %d\n", "priority reset period", go_struct.Priority_reset_period) - fmt.Printf("%s:\t %s\n", "priority type", go_struct.Priority_type) - fmt.Printf("%s:\t %d\n", "priority weight age", go_struct.Priority_weight_age) - fmt.Printf("%s:\t %d\n", "priority weight fs", go_struct.Priority_weight_fs) - fmt.Printf("%s:\t %d\n", "priority weight js", go_struct.Priority_weight_js) - fmt.Printf("%s:\t %d\n", "priority weight part", go_struct.Priority_weight_part) - fmt.Printf("%s:\t %d\n", "priority weight qos", go_struct.Priority_weight_qos) - fmt.Printf("%s:\t %d\n", "private data", go_struct.Private_data) - fmt.Printf("%s:\t %s\n", "proctrack type", go_struct.Proctrack_type) - fmt.Printf("%s:\t %s\n", "prolog", go_struct.Prolog) - fmt.Printf("%s:\t %s\n", "prolog slurmctld", go_struct.Prolog_slurmctld) - fmt.Printf("%s:\t %d\n", "propagate prio process", go_struct.Propagate_prio_process) - fmt.Printf("%s:\t %s\n", "propagate rlimits", go_struct.Propagate_rlimits) - fmt.Printf("%s:\t %s\n", "propagate rlimits except", go_struct.Propagate_rlimits_except) - fmt.Printf("%s:\t %s\n", "reboot program", go_struct.Reboot_program) - fmt.Printf("%s:\t %d\n", "reconfig flags", go_struct.Reconfig_flags) - fmt.Printf("%s:\t %s\n", "resume program", go_struct.Resume_program) - fmt.Printf("%s:\t %d\n", "resume rate", go_struct.Resume_rate) - fmt.Printf("%s:\t %d\n", "resume timeout", go_struct.Resume_timeout) - fmt.Printf("%s:\t %s\n", "resv epilog", go_struct.Resv_epilog) - fmt.Printf("%s:\t %d\n", "resv over run", go_struct.Resv_over_run) - fmt.Printf("%s:\t %s\n", "resv prolog", go_struct.Resv_prolog) - fmt.Printf("%s:\t %d\n", "ret2service", go_struct.Ret2service) - fmt.Printf("%s:\t %s\n", "salloc default command", go_struct.Salloc_default_command) - fmt.Printf("%s:\t %s\n", "sched logfile", go_struct.Sched_logfile) - fmt.Printf("%s:\t %d\n", "sched log level", go_struct.Sched_log_level) - fmt.Printf("%s:\t %s\n", "sched params", go_struct.Sched_params) - fmt.Printf("%s:\t %d\n", "sched time slice", go_struct.Sched_time_slice) - fmt.Printf("%s:\t %s\n", "schedtype", go_struct.Schedtype) - fmt.Printf("%s:\t %s\n", "select type", go_struct.Select_type) - fmt.Printf("%s:\t %d\n", "select type param", go_struct.Select_type_param) - fmt.Printf("%s:\t %s\n", "slurm conf", go_struct.Slurm_conf) - fmt.Printf("%s:\t %d\n", "slurm user id", go_struct.Slurm_user_id) - fmt.Printf("%s:\t %s\n", "slurm user name", go_struct.Slurm_user_name) - fmt.Printf("%s:\t %d\n", "slurmd user id", go_struct.Slurmd_user_id) - fmt.Printf("%s:\t %s\n", "slurmd user name", go_struct.Slurmd_user_name) - fmt.Printf("%s:\t %d\n", "slurmctld debug", go_struct.Slurmctld_debug) - fmt.Printf("%s:\t %s\n", "slurmctld logfile", go_struct.Slurmctld_logfile) - fmt.Printf("%s:\t %s\n", "slurmctld pidfile", go_struct.Slurmctld_pidfile) - fmt.Printf("%s:\t %s\n", "slurmctld plugstack", go_struct.Slurmctld_plugstack) - fmt.Printf("%s:\t %d\n", "slurmctld port", go_struct.Slurmctld_port) - fmt.Printf("%s:\t %d\n", "slurmctld port count", go_struct.Slurmctld_port_count) - fmt.Printf("%s:\t %d\n", "slurmctld timeout", go_struct.Slurmctld_timeout) - fmt.Printf("%s:\t %d\n", "slurmd debug", go_struct.Slurmd_debug) - fmt.Printf("%s:\t %s\n", "slurmd logfile", go_struct.Slurmd_logfile) - fmt.Printf("%s:\t %s\n", "slurmd pidfile", go_struct.Slurmd_pidfile) - fmt.Printf("%s:\t %d\n", "slurmd port", go_struct.Slurmd_port) - fmt.Printf("%s:\t %s\n", "slurmd spooldir", go_struct.Slurmd_spooldir) - fmt.Printf("%s:\t %d\n", "slurmd timeout", go_struct.Slurmd_timeout) - fmt.Printf("%s:\t %s\n", "srun epilog", go_struct.Srun_epilog) - fmt.Printf("%s:\t %s\n", "srun prolog", go_struct.Srun_prolog) - fmt.Printf("%s:\t %s\n", "state save location", go_struct.State_save_location) - fmt.Printf("%s:\t %s\n", "suspend exc nodes", go_struct.Suspend_exc_nodes) - fmt.Printf("%s:\t %s\n", "suspend exc parts", go_struct.Suspend_exc_parts) - fmt.Printf("%s:\t %s\n", "suspend program", go_struct.Suspend_program) - fmt.Printf("%s:\t %d\n", "suspend rate", go_struct.Suspend_rate) - fmt.Printf("%s:\t %d\n", "suspend time", go_struct.Suspend_time) - fmt.Printf("%s:\t %d\n", "suspend timeout", go_struct.Suspend_timeout) - fmt.Printf("%s:\t %s\n", "switch type", go_struct.Switch_type) - fmt.Printf("%s:\t %s\n", "task epilog", go_struct.Task_epilog) - fmt.Printf("%s:\t %s\n", "task plugin", go_struct.Task_plugin) - fmt.Printf("%s:\t %d\n", "task plugin param", go_struct.Task_plugin_param) - fmt.Printf("%s:\t %s\n", "task prolog", go_struct.Task_prolog) - fmt.Printf("%s:\t %s\n", "tmp fs", go_struct.Tmp_fs) - fmt.Printf("%s:\t %s\n", "topology plugin", go_struct.Topology_plugin) - fmt.Printf("%s:\t %d\n", "track wckey", go_struct.Track_wckey) - fmt.Printf("%s:\t %d\n", "tree width", go_struct.Tree_width) - fmt.Printf("%s:\t %s\n", "unkillable program", go_struct.Unkillable_program) - fmt.Printf("%s:\t %d\n", "unkillable timeout", go_struct.Unkillable_timeout) - fmt.Printf("%s:\t %d\n", "use pam", go_struct.Use_pam) - fmt.Printf("%s:\t %s\n", "version", go_struct.Version) - fmt.Printf("%s:\t %d\n", "vsize factor", go_struct.Vsize_factor) - fmt.Printf("%s:\t %d\n", "wait time", go_struct.Wait_time) -} - -func Version() int { - - ver := C.long(0) - ver = C.slurm_api_version() - - return int(ver) -} -func VersionString(v int) string { - - var major, minor, micro int - var version string - major = ((v >> 16) & 0xff) - minor = ((v >> 8) & 0xff) - micro = (v & 0xff) - version = fmt.Sprintf("%d.%d.%d", major, minor, micro) - return version -} - -func GetConfig() Ctl_conf { - - c_config := C.get_config(C.uint64_t(0)) - ret_config := Ctl_conf_convert_c_to_go(c_config) - return ret_config -} - -func GetErrorString(errno uint32) string { - msg := C.GoString(C.slurm_strerror(C.int(errno))) - return msg -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob/slurm_submit_job.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob/slurm_submit_job.go deleted file mode 100644 index 4cb9d761..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/submitjob/slurm_submit_job.go +++ /dev/null @@ -1,752 +0,0 @@ -package submit_job - -/* -#cgo LDFLAGS: -lslurm -#include -#include -#include -#include -#ifndef ptr_convert -#define ptr_convert -inline uint8_t uint8_ptr(uint8_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline int8_t int8_ptr(int8_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline uint16_t uint16_ptr(uint16_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline int16_t int16_ptr(int16_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline uint32_t uint32_ptr(uint32_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline int32_t int32_ptr(int32_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline uint64_t uint64_ptr(uint64_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} -inline int64_t int64_ptr(int16_t* pointer) { - if (NULL == pointer) { - return 0;} - return *pointer; -} - -#endif -struct submit_response_msg *submit_job(struct job_descriptor *desc) -{ - - struct submit_response_msg *resp_msg; - if (slurm_submit_batch_job(desc, - &resp_msg)) { - return NULL; - } - return resp_msg; - -} -int update_job (struct job_descriptor *msg) { - - return slurm_update_job (msg); -} - -void free_submit_response_msg(struct submit_response_msg *msg) -{ - slurm_free_submit_response_response_msg(msg); -} -*/ -import "C" - -import ( - job_info "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/cgo_tianhe/src/slurm/jobinfo" - "fmt" -) -import "unsafe" - -type Job_descriptor struct { - Account string - Acctg_freq string - Alloc_node string - Alloc_resp_port uint16 - Alloc_sid uint32 - Argc uint32 - Argv []string - Array_inx string - Begin_time int64 - Ckpt_interval uint16 - Ckpt_dir string - Comment string - Contiguous uint16 - Cpu_bind string - Cpu_bind_type uint16 - Dependency string - End_time int64 - Environment []string - Env_size uint32 - Exc_nodes string - Features string - Group_id uint32 - Immediate uint16 - Job_id uint32 - Kill_on_node_fail uint16 - Licenses string - Mail_type uint16 - Mail_user string - Mem_bind string - Mem_bind_type uint16 - Name string - Network string - Nice uint32 - Num_tasks uint32 - Open_mode uint8 - Other_port uint16 - Overcommit uint8 - Partition string - Plane_size uint16 - Priority uint32 - Profile uint32 - Qos string - Reboot uint16 - Resp_host string - Req_nodes string - Requeue uint16 - Reservation string - Script string - //script_buf void; - Shared uint16 - //spank_job_env char**; - Spank_job_env_size uint32 - Task_dist uint32 - Time_limit uint32 - Time_min uint32 - User_id uint32 - Wait_all_nodes uint16 - Warn_signal uint16 - Warn_time uint16 - Work_dir string - Cpus_per_task uint16 - Min_cpus uint32 - Max_cpus uint32 - Min_nodes uint32 - Max_nodes uint32 - Boards_per_node uint16 - Sockets_per_board uint16 - Sockets_per_node uint16 - Cores_per_socket uint16 - Threads_per_core uint16 - Ntasks_per_node uint16 - Ntasks_per_socket uint16 - Ntasks_per_core uint16 - Ntasks_per_board uint16 - Pn_min_cpus uint16 - Pn_min_memory uint64 - Pn_min_tmp_disk uint32 - Req_switch uint32 - Std_err string - Std_in string - Std_out string - Tres_req_cnt uint64 - Wait4switch uint32 - Wckey string -} - -func Job_descriptor_convert_c_to_go(c_struct *C.struct_job_descriptor) Job_descriptor { - var go_struct Job_descriptor - - go_struct.Account = C.GoString(c_struct.account) - go_struct.Acctg_freq = C.GoString(c_struct.acctg_freq) - go_struct.Alloc_node = C.GoString(c_struct.alloc_node) - go_struct.Alloc_resp_port = uint16(c_struct.alloc_resp_port) - go_struct.Alloc_sid = uint32(c_struct.alloc_sid) - go_struct.Argc = uint32(c_struct.argc) - go_struct.Array_inx = C.GoString(c_struct.array_inx) - go_struct.Begin_time = int64(c_struct.begin_time) - go_struct.Ckpt_interval = uint16(c_struct.ckpt_interval) - go_struct.Ckpt_dir = C.GoString(c_struct.ckpt_dir) - go_struct.Comment = C.GoString(c_struct.comment) - go_struct.Contiguous = uint16(c_struct.contiguous) - go_struct.Cpu_bind = C.GoString(c_struct.cpu_bind) - go_struct.Cpu_bind_type = uint16(c_struct.cpu_bind_type) - go_struct.Dependency = C.GoString(c_struct.dependency) - go_struct.End_time = int64(c_struct.end_time) - go_struct.Env_size = uint32(c_struct.env_size) - go_struct.Exc_nodes = C.GoString(c_struct.exc_nodes) - go_struct.Features = C.GoString(c_struct.features) - go_struct.Group_id = uint32(c_struct.group_id) - go_struct.Immediate = uint16(c_struct.immediate) - go_struct.Job_id = uint32(c_struct.job_id) - go_struct.Kill_on_node_fail = uint16(c_struct.kill_on_node_fail) - go_struct.Licenses = C.GoString(c_struct.licenses) - go_struct.Mail_type = uint16(c_struct.mail_type) - go_struct.Mail_user = C.GoString(c_struct.mail_user) - go_struct.Mem_bind = C.GoString(c_struct.mem_bind) - go_struct.Mem_bind_type = uint16(c_struct.mem_bind_type) - go_struct.Name = C.GoString(c_struct.name) - go_struct.Network = C.GoString(c_struct.network) - go_struct.Nice = uint32(c_struct.nice) - go_struct.Num_tasks = uint32(c_struct.num_tasks) - go_struct.Open_mode = uint8(c_struct.open_mode) - go_struct.Other_port = uint16(c_struct.other_port) - go_struct.Overcommit = uint8(c_struct.overcommit) - go_struct.Partition = C.GoString(c_struct.partition) - go_struct.Plane_size = uint16(c_struct.plane_size) - go_struct.Priority = uint32(c_struct.priority) - go_struct.Profile = uint32(c_struct.profile) - go_struct.Qos = C.GoString(c_struct.qos) - go_struct.Reboot = uint16(c_struct.reboot) - go_struct.Resp_host = C.GoString(c_struct.resp_host) - go_struct.Req_nodes = C.GoString(c_struct.req_nodes) - go_struct.Requeue = uint16(c_struct.requeue) - go_struct.Reservation = C.GoString(c_struct.reservation) - go_struct.Script = C.GoString(c_struct.script) - go_struct.Shared = uint16(c_struct.shared) - go_struct.Spank_job_env_size = uint32(c_struct.spank_job_env_size) - go_struct.Task_dist = uint32(c_struct.task_dist) - go_struct.Time_limit = uint32(c_struct.time_limit) - go_struct.Time_min = uint32(c_struct.time_min) - go_struct.User_id = uint32(c_struct.user_id) - go_struct.Wait_all_nodes = uint16(c_struct.wait_all_nodes) - go_struct.Warn_signal = uint16(c_struct.warn_signal) - go_struct.Warn_time = uint16(c_struct.warn_time) - go_struct.Work_dir = C.GoString(c_struct.work_dir) - go_struct.Cpus_per_task = uint16(c_struct.cpus_per_task) - go_struct.Min_cpus = uint32(c_struct.min_cpus) - go_struct.Max_cpus = uint32(c_struct.max_cpus) - go_struct.Min_nodes = uint32(c_struct.min_nodes) - go_struct.Max_nodes = uint32(c_struct.max_nodes) - go_struct.Boards_per_node = uint16(c_struct.boards_per_node) - go_struct.Sockets_per_board = uint16(c_struct.sockets_per_board) - go_struct.Sockets_per_node = uint16(c_struct.sockets_per_node) - go_struct.Cores_per_socket = uint16(c_struct.cores_per_socket) - go_struct.Threads_per_core = uint16(c_struct.threads_per_core) - go_struct.Ntasks_per_node = uint16(c_struct.ntasks_per_node) - go_struct.Ntasks_per_socket = uint16(c_struct.ntasks_per_socket) - go_struct.Ntasks_per_core = uint16(c_struct.ntasks_per_core) - go_struct.Ntasks_per_board = uint16(c_struct.ntasks_per_board) - go_struct.Pn_min_cpus = uint16(c_struct.pn_min_cpus) - go_struct.Pn_min_memory = uint64(c_struct.pn_min_memory) - go_struct.Pn_min_tmp_disk = uint32(c_struct.pn_min_tmp_disk) - go_struct.Req_switch = uint32(c_struct.req_switch) - go_struct.Std_err = C.GoString(c_struct.std_err) - go_struct.Std_in = C.GoString(c_struct.std_in) - go_struct.Std_out = C.GoString(c_struct.std_out) - go_struct.Wait4switch = uint32(c_struct.wait4switch) - go_struct.Wckey = C.GoString(c_struct.wckey) - return go_struct -} -func Print_Job_descriptor(go_struct Job_descriptor) { - fmt.Printf("%s:\t %s\n", "account", go_struct.Account) - fmt.Printf("%s:\t %s\n", "acctg freq", go_struct.Acctg_freq) - fmt.Printf("%s:\t %s\n", "alloc node", go_struct.Alloc_node) - fmt.Printf("%s:\t %d\n", "alloc resp port", go_struct.Alloc_resp_port) - fmt.Printf("%s:\t %d\n", "alloc sid", go_struct.Alloc_sid) - fmt.Printf("%s:\t %d\n", "argc", go_struct.Argc) - fmt.Printf("%s:\t %s\n", "array inx", go_struct.Array_inx) - fmt.Printf("%s:\t %d\n", "begin time", go_struct.Begin_time) - fmt.Printf("%s:\t %d\n", "ckpt interval", go_struct.Ckpt_interval) - fmt.Printf("%s:\t %s\n", "ckpt dir", go_struct.Ckpt_dir) - fmt.Printf("%s:\t %s\n", "comment", go_struct.Comment) - fmt.Printf("%s:\t %d\n", "contiguous", go_struct.Contiguous) - fmt.Printf("%s:\t %s\n", "cpu bind", go_struct.Cpu_bind) - fmt.Printf("%s:\t %d\n", "cpu bind type", go_struct.Cpu_bind_type) - fmt.Printf("%s:\t %s\n", "dependency", go_struct.Dependency) - fmt.Printf("%s:\t %d\n", "end time", go_struct.End_time) - fmt.Printf("%s:\t %d\n", "env size", go_struct.Env_size) - fmt.Printf("%s:\t %s\n", "exc nodes", go_struct.Exc_nodes) - fmt.Printf("%s:\t %s\n", "features", go_struct.Features) - fmt.Printf("%s:\t %d\n", "group id", go_struct.Group_id) - fmt.Printf("%s:\t %d\n", "immediate", go_struct.Immediate) - fmt.Printf("%s:\t %d\n", "job id", go_struct.Job_id) - fmt.Printf("%s:\t %d\n", "kill on node fail", go_struct.Kill_on_node_fail) - fmt.Printf("%s:\t %s\n", "licenses", go_struct.Licenses) - fmt.Printf("%s:\t %d\n", "mail type", go_struct.Mail_type) - fmt.Printf("%s:\t %s\n", "mail user", go_struct.Mail_user) - fmt.Printf("%s:\t %s\n", "mem bind", go_struct.Mem_bind) - fmt.Printf("%s:\t %d\n", "mem bind type", go_struct.Mem_bind_type) - fmt.Printf("%s:\t %s\n", "name", go_struct.Name) - fmt.Printf("%s:\t %s\n", "network", go_struct.Network) - fmt.Printf("%s:\t %d\n", "nice", go_struct.Nice) - fmt.Printf("%s:\t %d\n", "num tasks", go_struct.Num_tasks) - fmt.Printf("%s:\t %d\n", "open mode", go_struct.Open_mode) - fmt.Printf("%s:\t %d\n", "other port", go_struct.Other_port) - fmt.Printf("%s:\t %d\n", "overcommit", go_struct.Overcommit) - fmt.Printf("%s:\t %s\n", "partition", go_struct.Partition) - fmt.Printf("%s:\t %d\n", "plane size", go_struct.Plane_size) - fmt.Printf("%s:\t %d\n", "priority", go_struct.Priority) - fmt.Printf("%s:\t %d\n", "profile", go_struct.Profile) - fmt.Printf("%s:\t %s\n", "qos", go_struct.Qos) - fmt.Printf("%s:\t %d\n", "reboot", go_struct.Reboot) - fmt.Printf("%s:\t %s\n", "resp host", go_struct.Resp_host) - fmt.Printf("%s:\t %s\n", "req nodes", go_struct.Req_nodes) - fmt.Printf("%s:\t %d\n", "requeue", go_struct.Requeue) - fmt.Printf("%s:\t %s\n", "reservation", go_struct.Reservation) - fmt.Printf("%s:\t %s\n", "script", go_struct.Script) - fmt.Printf("%s:\t %d\n", "shared", go_struct.Shared) - fmt.Printf("%s:\t %d\n", "spank job env size", go_struct.Spank_job_env_size) - fmt.Printf("%s:\t %d\n", "task dist", go_struct.Task_dist) - fmt.Printf("%s:\t %d\n", "time limit", go_struct.Time_limit) - fmt.Printf("%s:\t %d\n", "time min", go_struct.Time_min) - fmt.Printf("%s:\t %d\n", "user id", go_struct.User_id) - fmt.Printf("%s:\t %d\n", "wait all nodes", go_struct.Wait_all_nodes) - fmt.Printf("%s:\t %d\n", "warn signal", go_struct.Warn_signal) - fmt.Printf("%s:\t %d\n", "warn time", go_struct.Warn_time) - fmt.Printf("%s:\t %s\n", "work dir", go_struct.Work_dir) - fmt.Printf("%s:\t %d\n", "cpus per task", go_struct.Cpus_per_task) - fmt.Printf("%s:\t %d\n", "min cpus", go_struct.Min_cpus) - fmt.Printf("%s:\t %d\n", "max cpus", go_struct.Max_cpus) - fmt.Printf("%s:\t %d\n", "min nodes", go_struct.Min_nodes) - fmt.Printf("%s:\t %d\n", "max nodes", go_struct.Max_nodes) - fmt.Printf("%s:\t %d\n", "boards per node", go_struct.Boards_per_node) - fmt.Printf("%s:\t %d\n", "sockets per board", go_struct.Sockets_per_board) - fmt.Printf("%s:\t %d\n", "sockets per node", go_struct.Sockets_per_node) - fmt.Printf("%s:\t %d\n", "cores per socket", go_struct.Cores_per_socket) - fmt.Printf("%s:\t %d\n", "threads per core", go_struct.Threads_per_core) - fmt.Printf("%s:\t %d\n", "ntasks per node", go_struct.Ntasks_per_node) - fmt.Printf("%s:\t %d\n", "ntasks per socket", go_struct.Ntasks_per_socket) - fmt.Printf("%s:\t %d\n", "ntasks per core", go_struct.Ntasks_per_core) - fmt.Printf("%s:\t %d\n", "ntasks per board", go_struct.Ntasks_per_board) - fmt.Printf("%s:\t %d\n", "pn min cpus", go_struct.Pn_min_cpus) - fmt.Printf("%s:\t %d\n", "pn min memory", go_struct.Pn_min_memory) - fmt.Printf("%s:\t %d\n", "pn min tmp disk", go_struct.Pn_min_tmp_disk) - fmt.Printf("%s:\t %d\n", "req switch", go_struct.Req_switch) - fmt.Printf("%s:\t %s\n", "std err", go_struct.Std_err) - fmt.Printf("%s:\t %s\n", "std in", go_struct.Std_in) - fmt.Printf("%s:\t %s\n", "std out", go_struct.Std_out) - fmt.Printf("%s:\t %d\n", "tres req cnt", go_struct.Tres_req_cnt) - fmt.Printf("%s:\t %d\n", "wait4switch", go_struct.Wait4switch) - fmt.Printf("%s:\t %s\n", "wckey", go_struct.Wckey) -} - -type Update_job_options struct { - Partition string - Qos string - Num_tasks uint32 - Ntasks_per_node uint16 - Ntasks_per_socket uint16 - Ntasks_per_core uint16 - Min_nodes uint32 - Max_nodes uint32 -} - -type Submit_response_msg struct { - Job_id uint32 - Step_id uint32 - Error_code uint32 -} - -func submit_response_msg_convert_c_to_go(c_struct *C.struct_submit_response_msg) Submit_response_msg { - var go_struct Submit_response_msg - - go_struct.Job_id = uint32(c_struct.job_id) - go_struct.Step_id = uint32(c_struct.step_id) - go_struct.Error_code = uint32(c_struct.error_code) - return go_struct -} -func Print_submit_response_msg(go_struct Submit_response_msg) { - fmt.Printf("%s:\t %d\n", "job id", go_struct.Job_id) - fmt.Printf("%s:\t %d\n", "step id", go_struct.Step_id) - fmt.Printf("%s:\t %d\n", "error code", go_struct.Error_code) -} - -/*This is an ugly function, since we start to convert everyting back*/ - -func Submit_job(go_struct *Job_descriptor) Submit_response_msg { - - var c_struct C.struct_job_descriptor - - C.slurm_init_job_desc_msg(&c_struct) - if go_struct.Account != "" { - account_s := C.CString(go_struct.Account) - defer C.free(unsafe.Pointer(account_s)) - c_struct.account = account_s - } - if go_struct.Acctg_freq != "" { - acctg_freq_s := C.CString(go_struct.Acctg_freq) - defer C.free(unsafe.Pointer(acctg_freq_s)) - c_struct.acctg_freq = acctg_freq_s - } - - if go_struct.Alloc_node != "" { - alloc_node_s := C.CString(go_struct.Alloc_node) - defer C.free(unsafe.Pointer(alloc_node_s)) - c_struct.alloc_node = alloc_node_s - } - if go_struct.Alloc_resp_port != 0 { - c_struct.alloc_resp_port = C.uint16_t(go_struct.Alloc_resp_port) - } - if go_struct.Alloc_sid != 0 { - c_struct.alloc_sid = C.uint32_t(go_struct.Alloc_sid) - } - if len(go_struct.Argv) > 0 { - c_struct.argc = C.uint32_t(len(go_struct.Argv)) - cArray := C.malloc(C.size_t(C.size_t(len(go_struct.Argv)) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - for i := 0; i < len(go_struct.Argv); i++ { - a[i] = C.CString(go_struct.Argv[i]) - } - c_struct.argv = (**C.char)(cArray) - fmt.Printf("test\n") - } - - if go_struct.Array_inx != "" { - array_inx_s := C.CString(go_struct.Array_inx) - defer C.free(unsafe.Pointer(array_inx_s)) - c_struct.array_inx = array_inx_s - } - if go_struct.Begin_time != 0 { - c_struct.begin_time = C.int64_t(go_struct.Begin_time) - } - if go_struct.Ckpt_interval != 0 { - c_struct.ckpt_interval = C.uint16_t(go_struct.Ckpt_interval) - } - if go_struct.Ckpt_dir != "" { - ckpt_dir_s := C.CString(go_struct.Ckpt_dir) - defer C.free(unsafe.Pointer(ckpt_dir_s)) - c_struct.ckpt_dir = ckpt_dir_s - } - if go_struct.Comment != "" { - comment_s := C.CString(go_struct.Comment) - defer C.free(unsafe.Pointer(comment_s)) - c_struct.comment = comment_s - } - if go_struct.Contiguous != 0 { - c_struct.contiguous = C.uint16_t(go_struct.Contiguous) - } - if go_struct.Cpu_bind != "" { - cpu_bind_s := C.CString(go_struct.Cpu_bind) - defer C.free(unsafe.Pointer(cpu_bind_s)) - c_struct.cpu_bind = cpu_bind_s - } - if go_struct.Cpu_bind_type != 0 { - c_struct.cpu_bind_type = C.uint16_t(go_struct.Cpu_bind_type) - } - if go_struct.Dependency != "" { - dependency_s := C.CString(go_struct.Dependency) - defer C.free(unsafe.Pointer(dependency_s)) - c_struct.dependency = dependency_s - } - if go_struct.End_time != 0 { - c_struct.end_time = C.int64_t(go_struct.End_time) - } - if len(go_struct.Environment) > 0 { - c_struct.env_size = C.uint32_t(len(go_struct.Environment)) - cArray := C.malloc(C.size_t(C.size_t(len(go_struct.Environment)) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - for i := 0; i < len(go_struct.Environment); i++ { - a[i] = C.CString(go_struct.Environment[i]) - defer C.free(unsafe.Pointer(a[i])) - } - c_struct.environment = (**C.char)(cArray) - } else { - c_struct.env_size = 1 - cArray := C.malloc(C.size_t(C.size_t(1) * C.size_t(unsafe.Sizeof(uintptr(0))))) - a := (*[1<<30 - 1]*C.char)(cArray) - a[0] = C.CString("SLURM_GO_JOB=TRUE") - defer C.free(unsafe.Pointer(a[0])) - c_struct.environment = (**C.char)(cArray) - - } - if go_struct.Exc_nodes != "" { - exc_nodes_s := C.CString(go_struct.Exc_nodes) - defer C.free(unsafe.Pointer(exc_nodes_s)) - c_struct.exc_nodes = exc_nodes_s - } - if go_struct.Features != "" { - features_s := C.CString(go_struct.Features) - defer C.free(unsafe.Pointer(features_s)) - c_struct.features = features_s - } - if go_struct.Group_id != 0 { - c_struct.group_id = C.uint32_t(go_struct.Group_id) - } - if go_struct.Immediate != 0 { - c_struct.immediate = C.uint16_t(go_struct.Immediate) - } - if go_struct.Job_id != 0 { - c_struct.job_id = C.uint32_t(go_struct.Job_id) - } - if go_struct.Kill_on_node_fail != 0 { - c_struct.kill_on_node_fail = C.uint16_t(go_struct.Kill_on_node_fail) - } - if go_struct.Licenses != "" { - licenses_s := C.CString(go_struct.Licenses) - defer C.free(unsafe.Pointer(licenses_s)) - c_struct.licenses = licenses_s - } - if go_struct.Mail_type != 0 { - c_struct.mail_type = C.uint16_t(go_struct.Mail_type) - } - if go_struct.Mail_user != "" { - mail_user_s := C.CString(go_struct.Mail_user) - defer C.free(unsafe.Pointer(mail_user_s)) - c_struct.mail_user = mail_user_s - } - if go_struct.Mem_bind != "" { - mem_bind_s := C.CString(go_struct.Mem_bind) - defer C.free(unsafe.Pointer(mem_bind_s)) - c_struct.mem_bind = mem_bind_s - } - if go_struct.Mem_bind_type != 0 { - c_struct.mem_bind_type = C.uint16_t(go_struct.Mem_bind_type) - } - if go_struct.Name != "" { - name_s := C.CString(go_struct.Name) - defer C.free(unsafe.Pointer(name_s)) - c_struct.name = name_s - } - if go_struct.Network != "" { - network_s := C.CString(go_struct.Network) - defer C.free(unsafe.Pointer(network_s)) - c_struct.network = network_s - } - //if go_struct.Nice != 0 { - // c_struct.nice = C.uint32_t(go_struct.Nice) - //} - if go_struct.Num_tasks != 0 { - c_struct.num_tasks = C.uint32_t(go_struct.Num_tasks) - } - if go_struct.Open_mode != 0 { - c_struct.open_mode = C.uint8_t(go_struct.Open_mode) - } - if go_struct.Other_port != 0 { - c_struct.other_port = C.uint16_t(go_struct.Other_port) - } - if go_struct.Overcommit != 0 { - c_struct.overcommit = C.uint8_t(go_struct.Overcommit) - } - if go_struct.Partition != "" { - partition_s := C.CString(go_struct.Partition) - defer C.free(unsafe.Pointer(partition_s)) - c_struct.partition = partition_s - } - if go_struct.Plane_size != 0 { - c_struct.plane_size = C.uint16_t(go_struct.Plane_size) - } - if go_struct.Priority != 0 { - c_struct.priority = C.uint32_t(go_struct.Priority) - } - if go_struct.Profile != 0 { - c_struct.profile = C.uint32_t(go_struct.Profile) - } - if go_struct.Qos != "" { - qos_s := C.CString(go_struct.Qos) - defer C.free(unsafe.Pointer(qos_s)) - c_struct.qos = qos_s - } - if go_struct.Reboot != 0 { - c_struct.reboot = C.uint16_t(go_struct.Reboot) - } - if go_struct.Resp_host != "" { - resp_host_s := C.CString(go_struct.Resp_host) - defer C.free(unsafe.Pointer(resp_host_s)) - c_struct.resp_host = resp_host_s - } - if go_struct.Req_nodes != "" { - req_nodes_s := C.CString(go_struct.Req_nodes) - defer C.free(unsafe.Pointer(req_nodes_s)) - c_struct.req_nodes = req_nodes_s - } - if go_struct.Requeue != 0 { - c_struct.requeue = C.uint16_t(go_struct.Requeue) - } - if go_struct.Reservation != "" { - reservation_s := C.CString(go_struct.Reservation) - defer C.free(unsafe.Pointer(reservation_s)) - c_struct.reservation = reservation_s - } - if go_struct.Script != "" { - script_s := C.CString(go_struct.Script) - defer C.free(unsafe.Pointer(script_s)) - c_struct.script = script_s - } - if go_struct.Shared != 0 { - c_struct.shared = C.uint16_t(go_struct.Shared) - } - if go_struct.Spank_job_env_size != 0 { - c_struct.spank_job_env_size = C.uint32_t(go_struct.Spank_job_env_size) - } - //if go_struct.Task_dist != 0 { - // c_struct.task_dist = C.uint32_t(go_struct.Task_dist) - //} - if go_struct.Time_limit != 0 { - c_struct.time_limit = C.uint32_t(go_struct.Time_limit) - } - if go_struct.Time_min != 0 { - c_struct.time_min = C.uint32_t(go_struct.Time_min) - } - if go_struct.User_id != 0 { - c_struct.user_id = C.uint32_t(go_struct.User_id) - } - if go_struct.Wait_all_nodes != 0 { - c_struct.wait_all_nodes = C.uint16_t(go_struct.Wait_all_nodes) - } - if go_struct.Warn_signal != 0 { - c_struct.warn_signal = C.uint16_t(go_struct.Warn_signal) - } - if go_struct.Warn_time != 0 { - c_struct.warn_time = C.uint16_t(go_struct.Warn_time) - } - if go_struct.Work_dir != "" { - work_dir_s := C.CString(go_struct.Work_dir) - defer C.free(unsafe.Pointer(work_dir_s)) - c_struct.work_dir = work_dir_s - } - if go_struct.Cpus_per_task != 0 { - c_struct.cpus_per_task = C.uint16_t(go_struct.Cpus_per_task) - } - if go_struct.Min_cpus != 0 { - c_struct.min_cpus = C.uint32_t(go_struct.Min_cpus) - } - if go_struct.Max_cpus != 0 { - c_struct.max_cpus = C.uint32_t(go_struct.Max_cpus) - } - if go_struct.Min_nodes != 0 { - c_struct.min_nodes = C.uint32_t(go_struct.Min_nodes) - } - if go_struct.Max_nodes != 0 { - c_struct.max_nodes = C.uint32_t(go_struct.Max_nodes) - } - if go_struct.Boards_per_node != 0 { - c_struct.boards_per_node = C.uint16_t(go_struct.Boards_per_node) - } - if go_struct.Sockets_per_board != 0 { - c_struct.sockets_per_board = C.uint16_t(go_struct.Sockets_per_board) - } - if go_struct.Sockets_per_node != 0 { - c_struct.sockets_per_node = C.uint16_t(go_struct.Sockets_per_node) - } - if go_struct.Cores_per_socket != 0 { - c_struct.cores_per_socket = C.uint16_t(go_struct.Cores_per_socket) - } - if go_struct.Threads_per_core != 0 { - c_struct.threads_per_core = C.uint16_t(go_struct.Threads_per_core) - } - if go_struct.Ntasks_per_node != 0 { - c_struct.ntasks_per_node = C.uint16_t(go_struct.Ntasks_per_node) - } - if go_struct.Ntasks_per_socket != 0 { - c_struct.ntasks_per_socket = C.uint16_t(go_struct.Ntasks_per_socket) - } - if go_struct.Ntasks_per_core != 0 { - c_struct.ntasks_per_core = C.uint16_t(go_struct.Ntasks_per_core) - } - if go_struct.Ntasks_per_board != 0 { - c_struct.ntasks_per_board = C.uint16_t(go_struct.Ntasks_per_board) - } - if go_struct.Pn_min_cpus != 0 { - c_struct.pn_min_cpus = C.uint16_t(go_struct.Pn_min_cpus) - } - - if go_struct.Pn_min_tmp_disk != 0 { - c_struct.pn_min_tmp_disk = C.uint32_t(go_struct.Pn_min_tmp_disk) - } - if go_struct.Req_switch != 0 { - c_struct.req_switch = C.uint32_t(go_struct.Req_switch) - } - if go_struct.Std_err != "" { - std_err_s := C.CString(go_struct.Std_err) - defer C.free(unsafe.Pointer(std_err_s)) - c_struct.std_err = std_err_s - } - if go_struct.Std_in != "" { - std_in_s := C.CString(go_struct.Std_in) - defer C.free(unsafe.Pointer(std_in_s)) - c_struct.std_in = std_in_s - } - if go_struct.Std_out != "" { - std_out_s := C.CString(go_struct.Std_out) - defer C.free(unsafe.Pointer(std_out_s)) - c_struct.std_out = std_out_s - } - - if go_struct.Wait4switch != 0 { - c_struct.wait4switch = C.uint32_t(go_struct.Wait4switch) - } - if go_struct.Wckey != "" { - wckey_s := C.CString(go_struct.Wckey) - defer C.free(unsafe.Pointer(wckey_s)) - c_struct.wckey = wckey_s - } - c_msg := C.submit_job(&c_struct) - - defer C.free_submit_response_msg(c_msg) - if c_msg == nil { - go_msg := Submit_response_msg{} - go_msg.Job_id = 1<<31 - 1 - go_msg.Error_code = uint32(C.slurm_get_errno()) - return go_msg - } - go_msg := submit_response_msg_convert_c_to_go(c_msg) - - return go_msg - -} - -func Update_job(update_info Update_job_options, JobId uint32) uint32 { - - var c_struct C.struct_job_descriptor - C.slurm_init_job_desc_msg(&c_struct) - if update_info.Partition != "" { - partition_s := C.CString(update_info.Partition) - defer C.free(unsafe.Pointer(partition_s)) - c_struct.partition = partition_s - } - if update_info.Qos != "" { - qos_s := C.CString(update_info.Qos) - defer C.free(unsafe.Pointer(qos_s)) - c_struct.qos = qos_s - } - if update_info.Num_tasks != 0 { - c_struct.num_tasks = C.uint32_t(update_info.Num_tasks) - } - if update_info.Ntasks_per_core != 0 { - c_struct.ntasks_per_core = C.uint16_t(update_info.Ntasks_per_core) - } - - if update_info.Ntasks_per_node != 0 { - c_struct.ntasks_per_node = C.uint16_t(update_info.Ntasks_per_node) - } - if update_info.Ntasks_per_socket != 0 { - c_struct.ntasks_per_socket = C.uint16_t(update_info.Ntasks_per_socket) - } - - if update_info.Max_nodes != 0 { - c_struct.max_nodes = C.uint32_t(update_info.Max_nodes) - } - if update_info.Min_nodes != 0 { - c_struct.min_nodes = C.uint32_t(update_info.Min_nodes) - } - - job_list := job_info.Get_job(uint32(JobId)) - - if job_list.Error_code != 0 { - return uint32(job_list.Error_code) - } - - job := job_list.Job_list[0] - if job.Job_state != C.JOB_PENDING { - return uint32(C.ESLURM_JOB_NOT_PENDING) - } - c_struct.job_id = C.uint32_t(JobId) - - err := C.update_job(&c_struct) - - return uint32(err) - -} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/test/test.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/test/test.go deleted file mode 100644 index 70a343db..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/test/test.go +++ /dev/null @@ -1,103 +0,0 @@ -package test - -// -///* -//#cgo LDFLAGS: -lslurmdb -// -//#include -//#include -//#include -//#include -//#include -// -//typedef struct user_info_msg { -// uint32_t record_count; -// slurmdb_user_rec_t *user_array; -//} user_info_msg_t; -// -//typedef struct slurmdb_user_rec{ -// uint16_t admin_level; -// List assoc_list; -// List coord_accts; -// char *default_acct; -// char *default_wckey; -// char *name; -// char *old_name; -// uint32_t uid; -// List wckey_list; -//} slurmdb_user_rec_t_f; -// -//struct user_info_msg get_user_info() { -// struct user_info_msg userinfo; -// List userList = NULL; -// slurmdb_user_cond_t *user_cond = NULL; -// void *db_conn; -// db_conn = slurmdb_connection_get(); -// userList = slurmdb_users_get(db_conn, user_cond); -// slurmdb_connection_close(&db_conn); -// -// slurmdb_user_rec_t *rec = NULL; -// ListIterator itr = slurm_list_iterator_create(userList); -// int i = 0; -// uint32_t length; -// length = slurm_list_count(userList); -// userinfo.record_count = length; -// userinfo.user_array = malloc(length * sizeof(slurmdb_user_rec_t)); -// while ((rec = slurm_list_next(itr))) { -// userinfo.user_array[i] = *rec; -// i++; -// } -// return userinfo; -//} -// -//struct slurmdb_user_rec *user_from_list(struct user_info_msg *list, int i) { -// return (struct slurmdb_user_rec *) &list->user_array[i]; -//} -// -//*/ -//import "C" -// -//type UserInfo struct { -// //uint16_t admin_level; /* really slurmdb_admin_level_t but for -// //packing purposes needs to be uint16_t */ -// //List assoc_list; /* list of slurmdb_association_rec_t *'s */ -// //List coord_accts; /* list of slurmdb_coord_rec_t *'s */ -// //char *default_acct; -// //char *default_wckey; -// Name string -// OldName string -// //uint32_t uid; -// //List wckey_list; /* list of slurmdb_wckey_rec_t *'s */ -//} -// -//type UserInfoMsg struct { -// Last_update int64 -// Record_count uint32 -// UserInfoList []UserInfo -//} -// -//func User_descriptor_convert_c_to_go(c_struct *C.struct_slurmdb_user_rec) UserInfo { -// var go_struct UserInfo -// go_struct.Name = C.GoString(c_struct.name) -// return go_struct -//} -// -//// []slurmpb.UserInfo -//func GetUserInfo() UserInfoMsg { -// var go_user_buffer UserInfoMsg -// c_user_buffer := C.get_user_info() -// go_user_buffer.Record_count = uint32(c_user_buffer.record_count) -// go_user_buffer.UserInfoList = make([]UserInfo, c_user_buffer.record_count, c_user_buffer.record_count) -// -// for i := uint32(0); i < go_user_buffer.Record_count; i++ { -// user := C.user_from_list(&c_user_buffer, C.int(i)) -// go_user := User_descriptor_convert_c_to_go(user) -// go_user_buffer.UserInfoList[i] = go_user -// } -// return go_user_buffer -//} -// -//func main() { -// userInfoMsg := GetUserInfo() -// println(userInfoMsg.UserInfoList[0].Name) -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info.go deleted file mode 100644 index 43ad2b39..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info.go +++ /dev/null @@ -1,90 +0,0 @@ -package user - -// -///* -//#cgo LDFLAGS: -lslurmdb -// -//#include -//#include -//#include -//#include -//#include -// -//typedef struct user_info_msg { -// uint32_t record_count; -// slurmdb_user_rec_t *user_array; -//} user_info_msg_t; -// -//typedef struct slurmdb_user_rec{ -// uint16_t admin_level; -// List assoc_list; -// List coord_accts; -// char *default_acct; -// char *default_wckey; -// char *name; -// char *old_name; -// uint32_t uid; -// List wckey_list; -//} slurmdb_user_rec_t_f; -// -//struct user_info_msg get_user_info() { -// struct user_info_msg userinfo; -// List userList = NULL; -// slurmdb_user_cond_t *user_cond = NULL; -// void *db_conn; -// db_conn = slurmdb_connection_get(); -// userList = slurmdb_users_get(db_conn, user_cond); -// slurmdb_connection_close(&db_conn); -// -// slurmdb_user_rec_t *rec = NULL; -// ListIterator itr = slurm_list_iterator_create(userList); -// int i = 0; -// uint32_t length; -// length = slurm_list_count(userList); -// userinfo.record_count = length; -// userinfo.user_array = malloc(length * sizeof(slurmdb_user_rec_t)); -// while ((rec = slurm_list_next(itr))) { -// userinfo.user_array[i] = *rec; -// i++; -// } -// return userinfo; -//} -// -//struct slurmdb_user_rec *user_from_list(struct user_info_msg *list, int i) { -// return (struct slurmdb_user_rec *) &list->user_array[i]; -//} -// -//*/ -//import "C" -// -//type UserInfo struct { -// Name string -// OldName string -//} -// -//type UserInfoMsg struct { -// Last_update int64 -// Record_count uint32 -// UserInfoList []UserInfo -//} -// -//func User_descriptor_convert_c_to_go(c_struct *C.struct_slurmdb_user_rec) UserInfo { -// var go_struct UserInfo -// go_struct.Name = C.GoString(c_struct.name) -// return go_struct -//} -// -//// []slurmpb.UserInfo -//func GetUserInfo() UserInfoMsg { -// var go_user_buffer UserInfoMsg -// c_user_buffer := C.get_user_info() -// go_user_buffer.Record_count = uint32(c_user_buffer.record_count) -// go_user_buffer.UserInfoList = make([]UserInfo, c_user_buffer.record_count, c_user_buffer.record_count) -// -// for i := uint32(0); i < go_user_buffer.Record_count; i++ { -// user := C.user_from_list(&c_user_buffer, C.int(i)) -// go_user := User_descriptor_convert_c_to_go(user) -// go_user_buffer.UserInfoList[i] = go_user -// } -// return go_user_buffer -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_bak.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_bak.go deleted file mode 100644 index 127e78fc..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_bak.go +++ /dev/null @@ -1,80 +0,0 @@ -package user - -// -///* -//#cgo LDFLAGS: -lslurmdb -// -//#include -//#include -//#include -// -//List Get_user_List() { -// __attribute__((unused)) List slurmdb_user_rec_t = NULL; -// slurmdb_user_cond_t *user_cond = NULL; -// slurmdb_user_rec_t = slurmdb_users_get(slurmdb_connection_get(), user_cond); -// return slurmdb_user_rec_t; -//} -// -//slurmdb_user_rec_t UserArray[900]; -// -//struct slurmdb_user_rec_t *user_from_list() { -// __attribute__((unused)) List userList = NULL; -// slurmdb_user_cond_t *user_cond = NULL; -// userList = slurmdb_users_get(slurmdb_connection_get(), user_cond); -// slurmdb_user_rec_t *rec = NULL; -// ListIterator itr = slurm_list_iterator_create(userList); -// int i = 0; -// while ((rec = slurm_list_next(itr))) { -// UserArray[i] = *rec; -// i++; -// } -// return (struct slurmdb_user_rec_t *) UserArray; -//} -//*/ -//import "C" -//import ( -// "fmt" -//) -// -//type SlurmdbUsers struct { -// slurm_user []SlurmdbUser -//} -//type SlurmdbUser struct { -// admin_level uint16 /* really slurmdb_admin_level_t but for -// packing purposes needs to be uint16_t */ -// //assoc_list List /* list of slurmdb_association_rec_t *'s */ -// //coord_accts List /* list of slurmdb_coord_rec_t *'s */ -// default_acct string -// default_wckey string -// name string -// old_name string -// uid uint32 -// //wckey_list List /* list of slurmdb_wckey_rec_t *'s */ -//} -// -//func User_descriptor_convert_c_to_go(c_struct *C.slurmdb_user_rec_t) SlurmdbUser { -// var go_struct SlurmdbUser -// go_struct.name = C.GoString(c_struct.name) -// return go_struct -//} -// -//func GetUserInfo() SlurmdbUsers { -// var go_struct SlurmdbUser -// var users SlurmdbUsers -// userCount := int(C.slurm_list_count(C.Get_user_List())) -// C.user_from_list() -// SlurmdbUserList := make([]SlurmdbUser, 0) -// for i := 0; i < userCount; i++ { -// C.user_from_list() -// user := C.UserArray[i] -// go_struct = User_descriptor_convert_c_to_go(&user) -// SlurmdbUserList = append(SlurmdbUserList, go_struct) -// users.slurm_user = append(users.slurm_user, go_struct) -// } -// return users -//} -// -//func main() { -// slurmdbUser := GetUserInfo() -// fmt.Println(slurmdbUser.slurm_user[0].name) -//} diff --git a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_new.go b/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_new.go deleted file mode 100644 index d2ae8037..00000000 --- a/adaptor/pcm_slurm/cgo_tianhe/src/slurm/user/get_user_info_new.go +++ /dev/null @@ -1,92 +0,0 @@ -package user - -// -//import "C" -//import slurmpb "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" -// -///* -//#cgo LDFLAGS: -lslurmdb -// -//#include -//#include -//#include -// -// -////slurmdb_user_rec_t UserArray[10]; -// -////struct slurmdb_user_rec_t *user_from_list() { -//// -//// __attribute__((unused)) List userList = NULL; -//// slurmdb_user_cond_t *user_cond = NULL; -//// userList = slurmdb_users_get(slurmdb_connection_get(), user_cond); -//// //slurmdb_user_rec_t *rec = NULL; -//// //ListIterator itr = slurm_list_iterator_create(userList); -//// //int i = 0; -//// //while ((rec = slurm_list_next(itr))) { -//// // UserArray[i] = *rec; -//// // i++; -//// //} -//// //return (struct slurmdb_user_rec_t *) UserArray; -//// return -////} -// -//typedef struct user_info_msg { -// time_t last_update; -// uint32_t record_count; -// slurmdb_user_rec_t *user_array[10]; -//} user_info_msg_t; -// -// -//struct user_info_msg_t *user_from_list() { -// user_info_msg_t* user_buffer; -// __attribute__((unused)) List userList = NULL; -// slurmdb_user_cond_t *user_cond = NULL; -// userList = slurmdb_users_get(slurmdb_connection_get(), user_cond); -// -// slurmdb_user_rec_t *rec = NULL; -// ListIterator itr = slurm_list_iterator_create(userList); -// int i = 0; -// int length; -// length = slurm_list_count(userList); -// slurmdb_user_rec_t UserArray[length]; -// while ((rec = slurm_list_next(itr))) { -// UserArray[i]=*rec; -// user_buffer->user_array[i] = &UserArray[i]; -// i++; -// } -// return user_buffer; -//} -// -// -//*/ -//import "C" -// -//func ConvertCToGo(cStruct *C.slurmdb_user_rec_t) slurmpb.UserInfo { -// var goStruct slurmpb.UserInfo -// goStruct.Name = C.GoString(cStruct.name) -// return goStruct -//} -// -//func GetUserInfo() slurmpb.UserInfoList { -// var users slurmpb.UserInfoList -// var goStruct slurmpb.UserInfo -// //userCount := int(C.slurm_list_count(C.Get_user_List())) -// c_users_buffer := C.user_from_list() -// println(c_users_buffer) -// SlurmUserList := make([]slurmpb.UserInfo, 0) -// for i := 0; i < 2; i++ { -// //c_users_buffer := C.user_from_list() -// //println(c_users_buffer) -// C.user_from_list() -// //user := C.UserArray[i] -// //goStruct = ConvertCToGo(&user) -// SlurmUserList = append(SlurmUserList, goStruct) -// users.UserInfos = append(users.UserInfos, &goStruct) -// } -// return users -//} -// -//func main() { -// users := GetUserInfo() -// println(users.UserInfos[0].Name) -//} diff --git a/adaptor/pcm_slurm/server/slurmImpl.go b/adaptor/pcm_slurm/server/slurmImpl.go index 51893bab..4ec55d87 100644 --- a/adaptor/pcm_slurm/server/slurmImpl.go +++ b/adaptor/pcm_slurm/server/slurmImpl.go @@ -2,7 +2,7 @@ package server import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" - slurmer "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service" + slurmer "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/common" "context" ) diff --git a/adaptor/pcm_slurm/service/slurmdb_account.go b/adaptor/pcm_slurm/service/common/account_db.go similarity index 58% rename from adaptor/pcm_slurm/service/slurmdb_account.go rename to adaptor/pcm_slurm/service/common/account_db.go index a44cd6b4..32ae7e7c 100644 --- a/adaptor/pcm_slurm/service/slurmdb_account.go +++ b/adaptor/pcm_slurm/service/common/account_db.go @@ -1,92 +1,16 @@ package slurmer -/* -#cgo LDFLAGS: -lslurmdb - -#include -#include -#include -#include -#include - -typedef struct account_info_msg { - uint32_t record_count; - slurmdb_account_rec_t *account_array; -} account_info_msg_t; - -typedef struct slurmdb_account_rec{ - List assoc_list; - List coord_accts; - char *description; - char *name; - char *organization; -} slurmdb_account_rec_pcm; - -struct account_info_msg get_account_info() { - struct account_info_msg accountinfo; - List accountList = NULL; - slurmdb_account_cond_t *account_cond = NULL; - void *db_conn; - db_conn = slurmdb_connection_get(); - accountList = slurmdb_accounts_get(db_conn, account_cond); - slurmdb_connection_close(&db_conn); - - slurmdb_account_rec_t *rec = NULL; - ListIterator itr = slurm_list_iterator_create(accountList); - int i = 0; - uint32_t length; - length = slurm_list_count(accountList); - accountinfo.record_count = length; - accountinfo.account_array = malloc(length * sizeof(slurmdb_account_rec_t)); - while ((rec = slurm_list_next(itr))) { - accountinfo.account_array[i] = *rec; - i++; - } - return accountinfo; -} - -struct slurmdb_account_rec *account_from_list(struct account_info_msg *list, int i) { - return (struct slurmdb_account_rec *) &list->account_array[i]; -} - -*/ -import "C" import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" "code.gitlink.org.cn/JCCE/PCM.git/common/ssh" "context" "strings" ) -type AcctInfoMsg struct { - LastUpdate int64 - RecordCount uint32 - AcctInfoList []pbslurm.AccountInfo -} - -func AcctDescriptorConvertCToGo(cStruct *C.struct_slurmdb_account_rec) pbslurm.AccountInfo { - var goStruct pbslurm.AccountInfo - goStruct.Name = C.GoString(cStruct.name) - return goStruct -} - -func GetAcctInfo() AcctInfoMsg { - var goAcctBuffer AcctInfoMsg - cAcctBuffer := C.get_account_info() - goAcctBuffer.RecordCount = uint32(cAcctBuffer.record_count) - goAcctBuffer.AcctInfoList = make([]pbslurm.AccountInfo, cAcctBuffer.record_count, cAcctBuffer.record_count) - - for i := uint32(0); i < goAcctBuffer.RecordCount; i++ { - Acct := C.account_from_list(&cAcctBuffer, C.int(i)) - goAcct := AcctDescriptorConvertCToGo(Acct) - goAcctBuffer.AcctInfoList[i] = goAcct - } - return goAcctBuffer -} - func (slurmStruct SlurmStruct) ListAccounts(ctx context.Context, req *pbslurm.ListAccountsReq) (*pbslurm.ListAccountsResp, error) { - acctList := GetAcctInfo() + acctList := tianhe.GetAcctInfo() resp := pbslurm.ListAccountsResp{} for _, acct := range acctList.AcctInfoList { @@ -102,7 +26,7 @@ func (slurmStruct SlurmStruct) ListAccounts(ctx context.Context, req *pbslurm.Li func (slurmStruct SlurmStruct) GetAccount(ctx context.Context, req *pbslurm.GetAccountReq) (*pbslurm.GetAccountResp, error) { - acctList := GetAcctInfo() + acctList := tianhe.GetAcctInfo() resp := pbslurm.GetAccountResp{} for _, acct := range acctList.AcctInfoList { diff --git a/adaptor/pcm_slurm/service/common/association_db.go b/adaptor/pcm_slurm/service/common/association_db.go new file mode 100644 index 00000000..85d2d612 --- /dev/null +++ b/adaptor/pcm_slurm/service/common/association_db.go @@ -0,0 +1,38 @@ +package slurmer + +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" + "context" + "strings" +) + +func (slurmStruct SlurmStruct) ListAssociations(ctx context.Context, req *pbslurm.ListAssociationsReq) (*pbslurm.ListAssociationsResp, error) { + + assocList := tianhe.GetAssociationInfos() + + resp := pbslurm.ListAssociationsResp{} + for _, assoc := range assocList.AssocInfoList { + assocResult := assoc + resp.AssocInfos = append(resp.AssocInfos, &assocResult) + } + + return &resp, nil +} + +func (slurmStruct SlurmStruct) GetAssociation(ctx context.Context, req *pbslurm.GetAssociationReq) (*pbslurm.GetAssociationResp, error) { + + assocList := tianhe.GetAssociationInfos() + + resp := pbslurm.GetAssociationResp{} + + for _, assoc := range assocList.AssocInfoList { + if (len(req.Cluster) != 0 || len(req.User) != 0 || len(req.Account) != 0 || len(req.Partition) != 0) && strings.Contains(assoc.Cluster, req.Cluster) && strings.Contains(assoc.Acct, req.Account) && strings.Contains(assoc.User, req.User) && strings.Contains(assoc.Partition, req.Partition) { + assocResult := assoc + resp.AssocInfos = append(resp.AssocInfos, &assocResult) + } + } + + return &resp, nil +} diff --git a/adaptor/pcm_slurm/service/slurmdb_cluster.go b/adaptor/pcm_slurm/service/common/cluster_db.go similarity index 52% rename from adaptor/pcm_slurm/service/slurmdb_cluster.go rename to adaptor/pcm_slurm/service/common/cluster_db.go index f7773ca1..7936cfaa 100644 --- a/adaptor/pcm_slurm/service/slurmdb_cluster.go +++ b/adaptor/pcm_slurm/service/common/cluster_db.go @@ -1,88 +1,16 @@ package slurmer -/* -#cgo LDFLAGS: -lslurmdb - -#include -#include -#include -#include -#include - -typedef struct cluster_info_msg { - uint32_t record_count; - slurmdb_cluster_rec_t *cluster_array; -} cluster_info_msg_t; - -typedef struct slurmdb_cluster_rec{ - char *name; -} slurmdb_cluster_rec_pcm; - -struct cluster_info_msg get_cluster_info() { - struct cluster_info_msg clusterinfo; - List clusterList = NULL; - slurmdb_cluster_cond_t *cluster_cond = NULL; - void *db_conn; - db_conn = slurmdb_connection_get(); - clusterList = slurmdb_clusters_get(db_conn, cluster_cond); - slurmdb_connection_close(&db_conn); - - slurmdb_cluster_rec_t *rec = NULL; - ListIterator itr = slurm_list_iterator_create(clusterList); - int i = 0; - uint32_t length; - length = slurm_list_count(clusterList); - clusterinfo.record_count = length; - clusterinfo.cluster_array = malloc(length * sizeof(slurmdb_cluster_rec_t)); - while ((rec = slurm_list_next(itr))) { - clusterinfo.cluster_array[i] = *rec; - i++; - } - return clusterinfo; -} - -struct slurmdb_cluster_rec *cluster_from_list(struct cluster_info_msg *list, int i) { - return (struct slurmdb_cluster_rec *) &list->cluster_array[i]; -} - -*/ -import "C" import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" "code.gitlink.org.cn/JCCE/PCM.git/common/ssh" "context" "strings" ) -type ClusterInfoMsg struct { - Last_update int64 - Record_count uint32 - ClusterInfoList []pbslurm.ClusterInfo -} - -func Cluster_descriptor_convert_c_to_go(c_struct *C.struct_slurmdb_cluster_rec) pbslurm.ClusterInfo { - var go_struct pbslurm.ClusterInfo - go_struct.Name = C.GoString(c_struct.name) - return go_struct -} - -func GetClusterInfo() ClusterInfoMsg { - var go_cluster_buffer ClusterInfoMsg - c_cluster_buffer := C.get_cluster_info() - go_cluster_buffer.Record_count = uint32(c_cluster_buffer.record_count) - go_cluster_buffer.ClusterInfoList = make([]pbslurm.ClusterInfo, c_cluster_buffer.record_count, c_cluster_buffer.record_count) - - for i := uint32(0); i < go_cluster_buffer.Record_count; i++ { - cluster := C.cluster_from_list(&c_cluster_buffer, C.int(i)) - go_cluster := Cluster_descriptor_convert_c_to_go(cluster) - go_cluster_buffer.ClusterInfoList[i] = go_cluster - } - return go_cluster_buffer -} - func (slurmStruct SlurmStruct) ListClusters(ctx context.Context, req *pbslurm.ListClustersReq) (*pbslurm.ListClustersResp, error) { - clusterList := GetClusterInfo() + clusterList := tianhe.GetClusterInfo() resp := pbslurm.ListClustersResp{} for _, cluster := range clusterList.ClusterInfoList { @@ -155,7 +83,7 @@ func (slurmStruct SlurmStruct) AddCluster(ctx context.Context, req *pbslurm.AddC func (slurmStruct SlurmStruct) GetCluster(ctx context.Context, req *pbslurm.GetClusterReq) (*pbslurm.GetClusterResp, error) { - clusterList := GetClusterInfo() + clusterList := tianhe.GetClusterInfo() resp := pbslurm.GetClusterResp{} for _, cluster := range clusterList.ClusterInfoList { diff --git a/adaptor/pcm_slurm/service/common/node.go b/adaptor/pcm_slurm/service/common/node.go new file mode 100644 index 00000000..a36fc55f --- /dev/null +++ b/adaptor/pcm_slurm/service/common/node.go @@ -0,0 +1,53 @@ +package slurmer + +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" + "context" + "strings" +) + +func (slurmStruct SlurmStruct) ListNodes(ctx context.Context, req *pbslurm.ListNodesReq) (*pbslurm.ListNodesResp, error) { + nodeList := tianhe.Get_all_nodes() + var resp = pbslurm.ListNodesResp{} + for _, node := range nodeList.NodeInfoList { + nodeInfoResult := pbslurm.NodeInfo{} + nodeInfoResult.Cpus = uint32(node.Cpus) + nodeInfoResult.Boards = uint32(node.Boards) + nodeInfoResult.RealMemory = node.RealMemory + nodeInfoResult.Sockets = uint32(node.Sockets) + nodeInfoResult.Threads = uint32(node.Threads) + resp.NodeInfos = append(resp.NodeInfos, &nodeInfoResult) + } + + return &resp, nil +} + +func (slurmStruct SlurmStruct) GetNode(ctx context.Context, req *pbslurm.GetNodeReq) (*pbslurm.GetNodeResp, error) { + NodeList := tianhe.GetNodeInfo() + resp := pbslurm.GetNodeResp{} + for _, node := range NodeList.NodeInfoList { + nodeInfoResult := node + if strings.Contains(node.Name, req.NodeName) { + resp.NodeInfos = append(resp.NodeInfos, &nodeInfoResult) + } + } + return &resp, nil +} + +/*func (slurmStruct SlurmStruct) GetNodeByName(ctx context.Context, req *pbnode.NodeInfoMsgReq) (*pbnode.NodeInfoMsgResp, error) { + node := Get_node_info(req.NodeName) + var resp = pbnode.NodeInfoMsgResp{} + for _, node := range node.Node_list { + nodeInfoResult := pbnode.Node_Info{} + nodeInfoResult.Cpus = uint32(node.Cpus) + nodeInfoResult.Boards = uint32(node.Boards) + nodeInfoResult.RealMemory = node.RealMemory + nodeInfoResult.Sockets = uint32(node.Sockets) + nodeInfoResult.Threads = uint32(node.Threads) + resp.NodeList = append(resp.NodeList, &nodeInfoResult) + } + + return &resp, nil +}*/ diff --git a/adaptor/pcm_slurm/service/common/partition.go b/adaptor/pcm_slurm/service/common/partition.go new file mode 100644 index 00000000..46e9cc14 --- /dev/null +++ b/adaptor/pcm_slurm/service/common/partition.go @@ -0,0 +1,31 @@ +package slurmer + +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" + "context" + "strings" +) + +func (slurmStruct SlurmStruct) ListPartitions(ctx context.Context, req *pbslurm.ListPartitionsReq) (*pbslurm.ListPartitionsResp, error) { + partitionList := tianhe.Get_partitions() + var resp = pbslurm.ListPartitionsResp{} + for _, partition := range partitionList.PartitionInfoList { + partitionInfoResult := partition + resp.PartitionList = append(resp.PartitionList, &partitionInfoResult) + } + return &resp, nil +} + +func (slurmStruct SlurmStruct) GetPartition(ctx context.Context, req *pbslurm.GetPartitionReq) (*pbslurm.GetPartitionResp, error) { + PartitionList := tianhe.GetPartitionsInfo() + resp := pbslurm.GetPartitionResp{} + for _, partition := range PartitionList.PartitionInfoList { + partitionInfoResult := partition + if strings.Contains(partition.Name, req.PartitionName) { + resp.PartitionInfos = append(resp.PartitionInfos, &partitionInfoResult) + } + } + return &resp, nil +} diff --git a/adaptor/pcm_slurm/service/slurm_ping.go b/adaptor/pcm_slurm/service/common/ping.go similarity index 96% rename from adaptor/pcm_slurm/service/slurm_ping.go rename to adaptor/pcm_slurm/service/common/ping.go index d16abf1a..00827481 100644 --- a/adaptor/pcm_slurm/service/slurm_ping.go +++ b/adaptor/pcm_slurm/service/common/ping.go @@ -1,7 +1,7 @@ package slurmer /* -#cgo LDFLAGS: -lslurm +//#cgo LDFLAGS: -lslurm #include #include #include diff --git a/adaptor/pcm_slurm/service/common/qos_db.go b/adaptor/pcm_slurm/service/common/qos_db.go new file mode 100644 index 00000000..a0333264 --- /dev/null +++ b/adaptor/pcm_slurm/service/common/qos_db.go @@ -0,0 +1,22 @@ +package slurmer + +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" + "context" +) + +func (slurmStruct SlurmStruct) ListQoss(ctx context.Context, req *pbslurm.ListQossReq) (*pbslurm.ListQossResp, error) { + + qosList := tianhe.GetQosInfo() + + resp := pbslurm.ListQossResp{} + for _, qos := range qosList.QosList { + qosInfoResult := qos + //userInfoResult.Name = user.Name + + resp.QosInfos = append(resp.QosInfos, &qosInfoResult) + } + + return &resp, nil +} diff --git a/adaptor/pcm_slurm/service/common/reservation.go b/adaptor/pcm_slurm/service/common/reservation.go new file mode 100644 index 00000000..6d895f2a --- /dev/null +++ b/adaptor/pcm_slurm/service/common/reservation.go @@ -0,0 +1,67 @@ +package slurmer + +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/service/tianhe" + "context" + "strings" +) + +func (slurmStruct SlurmStruct) ListReservations(ctx context.Context, req *pbslurm.ListReservationsReq) (*pbslurm.ListReservationsResp, error) { + reservationList := tianhe.Get_all_reservation() + + var resp = pbslurm.ListReservationsResp{} + for _, reservation := range reservationList.ReservationList { + reservationInfoResult := reservation + resp.ReservationList = append(resp.ReservationList, &reservationInfoResult) + } + return &resp, nil +} + +func (slurmStruct SlurmStruct) GetReservation(ctx context.Context, req *pbslurm.GetReservationReq) (*pbslurm.GetReservationResp, error) { + ReservationList := tianhe.GetReservationsInfo() + resp := pbslurm.GetReservationResp{} + for _, reservation := range ReservationList.ReservationList { + reservationInfoResult := reservation + if strings.Contains(reservation.Name, req.ReservationName) { + resp.ReservationInfos = append(resp.ReservationInfos, &reservationInfoResult) + } + } + return &resp, nil +} + +/*func (slurmStruct SlurmStruct) GetReservationByName(ctx context.Context, req *pbslurm.ReservationInfoMsgReq) (*pbslurm.ReservationInfoMsgResp, error) { + reservation := Get_reservation_info(req.ReservationName) + var resp = pbslurm.ReservationInfoMsgResp{} + for _, reservation := range reservation.Reservation_list { + reservationInfoResult := pbslurm.Reservation_Info{} + reservationInfoResult.Name = reservation.Name + /*nodeInfoResult.Boards = uint32(node.Boards) + nodeInfoResult.RealMemory = node.Real_memory + nodeInfoResult.Sockets = uint32(node.Sockets) + nodeInfoResult.Threads = uint32(node.Threads)* + resp.ReservationList = append(resp.ReservationList, &reservationInfoResult) + } + return &resp, nil +} + +func Get_reservation_info(name string) ReserveInfoMsg { + go_reservation_buffer := Get_all_reservation() + //partitionList := list.New() + for i := range go_reservation_buffer.ReservationList { + //遍历nodeList集合 + reservation := go_reservation_buffer.ReservationList[i] + fmt.Println("reservationName: " + reservation.Name) + //当集合中的名字等于传过来的值 + if name == reservation.Name { + /*partitionList.PushFront(partition.Name) + partitionList.PushFront(partition.Nodes)* + } else { + + } + //fmt.Println(partition.Node_inx) + } + return go_reservation_buffer + +}*/ diff --git a/adaptor/pcm_slurm/service/slurmer.go b/adaptor/pcm_slurm/service/common/slurmer.go similarity index 100% rename from adaptor/pcm_slurm/service/slurmer.go rename to adaptor/pcm_slurm/service/common/slurmer.go diff --git a/adaptor/pcm_slurm/service/tianhe.go b/adaptor/pcm_slurm/service/common/tianhe.go similarity index 100% rename from adaptor/pcm_slurm/service/tianhe.go rename to adaptor/pcm_slurm/service/common/tianhe.go diff --git a/adaptor/pcm_slurm/service/slurmdb_user.go b/adaptor/pcm_slurm/service/common/user_db.go similarity index 100% rename from adaptor/pcm_slurm/service/slurmdb_user.go rename to adaptor/pcm_slurm/service/common/user_db.go diff --git a/adaptor/pcm_slurm/service/slurmdb_wckey.go b/adaptor/pcm_slurm/service/common/wckey_db.go similarity index 100% rename from adaptor/pcm_slurm/service/slurmdb_wckey.go rename to adaptor/pcm_slurm/service/common/wckey_db.go diff --git a/adaptor/pcm_slurm/service/tianhe/account.go b/adaptor/pcm_slurm/service/tianhe/account.go new file mode 100644 index 00000000..1090d1ff --- /dev/null +++ b/adaptor/pcm_slurm/service/tianhe/account.go @@ -0,0 +1,82 @@ +package tianhe + +/* +#cgo LDFLAGS: -lslurmdb + +#include +#include +#include +#include +#include + +typedef struct account_info_msg { + uint32_t record_count; + slurmdb_account_rec_t *account_array; +} account_info_msg_t; + +typedef struct slurmdb_account_rec{ + List assoc_list; + List coord_accts; + char *description; + char *name; + char *organization; +} slurmdb_account_rec_pcm; + +struct account_info_msg get_account_info() { + struct account_info_msg accountinfo; + List accountList = NULL; + slurmdb_account_cond_t *account_cond = NULL; + void *db_conn; + db_conn = slurmdb_connection_get(); + accountList = slurmdb_accounts_get(db_conn, account_cond); + slurmdb_connection_close(&db_conn); + + slurmdb_account_rec_t *rec = NULL; + ListIterator itr = slurm_list_iterator_create(accountList); + int i = 0; + uint32_t length; + length = slurm_list_count(accountList); + accountinfo.record_count = length; + accountinfo.account_array = malloc(length * sizeof(slurmdb_account_rec_t)); + while ((rec = slurm_list_next(itr))) { + accountinfo.account_array[i] = *rec; + i++; + } + return accountinfo; +} + +struct slurmdb_account_rec *account_from_list(struct account_info_msg *list, int i) { + return (struct slurmdb_account_rec *) &list->account_array[i]; +} + +*/ +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" +) + +type AcctInfoMsg struct { + LastUpdate int64 + RecordCount uint32 + AcctInfoList []pbslurm.AccountInfo +} + +func AcctDescriptorConvertCToGo(cStruct *C.struct_slurmdb_account_rec) pbslurm.AccountInfo { + var goStruct pbslurm.AccountInfo + goStruct.Name = C.GoString(cStruct.name) + return goStruct +} + +func GetAcctInfo() AcctInfoMsg { + var goAcctBuffer AcctInfoMsg + cAcctBuffer := C.get_account_info() + goAcctBuffer.RecordCount = uint32(cAcctBuffer.record_count) + goAcctBuffer.AcctInfoList = make([]pbslurm.AccountInfo, cAcctBuffer.record_count, cAcctBuffer.record_count) + + for i := uint32(0); i < goAcctBuffer.RecordCount; i++ { + Acct := C.account_from_list(&cAcctBuffer, C.int(i)) + goAcct := AcctDescriptorConvertCToGo(Acct) + goAcctBuffer.AcctInfoList[i] = goAcct + } + return goAcctBuffer +} diff --git a/adaptor/pcm_slurm/service/slurmdb_association.go b/adaptor/pcm_slurm/service/tianhe/association.go similarity index 68% rename from adaptor/pcm_slurm/service/slurmdb_association.go rename to adaptor/pcm_slurm/service/tianhe/association.go index 242f0c3d..3c4af025 100644 --- a/adaptor/pcm_slurm/service/slurmdb_association.go +++ b/adaptor/pcm_slurm/service/tianhe/association.go @@ -1,10 +1,4 @@ -package slurmer - -import ( - pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" - "context" - "strings" -) +package tianhe /* #cgo LDFLAGS: -lslurmdb @@ -91,6 +85,7 @@ struct slurmdb_association_rec *assoc_from_list(struct assoc_info_msg *list, int */ import "C" +import pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" type AssocInfoMsg struct { LastUpdate int64 @@ -148,57 +143,3 @@ func GetAssociationInfos() AssocInfoMsg { } return goAssocBuffer } - -// SetAssociation set association info -func SetAssociation(accocInfo pbslurm.AssociationInfo) bool { - var goAssocBuffer AssocInfoMsg - cAssocBuffer := C.get_assoc_infos() - goAssocBuffer.RecordCount = uint32(cAssocBuffer.record_count) - goAssocBuffer.AssocInfoList = make([]pbslurm.AssociationInfo, cAssocBuffer.record_count, cAssocBuffer.record_count) - - for i := uint32(0); i < goAssocBuffer.RecordCount; i++ { - assoc := C.assoc_from_list(&cAssocBuffer, C.int(i)) - goAssociation := AssocDescriptorConvertCToGo(assoc) - goAssocBuffer.AssocInfoList[i] = goAssociation - } - return true -} - -func (slurmStruct SlurmStruct) ListAssociations(ctx context.Context, req *pbslurm.ListAssociationsReq) (*pbslurm.ListAssociationsResp, error) { - - assocList := GetAssociationInfos() - - resp := pbslurm.ListAssociationsResp{} - for _, assoc := range assocList.AssocInfoList { - assocResult := assoc - resp.AssocInfos = append(resp.AssocInfos, &assocResult) - } - - return &resp, nil -} - -func (slurmStruct SlurmStruct) SetAssociation(ctx context.Context, req *pbslurm.SetAssociationReq) (*pbslurm.SetAssociationResp, error) { - - result := SetAssociation(*req.AssocInfo) - - resp := pbslurm.SetAssociationResp{} - resp.Result = result - - return &resp, nil -} - -func (slurmStruct SlurmStruct) GetAssociation(ctx context.Context, req *pbslurm.GetAssociationReq) (*pbslurm.GetAssociationResp, error) { - - assocList := GetAssociationInfos() - - resp := pbslurm.GetAssociationResp{} - - for _, assoc := range assocList.AssocInfoList { - if (len(req.Cluster) != 0 || len(req.User) != 0 || len(req.Account) != 0 || len(req.Partition) != 0) && strings.Contains(assoc.Cluster, req.Cluster) && strings.Contains(assoc.Acct, req.Account) && strings.Contains(assoc.User, req.User) && strings.Contains(assoc.Partition, req.Partition) { - assocResult := assoc - resp.AssocInfos = append(resp.AssocInfos, &assocResult) - } - } - - return &resp, nil -} diff --git a/adaptor/pcm_slurm/service/tianhe/cluster.go b/adaptor/pcm_slurm/service/tianhe/cluster.go new file mode 100644 index 00000000..4049183a --- /dev/null +++ b/adaptor/pcm_slurm/service/tianhe/cluster.go @@ -0,0 +1,78 @@ +package tianhe + +/* +#cgo LDFLAGS: -lslurmdb + +#include +#include +#include +#include +#include + +typedef struct cluster_info_msg { + uint32_t record_count; + slurmdb_cluster_rec_t *cluster_array; +} cluster_info_msg_t; + +typedef struct slurmdb_cluster_rec{ + char *name; +} slurmdb_cluster_rec_pcm; + +struct cluster_info_msg get_cluster_info() { + struct cluster_info_msg clusterinfo; + List clusterList = NULL; + slurmdb_cluster_cond_t *cluster_cond = NULL; + void *db_conn; + db_conn = slurmdb_connection_get(); + clusterList = slurmdb_clusters_get(db_conn, cluster_cond); + slurmdb_connection_close(&db_conn); + + slurmdb_cluster_rec_t *rec = NULL; + ListIterator itr = slurm_list_iterator_create(clusterList); + int i = 0; + uint32_t length; + length = slurm_list_count(clusterList); + clusterinfo.record_count = length; + clusterinfo.cluster_array = malloc(length * sizeof(slurmdb_cluster_rec_t)); + while ((rec = slurm_list_next(itr))) { + clusterinfo.cluster_array[i] = *rec; + i++; + } + return clusterinfo; +} + +struct slurmdb_cluster_rec *cluster_from_list(struct cluster_info_msg *list, int i) { + return (struct slurmdb_cluster_rec *) &list->cluster_array[i]; +} + +*/ +import "C" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" +) + +type ClusterInfoMsg struct { + Last_update int64 + Record_count uint32 + ClusterInfoList []pbslurm.ClusterInfo +} + +func Cluster_descriptor_convert_c_to_go(c_struct *C.struct_slurmdb_cluster_rec) pbslurm.ClusterInfo { + var go_struct pbslurm.ClusterInfo + go_struct.Name = C.GoString(c_struct.name) + return go_struct +} + +func GetClusterInfo() ClusterInfoMsg { + var go_cluster_buffer ClusterInfoMsg + c_cluster_buffer := C.get_cluster_info() + go_cluster_buffer.Record_count = uint32(c_cluster_buffer.record_count) + go_cluster_buffer.ClusterInfoList = make([]pbslurm.ClusterInfo, c_cluster_buffer.record_count, c_cluster_buffer.record_count) + + for i := uint32(0); i < go_cluster_buffer.Record_count; i++ { + cluster := C.cluster_from_list(&c_cluster_buffer, C.int(i)) + go_cluster := Cluster_descriptor_convert_c_to_go(cluster) + go_cluster_buffer.ClusterInfoList[i] = go_cluster + } + return go_cluster_buffer +} diff --git a/adaptor/pcm_slurm/service/slurm_node.go b/adaptor/pcm_slurm/service/tianhe/node.go similarity index 73% rename from adaptor/pcm_slurm/service/slurm_node.go rename to adaptor/pcm_slurm/service/tianhe/node.go index 64c73d56..1e03c6a3 100644 --- a/adaptor/pcm_slurm/service/slurm_node.go +++ b/adaptor/pcm_slurm/service/tianhe/node.go @@ -1,7 +1,7 @@ -package slurmer +package tianhe /* -#cgo LDFLAGS: -lslurm +//#cgo LDFLAGS: -lslurm #include #include #include @@ -72,8 +72,6 @@ inline int64_t int64_ptr(int16_t* pointer) { import "C" import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" - "context" - "strings" ) type NodeInfoMsg struct { @@ -111,20 +109,23 @@ func Node_info_convert_c_to_go(c_struct *C.struct_node_info) pbslurm.NodeInfo { return go_struct } -func (slurmStruct SlurmStruct) ListNodes(ctx context.Context, req *pbslurm.ListNodesReq) (*pbslurm.ListNodesResp, error) { - nodeList := Get_all_nodes() - var resp = pbslurm.ListNodesResp{} - for _, node := range nodeList.NodeInfoList { - nodeInfoResult := pbslurm.NodeInfo{} - nodeInfoResult.Cpus = uint32(node.Cpus) - nodeInfoResult.Boards = uint32(node.Boards) - nodeInfoResult.RealMemory = node.RealMemory - nodeInfoResult.Sockets = uint32(node.Sockets) - nodeInfoResult.Threads = uint32(node.Threads) - resp.NodeInfos = append(resp.NodeInfos, &nodeInfoResult) - } +func NodeDescriptorConvertCToGo(cStruct *C.struct_node_info) pbslurm.NodeInfo { + var goStruct pbslurm.NodeInfo + goStruct.Name = C.GoString(cStruct.name) + return goStruct +} - return &resp, nil +func GetNodeInfo() NodeInfoMsg { + var goNodeBuffer NodeInfoMsg + cNodeBuffer := C.get_node_info() + goNodeBuffer.RecordCount = uint32(cNodeBuffer.record_count) + goNodeBuffer.NodeInfoList = make([]pbslurm.NodeInfo, cNodeBuffer.record_count, cNodeBuffer.record_count) + for i := uint32(0); i < goNodeBuffer.RecordCount; i++ { + Node := C.node_from_list(cNodeBuffer, C.int(i)) + goNode := NodeDescriptorConvertCToGo(Node) + goNodeBuffer.NodeInfoList[i] = goNode + } + return goNodeBuffer } func Get_all_nodes() NodeInfoMsg { @@ -148,50 +149,3 @@ func Get_all_nodes() NodeInfoMsg { return go_node_buffer } - -func NodeDescriptorConvertCToGo(cStruct *C.struct_node_info) pbslurm.NodeInfo { - var goStruct pbslurm.NodeInfo - goStruct.Name = C.GoString(cStruct.name) - return goStruct -} - -func GetNodeInfo() NodeInfoMsg { - var goNodeBuffer NodeInfoMsg - cNodeBuffer := C.get_node_info() - goNodeBuffer.RecordCount = uint32(cNodeBuffer.record_count) - goNodeBuffer.NodeInfoList = make([]pbslurm.NodeInfo, cNodeBuffer.record_count, cNodeBuffer.record_count) - for i := uint32(0); i < goNodeBuffer.RecordCount; i++ { - Node := C.node_from_list(cNodeBuffer, C.int(i)) - goNode := NodeDescriptorConvertCToGo(Node) - goNodeBuffer.NodeInfoList[i] = goNode - } - return goNodeBuffer -} - -func (slurmStruct SlurmStruct) GetNode(ctx context.Context, req *pbslurm.GetNodeReq) (*pbslurm.GetNodeResp, error) { - NodeList := GetNodeInfo() - resp := pbslurm.GetNodeResp{} - for _, node := range NodeList.NodeInfoList { - nodeInfoResult := node - if strings.Contains(node.Name, req.NodeName) { - resp.NodeInfos = append(resp.NodeInfos, &nodeInfoResult) - } - } - return &resp, nil -} - -/*func (slurmStruct SlurmStruct) GetNodeByName(ctx context.Context, req *pbnode.NodeInfoMsgReq) (*pbnode.NodeInfoMsgResp, error) { - node := Get_node_info(req.NodeName) - var resp = pbnode.NodeInfoMsgResp{} - for _, node := range node.Node_list { - nodeInfoResult := pbnode.Node_Info{} - nodeInfoResult.Cpus = uint32(node.Cpus) - nodeInfoResult.Boards = uint32(node.Boards) - nodeInfoResult.RealMemory = node.RealMemory - nodeInfoResult.Sockets = uint32(node.Sockets) - nodeInfoResult.Threads = uint32(node.Threads) - resp.NodeList = append(resp.NodeList, &nodeInfoResult) - } - - return &resp, nil -}*/ diff --git a/adaptor/pcm_slurm/service/slurm_partition.go b/adaptor/pcm_slurm/service/tianhe/partition.go similarity index 80% rename from adaptor/pcm_slurm/service/slurm_partition.go rename to adaptor/pcm_slurm/service/tianhe/partition.go index a6ad98ec..a8846c3b 100644 --- a/adaptor/pcm_slurm/service/slurm_partition.go +++ b/adaptor/pcm_slurm/service/tianhe/partition.go @@ -1,7 +1,7 @@ -package slurmer +package tianhe /* -#cgo LDFLAGS: -lslurm +//#cgo LDFLAGS: -lslurm #include #include @@ -25,8 +25,6 @@ package slurmer import "C" import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" - "context" - "strings" ) func Partition_info_convert_c_to_go(c_struct *C.struct_partition_info) pbslurm.PartitionInfo { @@ -90,16 +88,6 @@ func Get_partitions() PartitionInfoMsg { return go_partition_buffer } -func (slurmStruct SlurmStruct) ListPartitions(ctx context.Context, req *pbslurm.ListPartitionsReq) (*pbslurm.ListPartitionsResp, error) { - partitionList := Get_partitions() - var resp = pbslurm.ListPartitionsResp{} - for _, partition := range partitionList.PartitionInfoList { - partitionInfoResult := partition - resp.PartitionList = append(resp.PartitionList, &partitionInfoResult) - } - return &resp, nil -} - func GetPartitionsInfo() PartitionInfoMsg { var goPartitionBuffer PartitionInfoMsg cPartitionBuffer := C.get_partition_info() @@ -119,15 +107,3 @@ func PartitionDescriptorConvertCToGo(cStruct *C.struct_partition_info) pbslurm.P goStruct.Name = C.GoString(cStruct.name) return goStruct } - -func (slurmStruct SlurmStruct) GetPartition(ctx context.Context, req *pbslurm.GetPartitionReq) (*pbslurm.GetPartitionResp, error) { - PartitionList := GetPartitionsInfo() - resp := pbslurm.GetPartitionResp{} - for _, partition := range PartitionList.PartitionInfoList { - partitionInfoResult := partition - if strings.Contains(partition.Name, req.PartitionName) { - resp.PartitionInfos = append(resp.PartitionInfos, &partitionInfoResult) - } - } - return &resp, nil -} diff --git a/adaptor/pcm_slurm/service/slurmdb_qos.go b/adaptor/pcm_slurm/service/tianhe/qos.go similarity index 87% rename from adaptor/pcm_slurm/service/slurmdb_qos.go rename to adaptor/pcm_slurm/service/tianhe/qos.go index 773d42a4..c8fefa42 100644 --- a/adaptor/pcm_slurm/service/slurmdb_qos.go +++ b/adaptor/pcm_slurm/service/tianhe/qos.go @@ -1,7 +1,9 @@ -package slurmer +package tianhe import "C" -import pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" +import ( + pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" +) /* #cgo LDFLAGS: -lslurmdb @@ -84,9 +86,6 @@ struct slurmdb_qos_rec *qos_from_list(struct qos_info *qos_rec_t, int i) { } */ import "C" -import ( - "context" -) type Slurmdb_qos_rec struct { Description string @@ -141,18 +140,3 @@ func GetQosInfo() QosInfoMsg { } return goQosBuffer } - -func (slurmStruct SlurmStruct) ListQoss(ctx context.Context, req *pbslurm.ListQossReq) (*pbslurm.ListQossResp, error) { - - qosList := GetQosInfo() - - resp := pbslurm.ListQossResp{} - for _, qos := range qosList.QosList { - qosInfoResult := qos - //userInfoResult.Name = user.Name - - resp.QosInfos = append(resp.QosInfos, &qosInfoResult) - } - - return &resp, nil -} diff --git a/adaptor/pcm_slurm/service/slurm_reservation.go b/adaptor/pcm_slurm/service/tianhe/reservation.go similarity index 61% rename from adaptor/pcm_slurm/service/slurm_reservation.go rename to adaptor/pcm_slurm/service/tianhe/reservation.go index b8035aaa..2e490194 100644 --- a/adaptor/pcm_slurm/service/slurm_reservation.go +++ b/adaptor/pcm_slurm/service/tianhe/reservation.go @@ -1,7 +1,7 @@ -package slurmer +package tianhe /* -#cgo LDFLAGS: -lslurm +//#cgo LDFLAGS: -lslurm #include #include #include @@ -22,8 +22,6 @@ package slurmer import "C" import ( pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" - "context" - "strings" ) type ReservationInfoMsg struct { @@ -82,17 +80,6 @@ func Get_all_reservation() ReservationInfoMsg { return go_reservation_buffer } -func (slurmStruct SlurmStruct) ListReservations(ctx context.Context, req *pbslurm.ListReservationsReq) (*pbslurm.ListReservationsResp, error) { - reservationList := Get_all_reservation() - - var resp = pbslurm.ListReservationsResp{} - for _, reservation := range reservationList.ReservationList { - reservationInfoResult := reservation - resp.ReservationList = append(resp.ReservationList, &reservationInfoResult) - } - return &resp, nil -} - func GetReservationsInfo() ReservationInfoMsg { var goReservationBuffer ReservationInfoMsg cReservationBuffer := C.get_reserve_info() @@ -112,50 +99,3 @@ func ReservationDescriptorConvertCToGo(cStruct *C.struct_reserve_info) pbslurm.R goStruct.Name = C.GoString(cStruct.name) return goStruct } - -func (slurmStruct SlurmStruct) GetReservation(ctx context.Context, req *pbslurm.GetReservationReq) (*pbslurm.GetReservationResp, error) { - ReservationList := GetReservationsInfo() - resp := pbslurm.GetReservationResp{} - for _, reservation := range ReservationList.ReservationList { - reservationInfoResult := reservation - if strings.Contains(reservation.Name, req.ReservationName) { - resp.ReservationInfos = append(resp.ReservationInfos, &reservationInfoResult) - } - } - return &resp, nil -} - -/*func (slurmStruct SlurmStruct) GetReservationByName(ctx context.Context, req *pbslurm.ReservationInfoMsgReq) (*pbslurm.ReservationInfoMsgResp, error) { - reservation := Get_reservation_info(req.ReservationName) - var resp = pbslurm.ReservationInfoMsgResp{} - for _, reservation := range reservation.Reservation_list { - reservationInfoResult := pbslurm.Reservation_Info{} - reservationInfoResult.Name = reservation.Name - /*nodeInfoResult.Boards = uint32(node.Boards) - nodeInfoResult.RealMemory = node.Real_memory - nodeInfoResult.Sockets = uint32(node.Sockets) - nodeInfoResult.Threads = uint32(node.Threads)* - resp.ReservationList = append(resp.ReservationList, &reservationInfoResult) - } - return &resp, nil -} - -func Get_reservation_info(name string) ReserveInfoMsg { - go_reservation_buffer := Get_all_reservation() - //partitionList := list.New() - for i := range go_reservation_buffer.ReservationList { - //遍历nodeList集合 - reservation := go_reservation_buffer.ReservationList[i] - fmt.Println("reservationName: " + reservation.Name) - //当集合中的名字等于传过来的值 - if name == reservation.Name { - /*partitionList.PushFront(partition.Name) - partitionList.PushFront(partition.Nodes)* - } else { - - } - //fmt.Println(partition.Node_inx) - } - return go_reservation_buffer - -}*/ diff --git a/go.mod b/go.mod index ee375359..94b2f381 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/urfave/cli v1.22.2 github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea go.uber.org/zap v1.19.0 + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 google.golang.org/genproto v0.0.0-20221018160656-63c7b68cfc55 google.golang.org/grpc v1.50.1 google.golang.org/protobuf v1.28.1 @@ -106,7 +107,6 @@ require ( github.com/tjfoc/gmsm v1.3.2 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.1.0 // indirect golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect @@ -119,7 +119,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.22.3 // indirect k8s.io/component-base v0.21.4 // indirect k8s.io/klog/v2 v2.10.0 // indirect