github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/upgrades/rsyslogport.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package upgrades
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/juju/environs/config"
    10  	"github.com/juju/juju/mongo"
    11  	"github.com/juju/juju/state"
    12  )
    13  
    14  func updateRsyslogPort(context Context) error {
    15  	agentConfig := context.AgentConfig()
    16  	info, ok := agentConfig.MongoInfo()
    17  	if !ok {
    18  		return fmt.Errorf("Failed to get MongoInfo")
    19  	}
    20  	// we need to re-open state with a nil policay so we can bypass
    21  	// validation, as the syslog-port is normally immutable
    22  	st, err := state.Open(info, mongo.DefaultDialOpts(), nil)
    23  	if err != nil {
    24  		return err
    25  	}
    26  	defer st.Close()
    27  	attrs := map[string]interface{}{
    28  		"syslog-port": config.DefaultSyslogPort,
    29  	}
    30  	return st.UpdateEnvironConfig(attrs, nil, nil)
    31  }