// TestGetIloIPAddress verify get ip address for hardware
func TestGetIloIPAddress(t *testing.T) {

	var (
		d           *OVTest
		c           *ov.OVClient
		testData    utils.Nstring
		expectsData string
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("dev")
		testData = utils.Nstring(d.Tc.GetTestData(d.Env, "ServerHardwareURI").(string))
		expectsData = d.Tc.GetExpectsData(d.Env, "IloIPAddress").(string)
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		s, err := c.GetServerHardware(testData)
		assert.NoError(t, err, "GetServerHardware threw error -> %s", err)
		ip := s.GetIloIPAddress()
		log.Debugf("server -> %+v", s)
		log.Debugf("ip -> %+v", ip)
		assert.Equal(t, expectsData, ip)

	}

}
Пример #2
0
// SetStaticInterface - converts an interface from NetConfig.Interface from dhcp to static
func (n *NetConfig) SetStaticInterface(
	iface Interface,
	ipv4gateway utils.Nstring,
	ipv6gateway utils.Nstring,
	staticiplist utils.Nstring,
	isipv6 bool) {
	var inet NetConfigInterface
	var bupdated bool
	bupdated = false
	// update the existing interfaces in the list
	for i, neti := range n.Interfaces {
		if neti.MACAddr == iface.MACAddr {
			inet = n.NewNetConfigInterface(
				true,                      // enabled
				iface.MACAddr,             // mac address
				false,                     // disable dhcp
				isipv6,                    // ipv6
				ipv6gateway,               // ipv6 gateway
				ipv4gateway,               // ipv4 gateway
				staticiplist,              // static ip list
				utils.Nstring(iface.Slot), // interface name
				n.WINSList,                // wins list
				n.DNSNameList,             // dns list
				n.DNSSearchList,           // dns search
				i)                         // vlan id
			n.Interfaces[i] = inet
			bupdated = true
		}
	}
	// append to the interfaces if we didn't update it
	if !bupdated {
		inet = n.NewNetConfigInterface(
			true,                      // enabled
			iface.MACAddr,             // mac address
			false,                     // disable dhcp
			isipv6,                    // ipv6
			ipv6gateway,               // ipv6 gateway
			ipv4gateway,               // ipv4 gateway
			staticiplist,              // static ip list
			utils.Nstring(iface.Slot), // interface name
			n.WINSList,                // wins list
			n.DNSNameList,             // dns list
			n.DNSSearchList,           // dns search list
			len(n.Interfaces))         // vlan id
		n.Interfaces = append(n.Interfaces, inet)
	}
}
// get server hardware test
func TestGetAvailableHardware(t *testing.T) {
	var (
		d               *OVTest
		c               *ov.OVClient
		testHwType_URI  utils.Nstring
		testHWGroup_URI utils.Nstring
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("dev")
		testHwType_URI = utils.Nstring(d.Tc.GetTestData(d.Env, "HardwareTypeURI").(string))
		testHWGroup_URI = utils.Nstring(d.Tc.GetTestData(d.Env, "GroupURI").(string))
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		data, err := c.GetAvailableHardware(testHwType_URI, testHWGroup_URI)
		assert.NoError(t, err, "GetAvailableHardware threw error -> %s", err)
		// fmt.Printf("data.Connections -> %+v\n", data)
		log.Debugf("Abailable server -> %+v", data)
		log.Infof("Server Name -> %+v", data.Name)
		assert.NotEqual(t, "", data.Name)

	}
}
// testing power state type
func TestPowerState(t *testing.T) {
	var (
		d           *OVTest
		c           *ov.OVClient
		testData    utils.Nstring
		expectsData string
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("dev")
		testData = utils.Nstring(d.Tc.GetTestData(d.Env, "ServerHardwareURI").(string))
		expectsData = d.Tc.GetExpectsData(d.Env, "SerialNumber").(string)
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		// get a blade object
		blade, err := c.GetServerHardware(testData)
		assert.NoError(t, err, "GetServerHardware threw error -> %s", err)
		assert.Equal(t, expectsData, blade.SerialNumber.String())
		// get a power state object
		var pt *ov.PowerTask
		pt = pt.NewPowerTask(blade)
		pt.Timeout = 46 // timeout is 20 sec
		assert.Equal(t, expectsData, pt.Blade.SerialNumber.String())

		// Test the power state executor to off
		log.Info("------- Setting Power to Off")
		err = pt.PowerExecutor(ov.P_OFF)
		assert.NoError(t, err, "PowerExecutor threw no errors -> %s", err)

		// Test the power state executor to on
		log.Info("------- Setting Power to On")
		err = pt.PowerExecutor(ov.P_ON)
		assert.NoError(t, err, "PowerExecutor threw no errors -> %s", err)

		// Test the power state executor to off and leave off
		log.Info("------- Setting Power to Off")
		err = pt.PowerExecutor(ov.P_OFF)
		assert.NoError(t, err, "PowerExecutor threw no errors -> %s", err)

	}
}
// get server hardware test
func TestServerHardware(t *testing.T) {
	var (
		d           *OVTest
		c           *ov.OVClient
		testData    utils.Nstring
		expectsData string
	)
	if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("dev")
		testData = utils.Nstring(d.Tc.GetTestData(d.Env, "ServerHardwareURI").(string))
		expectsData = d.Tc.GetExpectsData(d.Env, "SerialNumber").(string)
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		data, err := c.GetServerHardware(testData)
		log.Debugf("%+v", data)
		assert.NoError(t, err, "GetServerHardware threw error -> %s", err)
		// fmt.Printf("data.Connections -> %+v\n", data)
		assert.Equal(t, expectsData, data.SerialNumber.String())

	}
}
Пример #6
0
// AddAllDHCP - make all the netconfig interfaces setup for dhcp
func (n *NetConfig) AddAllDHCP(interfaces []Interface, isipv6 bool, ipv6gateway utils.Nstring) {
	var emptystring utils.Nstring
	var netinterfaces []NetConfigInterface
	for i, iface := range interfaces {
		var niface NetConfigInterface
		niface = n.NewNetConfigInterface(
			true,                      // enabled
			iface.MACAddr,             // mac address
			true,                      // dhcp
			isipv6,                    // ipv6
			ipv6gateway,               // ipv6 gateway
			emptystring,               // ipv4 gateway
			emptystring,               // static nets
			utils.Nstring(iface.Slot), // name
			n.WINSList,                //wins
			n.DNSNameList,             //dns
			n.DNSSearchList,           // dns search
			i)                         // vlanid
		netinterfaces = append(netinterfaces, niface)
	}
	n.Interfaces = netinterfaces
}