當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Nstring.String方法代碼示例

本文整理匯總了Golang中github.com/HewlettPackard/oneview-golang/utils.Nstring.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Nstring.String方法的具體用法?Golang Nstring.String怎麽用?Golang Nstring.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/HewlettPackard/oneview-golang/utils.Nstring的用法示例。


在下文中一共展示了Nstring.String方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetAvailableHardware

// get available server
// blades = rest_api(:oneview, :get, "/rest/server-hardware?sort=name:asc&filter=serverHardwareTypeUri='#{server_hardware_type_uri}'&filter=serverGroupUri='#{enclosure_group_uri}'")
func (c *OVClient) GetAvailableHardware(hardwaretype_uri utils.Nstring, servergroup_uri utils.Nstring) (hw ServerHardware, err error) {
	var (
		hwlist ServerHardwareList
		f      = []string{"serverHardwareTypeUri='" + hardwaretype_uri.String() + "'",
			"serverGroupUri='" + servergroup_uri.String() + "'"}
	)
	if hwlist, err = c.GetServerHardwareList(f, "name:desc"); err != nil {
		return hw, err
	}
	if !(len(hwlist.Members) > 0) {
		return hw, errors.New("Error! No available blades that are compatible with the server profile!")
	}

	// pick an available blade
	for _, blade := range hwlist.Members {
		if H_NOPROFILE_APPLIED.Equal(blade.State) {
			hw = blade
			break
		}
	}
	if hw.Name == "" {
		return hw, errors.New("No more blades are available for provisioning!")
	}
	return hw, nil
}
開發者ID:wenlock,項目名稱:oneview-golang,代碼行數:27,代碼來源:server_hardware.go

示例2: GetBuildPlanByUri

func (c *ICSPClient) GetBuildPlanByUri(uri utils.Nstring) (OSDBuildPlan, error) {

	var bldplan OSDBuildPlan
	// grab the target
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return bldplan, err
	}
	log.Debugf("GetBuildPlan %s", data)
	if err := json.Unmarshal([]byte(data), &bldplan); err != nil {
		return bldplan, err
	}

	return bldplan, nil
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:15,代碼來源:build_plan.go

示例3: GetEnclosureGroupByUri

