Go (golang) plugin in Citellus

I wanted to practice a bit Go programing, so I divided that task in two parts, one, adding a golang extension for Citellus and a sample, but working plugin using it. If interested in the code it’s available at the review at https://review.gerrithub.io/c/citellusorg/citellus/+/495622. The final sample code for it has been: // Author: Pablo Iranzo Gómez ([email protected]) // Header for citellus metadata // long_name: Report detected number of CPU's // description: List the processors detected in the system // priority: 200 package main import ( "bufio" "io" "os" "runtime" "strconv" "strings" ) func main() { var OKAY, _ = strconv.Atoi(os.Getenv("RC_OKAY")) var SKIP, _ = strconv.Atoi(os.Getenv("RC_SKIPPED")) var INFO, _ = strconv.Atoi(os.Getenv("RC_INFO")) var CITELLUS_ROOT = os.Getenv("CITELLUS_ROOT") var CITELLUS_LIVE, _ = strconv.Atoi(os.Getenv("CITELLUS_LIVE")) var FAILED, _ = strconv.Atoi(os.Getenv("RC_FAILED")) if CITELLUS_LIVE == 1 { // Report # of CPU's var CPUS = runtime.NumCPU() os.Stderr.WriteString(strconv.Itoa(CPUS)) os.Exit(INFO) } else if CITELLUS_LIVE == 0 { file, err := os.Open(CITELLUS_ROOT + "/proc/cpuinfo") if err != nil { os.Stderr.WriteString("Failure to open required file " + CITELLUS_ROOT + "/proc/cpuinfo") os.Exit(SKIP) } defer file.Close() counts := wordCount(file) os.Stderr.WriteString(strconv.Itoa(counts["processor"])) os.Exit(INFO) } else { os.Stderr.WriteString("Undefined CITELLUS_LIVE status") os.Exit(FAILED) } // Failback case, exiting as OK os.Exit(OKAY) } // https://forgetcode.com/go/2348-count-the-number-of-word-occurrence-in-given-a-file func wordCount(rdr io.Reader) map[string]int { counts := map[string]int{} scanner := bufio.NewScanner(rdr) scanner.Split(bufio.ScanWords) for scanner.Scan() { word := scanner.Text() word = strings.ToLower(word) counts[word]++ } return counts } Of course, lot of googling helped to start building the pieces. ...

June 14, 2020 · 2 min · Pablo Iranzo Gómez

Dell racadm remote ISO load

In order to test IPv6 deployment on Dell hardware I was in need to patch the servers to ensure that UEFI boot mode is in use. Normally I would had use the DSU that runs from within Linux, but as the servers are part of an OpenShift installation (using baremetal-deploy) and using CoreOS as the underlying system I wanted to load ISO from HTTP server on the deployhost (running RHEL). The command is not that hard, let’s first define some variables: ...

May 12, 2020 · 1 min · Pablo Iranzo Gómez

Lego Speed Champions 76899 Lamborghini Urus ST-X & Lamborghini Huracán Super Trofeo EVO

Today I built the Lamborghini Urus ST-X & Lamborghini Huracán Super Trofeo EVO 🛒#ad. I liked especially the Huracán and the Urus was also very well done, a lot of details! Enjoy! (and if you do, you can Buy Me a Coffee ) ...

April 30, 2020 · 1 min · Pablo Iranzo Gómez

Lego Speed Champions 76898 Jaguar Racing GEN2 car & Jaguar I-PACE eTROPHY

Today I built the Jaguar Racing GEN2 car & Jaguar I-PACE eTROPHY 🛒#ad. I also bought a Light box to take pictures, so here are my first attempts. Enjoy! (and if you do, you can Buy Me a Coffee ) ...

April 28, 2020 · 1 min · Pablo Iranzo Gómez

Lego 10266 NASA Lunar Lander

Today, as part of my confinement Lego catchup I was building the Lego NASA Lunar Lander Apollo 11 🛒#ad. It covered the evening after work, and have some nice details. First bags are for the lunar surface and the remainder are for the module starting with the parts which are closer to the moon surface. It includes lots of gold-colour plates and some stickers for the external side (flag, controls of the lunar module and some external surfaces). ...

April 8, 2020 · 1 min · Pablo Iranzo Gómez
This blog is a participant in the Amazon Associate Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.