func (suite *environSuite) TestAcquireNodePassedAgentName(c *gc.C) { stor := NewStorage(suite.makeEnviron()) fakeTools := envtesting.MustUploadFakeToolsVersions(stor, version.Current)[0] env := suite.makeEnviron() suite.testMAASObject.TestServer.NewNode(`{"system_id": "node0", "hostname": "host0"}`) _, _, err := env.acquireNode("", constraints.Value{}, nil, nil, tools.List{fakeTools}) c.Check(err, gc.IsNil) requestValues := suite.testMAASObject.TestServer.NodeOperationRequestValues() nodeRequestValues, found := requestValues["node0"] c.Assert(found, gc.Equals, true) c.Assert(nodeRequestValues[0].Get("agent_name"), gc.Equals, exampleAgentName) }
func (suite *environSuite) TestAcquireNodeTakesConstraintsIntoAccount(c *gc.C) { stor := NewStorage(suite.makeEnviron()) fakeTools := envtesting.MustUploadFakeToolsVersions(stor, version.Current)[0] env := suite.makeEnviron() suite.testMAASObject.TestServer.NewNode(`{"system_id": "node0", "hostname": "host0"}`) constraints := constraints.Value{Arch: stringp("arm"), Mem: uint64p(1024)} _, _, err := env.acquireNode("", constraints, nil, nil, tools.List{fakeTools}) c.Check(err, gc.IsNil) requestValues := suite.testMAASObject.TestServer.NodeOperationRequestValues() nodeRequestValues, found := requestValues["node0"] c.Assert(found, gc.Equals, true) c.Assert(nodeRequestValues[0].Get("arch"), gc.Equals, "arm") c.Assert(nodeRequestValues[0].Get("mem"), gc.Equals, "1024") }
func (suite *environSuite) TestAcquireNodeByName(c *gc.C) { stor := NewStorage(suite.makeEnviron()) fakeTools := envtesting.MustUploadFakeToolsVersions(stor, version.Current)[0] env := suite.makeEnviron() suite.testMAASObject.TestServer.NewNode(`{"system_id": "node0", "hostname": "host0"}`) _, _, err := env.acquireNode("host0", constraints.Value{}, nil, nil, tools.List{fakeTools}) c.Check(err, gc.IsNil) operations := suite.testMAASObject.TestServer.NodeOperations() actions, found := operations["node0"] c.Assert(found, gc.Equals, true) c.Check(actions, gc.DeepEquals, []string{"acquire"}) // no "name" parameter should have been passed through values := suite.testMAASObject.TestServer.NodeOperationRequestValues()["node0"][0] nodeName := values.Get("name") c.Assert(nodeName, gc.Equals, "host0") }