func (c *OVClient) GetEnclosureGroupByUri(uri utils.Nstring) (EnclosureGroup, error) {
	var (
		enclosureGroup EnclosureGroup
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return enclosureGroup, err
	}
	log.Debugf("GetEnclosureGroup %s", data)
	if err := json.Unmarshal([]byte(data), &enclosureGroup); err != nil {
		return enclosureGroup, err
	}
	return enclosureGroup, nil
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:17,代碼來源:enclosure_group.go

示例4: GetInterconnectTypeByUri

func (c *OVClient) GetInterconnectTypeByUri(uri utils.Nstring) (InterconnectType, error) {
	var (
		interconnectType InterconnectType
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return interconnectType, err
	}
	log.Debugf("GetInterconnectType %s", data)
	if err := json.Unmarshal([]byte(data), &interconnectType); err != nil {
		return interconnectType, err
	}
	return interconnectType, nil
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:17,代碼來源:interconnect_type.go

示例5: GetProfileByURI

// GetProfileByURI - get the profile from a uri
func (c *OVClient) GetProfileByURI(uri utils.Nstring) (ServerProfile, error) {
	var (
		profile ServerProfile
	)

	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return profile, err
	}

	log.Debugf("GetProfileByURI %s", data)
	if err := json.Unmarshal([]byte(data), &profile); err != nil {
		return profile, err
	}
	return profile, nil
}
開發者ID:wenlock,項目名稱:oneview-golang,代碼行數:20,代碼來源:profiles.go

示例6: GetOSDeploymentPlan

// get an os deployment plan with uri
func (c *OVClient) GetOSDeploymentPlan(uri utils.Nstring) (OSDeploymentPlan, error) {

	var osDeploymentPlan OSDeploymentPlan
	// refresh login

	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	// rest call
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return osDeploymentPlan, err
	}

	log.Debugf("GetOSDeploymentPlan %s", data)
	if err := json.Unmarshal([]byte(data), &osDeploymentPlan); err != nil {
		return osDeploymentPlan, err
	}
	return osDeploymentPlan, nil
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:21,代碼來源:os_deployment_plan.go

示例7: GetServerHardware

// get a server hardware with uri
func (c *OVClient) GetServerHardware(uri utils.Nstring) (ServerHardware, error) {

	var hardware ServerHardware
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	// rest call
	data, err := c.RestAPICall(rest.GET, uri.String(), nil)
	if err != nil {
		return hardware, err
	}

	log.Debugf("GetServerHardware %s", data)
	if err := json.Unmarshal([]byte(data), &hardware); err != nil {
		return hardware, err
	}
	hardware.Client = c
	return hardware, nil
}
開發者ID:wenlock,項目名稱:oneview-golang,代碼行數:21,代碼來源:server_hardware.go

示例8: NewNetConfig

// NewNetConfig - create a new netconfig object without interfaces
func NewNetConfig(
	hostname utils.Nstring,
	workgroup utils.Nstring,
	domain utils.Nstring,
	winslist utils.Nstring,
	dnsnamelist utils.Nstring,
	dnssearchlist utils.Nstring) NetConfig {

	var netconfig NetConfig
	netconfig = NetConfig{
		WINSList:      winslist,
		DNSNameList:   dnsnamelist,
		DNSSearchList: dnssearchlist,
	}
	if !hostname.IsNil() {
		netconfig.Hostname = hostname.String()
	}
	if !workgroup.IsNil() {
		netconfig.Workgroup = workgroup.String()
	}
	if !domain.IsNil() {
		netconfig.Domain = domain.String()
	}
	return netconfig
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:26,代碼來源:netconfig.go

示例9: NewNetConfigInterface

// NewNetConfigInterface - creates an interface object for NetConfig
func (n *NetConfig) NewNetConfigInterface(
	enable bool,
	macaddr string,
	isdhcp bool,
	isipv6 bool,
	ipv6gateway utils.Nstring, // ipv6 gateway, required with isipv6 is true
	ipv4gateway utils.Nstring, // ipv4 gateway, required when isdhcp is false
	staticnets utils.Nstring, // comma seperated list of ip's, required when isdhcp is false
	name utils.Nstring, // optional name
	wins utils.Nstring, // comma seperated list of wins servers
	dnsservers utils.Nstring, // comma seperated list of dns servers
	dnssearch utils.Nstring,
	vlandid int) NetConfigInterface { // comma seperated list of dns search

	var inetconfig NetConfigInterface

	inetconfig = NetConfigInterface{
		Enabled:        enable,
		MACAddr:        macaddr,
		DHCPv4:         isdhcp,
		IPv6Autoconfig: isipv6,
		VlanID:         vlandid,
	}
	if macaddr == "" {
		log.Error("Network configuration (NetConfigInterface) requires a MAC Address to create a new interface object.")
	}
	if isipv6 {
		if ipv6gateway.IsNil() {
			log.Error("Gateway for ipv6 is required, configure IPv6Gateway")
		}
		inetconfig.IPv6Gateway = ipv6gateway.String()
	}
	if !isdhcp {
		if ipv4gateway.IsNil() {
			log.Error("Static ipv4 configuration requires a gateway configured (IPv4Gateway)")
		}
		inetconfig.IPv4Gateway = ipv4gateway.String()
		if staticnets.IsNil() {
			log.Error("Static ipv4 configuration requires static network list")
		}
		inetconfig.StaticNetworks = strings.Split(staticnets.String(), SplitSep)
	}
	if !name.IsNil() {
		inetconfig.Name = name.String()
	}
	if !wins.IsNil() {
		inetconfig.WINSServers = strings.Split(wins.String(), SplitSep)
	}
	if !dnsservers.IsNil() {
		inetconfig.DNSServers = strings.Split(dnsservers.String(), SplitSep)
	}
	if !dnssearch.IsNil() {
		inetconfig.DNSSearch = strings.Split(dnssearch.String(), SplitSep)
	}
	return inetconfig
}
開發者ID:HewlettPackard,項目名稱:oneview-golang,代碼行數:57,代碼來源:netconfig.go


注:本文中的github.com/HewlettPackard/oneview-golang/utils.Nstring.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。