本文整理汇总了Golang中github.com/justinsb/gova/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: addCharmViaAPI
// addCharmViaAPI calls the appropriate client API calls to add the
// given charm URL to state. Also displays the charm URL of the added
// charm on stdout.
func addCharmViaAPI(client *api.Client, curl *charm.URL, repo charm.Repository) (*charm.URL, error) {
if curl.Revision < 0 {
latest, err := charm.Latest(repo, curl)
if err != nil {
log.Info("Error find latest version for: %v", curl.String(), err)
return nil, err
}
curl = curl.WithRevision(latest)
}
switch curl.Schema {
case "local":
ch, err := repo.Get(curl)
if err != nil {
return nil, err
}
stateCurl, err := client.AddLocalCharm(curl, ch)
if err != nil {
return nil, err
}
curl = stateCurl
case "cs":
err := client.AddCharm(curl)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported charm URL schema: %q", curl.Schema)
}
log.Info("Added charm %q to the environment.", curl)
return curl, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:34,代码来源:charm.go
示例2: HttpGet
func (self *EndpointServiceInstance) HttpGet() (*rs.HttpResponse, error) {
service := self.getService()
log.Info("CF instance GET request: %v", self.Id)
bundleType, instance := service.getInstance(self.Id)
if instance == nil || bundleType == nil {
return nil, rs.ErrNotFound()
}
state, err := instance.GetState()
if err != nil {
log.Warn("Error while waiting for instance to become ready", err)
return nil, err
}
ready := false
if state == nil {
log.Warn("Instance not yet created")
} else {
status := state.Status
if status == "started" {
ready = true
} else if status == "pending" {
ready = false
} else {
log.Warn("Unknown instance status: %v", status)
}
}
response := &CfCreateInstanceResponse{}
// TODO: We need a dashboard URL - maybe a Juju GUI?
response.DashboardUrl = "http://localhost:8080"
var cfState string
if ready {
cfState = CF_STATE_SUCCEEDED
} else {
cfState = CF_STATE_IN_PROGRESS
}
response.State = cfState
response.LastOperation = &CfOperation{}
response.LastOperation.State = cfState
log.Info("Sending response to CF service get", log.AsJson(response))
httpResponse := &rs.HttpResponse{Status: http.StatusOK}
httpResponse.Content = response
return httpResponse, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:50,代码来源:service_instance.go
示例3: listSubkeys
func (self *EtcdRouterRegistry) listSubkeys(key string) ([]string, error) {
response, err := self.client.Get(key, false, false)
if err != nil {
etcdError, ok := err.(*etcd.EtcdError)
if ok && etcdError.ErrorCode == etcdErrorKeyNotFound {
log.Debug("Etcd key not found: %v", key)
return []string{}, nil
}
log.Warn("Error reading key from etcd: %v", key, err)
return nil, err
}
if response == nil || response.Node == nil || response.Node.Nodes == nil {
log.Info("No children for key from etcd: %v", key)
return []string{}, nil
}
names := []string{}
for _, node := range response.Node.Nodes {
nodeKey := node.Key
if !strings.HasPrefix(nodeKey, key) {
return nil, fmt.Errorf("Key without expected prefix: %v vs %v", nodeKey, key)
}
suffix := nodeKey[len(key):]
names = append(names, suffix)
}
return names, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:29,代码来源:etcd_router_registry.go
示例4: getCharmInfo
func getCharmInfo(client *api.Client, charmName string, localRepoPath string, defaultSeries string) (*api.CharmInfo, error) {
curl, err := resolveCharmURL(client, charmName, defaultSeries)
if err != nil {
return nil, err
}
repo, err := charm.InferRepository(curl.Reference, localRepoPath)
if err != nil {
return nil, err
}
// repo = config.SpecializeCharmRepo(repo, defaultSeries)
curl, err = addCharmViaAPI(client, curl, repo)
if err != nil {
return nil, err
}
charmInfo, err := client.CharmInfo(curl.String())
if err != nil {
log.Info("Error getting charm info for: %v", curl.String(), err)
return nil, err
}
return charmInfo, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:25,代码来源:charm.go
示例5: read
func (self *EtcdRouterRegistry) read(key string) (*etcdRouterData, error) {
response, err := self.client.Get(key, false, false)
if err != nil {
etcdError, ok := err.(*etcd.EtcdError)
if ok && etcdError.ErrorCode == etcdErrorKeyNotFound {
log.Debug("Etcd key not found: %v", key)
return nil, nil
}
log.Warn("Error reading key from etcd: %v", key, err)
return nil, err
}
node := response.Node
if node == nil || node.Value == "" {
log.Info("No contents for key from etcd: %v", key)
return nil, nil
}
decoded := &etcdRouterData{}
err = json.Unmarshal([]byte(node.Value), decoded)
if err != nil {
log.Warn("Error parsing value from etcd: %v", node.Value, err)
return nil, err
}
return decoded, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:28,代码来源:etcd_router_registry.go
示例6: HttpDelete
func (self *EndpointServiceInstance) HttpDelete(httpRequest *http.Request) (*CfDeleteInstanceResponse, error) {
service := self.getService()
queryValues := httpRequest.URL.Query()
serviceId := queryValues.Get("service_id")
// planId := queryValues.Get("plan_id")
if serviceId != service.CfServiceId {
log.Warn("Service mismatch: %v vs %v", serviceId, service.CfServiceId)
return nil, rs.ErrNotFound()
}
log.Info("Deleting item %v %v", serviceId, self.Id)
bundletype, instance := service.getInstance(self.getInstanceId())
if instance == nil || bundletype == nil {
return nil, rs.ErrNotFound()
}
err := instance.Delete()
if err != nil {
return nil, err
}
// TODO: Wait for deletion?
response := &CfDeleteInstanceResponse{}
return response, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:29,代码来源:service_instance.go
示例7: HttpPut
func (self *EndpointInstanceScaling) HttpPut(policyUpdate *model.ScalingPolicy) (*model.Scaling, error) {
instance := self.Parent.getInstance()
log.Info("Policy update: %v", policyUpdate)
exists, err := instance.Exists()
if err != nil {
return nil, err
}
if !exists {
return nil, rs.ErrNotFound()
}
if policyUpdate != nil {
_, err := instance.UpdateScalingPolicy(policyUpdate)
if err != nil {
log.Warn("Error updating scaling policy", err)
return nil, err
}
}
results, err := instance.RunScaling(true)
if err != nil {
return nil, err
}
return results, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:27,代码来源:instance_scaling.go
示例8: DeleteRelationInfo
// Delete any relation properties relating to the specified unit; that unit is going away.
func (self *Instance) DeleteRelationInfo(unitId string, relationId string) error {
jujuClient := self.GetJujuClient()
serviceId := self.primaryServiceId
prefix := ANNOTATION_PREFIX_RELATIONINFO + unitId + "_" + relationId + "_"
annotations, err := jujuClient.GetServiceAnnotations(serviceId)
if err != nil {
log.Warn("Error getting annotations", err)
// TODO: Mask error?
return err
}
deleteKeys := []string{}
for tagName, _ := range annotations {
if !strings.HasPrefix(tagName, prefix) {
continue
}
deleteKeys = append(deleteKeys, tagName)
}
if len(deleteKeys) != 0 {
log.Info("Deleting annotations on service %v: %v", serviceId, deleteKeys)
err = jujuClient.DeleteServiceAnnotations(serviceId, deleteKeys)
if err != nil {
log.Warn("Error deleting annotations", err)
return err
}
}
return nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:36,代码来源:instance.go
示例9: localIP
func localIP() (net.IP, error) {
netInterfaces, err := net.Interfaces()
if err != nil {
return nil, err
}
for _, netInterface := range netInterfaces {
addresses, err := netInterface.Addrs()
if err != nil {
return nil, err
}
for _, address := range addresses {
ipnet, ok := address.(*net.IPNet)
if !ok {
continue
}
v4 := ipnet.IP.To4()
if v4 == nil || v4[0] == 127 { // loopback address
continue
}
log.Info("Chose local IP: %v", v4)
return v4, nil
}
}
return nil, errors.New("Cannot find local IP address")
}
开发者ID:jxaas,项目名称:jxaas,代码行数:25,代码来源:options.go
示例10: GetOptions
func GetOptions() *Options {
flag.Parse()
self := &Options{}
self.AgentConf = *flagAgentConf
self.ApiPasswordPath = *flagApiPasswordPath
self.CfTenantId = *flagCfTenantId
self.ListenAddress = *flagListenAddress
host, port, err := net.SplitHostPort(self.ListenAddress)
if err != nil {
log.Warn("Cannot parse listen address: %v", self.ListenAddress)
return nil
}
var portNum int
if port == "" {
portNum = 8080
} else {
portNum, err = net.LookupPort("tcp", port)
if err != nil {
log.Warn("Cannot resolve port: %v", port)
return nil
}
}
privateUrl := *flagPrivateUrl
if privateUrl == "" {
privateHost := host
if privateHost == "" {
ip, err := localIP()
if err != nil {
log.Warn("Error finding local IP", err)
return nil
}
privateHost = ip.String()
}
privateUrl = fmt.Sprintf("http://%v:%v/xaasprivate", privateHost, portNum)
log.Info("Chose private url: %v", privateUrl)
}
self.PrivateUrl = privateUrl
authMode := *flagAuth
authMode = strings.TrimSpace(authMode)
authMode = strings.ToLower(authMode)
if authMode == "openstack" {
keystoneUrl := *flagKeystoneUrl
self.Authenticator = auth.NewOpenstackMultiAuthenticator(keystoneUrl)
} else if authMode == "development" {
self.Authenticator = auth.NewDevelopmentAuthenticator()
} else {
log.Warn("Unknown authentication mode: %v", authMode)
return nil
}
return self
}
开发者ID:jxaas,项目名称:jxaas,代码行数:59,代码来源:options.go
示例11: HttpPost
// update_relation_properties RPC handler
func (self *EndpointRpcUpdateRelationProperties) HttpPost(huddle *core.Huddle, request *RpcUpdateRelationPropertiesRequest) (*RpcUpdateRelationPropertiesResponse, error) {
// TODO: Validate that this is coming from one of our machines?
log.Info("Got RPC request: UpdateRelationProperties: %v", request)
response := &RpcUpdateRelationPropertiesResponse{}
// Sanitize
if request.Properties == nil {
request.Properties = make(map[string]string)
}
localUnit := request.ServiceName
if localUnit == "" {
return nil, fmt.Errorf("ServiceName is required")
}
tenant, bundleTypeName, instanceId, _, _, err := core.ParseUnit(localUnit)
if err != nil {
return nil, err
}
bundleType := huddle.System.GetBundleType(bundleTypeName)
if bundleType == nil {
return nil, fmt.Errorf("Unknown bundle type: %v", bundleTypeName)
}
primaryService := bundleType.PrimaryJujuService()
// remoteUnit := request.RemoteName
// if remoteUnit == "" {
// // We're a bit stuck here. We do have the relationId and other info,
// // we just don't have the remote relation, and we're storing the attributes on the remote relation
// // TODO: Infer the remote relation? (-stubclient to -primary)?
// log.Warn("No remote unit; can't remove relations")
// return response, nil
// }
//
// _, _, remoteInstanceId, _, remoteUnitId, err := core.ParseUnit(remoteUnit)
// if err != nil {
// return nil, err
// }
instance := huddle.NewInstance(tenant, bundleType, instanceId)
relationId := request.RelationId
if request.Action == "broken" {
err = instance.DeleteRelationInfo(primaryService, relationId)
} else {
err = instance.SetRelationInfo(primaryService, relationId, request.Properties)
}
if err != nil {
return nil, err
}
return response, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:59,代码来源:rpc.go
示例12: isHuddleReady
func isHuddleReady(huddle *core.Huddle) bool {
for key, service := range huddle.SystemServices {
if service.PublicAddress == "" {
log.Info("Service not ready (no public address): %v", key)
return false
}
}
return true
}
开发者ID:jxaas,项目名称:jxaas,代码行数:9,代码来源:main.go
示例13: checkService
func (self *ServiceHealthCheck) checkService(instance jxaas.Instance, serviceId string, repair bool, dest *model.Health) error {
client := instance.GetJujuClient()
command := "service " + self.ServiceName + " status"
log.Info("Running command on %v: %v", serviceId, command)
runResults, err := client.Run(serviceId, nil, command, 5*time.Second)
if err != nil {
return err
}
for _, runResult := range runResults {
unitId := juju.ParseUnit(runResult.UnitId)
code := runResult.Code
stdout := string(runResult.Stdout)
stderr := string(runResult.Stderr)
log.Debug("Result: %v %v %v %v", runResult.UnitId, code, stdout, stderr)
healthy := true
if !strings.Contains(stdout, "start/running") {
log.Info("Service %v not running on %v", serviceId, runResult.UnitId)
healthy = false
if repair {
command := "service " + self.ServiceName + " start"
log.Info("Running command on %v: %v", serviceId, command)
_, err := client.Run(serviceId, []string{unitId}, command, 5*time.Second)
if err != nil {
return err
}
}
}
dest.Units[unitId] = healthy
}
return nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:42,代码来源:servicecheck.go
示例14: ApplyImplicits
func (self *Bundle) ApplyImplicits(templateContext *TemplateContext) {
for _, v := range self.Services {
v.applyImplicits(templateContext)
}
for _, v := range self.Relations {
v.applyImplicits(templateContext)
}
for k, v := range self.Provides {
v.applyImplicits(templateContext, k)
}
stub, found := self.Services["sc"]
if found {
self.configureStubClient(templateContext, stub)
log.Info("Configured stubclient: %v", stub)
} else {
log.Info("sc (stubclient) not found")
}
}
开发者ID:jxaas,项目名称:jxaas,代码行数:21,代码来源:implicits.go
示例15: read
func (self *CharmReader) read(name string) ([]byte, error) {
inputStream, err := self.byteSource.Open()
if err != nil {
return nil, err
}
defer func() {
closeable, ok := inputStream.(io.Closer)
if ok {
closeable.Close()
}
}()
size, err := self.byteSource.Size()
if err != nil {
return nil, err
}
readerAt, ok := inputStream.(io.ReaderAt)
if !ok {
return nil, fmt.Errorf("Expected ReaderAt")
}
r, err := zip.NewReader(readerAt, size)
if err != nil {
return nil, err
}
for _, f := range r.File {
log.Info("File: %v", f.Name)
}
for _, f := range r.File {
if f.Name != name {
continue
}
rc, err := f.Open()
if err != nil {
return nil, err
}
defer rc.Close()
data, err := ioutil.ReadAll(rc)
if err != nil {
return nil, err
}
return data, nil
}
return nil, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:53,代码来源:charm_parser.go
示例16: cleanupOldMachines
func (self *Huddle) cleanupOldMachines(state map[string]int, threshold int) (map[string]int, error) {
status, err := self.JujuClient.GetSystemStatus()
if err != nil {
log.Warn("Error getting system status", err)
return nil, err
}
unitsByMachine := map[string]*api.UnitStatus{}
for _, serviceStatus := range status.Services {
for _, unitStatus := range serviceStatus.Units {
machineId := unitStatus.Machine
unitsByMachine[machineId] = &unitStatus
}
}
idleMachines := map[string]*api.MachineStatus{}
for machineId, machineStatus := range status.Machines {
unit := unitsByMachine[machineId]
if unit != nil {
continue
}
idleMachines[machineId] = &machineStatus
}
idleCounts := map[string]int{}
for machineId, _ := range idleMachines {
idleCount := state[machineId]
idleCount++
idleCounts[machineId] = idleCount
}
for machineId, idleCount := range idleCounts {
if idleCount < threshold {
continue
}
if machineId == "0" {
// Machine id 0 is special (the system machine); we can't destroy it
continue
}
log.Info("Machine is idle; removing: %v", machineId)
err = self.JujuClient.DestroyMachine(machineId)
if err != nil {
log.Warn("Failed to delete machine %v", machineId, err)
}
}
return idleCounts, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:51,代码来源:huddle.go
示例17: setServiceAnnotations
// Sets annotations on the specified instance.
func (self *Instance) setServiceAnnotations(pairs map[string]string) error {
jujuClient := self.GetJujuClient()
serviceId := self.primaryServiceId
log.Info("Setting annotations on service %v: %v", serviceId, pairs)
err := jujuClient.SetServiceAnnotations(serviceId, pairs)
if err != nil {
log.Warn("Error setting annotations", err)
// TODO: Mask error?
return err
}
return nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:16,代码来源:instance.go
示例18: BuildRelationInfo
func (self *baseBundleType) BuildRelationInfo(templateContext *bundle.TemplateContext, bundle *bundle.Bundle, relationKey string) (*model.RelationInfo, error) {
log.Info("BuildRelationInfo with %v", templateContext)
// Find the properties the juju charm is exposing
relationProperties := templateContext.Relations[relationKey]
// Map those properties using the definition
provideProperties := map[string]string{}
if len(bundle.Provides) == 0 {
// No explicit provides => derive automatically
for k, v := range relationProperties {
v = templateContext.GetSpecialProperty(relationKey, k, v)
provideProperties[k] = v
}
// Auto-populate required properties that we generate
required := []string{"protocol", "port"}
for _, k := range required {
v, found := relationProperties[k]
if !found {
v = templateContext.GetSpecialProperty(relationKey, k, v)
}
provideProperties[k] = v
}
} else {
definition, found := bundle.Provides[relationKey]
if !found {
// Explicit provides, but no definition => no relation
log.Debug("Request for relation, but no definition found: %v", relationKey)
return nil, nil
}
for k, v := range definition.Properties {
provideProperties[k] = v
}
}
relationInfo := &model.RelationInfo{}
if templateContext.Proxy != nil {
relationInfo.PublicAddresses = []string{templateContext.Proxy.Host}
}
relationInfo.Properties = provideProperties
return relationInfo, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:47,代码来源:bundletype.go
示例19: TestBundleStore_Get
func TestBundleStore_Get(t *testing.T) {
store := NewBundleStore("../templates")
templateContext := &TemplateContext{}
tenant := "123"
serviceType := "mysql"
name := "test"
templateContext.NumberUnits = 3
templateContext.Options = map[string]string{}
templateContext.Options["performance"] = "high"
bundle, err := store.GetBundle(templateContext, tenant, serviceType, name)
if err != nil {
t.Fatal("Unable to load bundle", err)
}
if bundle == nil {
t.Fatal("Bundle was nil")
}
prefix := buildPrefix(tenant, serviceType, name)
service, found := bundle.Services[prefix+"mysql"]
if !found {
log.Info("Services: %v", bundle.Services)
t.Fatal("mysql service not found")
}
if service.NumberUnits != 3 {
t.Fatal("NumberUnits was not copied")
}
if service.Options["performance"] != "high" {
t.Fatal("Performance option was not copied")
}
}
开发者ID:jxaas,项目名称:jxaas,代码行数:38,代码来源:bundles_test.go
示例20: NewHuddle
func NewHuddle(system *System, bundleStore *bundle.BundleStore, jujuApi *juju.Client, privateUrl string) (*Huddle, error) {
key := "shared"
huddle := &Huddle{}
environmentInfo, err := jujuApi.EnvironmentInfo()
if err != nil {
log.Warn("Error reading juju environment info", err)
return nil, err
}
if environmentInfo == nil {
return nil, fmt.Errorf("No juju environment info found")
}
huddle.environmentProviderType = environmentInfo.ProviderType
if huddle.environmentProviderType == "" {
return nil, fmt.Errorf("Juju environment info invalid: no ProviderType")
}
log.Info("Juju environment ProviderType is '%v'", huddle.environmentProviderType)
systemBundle, err := bundleStore.GetSystemBundle(key)
if err != nil {
log.Warn("Error loading system bundle: %v", key, err)
return nil, err
}
if systemBundle == nil {
log.Warn("Cannot load system bundle: %v", key, err)
return nil, nil
}
info, err := systemBundle.Deploy("jx-", jujuApi)
if err != nil {
log.Warn("Error deploying system bundle", err)
return nil, err
}
huddle.PrivateUrl = privateUrl
huddle.SystemServices = map[string]*SystemService{}
huddle.assignedPublicPorts = map[string]int{}
for key, service := range info.Services {
systemService := &SystemService{}
systemService.JujuName = "jx-" + key
systemService.Key = key
status := service.Status
if status != nil {
for _, unit := range status.Units {
if unit.PublicAddress != "" {
systemService.PublicAddress = unit.PublicAddress
}
externalAddress := ""
if unit.Machine != "" {
externalAddress, err = jujuApi.PublicAddress(unit.Machine)
if err != nil {
log.Warn("Error getting public address for machine", err)
return nil, err
} else {
if huddle.IsAmazon() {
// Work around a problem where we sometimes get an address that is ip-X-X-X-X.ece2.internal
// I think this is a Juju bug (?)
if strings.HasSuffix(externalAddress, ".ec2.internal") {
log.Warn("Juju gave invalid PublicAddress: %v", externalAddress)
externalAddress = systemService.PublicAddress
}
// Amazon has a special DNS name: ec2-54-172-123-123.compute-1.amazonaws.com
// Externally that resolves to 54.172.123.123 (i.e. the value embedded in the name)
// Internally (inside EC2) that resolves to the internal IP (172.16.x.x)
// We don't want that internal resolution to happen here (this is an _external_ IP)
// But we may be within EC2, so we can't simply resolve the name
if strings.HasPrefix(externalAddress, "ec2-") && strings.HasSuffix(externalAddress, ".compute-1.amazonaws.com") {
ipString := externalAddress[4:]
firstDot := strings.IndexRune(ipString, '.')
ipString = ipString[:firstDot]
ipString = strings.Replace(ipString, "-", ".", -1)
log.Info("Replaced EC2 switching-address '%v' with IP '%v'", externalAddress, ipString)
externalAddress = ipString
}
}
if externalAddress != "" {
log.Info("Chose public address for machine: '%v'", externalAddress)
} else {
log.Warn("Got empty public address for machine: %v", unit.Machine)
}
}
}
if externalAddress == "" {
log.Warn("Unable to get external address for machine %v, falling back to public address %v", unit.Machine, systemService.PublicAddress)
externalAddress = systemService.PublicAddress
}
systemService.ExternalAddress = externalAddress
}
}
//.........这里部分代码省略.........
开发者ID:jxaas,项目名称:jxaas,代码行数:101,代码来源:huddle.go
注:本文中的github.com/justinsb/gova/log.Info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论