<commit_before>/*
(c) Copyright [2015] Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package ov -
package ov

import (
	"strings"

	"github.com/Pooja-S-Rao/oneview-golang/liboneview"
	"github.com/Pooja-S-Rao/oneview-golang/utils"
	"github.com/docker/machine/libmachine/log"
)

// introduced in v200 for oneview, new v2 hardware attributes
// such as support for different types of ilo connections

// IsHardwareSchemaV2 - true when we are using v2, false for v1
func (c *OVClient) IsHardwareSchemaV2() bool {
	var currentversion liboneview.Version
	var asc liboneview.APISupport
	currentversion = currentversion.CalculateVersion(c.APIVersion, 108) // force icsp to 108 version since icsp version doesn't matter
	asc = asc.NewByName("server_hardwarev2.go")
	if asc.IsSupported(currentversion) {
		log.Debugf("IsHardwareSchemaV2 is supported: %+v", currentversion)
		return true
	}
	return false
}

// ServerHardwarev200 get server hardware from ov
// mphostinfo is private to force calls to GetIloIPAddress
type ServerHardwarev200 struct {
	IntelligentProvisioningVersion string              `json:"intelligentProvisioningVersion,omitempty"` // intelligentProvisioningVersion The installed version of the Intelligent Provisioning embedded server provisioning tool. string
	MpHostInfo                     *MpHostInfov200     `json:"mpHostInfo,omitempty"`                     // The host name and IP address information for the Management Processor that resides on this server.
	MpState                        string              `json:"mpState,omitempty"`                        //  Indicates the current state of the management processor.
	PortMap                        *PortMapv200        `json:"portMap,omitempty"`                        //  A list of adapters/slots, their ports and attributes. This information is available for blade servers but not rack servers.
	ServerSettings                 *ServerSettingsv200 `json:"serverSettings,omitempty"`                 //  Indicates the current settings on the server and state of these settings.
	Signature                      *Signaturev200      `json:"signature,omitempty"`                      // Data representing the current configuration or 'signature' of the server.
}

// TODO: needs a type
// PhysicalServerMPState<commit_msg>Update server_hardwarev2.go<commit_after>/*
(c) Copyright [2015] Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package ov -
package ov

import (
	"strings"

	"github.com/Pooja-S-Rao/oneview-golang/liboneview"
	"github.com/Pooja-S-Rao/oneview-golang/utils"
	"github.com/docker/machine/libmachine/log"
)

// introduced in v200 for oneview, new v2 hardware attributes
// such as support for different types of ilo connections

// IsHardwareSchemaV2 - true when we are using v2, false for v1
func (c *OVClient) IsHardwareSchemaV2() bool {
	var currentversion liboneview.Version
	var asc liboneview.APISupport
	currentversion = currentversion.CalculateVersion(c.APIVersion, 108) // force icsp to 108 version since icsp version doesn't matter
	log.Infof("inside server_hardwarev2 :%s",currentversion)
	asc = asc.NewByName("server_hardwarev2.go")
	if asc.IsSupported(currentversion) {
		log.Debugf("IsHardwareSchemaV2 is supported: %+v", currentversion)
		return true
	}
	return false
}

// ServerHardwarev200 get server hardware from ov
// mphostinfo is private to force calls to GetIloIPAddress
type ServerHardwarev200 struct {
	IntelligentProvisioningVersion string              `json:"intelligentProvisioningVersion,omitempty"` // intelligentProvisioningVersion The installed version of the Intelligent Provisioning embedded server provisioning tool. string
	MpHostInfo                     *MpHostInfov200     `json:"mpHostInfo,omitempty"`                     // The host name and IP address information for the Management Processor that resides on this server.
	MpState                        string              `json:"mpState,omitempty"`                        //  Indicates the current state of the management processor.
	PortMap                        *PortMapv200        `json:"portMap,omitempty"`                        //  A list of adapters/slots, their ports and attributes. This information is available for blade servers but not rack servers.
	ServerSettings                 *ServerSettingsv200 `json:"serverSettings,omitempty"`                 //  Indicates the current settings on the server and state of these settings.
	Signature                      *Signaturev200      `json:"signature,omitempty"`                      // Data representing the current configuration or 'signature' of the server.
}

// TODO: needs a type
// PhysicalServerMPState
{'fraction_non_alphanumeric': 0.06784712482468443, 'fraction_numerical': 0.015077138849929873, 'mean_word_length': 3.2134416543574593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6577118', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1445, 'n_words': 561}