本文整理汇总了Golang中github.com/att/gopkgs/clike.Atoi函数的典型用法代码示例。如果您正苦于以下问题:Golang Atoi函数的具体用法?Golang Atoi怎么用?Golang Atoi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Atoi函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: bw_vlan2string
/*
Formats v1 and v2 in the {n} format for adding to a host representation which is
now token/project/vm:port{vlan}.
*/
func (p *Pledge_bw) bw_vlan2string() (v1 string, v2 string) {
v1 = ""
v2 = ""
if p.vlan1 != nil && clike.Atoi(*p.vlan1) > 0 {
v1 = "{" + *p.vlan1 + "}"
}
if p.vlan2 != nil && clike.Atoi(*p.vlan2) > 0 {
v2 = "{" + *p.vlan2 + "}"
}
return v1, v2
}
开发者ID:prydeep,项目名称:tegu,代码行数:16,代码来源:pledge_bw.go
示例2: vlan2string
/*
Returns {ID} if the vlan is defined and > 0. Returns an empty string if not
defined, or invalid value.
*/
func (p *Pledge_pass) vlan2string() (vlan string) {
vlan = ""
if p.vlan != nil && clike.Atoi(*p.vlan) > 0 {
vlan = "{" + *p.vlan + "}"
}
return vlan
}
开发者ID:dhanunjaya,项目名称:tegu,代码行数:12,代码来源:pledge_pass.go
示例3: vlan2string
/*
Formats vlan in the {n} format for adding to a host representation which is
now token/project/vm:port{vlan}. If vlan is < 0 then the empty string is returned.
*/
func (p *Pledge_bwow) vlan2string() (v string) {
if p != nil {
v = ""
if p.src_vlan != nil && clike.Atoi(*p.src_vlan) > 0 {
v = "{" + *p.src_vlan + "}"
}
}
return ""
}
开发者ID:dhanunjaya,项目名称:tegu,代码行数:14,代码来源:pledge_bwow.go
示例4: Initialise
/*
Sets up the global variables needed by the whole package. This should be invoked by the
main tegu function (main/tegu.go).
CAUTION: this is not implemented as an init() function as we must pass information from the
main to here.
*/
func Initialise(cfg_fname *string, ver *string, nwch chan *ipc.Chmsg, rmch chan *ipc.Chmsg, rmluch chan *ipc.Chmsg, osifch chan *ipc.Chmsg, fqch chan *ipc.Chmsg, amch chan *ipc.Chmsg) (err error) {
err = nil
def_log_dir := "."
log_dir := &empty_str
nw_ch = nwch
rmgr_ch = rmch
rmgrlu_ch = rmluch
osif_ch = osifch
fq_ch = fqch
am_ch = amch
if ver != nil {
version = *ver
}
tegu_sheep = bleater.Mk_bleater(1, os.Stderr) // the main (parent) bleater used by libraries and as master 'volume' control
tegu_sheep.Set_prefix("tegu")
pid = os.Getpid() // used to keep reservation names unique across invocations
tklr = ipc.Mk_tickler(30) // shouldn't need more than 30 different tickle spots
tklr.Add_spot(2, rmgr_ch, REQ_NOOP, nil, 1) // a quick burst tickle to prevent a long block if the first goroutine to schedule a tickle schedules a long wait
if cfg_fname != nil {
cfg_data, err = config.Parse2strs(nil, *cfg_fname) // capture config data as strings -- referenced as cfg_data["sect"]["key"]
if err != nil {
err = fmt.Errorf("unable to parse config file %s: %s", *cfg_fname, err)
return
}
if p := cfg_data["default"]["shell"]; p != nil {
shell_cmd = *p
}
if p := cfg_data["default"]["verbose"]; p != nil {
tegu_sheep.Set_level(uint(clike.Atoi(*p)))
}
if log_dir = cfg_data["default"]["log_dir"]; log_dir == nil {
log_dir = &def_log_dir
}
} else {
cfg_data = nil
}
tegu_sheep.Add_child(gizmos.Get_sheep()) // since we don't directly initialise the gizmo environment we ask for its sheep
if *log_dir != "stderr" { // if overriden in config
lfn := tegu_sheep.Mk_logfile_nm(log_dir, 86400)
tegu_sheep.Baa(1, "switching to log file: %s", *lfn)
tegu_sheep.Append_target(*lfn, false) // switch bleaters to the log file rather than stderr
go tegu_sheep.Sheep_herder(log_dir, 86400) // start the function that will roll the log now and again
}
return
}
开发者ID:prydeep,项目名称:tegu,代码行数:62,代码来源:globals.go
示例5: shift_values
/*
Accepts a string of space separated dscp values and returns a string with the values
appropriately shifted so that they can be used by the agent in a flow-mod command. E.g.
a dscp value of 40 is shifted to 160.
*/
func shift_values(list string) (new_list string) {
new_list = ""
sep := ""
toks := strings.Split(list, " ")
for i := range toks {
n := clike.Atoi(toks[i])
new_list += fmt.Sprintf("%s%d", sep, n<<2)
sep = " "
}
return
}
开发者ID:prydeep,项目名称:tegu,代码行数:18,代码来源:agent.go
示例6: get_hostinfo
/*
Given a name, get host info (IP, mac, switch-id, switch-port) from network.
*/
func get_hostinfo( name *string ) ( *string, *string, *string, int ) {
if name != nil && *name != "" {
ch := make( chan *ipc.Chmsg );
req := ipc.Mk_chmsg( )
req.Send_req( nw_ch, ch, REQ_HOSTINFO, name, nil ) // get host info string (mac, ip, switch)
req = <- ch
if req.State == nil {
htoks := strings.Split( req.Response_data.( string ), "," ) // results are: ip, mac, switch-id, switch-port; all strings
return &htoks[0], &htoks[1], &htoks[2], clike.Atoi( htoks[3] )
} else {
rm_sheep.Baa( 1, "get_hostinfo: error from network mgr: %s", req.State )
}
}
rm_sheep.Baa( 1, "get_hostinfo: no name provided" )
return nil, nil, nil, 0
}
开发者ID:att,项目名称:tegu,代码行数:21,代码来源:res_mgr.go
示例7: add_ulcap
/*
Set the user link capacity and forward it on to the network manager. We expect this
to be a request from the far side (user/admin) or read from the chkpt file so
the value is passed as a string (which is also what network wants too.
*/
func (inv *Inventory) add_ulcap( name *string, sval *string ) {
val := clike.Atoi( *sval )
pdata := make( []*string, 2 ) // parameters for message to network
pdata[0] = name
pdata[1] = sval
if val >= 0 && val < 101 {
rm_sheep.Baa( 2, "adding user cap: %s %d", *name, val )
inv.ulcap_cache[*name] = val
req := ipc.Mk_chmsg( )
req.Send_req( nw_ch, nil, REQ_SETULCAP, pdata, nil ) // push into the network environment
} else {
if val == -1 {
delete( inv.ulcap_cache, *name )
req := ipc.Mk_chmsg( )
req.Send_req( nw_ch, nil, REQ_SETULCAP, pdata, nil ) // push into the network environment
} else {
rm_sheep.Baa( 1, "user link capacity not set %d is out of range (1-100)", val )
}
}
}
开发者ID:att,项目名称:tegu,代码行数:29,代码来源:res_mgr.go
示例8: set_value
/*
Given a thing (field value in a struct), set the thing with the element in the map (key)
the map value to the proper type.
*/
func set_value(thing reflect.Value, kind reflect.Kind, key string, tag_id string, pfx string, annon bool, m map[string]string) {
if !thing.CanAddr() { // prevent stack dump
return
}
switch kind {
default:
fmt.Fprintf(os.Stderr, "transform.mts: tagged sturct member cannot be converted from map: tag=%s kind=%v\n", key, thing.Kind())
case reflect.String:
thing.SetString(m[key])
case reflect.Ptr:
p := thing.Elem() // get the pointer value; allows us to suss the type
if !p.IsValid() { // ptr is nill in the struct so we must allocate a pointer to 0 so it can be changed below
thing.Set(reflect.New(thing.Type().Elem()))
p = thing.Elem()
}
switch p.Kind() {
case reflect.String:
s := m[key] // copy it and then point to the copy
thing.Set(reflect.ValueOf(&s))
case reflect.Int:
i := clike.Atoi(m[key]) // convert to integer and then point at the value
thing.Set(reflect.ValueOf(&i))
case reflect.Int64:
i := clike.Atoi64(m[key])
thing.Set(reflect.ValueOf(&i))
case reflect.Int32:
i := clike.Atoi32(m[key])
thing.Set(reflect.ValueOf(&i))
case reflect.Int16:
i := clike.Atoi16(m[key])
thing.Set(reflect.ValueOf(&i))
case reflect.Int8:
i := int8(clike.Atoi16(m[key]))
thing.Set(reflect.ValueOf(&i))
case reflect.Uint:
ui := clike.Atou(m[key])
thing.Set(reflect.ValueOf(&ui))
case reflect.Uint64:
ui := clike.Atou64(m[key])
thing.Set(reflect.ValueOf(&ui))
case reflect.Uint32:
ui := clike.Atou32(m[key])
thing.Set(reflect.ValueOf(&ui))
case reflect.Uint16:
ui := clike.Atou16(m[key])
thing.Set(reflect.ValueOf(&ui))
case reflect.Uint8:
ui := uint8(clike.Atou16(m[key]))
thing.Set(reflect.ValueOf(&ui))
case reflect.Float64:
fv := clike.Atof(m[key])
thing.Set(reflect.ValueOf(&fv))
case reflect.Float32:
fv := float32(clike.Atof(m[key]))
thing.Set(reflect.ValueOf(&fv))
case reflect.Bool:
b := m[key] == "true" || m[key] == "True" || m[key] == "TRUE"
thing.Set(reflect.ValueOf(&b))
case reflect.Struct:
map_to_struct(m, p, p.Type(), tag_id, pfx) // recurse to process
}
case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8:
thing.SetInt(clike.Atoi64(m[key]))
case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8:
thing.SetUint(uint64(clike.Atoi64(m[key])))
case reflect.Float64, reflect.Float32:
thing.SetFloat(clike.Atof(m[key]))
case reflect.Bool:
thing.SetBool(m[key] == "true")
case reflect.Map:
new_map := reflect.MakeMap(thing.Type()) // create the map
thing.Set(new_map) // put it in the struct
//.........这里部分代码省略.........
开发者ID:prydeep,项目名称:gopkgs,代码行数:101,代码来源:tostruct.go
示例9: Res_manager
/*
Executes as a goroutine to drive the reservation manager portion of tegu.
*/
func Res_manager( my_chan chan *ipc.Chmsg, cookie *string ) {
var (
inv *Inventory
msg *ipc.Chmsg
ckptd string
last_qcheck int64 = 0 // time that the last queue check was made to set window
last_chkpt int64 = 0 // time that the last checkpoint was written
retry_chkpt bool = false // checkpoint needs to be retried because of a timing issue
queue_gen_type = REQ_GEN_EPQMAP
alt_table = DEF_ALT_TABLE // table number where meta marking happens
all_sys_up bool = false; // set when we receive the all_up message; some functions (chkpt) must wait for this
hto_limit int = 3600 * 18 // OVS has a size limit to the hard timeout value, this caps it just under the OVS limit
res_refresh int64 = 0 // next time when we must force all reservations to refresh flow-mods (hto_limit nonzero)
rr_rate int = 3600 // refresh rate (1 hour)
favour_v6 bool = true // favour ipv6 addresses if a host has both defined.
)
super_cookie = cookie // global for all methods
rm_sheep = bleater.Mk_bleater( 0, os.Stderr ) // allocate our bleater and attach it to the master
rm_sheep.Set_prefix( "res_mgr" )
tegu_sheep.Add_child( rm_sheep ) // we become a child so that if the master vol is adjusted we'll react too
p := cfg_data["default"]["queue_type"] // lives in default b/c used by fq-mgr too
if p != nil {
if *p == "endpoint" {
queue_gen_type = REQ_GEN_EPQMAP
} else {
queue_gen_type = REQ_GEN_QMAP
}
}
p = cfg_data["default"]["alttable"] // alt table for meta marking
if p != nil {
alt_table = clike.Atoi( *p )
}
p = cfg_data["default"]["favour_ipv6"]
if p != nil {
favour_v6 = *p == "true"
}
if cfg_data["resmgr"] != nil {
cdp := cfg_data["resmgr"]["chkpt_dir"]
if cdp == nil {
ckptd = "/var/lib/tegu/resmgr" // default directory and prefix
} else {
ckptd = *cdp + "/resmgr" // add prefix to directory in config
}
p = cfg_data["resmgr"]["verbose"]
if p != nil {
rm_sheep.Set_level( uint( clike.Atoi( *p ) ) )
}
/*
p = cfg_data["resmgr"]["set_vlan"]
if p != nil {
set_vlan = *p == "true"
}
*/
p = cfg_data["resmgr"]["super_cookie"]
if p != nil {
super_cookie = p
rm_sheep.Baa( 1, "super-cookie was set from config file" )
}
p = cfg_data["resmgr"]["hto_limit"] // if OVS or whatever has a max timeout we can ensure it's not surpassed
if p != nil {
hto_limit = clike.Atoi( *p )
}
p = cfg_data["resmgr"]["res_refresh"] // rate that reservations are refreshed if hto_limit is non-zero
if p != nil {
rr_rate = clike.Atoi( *p )
if rr_rate < 900 {
if rr_rate < 120 {
rm_sheep.Baa( 0, "NOTICE: reservation refresh rate in config is insanely low (%ds) and was changed to 1800s", rr_rate )
rr_rate = 1800
} else {
rm_sheep.Baa( 0, "NOTICE: reservation refresh rate in config is too low: %ds", rr_rate )
}
}
}
}
send_meta_counter := 200; // send meta f-mods only now and again
rm_sheep.Baa( 1, "ovs table number %d used for metadata marking", alt_table )
res_refresh = time.Now().Unix() + int64( rr_rate ) // set first refresh in an hour (ignored if hto_limit not set
inv = Mk_inventory( )
inv.chkpt = chkpt.Mk_chkpt( ckptd, 10, 90 )
last_qcheck = time.Now().Unix()
//.........这里部分代码省略.........
开发者ID:att,项目名称:tegu,代码行数:101,代码来源:res_mgr.go
示例10: Osif_mgr
/*
executed as a goroutine this loops waiting for messages from the tickler and takes
action based on what is needed.
*/
func Osif_mgr(my_chan chan *ipc.Chmsg) {
var (
msg *ipc.Chmsg
os_list string = ""
os_sects []string // sections in the config file
os_refs map[string]*ostack.Ostack // creds for each project we need to request info from
os_projects map[string]*osif_project // list of project info (maps)
os_admin *ostack.Ostack // admin creds
refresh_delay int = 15 // config file can override
id2pname map[string]*string // project id/name translation maps
pname2id map[string]*string
req_token bool = false // if set to true in config file the token _must_ be present when called to validate
def_passwd *string // defaults and what we assume are the admin creds
def_usr *string
def_url *string
def_project *string
def_region *string
)
osif_sheep = bleater.Mk_bleater(0, os.Stderr) // allocate our bleater and attach it to the master
osif_sheep.Set_prefix("osif_mgr")
tegu_sheep.Add_child(osif_sheep) // we become a child so that if the master vol is adjusted we'll react too
//ostack.Set_debugging( 0 );
// ---- pick up configuration file things of interest --------------------------
if cfg_data["osif"] != nil { // cannot imagine that this section is missing, but don't fail if it is
def_passwd = cfg_data["osif"]["passwd"] // defaults applied if non-section given in list, or info omitted from the section
def_usr = cfg_data["osif"]["usr"]
def_url = cfg_data["osif"]["url"]
def_project = cfg_data["osif"]["project"]
p := cfg_data["osif"]["refresh"]
if p != nil {
refresh_delay = clike.Atoi(*p)
if refresh_delay < 15 {
osif_sheep.Baa(1, "resresh was too small (%ds), setting to 15", refresh_delay)
refresh_delay = 15
}
}
p = cfg_data["osif"]["debug"]
if p != nil {
v := clike.Atoi(*p)
if v > -5 {
ostack.Set_debugging(v)
}
}
p = cfg_data["osif"]["region"]
if p != nil {
def_region = p
}
p = cfg_data["osif"]["ostack_list"] // preferred placement in osif section
if p == nil {
p = cfg_data["default"]["ostack_list"] // originally in default, so backwards compatable
}
if p != nil {
os_list = *p
}
p = cfg_data["osif"]["require_token"]
if p != nil && *p == "true" {
req_token = true
}
p = cfg_data["osif"]["verbose"]
if p != nil {
osif_sheep.Set_level(uint(clike.Atoi(*p)))
}
}
if os_list == " " || os_list == "" || os_list == "off" {
osif_sheep.Baa(0, "osif disabled: no openstack list (ostack_list) defined in configuration file or setting is 'off'")
} else {
// TODO -- investigate getting id2pname maps from each specific set of creds defined if an overarching admin name is not given
os_admin = get_admin_creds(def_url, def_usr, def_passwd, def_project, def_region) // this will block until we authenticate
if os_admin != nil {
osif_sheep.Baa(1, "admin creds generated, mapping tenants")
pname2id, id2pname, _ = os_admin.Map_tenants() // list only projects we belong to
for k, v := range pname2id {
osif_sheep.Baa(1, "project known: %s %s", k, *v) // useful to see in log what projects we can see
}
} else {
id2pname = make(map[string]*string) // empty maps and we'll never generate a translation from project name to tenant ID since there are no default admin creds
pname2id = make(map[string]*string)
if def_project != nil {
osif_sheep.Baa(0, "WRN: unable to use admin information (%s, proj=%s, reg=%s) to authorise with openstack [TGUOSI009]", def_usr, def_project, def_region)
} else {
osif_sheep.Baa(0, "WRN: unable to use admin information (%s, proj=no-project, reg=%s) to authorise with openstack [TGUOSI009]", def_usr, def_region) // YES msg ids are duplicated here
}
}
//.........这里部分代码省略.........
开发者ID:krjoshi,项目名称:tegu,代码行数:101,代码来源:osif.go
示例11: Agent_mgr
func Agent_mgr(ach chan *ipc.Chmsg) {
var (
port string = "29055" // port we'll listen on for connections
adata *agent_data
host_list string = ""
dscp_list string = "46 26 18" // list of dscp values that are used to promote a packet to the pri queue in intermed switches
refresh int64 = 60
iqrefresh int64 = 1800 // intermediate queue refresh (this can take a long time, keep from clogging the works)
)
adata = &agent_data{}
adata.agents = make(map[string]*agent)
am_sheep = bleater.Mk_bleater(0, os.Stderr) // allocate our bleater and attach it to the master
am_sheep.Set_prefix("agentmgr")
tegu_sheep.Add_child(am_sheep) // we become a child so that if the master vol is adjusted we'll react too
// suss out config settings from our section
if cfg_data["agent"] != nil {
if p := cfg_data["agent"]["port"]; p != nil {
port = *p
}
if p := cfg_data["agent"]["verbose"]; p != nil {
am_sheep.Set_level(uint(clike.Atoi(*p)))
}
if p := cfg_data["agent"]["refresh"]; p != nil {
refresh = int64(clike.Atoi(*p))
}
if p := cfg_data["agent"]["iqrefresh"]; p != nil {
iqrefresh = int64(clike.Atoi(*p))
if iqrefresh < 90 {
am_sheep.Baa(1, "iqrefresh in configuration file is too small, set to 90 seconds")
iqrefresh = 90
}
}
}
if cfg_data["default"] != nil { // we pick some things from the default section too
if p := cfg_data["default"]["pri_dscp"]; p != nil { // list of dscp (diffserv) values that match for priority promotion
dscp_list = *p
am_sheep.Baa(1, "dscp priority list from config file: %s", dscp_list)
} else {
am_sheep.Baa(1, "dscp priority list not in config file, using defaults: %s", dscp_list)
}
}
dscp_list = shift_values(dscp_list) // must shift values before giving to agent
// enforce some sanity on config file settings
am_sheep.Baa(1, "agent_mgr thread started: listening on port %s", port)
tklr.Add_spot(2, ach, REQ_MAC2PHOST, nil, 1) // tickle once, very soon after starting, to get a mac translation
tklr.Add_spot(10, ach, REQ_INTERMEDQ, nil, 1) // tickle once, very soon, to start an intermediate refresh asap
tklr.Add_spot(refresh, ach, REQ_MAC2PHOST, nil, ipc.FOREVER) // reocurring tickle to get host mapping
tklr.Add_spot(iqrefresh, ach, REQ_INTERMEDQ, nil, ipc.FOREVER) // reocurring tickle to ensure intermediate switches are properly set
sess_chan := make(chan *connman.Sess_data, 1024) // channel for comm from agents (buffers, disconns, etc)
smgr := connman.NewManager(port, sess_chan)
for {
select { // wait on input from either channel
case req := <-ach:
req.State = nil // nil state is OK, no error
am_sheep.Baa(3, "processing request %d", req.Msg_type)
switch req.Msg_type {
case REQ_NOOP: // just ignore -- acts like a ping if there is a return channel
case REQ_SENDALL: // send request to all agents
if req.Req_data != nil {
adata.send2all(smgr, req.Req_data.(string))
}
case REQ_SENDLONG: // send a long request to one agent
if req.Req_data != nil {
adata.send2one(smgr, req.Req_data.(string))
}
case REQ_SENDSHORT: // send a short request to one agent (round robin)
if req.Req_data != nil {
adata.send2one(smgr, req.Req_data.(string))
}
case REQ_MAC2PHOST: // send a request for agent to generate mac to phost map
if host_list != "" {
adata.send_mac2phost(smgr, &host_list)
}
case REQ_CHOSTLIST: // a host list from fq-manager
if req.Req_data != nil {
host_list = *(req.Req_data.(*string))
}
case REQ_INTERMEDQ:
req.Response_ch = nil
if host_list != "" {
adata.send_intermedq(smgr, &host_list, &dscp_list)
}
}
//.........这里部分代码省略.........
开发者ID:prydeep,项目名称:tegu,代码行数:101,代码来源:agent.go
示例12: Fq_mgr
/*
the main go routine to act on messages sent to our channel. We expect messages from the
reservation manager, and from a tickler that causes us to evaluate the need to resize
ovs queues.
DSCP values: Dscp values range from 0-64 decimal, but when described on or by
flow-mods are shifted two bits to the left. The send flow mod function will
do the needed shifting so all values outside of that one funciton should assume/use
decimal values in the range of 0-64.
*/
func Fq_mgr(my_chan chan *ipc.Chmsg, sdn_host *string) {
var (
uri_prefix string = ""
msg *ipc.Chmsg
data []interface{} // generic list of data on some requests
fdata *Fq_req // flow-mod request data
qcheck_freq int64 = 5
hcheck_freq int64 = 180
host_list *string // current set of openstack real hosts
ip2mac map[string]*string // translation from ip address to mac
switch_hosts *string // from config file and overrides openstack list if given (mostly testing)
ssq_cmd *string // command string used to set switch queues (from config file)
send_all bool = false // send all flow-mods; false means send just ingress/egress and not intermediate switch f-mods
alt_table int = DEF_ALT_TABLE // meta data marking table
phost_suffix *string = nil // physical host suffix added to each host name in the list from openstack (config)
//max_link_used int64 = 0 // the current maximum link utilisation
)
fq_sheep = bleater.Mk_bleater(0, os.Stderr) // allocate our bleater and attach it to the master
fq_sheep.Set_prefix("fq_mgr")
tegu_sheep.Add_child(fq_sheep) // we become a child so that if the master vol is adjusted we'll react too
// -------------- pick up config file data if there --------------------------------
if *sdn_host == "" { // not supplied on command line, pull from config
if sdn_host = cfg_data["default"]["sdn_host"]; sdn_host == nil { // no default; when not in config, then it's turned off and we send to agent
sdn_host = &empty_str
}
}
if cfg_data["default"]["queue_type"] != nil {
if *cfg_data["default"]["queue_type"] == "endpoint" {
send_all = false
} else {
send_all = true
}
}
if p := cfg_data["default"]["alttable"]; p != nil { // this is the base; we use alt_table to alt_table + (n-1) when we need more than 1 table
alt_table = clike.Atoi(*p)
}
if cfg_data["fqmgr"] != nil { // pick up things in our specific setion
if dp := cfg_data["fqmgr"]["ssq_cmd"]; dp != nil { // set switch queue command
ssq_cmd = dp
}
/*
if p := cfg_data["fqmgr"]["default_dscp"]; p != nil { // this is a single value and should not be confused with the dscp list in the default section of the config
dscp = clike.Atoi( *p )
}
*/
if p := cfg_data["fqmgr"]["queue_check"]; p != nil { // queue check frequency from the control file
qcheck_freq = clike.Atoi64(*p)
if qcheck_freq < 5 {
qcheck_freq = 5
}
}
if p := cfg_data["fqmgr"]["host_check"]; p != nil { // frequency of checking for new _real_ hosts from openstack
hcheck_freq = clike.Atoi64(*p)
if hcheck_freq < 30 {
hcheck_freq = 30
}
}
if p := cfg_data["fqmgr"]["switch_hosts"]; p != nil {
switch_hosts = p
}
if p := cfg_data["fqmgr"]["verbose"]; p != nil {
fq_sheep.Set_level(uint(clike.Atoi(*p)))
}
if p := cfg_data["fqmgr"]["phost_suffix"]; p != nil { // suffix added to physical host strings for agent commands
if *p != "" {
phost_suffix = p
fq_sheep.Baa(1, "physical host names will be suffixed with: %s", *phost_suffix)
}
}
}
// ----- end config file munging ---------------------------------------------------
//tklr.Add_spot( qcheck_freq, my_chan, REQ_SETQUEUES, nil, ipc.FOREVER ); // tickle us every few seconds to adjust the ovs queues if needed
if switch_hosts == nil {
tklr.Add_spot(2, my_chan, REQ_CHOSTLIST, nil, 1) // tickle once, very soon after starting, to get a host list
tklr.Add_spot(hcheck_freq, my_chan, REQ_CHOSTLIST, nil, ipc.FOREVER) // tickles us every once in a while to update host list
//.........这里部分代码省略.........
开发者ID:robert-eby,项目名称:tegu,代码行数:101,代码来源:fq_mgr.go
示例13: cvt2desired
/*
Internal funciton to convert an interface into a supported desired value.
*/
func cvt2desired(v interface{}, desired int) interface{} {
switch v.(type) {
case string:
switch desired {
case ET_STRING:
return v
case ET_STRINGP:
return &v
case ET_INT:
return v.(int)
case ET_UINT:
return v.(uint)
case ET_INT64:
return v.(int64)
case ET_FLOAT:
return v.(float64)
case ET_BOOL:
return v == "true"
}
case *string:
switch desired {
case ET_STRING:
return *(v.(*string))
case ET_STRINGP:
return v
case ET_INT:
return clike.Atoi(*(v.(*string)))
case ET_UINT:
return clike.Atou(*(v.(*string)))
case ET_INT64:
return clike.Atoll(*(v.(*string)))
case ET_FLOAT:
return clike.Atof(*(v.(*string)))
case ET_BOOL:
return *(v.(*string)) == "true"
}
case float64:
switch desired {
case ET_STRING:
return fmt.Sprintf("%.2f", v)
case ET_STRINGP:
s := fmt.Sprintf("%.2f", v)
return &s
case ET_INT:
return int(v.(float64))
case ET_UINT:
return uint(v.(float64))
case ET_INT64:
return int64(v.(float64))
case ET_FLOAT:
return v
case ET_BOOL:
return v.(float64) != 0.0
}
case int:
switch desired {
case ET_STRING:
return fmt.Sprintf("%d", v)
case ET_STRINGP:
s := fmt.Sprintf("%d", v)
return &s
case ET_INT:
return v
case ET_UINT:
return uint(v.(int))
case ET_INT64:
return int64(v.(int))
case ET_FLOAT:
return float64(v.(int))
case ET_BOOL:
return v.(int) != 0
}
case int64:
switch desired {
case ET_STRING:
return fmt.Sprintf("%d", v)
case ET_STRINGP:
s := fmt.Sprintf("%d", v)
return &s
case ET_INT:
return int(v.(int64))
case ET_UINT:
return uint(v.(int64))
case ET_INT64:
return v
case ET_FLOAT:
return float64(v.(int64))
case ET_BOOL:
return v.(int64) != 0
}
case bool:
//.........这里部分代码省略.........
开发者ID:att,项目名称:gopkgs,代码行数:101,代码来源:cfg_file.go
注:本文中的github.com/att/gopkgs/clike.Atoi函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论