本文整理汇总了Golang中github.com/skyrings/skyring-common/tools/logger.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getLdapConfig
func (a *App) getLdapConfig(rw http.ResponseWriter, req *http.Request) {
ctxt, err := GetContext(req)
if err != nil {
logger.Get().Error("Error Getting the context. error: %v", err)
}
ldapConfig, err := GetAuthProvider().GetDirectory()
if err != nil {
logger.Get().Error("%s-Unable to reterive directory service configuration:%s", ctxt, err)
HandleHttpError(rw, err)
return
}
json.NewEncoder(rw).Encode(
struct {
LdapServer string `json:"ldapserver"`
Port uint `json:"port"`
Base string `json:"base"`
Type string `json:"ldaptype"`
DomainAdmin string `json:"domainadmin"`
Password string `json:"password"`
Uid string `json:"uid"`
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
DisplayName string `json:"displayname"`
Email string `json:"email"`
}{ldapConfig.LdapServer, ldapConfig.Port, ldapConfig.Base, ldapConfig.Type,
ldapConfig.DomainAdmin, "", ldapConfig.Uid, ldapConfig.FirstName,
ldapConfig.LastName, ldapConfig.DisplayName, ldapConfig.Email})
}
开发者ID:skyrings,项目名称:skyring,代码行数:29,代码来源:auth.go
示例2: CreateDefaultECProfiles
func CreateDefaultECProfiles(ctxt string, mon string, clusterId uuid.UUID) (bool, error) {
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
var cluster models.Cluster
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_CLUSTERS)
if err := coll.Find(bson.M{"clusterid": clusterId}).One(&cluster); err != nil {
logger.Get().Error("%s-Error getting cluster details for %v. error: %v", ctxt, clusterId, err)
return false, err
}
var cmdMap map[string]string = map[string]string{
"4+2": fmt.Sprintf("ceph osd erasure-code-profile set k4m2 plugin=jerasure k=4 m=2 --cluster %s", cluster.Name),
"6+3": fmt.Sprintf("ceph osd erasure-code-profile set k6m3 plugin=jerasure k=6 m=3 --cluster %s", cluster.Name),
"8+4": fmt.Sprintf("ceph osd erasure-code-profile set k8m4 plugin=jerasure k=8 m=4 --cluster %s", cluster.Name),
}
for k, v := range cmdMap {
ok, _, err := cephapi_backend.ExecCmd(mon, clusterId, v, ctxt)
if err != nil || !ok {
logger.Get().Error("%s-Error creating EC profile for %s. error: %v", ctxt, k, err)
continue
} else {
logger.Get().Debug("%s-Added EC profile for %s", ctxt, k)
}
}
return true, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:26,代码来源:provider.go
示例3: getUser
func (a *App) getUser(rw http.ResponseWriter, req *http.Request) {
ctxt, err := GetContext(req)
if err != nil {
logger.Get().Error("Error Getting the context. error: %v", err)
}
vars := mux.Vars(req)
user, err := GetAuthProvider().GetUser(vars["username"], req)
if err != nil {
rw.WriteHeader(http.StatusNotFound)
bytes, _ := json.Marshal(apiError{Error: err.Error()})
rw.Write(bytes)
logger.Get().Error("%s-Unable to Get the user:%s", ctxt, err)
return
}
//hide the hash field
bytes, err := json.Marshal(struct {
*models.User
Hash bool `json:"hash,omitempty"`
}{
User: &user,
})
if err != nil {
logger.Get().Error("%s-Unable to marshal the User:%s", ctxt, err)
HandleHttpError(rw, err)
return
}
rw.Write(bytes)
}
开发者ID:skyrings,项目名称:skyring,代码行数:31,代码来源:auth.go
示例4: About
func (a *App) About(w http.ResponseWriter, r *http.Request) {
ctxt, err := GetContext(r)
if err != nil {
logger.Get().Error("Error Getting the context. error: %v", err)
}
var syscapabilities conf.SystemCapabilities
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_SYSTEM_CAPABILITIES)
if err := coll.Find(nil).One(&syscapabilities); err != nil {
HttpResponse(w, http.StatusBadRequest, fmt.Sprintf("Error in retrieving System Capabilities detail. error: %v", err))
logger.Get().Error("%s-Error in retrieving System Capabilities detail. error: %v", ctxt, err)
return
}
storage_provider_details := make(map[string]string)
for key, val := range syscapabilities.StorageProviderDetails {
storage_provider_details[strings.Title(key)] = val
delete(syscapabilities.StorageProviderDetails, key)
}
syscapabilities.StorageProviderDetails = storage_provider_details
if err := json.NewEncoder(w).Encode(syscapabilities); err != nil {
logger.Get().Error("%s-Error encoding data: %v", ctxt, err)
HttpResponse(w, http.StatusInternalServerError, err.Error())
}
}
开发者ID:skyrings,项目名称:skyring,代码行数:25,代码来源:about.go
示例5: FetchClusterDetailsFromProvider
func (a *App) FetchClusterDetailsFromProvider(ctxt string, clusterId uuid.UUID) (retVal map[string]map[string]interface{}, err error) {
retVal = make(map[string]map[string]interface{})
var result models.RpcResponse
vars := make(map[string]string)
vars["cluster-id"] = clusterId.String()
provider := a.GetProviderFromClusterId(ctxt, clusterId)
if provider == nil {
logger.Get().Error("%s-Faield to get provider for cluster: %v", ctxt, clusterId)
return nil, fmt.Errorf("Faield to get provider for cluster: %v", clusterId)
}
err = provider.Client.Call(fmt.Sprintf("%s.%s", provider.Name, "GetClusterSummary"), models.RpcRequest{RpcRequestVars: vars, RpcRequestData: []byte{}, RpcRequestContext: ctxt}, &result)
if result.Status.StatusCode == http.StatusOK || result.Status.StatusCode == http.StatusPartialContent {
providerResult := make(map[string]interface{})
unmarshalError := json.Unmarshal(result.Data.Result, &providerResult)
if unmarshalError != nil {
logger.Get().Error("%s - Error unmarshalling the monitoring data from provider %v.Error %v", ctxt, provider.Name, unmarshalError.Error())
return nil, fmt.Errorf("%s - Error unmarshalling the monitoring data from provider %v.Error %v", ctxt, provider.Name, unmarshalError.Error())
}
retVal[provider.Name] = providerResult
}
if err != nil {
return retVal, fmt.Errorf("%s - Call to provider %v failed.Err: %v\n", ctxt, provider.Name, err)
}
if result.Status.StatusMessage != "" && (result.Status.StatusCode == http.StatusPartialContent || result.Status.StatusCode == http.StatusInternalServerError || result.Status.StatusCode == http.StatusBadRequest) {
return retVal, fmt.Errorf("%s - Call to provider %v failed.Err: %v\n", ctxt, provider.Name, result.Status.StatusMessage)
}
return retVal, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:28,代码来源:request-router.go
示例6: GetEventById
func GetEventById(w http.ResponseWriter, r *http.Request) {
ctxt, err := GetContext(r)
if err != nil {
logger.Get().Error("Error Getting the context. error: %v", err)
}
vars := mux.Vars(r)
event_id_str := vars["event-id"]
event_id, err := uuid.Parse(event_id_str)
if err != nil {
logger.Get().Error("%s-Error parsing event id: %s", ctxt, event_id_str)
HttpResponse(w, http.StatusBadRequest, fmt.Sprintf("Error parsing event id: %s", event_id_str))
return
}
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
collection := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_APP_EVENTS)
var event models.AppEvent
if err := collection.Find(bson.M{"eventid": *event_id}).One(&event); err == mgo.ErrNotFound {
HttpResponse(w, http.StatusNotFound, "Event not found")
logger.Get().Error("%s-Event: %v not found. error: %v", ctxt, *event_id, err)
return
} else if err != nil {
logger.Get().Error("%s-Error getting the event detail for %v. error: %v", ctxt, *event_id, err)
HttpResponse(w, http.StatusBadRequest, "Event finding the record")
return
} else {
json.NewEncoder(w).Encode(event)
}
}
开发者ID:skyrings,项目名称:skyring,代码行数:32,代码来源:events.go
示例7: LoggingContext
//Middleware to create the logging context
func (a *App) LoggingContext(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
session, err := Store.Get(r, "session-key")
if err != nil {
logger.Get().Error("Error Getting the session. error: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
var username string
if val, ok := session.Values["username"]; ok {
username = val.(string)
}
reqId, err := uuid.New()
if err != nil {
logger.Get().Error("Error Creating the RequestId. error: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
loggingContext := fmt.Sprintf("%v:%v", username, reqId.String())
context.Set(r, LoggingCtxt, loggingContext)
defer context.Clear(r)
next(w, r)
}
开发者ID:skyrings,项目名称:skyring,代码行数:27,代码来源:skyring.go
示例8: checkAndUpdateAutoExpand
func checkAndUpdateAutoExpand(t *task.Task, clusterId uuid.UUID, ctxt string) {
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_LOGICAL_UNITS)
var slus []models.StorageLogicalUnit
if err := coll.Find(bson.M{"clusterid": clusterId}).All(&slus); err != nil {
logger.Get().Error(
"%s-Error getting SLUs of cluster: %v for colocation check. error: %v",
ctxt,
clusterId,
err)
return
}
for _, slu := range slus {
journalDet := slu.Options["journal"].(map[string]interface{})
if slu.Options["device"] == journalDet["journaldisk"].(string) {
coll1 := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_CLUSTERS)
if err := coll1.Update(
bson.M{"clusterid": clusterId},
bson.M{"$set": bson.M{"autoexpand": false}}); err != nil {
logger.Get().Error(
"%s-Error setting autoexpand flag for cluster: %v. error: %v",
ctxt,
clusterId,
err)
return
}
t.UpdateStatus("Disabled auto expand for cluster")
break
}
}
return
}
开发者ID:skyrings,项目名称:bigfin,代码行数:34,代码来源:import_cluster.go
示例9: NewLdapAuthProvider
func NewLdapAuthProvider(config io.Reader) (*Authorizer, error) {
if config == nil {
errStr := "missing configuration file for Ldap Auth provider"
logger.Get().Error(errStr)
return nil, fmt.Errorf(errStr)
}
userDao := skyring.GetDbProvider().UserInterface()
session := db.GetDatastore()
c := session.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_LDAP)
ldapDao := models.Directory{}
err := c.Find(bson.M{}).One(&ldapDao)
if err != nil {
logger.Get().Info("Failed to open ldap db collection:%s", err)
}
//Create the Provider
if provider, err := NewAuthorizer(userDao, ldapDao); err != nil {
logger.Get().Error("Unable to initialize the authorizer for Ldapauthprovider. error: %v", err)
panic(err)
} else {
return &provider, nil
}
}
开发者ID:skyrings,项目名称:skyring,代码行数:25,代码来源:ldapauth.go
示例10: SyncNodeUtilizations
func SyncNodeUtilizations(params map[string]interface{}) {
ctxt, ctxtOk := params["ctxt"].(string)
if !ctxtOk {
logger.Get().Error("Failed to fetch context")
return
}
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_NODES)
var nodes []models.Node
if err := coll.Find(bson.M{"state": models.NODE_STATE_ACTIVE}).All(&nodes); err != nil {
if err == mgo.ErrNotFound {
return
}
logger.Get().Warning("%s - Failed to fetch nodes in active state.Error %v", ctxt, err)
}
time_stamp_str := strconv.FormatInt(time.Now().Unix(), 10)
var nodeNames []string
for _, node := range nodes {
if node.State == models.NODE_STATE_ACTIVE {
nodeNames = append(nodeNames, node.Hostname)
}
}
if len(nodeNames) == 0 {
return
}
for _, node := range nodes {
go SyncNodeUtilization(ctxt, node, time_stamp_str)
}
go ComputeSystemSummary(make(map[string]interface{}))
}
开发者ID:skyrings,项目名称:skyring,代码行数:35,代码来源:sync.go
示例11: UpdateAlarmCount
func UpdateAlarmCount(event models.AppEvent, severity models.AlarmStatus, ctxt string) error {
if presentInList(ClusterAffectingEntities, event.NotificationEntity) {
if err := UpdateClusterAlarmCount(event, severity, ctxt); err != nil {
logger.Get().Error("%s-Could not update Alarm count for Cluster, for alert: %v. Error: %v", ctxt, event.EventId, err)
}
}
if presentInList(HostAffectingEntities, event.NotificationEntity) {
if err := UpdateNodeAlarmCount(event, severity, ctxt); err != nil {
logger.Get().Error("%s-Could not update Alarm count for node, for alert: %v. Error: %v", ctxt, event.EventId, err)
}
}
if presentInList(SluAffectingEntities, event.NotificationEntity) {
if err := UpdateSluAlarmCount(event, severity, ctxt); err != nil {
logger.Get().Error("%s-Could not update Alarm count for Slu, for alert: %v. Error: %v", ctxt, event.EventId, err)
}
}
if presentInList(StorageAffectingEntities, event.NotificationEntity) {
if err := UpdateStorageAlarmCount(event, severity, ctxt); err != nil {
logger.Get().Error("%s-Could not update Alarm count for storage, for alert: %v. Error: %v", ctxt, event.EventId, err)
}
}
if presentInList(BlockDeviceAffectingEntities, event.NotificationEntity) {
if err := UpdateBlockDeviceAlarmCount(event, severity, ctxt); err != nil {
logger.Get().Error("%s-Could not update Alarm count for Block Device, for alert: %v. Error: %v", ctxt, event.EventId, err)
}
}
return nil
}
开发者ID:skyrings,项目名称:skyring-common,代码行数:28,代码来源:handler.go
示例12: AuditLog
func AuditLog(ctxt string, event models.AppEvent, dbprovider dbprovider.DbInterface) error {
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
if event.ClusterName == "" {
coll := sessionCopy.DB(
conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_CLUSTERS)
var cluster models.Cluster
if err := coll.Find(bson.M{"clusterid": event.ClusterId}).One(&cluster); err == nil {
event.ClusterName = cluster.Name
}
}
event.Context = ctxt
if event.Notify {
subject, body, err := getMailDetails(event)
if err != nil {
logger.Get().Error("%s-Could not get mail details for event: %s", ctxt, event.Name)
} else {
if err = notifier.MailNotify(subject, body, dbprovider, ctxt); err == nil {
event.Notified = true
} else {
logger.Get().Error("%s-Could not send mail for event: %s", ctxt, event.Name)
}
}
}
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_APP_EVENTS)
if err := coll.Insert(event); err != nil {
logger.Get().Error("%s-Error adding the app event: %v", ctxt, err)
return err
}
return nil
}
开发者ID:skyrings,项目名称:skyring-common,代码行数:32,代码来源:audit_logger.go
示例13: node_lost_handler
func node_lost_handler(event models.AppEvent, ctxt string) (models.AppEvent, error) {
//worry about the node only if the node in active state
state, err := skyringutils.GetNodeStateById(ctxt, event.NodeId)
if state == models.NODE_STATE_ACTIVE && err == nil {
if err := skyringutils.Update_node_status_byId(ctxt, event.NodeId, models.NODE_STATUS_ERROR); err != nil {
return event, err
}
}
event.Name = skyring.EventTypes["NODE_STATE_CHANGED"]
event.Message = fmt.Sprintf("Host: %s lost contact", event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_MAJOR
event.NotificationEntity = models.NOTIFICATION_ENTITY_HOST
event.Notify = true
util.AppendServiceToNode(bson.M{"nodeid": event.NodeId}, models.SkyringServices[1], models.STATUS_DOWN, ctxt)
if err := update_alarm_count(event, ctxt); err != nil {
logger.Get().Error("%s-could not update alarm"+
" count for event: %s", ctxt, event.EventId.String())
return event, err
}
app := skyring.GetApp()
if err := app.RouteProviderEvents(ctxt, event); err != nil {
logger.Get().Error("%s-Event:%s could not be handled for node: %s. error: %v", ctxt, event.Name, event.NodeName, err)
}
return event, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:28,代码来源:handler.go
示例14: TestMailNotify
func TestMailNotify(notifier models.MailNotifier, subject string, body string, recepient []string, ctxt string) error {
subject = fmt.Sprintf("%s: ", notifier.SubPrefix) + subject
msg := []byte("To: " + recepient[0] + "\r\n" +
"Subject: " + subject + "\r\n" +
"\r\n" +
body + "\r\n")
err := SetMailClient(notifier, ctxt)
if err != nil {
logger.Get().Error("%s-Error setting the Mail Client Error: %v", ctxt, err)
return err
}
err = sendMail(notifier.MailId, recepient, msg)
if err != nil {
// retry once again after setting the client, as client might have timed out
if err := SetMailClient(notifier, ctxt); err != nil {
if err != nil {
logger.Get().Error("%s-Error setting the Mail Client Error: %v", ctxt, err)
return err
}
}
if err := sendMail(notifier.MailId, recepient, msg); err != nil {
logger.Get().Error("%s-Could not Send the Mail Notification. Error: %v", ctxt, err)
return err
}
}
client = nil
return nil
}
开发者ID:skyrings,项目名称:skyring-common,代码行数:29,代码来源:mail_notifier.go
示例15: InitAuthProvider
// InitPlugin creates an instance of the named plugin.
func InitAuthProvider(name string, configFilePath string) (AuthInterface, error) {
var authprovider AuthInterface
if name == "" {
logger.Get().Info("No providers specified.")
return nil, nil
}
var err error
if configFilePath != "" {
config, err := os.Open(configFilePath)
if err != nil {
logger.Get().Critical("Couldn't open auth provider configuration %s. error: %v",
configFilePath, err)
}
defer config.Close()
authprovider, err = GetAuthProvider(name, config)
} else {
// Pass explicit nil so providers can actually check for nil. See
// "Why is my nil error value not equal to nil?" in golang.org/doc/faq.
authprovider, err = GetAuthProvider(name, nil)
}
if err != nil {
return nil, fmt.Errorf("could not init plugin %s. error: %v", name, err)
}
if authprovider == nil {
return nil, fmt.Errorf("unknown plugin %s", name)
}
return authprovider, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:35,代码来源:authprovider.go
示例16: LoadAppConfiguration
func LoadAppConfiguration(configFilePath string, configFile string) {
file, err := ioutil.ReadFile(path.Join(configFilePath, configFile))
if err != nil {
logger.Get().Critical("Error reading skyring config. error: %v", err)
return
}
err = json.Unmarshal(file, &SystemConfig)
if err != nil {
logger.Get().Critical("Error unmarshalling skyring config. error: %v", err)
return
}
//Initialize the Provisioner Map
SystemConfig.Provisioners = make(map[string]ProvisionerConfig)
//Initialize System_capabilities
file, err = ioutil.ReadFile(path.Join(configFilePath, aboutConfigFile))
if err != nil {
logger.Get().Critical("Error reading about config. error: %v", err)
return
}
err = json.Unmarshal(file, &SystemConfig.SysCapabilities)
if err != nil {
logger.Get().Critical("Error unmarshalling about config. error: %v", err)
return
}
SystemConfig.SysCapabilities.StorageProviderDetails = make(map[string]string)
}
开发者ID:skyrings,项目名称:skyring-common,代码行数:26,代码来源:conf.go
示例17: GET_ClusterBlockDevices
func (a *App) GET_ClusterBlockDevices(w http.ResponseWriter, r *http.Request) {
ctxt, err := GetContext(r)
if err != nil {
logger.Get().Error("Error Getting the context. error: %v", err)
}
vars := mux.Vars(r)
cluster_id_str := vars["cluster-id"]
cluster_id, err := uuid.Parse(cluster_id_str)
if err != nil {
logger.Get().Error("%s - Error parsing the cluster id: %s. error: %v", ctxt, cluster_id_str, err)
HttpResponse(w, http.StatusBadRequest, fmt.Sprintf("Error parsing the cluster id: %s", cluster_id_str))
return
}
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
collection := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_BLOCK_DEVICES)
var blkDevices []models.BlockDevice
if err := collection.Find(bson.M{"clusterid": *cluster_id}).All(&blkDevices); err != nil {
if err == mgo.ErrNotFound {
HttpResponse(w, http.StatusNotFound, err.Error())
} else {
HttpResponse(w, http.StatusInternalServerError, err.Error())
}
logger.Get().Error("%s - Error getting the block devices list for cluster: %v. error: %v", ctxt, *cluster_id, err)
return
}
if len(blkDevices) == 0 {
json.NewEncoder(w).Encode([]models.BlockDevice{})
} else {
json.NewEncoder(w).Encode(blkDevices)
}
}
开发者ID:skyrings,项目名称:skyring,代码行数:35,代码来源:block_devices.go
示例18: GetUser
// CurrentUser returns the currently logged in user and a boolean validating
// the information.
func (a Authorizer) GetUser(u string, req *http.Request) (user models.User, e error) {
// This should search and fetch the user name based on the given value
// and can also check whether the available users are already imported
// into the database or not.
//if username is me, get the currently loggedin user
if u == authprovider.CurrentUser {
session, err := skyring.Store.Get(req, "session-key")
if err != nil {
logger.Get().Error("Error getting the session for user: %s. error: %v", u, err)
return user, err
}
if val, ok := session.Values["username"]; ok {
u = val.(string)
} else {
logger.Get().Error("Unable to identify the user: %s from session", u)
return user, mkerror("Unable to identify the user from session")
}
}
user, e = a.userDao.User(u)
if e != nil {
logger.Get().Error("Error retrieving the user: %s. error: %v", user, e)
return user, e
}
return user, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:28,代码来源:ldapauth.go
示例19: NewLocalAuthProvider
func NewLocalAuthProvider(config io.Reader) (*Authorizer, error) {
if config == nil {
logger.Get().Error("missing configuration file for Local Auth provider")
return nil, fmt.Errorf("missing configuration file for Local Auth provider")
}
providerCfg := LocalProviderCfg{}
bytes, err := ioutil.ReadAll(config)
if err != nil {
logger.Get().Error("Error reading configuration file. error: %v", err)
return nil, err
}
if err = json.Unmarshal(bytes, &providerCfg); err != nil {
logger.Get().Error("Unable to Unmarshall the data. error: %v", err)
return nil, err
}
//Create DB Backend
userDao := skyring.GetDbProvider().UserInterface()
//Create the Provider
if provider, err := NewAuthorizer(userDao, providerCfg.DefaultRole, providerCfg.Roles); err != nil {
logger.Get().Error("Unable to initialize the authorizer for localauthprovider. error: %v", err)
panic(err)
} else {
return &provider, nil
}
}
开发者ID:skyrings,项目名称:skyring,代码行数:28,代码来源:auth.go
示例20: sync_cluster_status
func sync_cluster_status(ctxt string, cluster models.Cluster, provider *Provider) (bool, error) {
var result models.RpcResponse
vars := make(map[string]string)
vars["cluster-id"] = cluster.ClusterId.String()
err = provider.Client.Call(
fmt.Sprintf("%s.%s", provider.Name, sync_functions["cluster_status"]),
models.RpcRequest{RpcRequestVars: vars, RpcRequestData: []byte{}, RpcRequestContext: ctxt},
&result)
if err != nil || result.Status.StatusCode != http.StatusOK {
logger.Get().Error("%s-Error getting status for cluster: %s. error:%v", ctxt, cluster.Name, err)
return false, err
}
clusterStatus, err := strconv.Atoi(string(result.Data.Result))
if err != nil {
logger.Get().Error("%s-Error getting status for cluster: %s. error:%v", ctxt, cluster.Name, err)
return false, err
}
// Set the cluster status
sessionCopy := db.GetDatastore().Copy()
defer sessionCopy.Close()
coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_STORAGE_CLUSTERS)
logger.Get().Info("%s-Updating the status of the cluster: %s to %d", ctxt, cluster.Name, clusterStatus)
if err := coll.Update(bson.M{"clusterid": cluster.ClusterId}, bson.M{"$set": bson.M{"status": clusterStatus}}); err != nil {
logger.Get().Error("%s-Error updating status for cluster: %s. error:%v", ctxt, cluster.Name, err)
return false, err
}
return true, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:30,代码来源:sync.go
注:本文中的github.com/skyrings/skyring-common/tools/logger.Get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论