func (s *S) TestGet(c *check.C) {
	client, _ := api.NewClient(s.cm)
	flav := TemplateReqs{TemplateName: "newone", T: client}
	res, error := flav.Get()
	c.Assert(error, check.IsNil)
	c.Assert(res, check.NotNil)
}
Esempio n. 2
0
func (s *S) TestDelete(c *check.C) {
	cl, _ := api.NewClient(s.cm)
	v := VirtualMachine{Name: "test", T: cl}
	c.Assert(v, check.NotNil)
	_, err := v.Delete()
	c.Assert(err, check.IsNil)
}
Esempio n. 3
0
func (s *S) TestPoweroff(c *check.C) {
	cl, _ := api.NewClient(s.cm)
	vmObj := VirtualMachine{Name: "test", T: cl}
	c.Assert(vmObj, check.NotNil)
	_, err := vmObj.Poweroff()
	c.Assert(err, check.IsNil)
}
Esempio n. 4
0
func (s *S) TestCreate(c *check.C) {
	cl, _ := api.NewClient(s.cm)
	v := VirtualMachine{Name: "test", TemplateName: "megam", Cpu: "1", Memory: "1024", Image: "megam", T: cl, ContextMap: map[string]string{"assembly_id": "ASM-007", "assemblies_id": "AMS-007"}} //memory in terms of MB! duh!
	c.Assert(v, check.NotNil)
	_, err := v.Create()
	c.Assert(err, check.IsNil)
}
func (s *S) TestGet(c *check.C) {
	client, _ := api.NewClient(s.cm)
	vm := Accounting{Api: client, StartTime: time.Now().Add(-10 * time.Minute).Unix(), EndTime: time.Now().Unix()}
	res, error := vm.Get()
	c.Assert(error, check.IsNil)
	se := []byte(res.(string))
	ons := &OpenNebulaStatus{}
	error = xml.Unmarshal(se, ons)
	c.Assert(error, check.IsNil)
}
Esempio n. 6
0
func (s *S) TestImageList(c *check.C) {
	cl, _ := api.NewClient(s.cm)

	v := &Image{T: cl}

	c.Assert(v, check.NotNil)
	res, err := v.ImageList()
	fmt.Println(res)
	c.Assert(err, check.IsNil)
}
Esempio n. 7
0
func (s *S) TestImageShow(c *check.C) {
	cl, _ := api.NewClient(s.cm)

	v := &Image{T: cl, Id: 94}

	c.Assert(v, check.NotNil)
	res, err := v.ImageShow()
	fmt.Println("Image State: ", res.State_string())
	c.Assert(err, check.IsNil)
}
Esempio n. 8
0
func (c *Cluster) getNodeByObject(nodeo Node) (node, error) {
	var n node
	client, err := api.NewClient(map[string]string{api.ENDPOINT: nodeo.Address, api.USERID: nodeo.Metadata[api.USERID], api.PASSWORD: nodeo.Metadata[api.PASSWORD]})

	if err != nil {
		return n, err
	}

	template := nodeo.Metadata[api.TEMPLATE]

	return node{addr: nodeo.Address, template: template, Client: client}, nil
}
Esempio n. 9
0
func (s *S) TestGetUsers(c *check.C) {
	client, _ := api.NewClient(s.cm)
	u := User{
		UserName:   "******",
		Password:   "******",
		AuthDriver: "core",
		GroupIds:   []int{0},
	}
	vm := UserTemplate{
		T:     client,
		Users: u,
	}
	_, err := vm.CreateUsers()
	c.Assert(err, check.NotNil)
}
func (s *S) TestGetVMTemplate(c *check.C) {
	client, _ := api.NewClient(s.cm)
	vm := Vnc{VmId: "2", T: client}
	_, err := vm.GetVm()
	c.Assert(err, check.IsNil)
}
func (s *S) TestGet(c *check.C) {
	client, _ := api.NewClient(s.cm)
	vm := Accounting{Api: client, StartTime: time.Now().Add(-10 * time.Minute).Unix(), EndTime: time.Now().Unix()}
	_, error := vm.Get()
	c.Assert(error, check.IsNil)
}
func (s *S) TestGetByName(c *check.C) {
	client, _ := api.NewClient(s.cm)
	vm := Query{VMName: "yeshapp", T: client}
	_, err := vm.GetByName()
	c.Assert(err, check.IsNil)
}