本文整理匯總了Golang中github.com/HewlettPackard/oneview-golang/ov.OVClient類的典型用法代碼示例。如果您正苦於以下問題:Golang OVClient類的具體用法?Golang OVClient怎麽用?Golang OVClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了OVClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGetIloIPAddress
// 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: TestGetFCNetworks
func TestGetFCNetworks(t *testing.T) {
var (
c *ov.OVClient
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
_, c = getTestDriverA("test_fc_network")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
fcNetworks, err := c.GetFCNetworks("", "")
assert.NoError(t, err, "GetFCNetworks threw an error -> %s. %+v\n", err, fcNetworks)
fcNetworks, err = c.GetFCNetworks("", "name:asc")
assert.NoError(t, err, "GetFCNetworks name:asc error -> %s. %+v\n", err, fcNetworks)
} else {
_, c = getTestDriverU("test_fc_network")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
data, err := c.GetFCNetworks("", "")
assert.Error(t, err, fmt.Sprintf("All OK, no error, caught as expected: %s,%+v\n", err, data))
}
_, c = getTestDriverU("test_fc_network")
data, err := c.GetFCNetworks("", "")
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
}
示例3: TestGetProfileTemplateByName
// GetProfileTemplateByName get a template profile
func TestGetProfileTemplateByName(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testname string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_server_profile_template")
// determine if we should execute
testname = d.Tc.GetTestData(d.Env, "Name").(string)
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
data, err := c.GetProfileTemplateByName(testname)
assert.NoError(t, err, "GetProfileTemplateByName threw error -> %s", err)
assert.Equal(t, testname, data.Name)
data, err = c.GetProfileTemplateByName("foo")
assert.NoError(t, err, "GetProfileTemplateByName with fake name -> %+v", err)
assert.Equal(t, "", data.Name)
} else {
d, c = getTestDriverU("test_server_profile_template")
// determine if we should execute
if c.ProfileTemplatesNotSupported() {
return
}
testname = d.Tc.GetTestData(d.Env, "Name").(string)
data, err := c.GetProfileTemplateByName(testname)
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
}
}
示例4: TestDeleteLogicalInterconnectGroup
func TestDeleteLogicalInterconnectGroup(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
testLogicalInterconnectGroup ov.LogicalInterconnectGroup
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_logical_interconnect_group")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
testName = d.Tc.GetTestData(d.Env, "Name").(string)
err := c.DeleteLogicalInterconnectGroup(testName)
assert.NoError(t, err, "DeleteLogicalInterconnectGroup err-> %s", err)
testLogicalInterconnectGroup, err = c.GetLogicalInterconnectGroupByName(testName)
assert.NoError(t, err, "GetLogicalInterconnectGroupByName with deleted logical interconnect gorup-> %+v", err)
assert.Equal(t, "", testLogicalInterconnectGroup.Name, fmt.Sprintf("Problem getting logicalInterconnectGroup name, %+v", testLogicalInterconnectGroup))
} else {
_, c = getTestDriverU("test_logical_interconnect_group")
err := c.DeleteLogicalInterconnectGroup("footest")
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testLogicalInterconnectGroup))
}
}
示例5: TestDeleteNetworkSet
func TestDeleteNetworkSet(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
testNetSet ov.NetworkSet
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_network_set")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
testName = d.Tc.GetTestData(d.Env, "Name").(string)
err := c.DeleteNetworkSet(testName)
assert.NoError(t, err, "DeleteNetworkSet err-> %s", err)
testNetSet, err = c.GetNetworkSetByName(testName)
assert.NoError(t, err, "GetNetworkSetByName with deleted network set-> %+v", err)
assert.Equal(t, "", testNetSet.Name, fmt.Sprintf("Problem getting netset name, %+v", testNetSet))
} else {
_, c = getTestDriverU("test_network_set")
err := c.DeleteNetworkSet("footest")
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testNetSet))
}
}
示例6: TestGetServerHardwareByName
func TestGetServerHardwareByName(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_server_hardware")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
testName = d.Tc.GetTestData(d.Env, "Name").(string)
testServerHardware, err := c.GetServerHardwareByName(testName)
assert.NoError(t, err, "GetServerHardwareByName thew an error -> %s", err)
assert.Equal(t, testName, testServerHardware.Name)
testServerHardware, err = c.GetServerHardwareByName("bad")
assert.NoError(t, err, "GetServerHardwareByName with fake name -> %s", err)
assert.Equal(t, "", testServerHardware.Name)
} else {
d, c = getTestDriverU("test_server_hardware")
testName = d.Tc.GetTestData(d.Env, "Name").(string)
data, err := c.GetServerHardwareByName(testName)
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
}
}
示例7: TestDeleteStorageVolume
func TestDeleteStorageVolume(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
testSVol ov.StorageVolumeV3
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_storage_volume")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
testName = d.Tc.GetTestData(d.Env, "Name").(string)
err := c.DeleteStorageVolume(testName)
assert.NoError(t, err, "DeleteStorageVolume err-> %s", err)
testSVol, err = c.GetStorageVolumeByName(testName)
assert.NoError(t, err, "GetStorageVolumeByName with deleted storage volume -> %+v", err)
assert.Equal(t, "", testSVol.Name, fmt.Sprintf("Problem getting storage volume name, %+v", testSVol))
} else {
_, c = getTestDriverU("test_storage_volume")
err := c.DeleteStorageVolume("footest")
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testSVol))
}
}
示例8: TestCreateStorageVolume
func TestCreateStorageVolume(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_storage_volume")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
// find out if the test ethernet network already exist
testName = d.Tc.GetTestData(d.Env, "Name").(string)
testSVol, err := c.GetStorageVolumeByName(testName)
assert.NoError(t, err, "CreateStorageVolume get the Storage Volume error -> %s", err)
pMap := d.Tc.GetTestData(d.Env, "ProvisioningParameters").(map[string]interface{})
provParams := ov.ProvisioningParameters{StoragePoolUri: utils.NewNstring(pMap["storagePoolUri"].(string)), RequestedCapacity: pMap["requestedCapacity"].(string), ProvisionType: pMap["provisionType"].(string), Shareable: pMap["shareable"].(bool)}
if testSVol.URI.IsNil() {
testSVol = ov.StorageVolumeV3{
Name: testName,
StorageSystemUri: utils.NewNstring(d.Tc.GetTestData(d.Env, "StorageSystemUri").(string)),
Type: d.Tc.GetTestData(d.Env, "Type").(string),
ProvisioningParameters: provParams,
}
// not changed after this TODO: update to storage volume tests
err := c.CreateStorageVolume(testSVol)
assert.NoError(t, err, "CreateStorageVolume error -> %s", err)
err = c.CreateStorageVolume(testSVol)
assert.Error(t, err, "CreateStorageVolume should error because the Storage volume already exists, err-> %s", err)
} else {
log.Warnf("The storage volume already exist, so skipping CreateStorageVolume test for %s", testName)
}
// reload the test profile that we just created
testSVol, err = c.GetStorageVolumeByName(testName)
assert.NoError(t, err, "GetStorageVolumeByName error -> %s", err)
}
}
示例9: TestPowerState
// 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)
}
}
示例10: TestServerHardware
// 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())
}
}
示例11: TestCreateMachine
// TestCreateMachine - simulate first part of create
func TestCreateMachine(t *testing.T) {
var (
driver Driver
d *OneViewTest
c *ov.OVClient
ic *icsp.ICSPClient
template, hostname string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") != "true" {
return
}
d, c, ic = d.GetTestDriverA()
template = d.Tc.GetTestData(d.Env, "TemplateProfile").(string)
hostname = d.Tc.GetTestData(d.Env, "HostName").(string)
driver = Driver{
ClientICSP: ic,
ClientOV: c,
BaseDriver: &drivers.BaseDriver{
MachineName: hostname,
StorePath: "",
},
}
err := c.CreateMachine(hostname, template)
assert.NoError(t, err, "CreateMachine threw error -> %s\n", err)
err = driver.getBlade()
assert.NoError(t, err, "getBlade threw error -> %s\n", err)
// power on the server, and leave it in that state
err = driver.Hardware.PowerOn()
assert.NoError(t, err, "PowerOn threw error -> %s\n", err)
// power on the server, and leave it in that state
err = driver.Hardware.PowerOff()
assert.NoError(t, err, "PowerOff threw error -> %s\n", err)
}
示例12: TestCreateEthernetNetwork
func TestCreateEthernetNetwork(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_ethernet_network")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
// find out if the test ethernet network already exist
testName = d.Tc.GetTestData(d.Env, "Name").(string)
testEthNet, err := c.GetEthernetNetworkByName(testName)
assert.NoError(t, err, "CreateEthernetNetwork get the EthernetNetwork error -> %s", err)
if testEthNet.URI.IsNil() {
testEthNet = ov.EthernetNetwork{
Name: testName,
VlanId: 7,
Purpose: d.Tc.GetTestData(d.Env, "Purpose").(string),
SmartLink: d.Tc.GetTestData(d.Env, "SmartLink").(bool),
PrivateNetwork: d.Tc.GetTestData(d.Env, "PrivateNetwork").(bool),
EthernetNetworkType: d.Tc.GetTestData(d.Env, "EthernetNetworkType").(string),
Type: d.Tc.GetTestData(d.Env, "Type").(string),
}
err := c.CreateEthernetNetwork(testEthNet)
assert.NoError(t, err, "CreateEthernetNetwork error -> %s", err)
err = c.CreateEthernetNetwork(testEthNet)
assert.Error(t, err, "CreateEthernetNetwork should error because the EthernetNetwork already exists, err-> %s", err)
} else {
log.Warnf("The ethernetNetwork already exist, so skipping CreateEthernetNetwork test for %s", testName)
}
// reload the test profile that we just created
testEthNet, err = c.GetEthernetNetworkByName(testName)
assert.NoError(t, err, "GetEthernetNetwork error -> %s", err)
}
}
示例13: TestGetAvailableHardware
// 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)
}
}
示例14: TestGetAPIVersion
// TestGetAPIVersion get the version from endpoints
func TestGetAPIVersion(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("dev")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
data, err := c.GetAPIVersion()
// fmt.Printf("after GetAPIVersion: %s -> (err) %s", data.CurrentVersion, err)
// assert.Error(t,err, fmt.Sprintf("Error caught as expected: %s",err))
assert.NoError(t, err, "GetAPIVersion threw error -> %s", err)
assert.True(t, d.Tc.IsGreaterEqual(data.CurrentVersion, d.Tc.GetExpectsData(d.Env, "CurrentVersion")))
assert.True(t, d.Tc.IsGreaterEqual(data.MinimumVersion, d.Tc.GetExpectsData(d.Env, "MinimumVersion")))
} else {
_, c = getTestDriverU("dev")
data, err := c.GetAPIVersion()
assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
}
}
示例15: TestCreateLogicalFCNetwork
func TestCreateLogicalFCNetwork(t *testing.T) {
var (
d *OVTest
c *ov.OVClient
testName string
)
if os.Getenv("ONEVIEW_TEST_ACCEPTANCE") == "true" {
d, c = getTestDriverA("test_fc_network")
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
testName = d.Tc.GetTestData(d.Env, "Name").(string)
fcNetwork, err := c.GetFCNetworkByName(testName)
assert.NoError(t, err, "getFcNetworkByName error -> %s", err)
if fcNetwork.URI.IsNil() {
falseVar := false
fcNetwork := ov.FCNetwork{
AutoLoginRedistribution: falseVar,
Description: "Test FC Network",
LinkStabilityTime: 30,
FabricType: d.Tc.GetTestData(d.Env, "FabricType").(string),
Name: testName,
Type: d.Tc.GetTestData(d.Env, "Type").(string),
}
err := c.CreateFCNetwork(fcNetwork)
assert.NoError(t, err, "CreateFCNetwork error -> %s", err)
err = c.CreateFCNetwork(fcNetwork)
assert.Error(t, err, "CreateFCNetwork should error becaue the network already exists, err -> %s", err)
} else {
log.Warnf("The FCNetwork already exists so skipping CreateFCNetwork test for %s", testName)
}
//Reload the the test profile
fcNetwork, err = c.GetFCNetworkByName(testName)
assert.NoError(t, err, "GetFCNetwork error -> %s", err)
}
}