// Adds a guest OS name to hypervisor OS name mapping
485082
func (s *GuestOSService) AddGuestOsMapping(p *AddGuestOsMappingParams) (*AddGuestOsMappingResponse, error) {
	resp, err := s.cs.newRequest("addGuestOsMapping", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r AddGuestOsMappingResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
986795
func (hostnames *Hostnames) NewHostname() *Hostname {
	hostname := NewHostname(hostnames)
	hostnames.Hostnames.Items = append(hostnames.Hostnames.Items, hostname)
	return hostname
}
389510
func EvaluateHostnameOverride(hostnameOverride string) (string, error) {
	if hostnameOverride == "" || hostnameOverride == "@hostname" {
		return "", nil
	}
	k := strings.TrimSpace(hostnameOverride)
	k = strings.ToLower(k)

	if k != "@aws" {
		return hostnameOverride, nil
	}

	// We recognize @aws as meaning "the local-hostname from the aws metadata service"
	vBytes, err := vfs.Context.ReadFile("metadata://aws/meta-data/local-hostname")
	if err != nil {
		return "", fmt.Errorf("error reading local hostname from AWS metadata: %v", err)
	}

	// The local-hostname gets it's hostname from the AWS DHCP Option Set, which
	// may provide multiple hostnames separated by spaces. For now just choose
	// the first one as the hostname.
	domains := strings.Fields(string(vBytes))
	if len(domains) == 0 {
		glog.Warningf("Local hostname from AWS metadata service was empty")
		return "", nil
	}
	domain := domains[0]

	glog.Infof("Using hostname from AWS metadata service: %s", domain)

	return domain, nil
}
649982
func (z *vmwareAvailZone) Name() string {
	// The name for this zone is the compute resource name and the
	// path of the pool without the prefix, so for
	// /QA/host/aron.internal/Resources/High/Child, the name should be
	// aron.internal/High/Child.
	path := strings.TrimRight(z.pool.InventoryPath, "/")
	parts := strings.Split(path, "/")
	poolPath := ""
	if len(parts) > poolPathPrefixParts {
		// This isn't the root pool for this compute resource, include
		// the pool's path.
		poolPath = "/" + strings.Join(parts[poolPathPrefixParts:], "/")
	}

	return z.r.Name + poolPath
}
1092464
func Hostname() string {
	hostname := os.Getenv("HOSTNAME")
	if len(hostname) > 0 {
		return hostname
	}
	hostname, err := os.Hostname()
	if err == nil {
		return hostname
	}
	return "localhost"
}
520806
func osName(osSplit []string) (name, version string) {
	if len(osSplit) == 1 {
		name = osSplit[0]
		version = ""
	} else {
		// Assume version is stored in the last part of the array.
		nameSplit := osSplit[:len(osSplit)-1]
		version = osSplit[len(osSplit)-1]

		// Nicer looking Mac OS X
		if len(nameSplit) >= 2 && nameSplit[0] == "Intel" && nameSplit[1] == "Mac" {
			nameSplit = nameSplit[1:]
		}
		name = strings.Join(nameSplit, " ")

		if strings.Contains(version, "x86") || strings.Contains(version, "i686") {
			// x86_64 and i868 are not Linux versions but architectures
			version = ""
		} else if version == "X" && name == "Mac OS" {
			// X is not a version for Mac OS.
			name = name + " " + version
			version = ""
		}
	}
	return name, version
}
115376
func (s *Service) AddVirtualHost(application, vhostName string, isEnabled bool) (*servicedefinition.VHost, error) {
	if s.Endpoints != nil {

		//find the matching endpoint
		for i := range s.Endpoints {
			ep := &s.Endpoints[i]

			if ep.Application == application && ep.Purpose == "export" {
				_vhostName := strings.ToLower(vhostName)
				vhosts := make([]servicedefinition.VHost, 0)
				for _, vhost := range ep.VHostList {
					if strings.ToLower(vhost.Name) != _vhostName {
						vhosts = append(vhosts, vhost)
					}
				}
				vhost := &servicedefinition.VHost{Name: _vhostName, Enabled: isEnabled}
				ep.VHostList = append(vhosts, *vhost)
				return vhost, nil
			}
		}
	}

	return nil, fmt.Errorf("unable to find application %s in service: %s", application, s.Name)
}
595119
func (r Spec) Hostname() string {
	i := strings.Index(r.Locator, "/")

	if i < 0 {
		i = len(r.Locator) + 1
	}
	return r.Locator[:i]
}
104632
func (b *Bundle) buildHostnames() {
	if b.Cert == nil {
		return
	}
	// hset keeps a set of unique hostnames.
	hset := make(map[string]bool)
	// insert CN into hset
	if b.Cert.Subject.CommonName != "" {
		hset[b.Cert.Subject.CommonName] = true
	}
	// insert all DNS names into hset
	for _, h := range b.Cert.DNSNames {
		hset[h] = true
	}

	// convert hset to an array of hostnames
	b.Hostnames = make([]string, len(hset))
	i := 0
	for h := range hset {
		b.Hostnames[i] = h
		i++
	}
}
575144
func (l VirtualDeviceList) Name(device types.BaseVirtualDevice) string {
	var key string
	var UnitNumber int32
	d := device.GetVirtualDevice()
	if d.UnitNumber != nil {
		UnitNumber = *d.UnitNumber
	}

	dtype := l.Type(device)
	switch dtype {
	case DeviceTypeEthernet:
		key = fmt.Sprintf("%d", UnitNumber-7)
	case DeviceTypeDisk:
		key = fmt.Sprintf("%d-%d", d.ControllerKey, UnitNumber)
	default:
		key = fmt.Sprintf("%d", d.Key)
	}

	return fmt.Sprintf("%s-%s", dtype, key)
}
689727
func (g *Generator) SetHostname(s string) {
	g.initConfig()
	g.Config.Hostname = s
}
760713
func (s *CreateVirtualNodeInput) SetVirtualNodeName(v string) *CreateVirtualNodeInput {
	s.VirtualNodeName = &v
	return s
}
745805
func (s *VirtualNodeData) SetVirtualNodeName(v string) *VirtualNodeData {
	s.VirtualNodeName = &v
	return s
}
1260015
func (s *NewTransitVirtualInterfaceAllocation) SetVirtualInterfaceName(v string) *NewTransitVirtualInterfaceAllocation {
	s.VirtualInterfaceName = &v
	return s
}
271699
func (r Ticket) RemoveAttachedVirtualGuest(guestId *int) (resp bool, err error) {
	params := []interface{}{
		guestId,
	}
	err = r.Session.DoRequest("SoftLayer_Ticket", "removeAttachedVirtualGuest", params, &r.Options, &resp)
	return
}
411001
func (s *GuestOSService) NewAddGuestOsParams(details map[string]string, oscategoryid string, osdisplayname string) *AddGuestOsParams {
	p := &AddGuestOsParams{}
	p.p = make(map[string]interface{})
	p.p["details"] = details
	p.p["oscategoryid"] = oscategoryid
	p.p["osdisplayname"] = osdisplayname
	return p
}
1023043
func (util *ISCSIUtil) MakeGlobalVDPDName(iscsi iscsiDisk) string {
	return makeVDPDNameInternal(iscsi.plugin.host, iscsi.Portals[0], iscsi.Iqn, iscsi.Lun, iscsi.Iface)
}