예제 #1
0
func (s *instanceSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	cli, err := gosigma.NewClient(mock.Endpoint(""), mock.TestUser, mock.TestPassword, nil)
	c.Assert(err, gc.IsNil)

	mock.ResetServers()

	ds, err := data.ReadServer(strings.NewReader(jsonInstanceData))
	c.Assert(err, gc.IsNil)
	mock.AddServer(ds)

	mock.AddServer(&data.Server{
		Resource: data.Resource{URI: "uri", UUID: "uuid-no-ip"},
	})

	server, err := cli.Server("f4ec5097-121e-44a7-a207-75bc02163260")
	c.Assert(err, gc.IsNil)
	c.Assert(server, gc.NotNil)
	s.inst = &sigmaInstance{server}

	server, err = cli.Server("uuid-no-ip")
	c.Assert(err, gc.IsNil)
	c.Assert(server, gc.NotNil)
	s.instWithoutIP = &sigmaInstance{server}
}
예제 #2
0
파일: client.go 프로젝트: imoapps/juju
func (tracer) Logf(format string, args ...interface{}) {
	logger.Tracef(format, args...)
}

// newClient returns an instance of the CloudSigma client.
var newClient = func(cfg *environConfig) (client *environClient, err error) {
	uuid, ok := cfg.UUID()
	if !ok {
		return nil, errors.New("Environ uuid must not be empty")
	}

	logger.Debugf("creating CloudSigma client: id=%q", uuid)

	// create connection to CloudSigma
	conn, err := gosigma.NewClient(cfg.region(), cfg.username(), cfg.password(), nil)
	if err != nil {
		return nil, err
	}

	// configure trace logger
	if logger.LogLevel() <= loggo.TRACE {
		conn.Logger(&tracer{})
	}

	client = &environClient{
		conn:   conn,
		uuid:   uuid,
		config: cfg,
	}
예제 #3
0
파일: client.go 프로젝트: xushiwei/juju
	config *environConfig
}

type tracer struct{}

func (tracer) Logf(format string, args ...interface{}) {
	logger.Tracef(format, args...)
}

// newClient returns an instance of the CloudSigma client.
var newClient = func(cfg *environConfig) (client *environClient, err error) {
	uuid := cfg.UUID()
	logger.Debugf("creating CloudSigma client: id=%q", uuid)

	// create connection to CloudSigma
	conn, err := gosigma.NewClient(cfg.endpoint(), cfg.username(), cfg.password(), nil)
	if err != nil {
		return nil, err
	}

	// configure trace logger
	if logger.LogLevel() <= loggo.TRACE {
		conn.Logger(&tracer{})
	}

	client = &environClient{
		conn:   conn,
		uuid:   uuid,
		config: cfg,
	}