Skip to content

pfcon get set internalvars

Rudolph Pienaar edited this page Nov 1, 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"
            }
}'

which should return

{                                                                                                                    
    "d_ret": {                                                                                                       
        "service": {                                                                                                 
            "host": {                                                                                                
                "compute": {                                                                                         
                    "addr": "172.20.0.4:5010",                                                                       
                    "authToken": "password",                                                                         
                    "baseURLpath": "api/v1/cmd/",                                                                    
                    "status": "undefined"                                                                            
                },                                                                                                   
                "data": {                                                                                            
                    "addr": "172.20.0.2:5055",                                                                       
                    "authToken": "password",                                                                         
                    "baseURLpath": "api/v1/cmd/",                                                                    
                    "status": "undefined"                                                                            
                }                                                                                                    
            },                                                                                                       
            "localhost": {                                                                                           
                "compute": {                                                                                         
                    "addr": "127.0.0.1:5010",                                                                        
                    "baseURLpath": "api/v1/cmd/",                                                                    
                    "status": "undefined"                                                                            
                },                                                                                                   
                "data": {                                                                                            
                    "addr": "127.0.0.1:5055",                                                                        
                    "baseURLpath": "api/v1/cmd/",                                                                    
                    "status": "undefined"                                                                            
                }                                                                                                    
            },
            "moc": {
                "compute": {
                    "addr": "pman-radiology.k-apps.osh.massopen.cloud",
                    "baseURLpath": "api/v1/cmd/",
                    "status": "undefined"
                },
                "data": {
                    "addr": "pfioh-radiology.k-apps.osh.massopen.cloud",
                    "baseURLpath": "api/v1/cmd/",
                    "status": "undefined"
                }
            },
            "openshiftlocal": {
                "compute": {
                    "addr": "pman-myproject.127.0.0.1.nip.io",
                    "authToken": "password",
                    "baseURLpath": "api/v1/cmd/",
                    "status": "undefined"
                },
                "data": {
                    "addr": "pfioh-myproject.127.0.0.1.nip.io",
                    "authToken": "password",
                    "baseURLpath": "api/v1/cmd/",
                    "status": "undefined"
                }
            }
        }
    },
    "status": true
}

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"
                }
            }
}'

set a PROXY:

pfurl --verb POST --raw \
      --http ${HOST_IP}:5005/api/v1/cmd \
      --httpResponseBodyParse \
      --jsonwrapper 'payload' \
      --msg \
'{  "action": "internalctl",
    "meta": {
                "var":     "/self/httpProxy",
                "set":     {
                    "httpSpec":   "http://proxy.tch.harvard.edu",
                    "use":        true
                }
            }
}'

--30--