Skip to content

pfcon get set internalvars

Rudolph Pienaar edited this page Jun 3, 2019 · 15 revisions

pfcon get/set internalvars

Abstract

This page describes how to directly set/get internal variables in pfcon. These variables are typically settings such as host service names, IP addresses, etc.

Preconditions

  • A HOST_IP environment variable that denotes the IP of the host housing the service. In Linux, you can do:
export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}')
  • Make sure that pfcon has been started (see here for more info)
pfcon --forever --httpResponse

msg summary

The msg payload of the REST interaction with pfcon is:

'{  "action": "internalctl",
    "meta": {
                "var":          "storeAddress",
                "get":          "value"
            }
}'

get

pfurl calling syntax

Assuming satisfied preconditions, let's get some data in the internal tree dictionary of the process

pfurl --verb POST --raw \
        --http ${HOST_IP}:5005/api/v1/cmd \
        --httpResponseBodyParse \
        --jsonwrapper 'payload' \
        --msg \
'{  "action": "internalctl",
    "meta": {
                "var":     "/service",
                "get":      "value"
            }
}'

set

pfurl calling syntax

Assuming satisfied preconditions, we can set an entire dictionary of values

./pfurl --verb POST --raw --http ${HOST_IP}:5005/api/v1/cmd --httpResponseBodyParse --jsonwrapper 'payload' --msg \
'{  "action": "internalctl",
    "meta": {
                "var":     "/service/megalodon",
                "set":     {
                    "compute": {
                        "addr": "10.20.1.71:5010",
                        "baseURLpath": "api/v1/cmd/",
                        "status": "undefined"
                    },
                    "data": {
                        "addr": "10.20.1.71:5055",
                        "baseURLpath": "api/v1/cmd/",
                        "status": "undefined"
                    }
                }
            }
}'

or

./pfurl --verb POST --raw --http ${HOST_IP}:5005/api/v1/cmd --httpResponseBodyParse --jsonwrapper 'payload' --msg \
'{  "action": "internalctl",
    "meta": {
                "var":     "/swift",
                "set":     {
                    "auth_url":                 "http://swift_service:8080/auth/v1.0",
                    "username":                 "chris:chris1234",
                    "key":                      "testing",
                    "container_name":           "users",
                    "auto_create_container":    true,
                    "file_storage":             "swift.storage.SwiftStorage"
                }
            }
}'

return payload

--30--