Exemple #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}
}
Exemple #2
0
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,
	}
Exemple #3
0
	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,
	}