Documentation ¶
Index ¶
- Constants
- Variables
- func AddPrefix(collection, entity string) string
- func AppendUniqueStrings(des []string, src ...string) []string
- func CheckPermission(ctx context.Context, perm realms.Permission, realm string) error
- func ContainsAnyStrings(list []string, inputs ...string) bool
- func CurrentUser(ctx context.Context) string
- func DUTToLSE(dut *lab.DeviceUnderTest, deviceID string, updatedTime *timestamp.Timestamp) *ufspb.MachineLSE
- func DeviceToAssetMeta(d *lab.ChromeOSDevice) (*ufspb.AssetInfo, string, ufspb.AssetType)
- func ExecuteRequest(ctx context.Context, hc *http.Client, req *http.Request, value proto.Message) error
- func FormatDHCPHostname(old string) string
- func FormatDHCPHostnames(names []string) []string
- func FormatDeploymentRecord(hostname, serialNumber string) *ufspb.MachineLSEDeployment
- func FormatIP(vlanName, ipAddress string, reserve, occupied bool) *ufspb.IP
- func FormatInputNames(names []string) []string
- func FormatResourceName(old string) string
- func GetATLLabName(raw string) string
- func GetBrowserLabName(raw string) string
- func GetCrOSLabName(raw string) string
- func GetHiveForDut(hostname string) string
- func GetHostnameWithNoHostPrefix(suffix string) string
- func GetIPName(vlanName, ipv4Str string) string
- func GetNewNicNameForRenameMachine(oldNicName, oldMachineName, newMachineName string) string
- func GetNicName(nicName, machineName string) string
- func GetOSMachineLSEPrototypes() []*ufspb.MachineLSEPrototype
- func GetPageSize(pageSize int32) int32
- func GetPrefix(resourceName string) string
- func GetRackHostname(rackName string) string
- func GetResourcePrefix(message proto.Message) (string, error)
- func GetStateDescription(state string) string
- func GetSuffixAfterSeparator(name, seprator string) string
- func GetValidRealmName(realm string) string
- func HostnameToLocation(hostname string) *ufspb.Location
- func IPv4IntToStr(ipAddress uint32) string
- func IPv4StrToInt(ipAddress string) (uint32, error)
- func Int32ToStr(v int32) string
- func Int64ToStr(v int64) string
- func IsAntennaConnection(antennaConnection string) bool
- func IsAssetType(assetType string) bool
- func IsCableType(cableType string) bool
- func IsCameraType(cameraType string) bool
- func IsChameleonType(chameleonType string) bool
- func IsClientNamespace(namespace string) bool
- func IsFacing(facing string) bool
- func IsInBrowserZone(name string) bool
- func IsInternalError(err error) bool
- func IsLicenseType(licenseType string) bool
- func IsLight(light string) bool
- func IsMacFormatValid(userMac string) error
- func IsNotFoundError(err error) bool
- func IsRouter(router string) bool
- func IsSchedulingUnitType(schedulingUnitType string) bool
- func IsUFSState(state string) bool
- func IsUFSZone(zone string) bool
- func LabToZone(lab string) ufspb.Zone
- func LabstationToLSE(l *lab.Labstation, deviceID string, updatedTime *timestamp.Timestamp) *ufspb.MachineLSE
- func Min(a, b int) int
- func ParseATLTopology(data *sheets.Spreadsheet) (map[string]*ufspb.Vlan, []*ufspb.Vlan)
- func ParseMac(userMac string) (string, error)
- func ParseVlan(vlanName, cidr, freeStartIP, freeEndIP string) ([]*ufspb.IP, int, string, string, error)
- func ProcessDatacenters(dc *crimsonconfig.Datacenter) ([]*ufspb.Rack, []*ufspb.KVM, []*ufspb.Switch, []*ufspb.DHCPConfig)
- func ProcessNetworkInterfaces(nics []*crimson.NIC, dracs []*crimson.DRAC, machines []*crimson.Machine) ([]*ufspb.Nic, []*ufspb.Drac, []*ufspb.DHCPConfig, map[string][]string, ...)
- func ProtoEqual(i, j proto.Message) bool
- func PublishHaRTAssetInfoRequest(ctx context.Context, assets []string) (err error)
- func RemoveGivenPrefix(msg, prefix string) string
- func RemovePrefix(name string) string
- func RemoveStatePrefix(state string) string
- func RemoveStringEntry(slice []string, entry string) []string
- func RemoveZonePrefix(zone string) string
- func SetupDatastoreNamespace(ctx context.Context, namespace string) (context.Context, error)
- func ToAntennaConnection(antennaConnection string) chromeosLab.Wifi_AntennaConnection
- func ToAssetType(assetType string) ufspb.AssetType
- func ToCableType(cableType string) chromeosLab.CableType
- func ToCameraType(cameraType string) chromeosLab.CameraType
- func ToChameleonType(chameleonType string) chromeosLab.ChameleonType
- func ToChromeMachines(old []*crimson.Machine, machineToNics map[string][]string, ...) []*ufspb.Machine
- func ToChromePlatforms(oldP *crimsonconfig.Platforms) []*ufspb.ChromePlatform
- func ToFacing(facing string) chromeosLab.Camerabox_Facing
- func ToLab(datacenter string) ufspb.Lab
- func ToLicenseType(licenseType string) chromeosLab.LicenseType
- func ToLight(light string) chromeosLab.Camerabox_Light
- func ToMachineLSEs(hosts []*crimson.PhysicalHost, vms []*crimson.VM, machines []*crimson.Machine, ...) ([]*ufspb.MachineLSE, []*ufspb.VM, []*ufspb.IP, []*ufspb.DHCPConfig)
- func ToOSAssets(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig, ...) []*ufspb.Asset
- func ToOSDutStates(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig) []*chromeosLab.DutState
- func ToOSMachineLSEs(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig) ([]*ufspb.MachineLSE, ...)
- func ToOses(old []*crimson.OS) []*ufspb.OSVersion
- func ToRouter(router string) chromeosLab.Wifi_Router
- func ToSchedulingUnitType(schedulingUnitType string) ufspb.SchedulingUnitType
- func ToState(state crimsoncommon.State) ufspb.State
- func ToUFSDeploymentEnv(env string) ufspb.DeploymentEnv
- func ToUFSDept(zone string) string
- func ToUFSDeviceType(devicetype string) ufspb.ChromeOSDeviceType
- func ToUFSRealm(zone string) string
- func ToUFSState(state string) ufspb.State
- func ToUFSZone(zone string) ufspb.Zone
- func ToZone(datacenter string) ufspb.Zone
- func ValidAntennaConnectionStr() []string
- func ValidAssetTypeStr() []string
- func ValidCableTypeStr() []string
- func ValidCameraTypeStr() []string
- func ValidChameleonTypeStr() []string
- func ValidClientNamespaceStr() []string
- func ValidDeploymentEnvStr() []string
- func ValidDeviceTypeStr() []string
- func ValidFacingStr() []string
- func ValidLicenseTypeStr() []string
- func ValidLightStr() []string
- func ValidRouterStr() []string
- func ValidSchedulingUnitTypeStr() []string
- func ValidStateStr() []string
- func ValidZoneStr() []string
- func ValidateTags(tags []string) bool
- type DHCPConf
- type HTTPError
- type Key
- type PSRequest
Constants ¶
const ( ColonSeparator string = ":" Lab string = "lab" ATL string = "atl" ACS string = "acs" Browser string = "browser" CrOS string = "cros" // https://cloud.google.com/datastore/docs/concepts/limits OperationPageSize int = 500 // Version Key format of inventory TimestampBasedVersionKeyFormat string = "2006-01-02 15:04:05.000 UTC" )
message for filtering
const ( // AssetCollection refers to the prefix of the corresponding resource. AssetCollection string = "assets" // MachineCollection refers to the prefix of the corresponding resource. MachineCollection string = "machines" // RackCollection refers to the prefix of the corresponding resource. RackCollection string = "racks" // VMCollection refers to the prefix of the corresponding resource. VMCollection string = "vms" // ChromePlatformCollection refers to the prefix of the corresponding resource. ChromePlatformCollection string = "chromeplatforms" // MachineLSECollection refers to the prefix of the corresponding resource. MachineLSECollection string = "machineLSEs" // MachineLSEDeploymentCollection refers to the prefix of the corresponding resource. MachineLSEDeploymentCollection string = "machineLSEDeployments" // HostCollection refers to the prefix of the corresponding resource. HostCollection string = "hosts" // RackLSECollection refers to the prefix of the corresponding resource. RackLSECollection string = "rackLSEs" // NicCollection refers to the prefix of the corresponding resource. NicCollection string = "nics" // KVMCollection refers to the prefix of the corresponding resource. KVMCollection string = "kvms" // RPMCollection refers to the prefix of the corresponding resource. RPMCollection string = "rpms" // DracCollection refers to the prefix of the corresponding resource. DracCollection string = "dracs" // SwitchCollection refers to the prefix of the corresponding resource. SwitchCollection string = "switches" // VlanCollection refers to the prefix of the corresponding resource. VlanCollection string = "vlans" // MachineLSEPrototypeCollection refers to the prefix of the corresponding resource. MachineLSEPrototypeCollection string = "machineLSEPrototypes" // RackLSEPrototypeCollection refers to the prefix of the corresponding resource. RackLSEPrototypeCollection string = "rackLSEPrototypes" // DHCPCollection refers to the prefix of the dhcp config id in change history DHCPCollection string = "dhcps" // IPCollection refers to the prefix of the ip id in change history IPCollection string = "ips" // StateCollection refers to the prefix of the states id in change history StateCollection string = "states" // CachingServiceCollection refers to the prefix of the CachingService. CachingServiceCollection string = "cachingservices" // DutStateCollection refers to the prefix of the DutStates id in change history DutStateCollection string = "dutstates" // SchedulingUnitCollection refers to the prefix of the SchedulingUnit. SchedulingUnitCollection string = "schedulingunits" // DefaultImporter refers to the user of the cron job importer DefaultImporter string = "crimson-importer" // MaxPageSize maximum page size for list operations MaxPageSize int32 = 1000 // NoHostPrefix is the prefix string for generating a fake non-existing hostname NoHostPrefix string = "no-host-yet-" )
const AcsLabAdminRealm = "@internal:ufs/os-acs"
AcsLabAdminRealm is the admin realm for acs lab.
const AtlLabAdminRealm = "@internal:ufs/os-atl"
AtlLabAdminRealm is the admin realm for atl lab.
const BrowserLabAdminRealm = "@internal:ufs/browser"
BrowserLabAdminRealm is the admin realm for browser lab.
const OldBrowserLabAdminRealm = "chromium:ufs/browser-admin"
OldBrowserLabAdminRealm is the Old realm for browser lab
If a client sends this realm, replace it with BrowserLabAdminRealm
Variables ¶
var ( ZoneFilterName string = "zone" RackFilterName string = "rack" MachineFilterName string = "machine" HostFilterName string = "host" NicFilterName string = "nic" DracFilterName string = "drac" KVMFilterName string = "kvm" KVMPortFilterName string = "kvmport" MacAddressFilterName string = "mac" RPMFilterName string = "rpm" RPMPortFilterName string = "rpmport" SwitchFilterName string = "switch" SwitchPortFilterName string = "switchport" ServoFilterName string = "servo" ServoTypeFilterName string = "servotype" TagFilterName string = "tag" ChromePlatformFilterName string = "platform" MachinePrototypeFilterName string = "machineprototype" RackPrototypeFilterName string = "rackprototype" VlanFilterName string = "vlan" StateFilterName string = "state" IPV4FilterName string = "ipv4" IPV4StringFilterName string = "ipv4str" OccupiedFilterName string = "occupied" ManufacturerFilterName string = "man" FreeVMFilterName string = "free" ResourceTypeFilterName string = "resourcetype" OSVersionFilterName string = "osversion" OSFilterName string = "os" VirtualDatacenterFilterName string = "vdc" ModelFilterName string = "model" BuildTargetFilterName string = "target" BoardFilterName string = "board" DeviceTypeFilterName string = "devicetype" PhaseFilterName string = "phase" AssetTypeFilterName string = "assettype" SubnetsFilterName string = "subnets" PoolsFilterName string = "pools" DeploymentIdentifierFilterName string = "deploymentidentifier" DeploymentEnvFilterName string = "deploymentenv" MachineLSEsFilterName string = "duts" TypeFilterName string = "type" SerialNumberFilterName string = "serialnumber" )
Filter names for indexed properties in datastore for different entities
var ( // OSNamespace os namespace to be set in client context metadata. OS data is stored in os namespace in the datastore. OSNamespace = "os" // BrowserNamespace browser namespace to be set in client context metadata. Browser data is stored in default namespace in the datastore. BrowserNamespace = "browser" //Namespace key in the incoming context metadata Namespace = "namespace" )
Namespace namespace to be set by clients in context metadata This will be used to set the actual datastore namespace in the context
var ( // ConfigurationsGet allows to get configuration resources. ConfigurationsGet = realms.RegisterPermission("ufs.configurations.get") // ConfigurationsList allows to list configuration resources. ConfigurationsList = realms.RegisterPermission("ufs.configurations.list") // ConfigurationsCreate allows to create configuration resources. ConfigurationsCreate = realms.RegisterPermission("ufs.configurations.create") // ConfigurationUpdate allows to update configuration resources. ConfigurationsUpdate = realms.RegisterPermission("ufs.configurations.update") // ConfigurationsDelete allows to delete configuration resources. ConfigurationsDelete = realms.RegisterPermission("ufs.configurations.delete") // RegistrationsGet allows to get registration resources. RegistrationsGet = realms.RegisterPermission("ufs.registrations.get") // RegistrationsList allows to list registration resources. RegistrationsList = realms.RegisterPermission("ufs.registrations.list") // RegistrationsCreate allows to create registration resources. RegistrationsCreate = realms.RegisterPermission("ufs.registrations.create") // RegistrationsUpdate allows to update registration resources. RegistrationsUpdate = realms.RegisterPermission("ufs.registrations.update") // RegistrationsDelete allows to delete registration resources. RegistrationsDelete = realms.RegisterPermission("ufs.registrations.delete") // InventoriesGet allows to get inventory resources. InventoriesGet = realms.RegisterPermission("ufs.inventories.get") // InventoriesList allows to list inventory resources. InventoriesList = realms.RegisterPermission("ufs.inventories.list") // InventoriesCreate allows to create inventory resources. InventoriesCreate = realms.RegisterPermission("ufs.inventories.create") // InventoriesUpdate allows to update inventory resources. InventoriesUpdate = realms.RegisterPermission("ufs.inventories.update") // InventoriesDelete allows to delete inventory resources. InventoriesDelete = realms.RegisterPermission("ufs.inventories.delete") // NetworksGet allows to get network resources. NetworksGet = realms.RegisterPermission("ufs.networks.get") // NetworksList allows to list network resources. NetworksList = realms.RegisterPermission("ufs.networks.list") // NetworksCreate allows to create network resources. NetworksCreate = realms.RegisterPermission("ufs.networks.create") // NetworksUpdate allows to update network resources. NetworksUpdate = realms.RegisterPermission("ufs.networks.update") // NetworksDelete allows to delete network resources. NetworksDelete = realms.RegisterPermission("ufs.networks.delete") // ResourcesImport allows to import resource resources. ResourcesImport = realms.RegisterPermission("ufs.resources.import") )
UFS registered permissions in process registry
var ClientToDatastoreNamespace = map[string]string{ BrowserNamespace: "", OSNamespace: OSNamespace, }
ClientToDatastoreNamespace refers a map between client namespace(set in context metadata) to actual datastore namespace
var ServoV3HostnameRegex = regexp.MustCompile(`.*-servo`)
ServoV3HostnameRegex is used to identify servo V3 hosts.
var SkipRealmsCheck = false
SkipRealmsCheck flag to skip realms check
var StateToDescription = map[string]string{
"registered": "Needs deploy",
"deployed_pre_serving": "Deployed but not placed in prod",
"deployed_testing": "Deployed to the prod, but for testing",
"serving": "Deployed to the prod, serving",
"needs_reset": "Deployed to the prod, but required cleanup and verify",
"needs_repair": "Deployed to the prod, needs repair",
"repair_failed": "Deployed to the prod, failed to be repaired in previous step and requires new repair attempt",
"disabled": "Deployed to the prod, but disabled",
"reserved": "Deployed to the prod, but reserved (e.g. locked)",
"decommissioned": "Decommissioned from the prod, but still lives in UFS record",
"deploying": "Deploying the resource with required configs just before it is READY",
"ready": "Resource is ready for use or free to use",
}
StateToDescription refers a map between a State to its description.
var StrToAntennaConnection = map[string]string{
"unknown": "CONN_UNKNOWN",
"conductive": "CONN_CONDUCTIVE",
"ota": "CONN_OTA",
}
StrToAntennaConnection refers a map between a string to a AntennaConnection map.
var StrToCableType = map[string]string{
"invalid": "CABLE_INVALID",
"audiojack": "CABLE_AUDIOJACK",
"usbaudio": "CABLE_USBAUDIO",
"usbprinting": "CABLE_USBPRINTING",
"hdmiaudio": "CABLE_HDMIAUDIO",
}
StrToCableType refers a map between a string to a CableType map.
var StrToCameraType = map[string]string{
"invalid": "CAMERA_INVALID",
"huddly": "CAMERA_HUDDLY",
"ptzpro2": "CAMERA_PTZPRO2",
}
StrToCameraType refers a map between a string to a CameraType map.
var StrToChameleonType = map[string]string{
"invalid": "CHAMELEON_TYPE_INVALID",
"dp": "CHAMELEON_TYPE_DP",
"dphdmi": "CHAMELEON_TYPE_DP_HDMI",
"vga": "CHAMELEON_TYPE_VGA",
"hdmi": "CHAMELEON_TYPE_HDMI",
}
StrToChameleonType refers a map between a string to a ChameleonType map.
var StrToFacing = map[string]string{
"unknown": "FACING_UNKNOWN",
"back": "FACING_BACK",
"front": "FACING_FRONT",
}
StrToFacing refers a map between a string to a Facing map.
var StrToLicenseType = map[string]string{
"invalid": "LICENSE_TYPE_UNSPECIFIED",
"windows10pro": "LICENSE_TYPE_WINDOWS_10_PRO",
"msofficestd": "LICENSE_TYPE_MS_OFFICE_STANDARD",
}
StrToLicenseType refers a map between a string to a LicenseType map.
var StrToLight = map[string]string{
"unknown": "LIGHT_UNKNOWN",
"led": "LIGHT_LED",
"noled": "LIGHT_NOLED",
}
StrToLight refers a map between a string to a Light map.
var StrToRouter = map[string]string{
"unspecified": "ROUTER_UNSPECIFIED",
"80211ax": "ROUTER_802_11AX",
}
StrToRouter refers a map between a string to a Router map.
var StrToSchedulingUnitType = map[string]string{
"invalid": "SCHEDULING_UNIT_TYPE_INVALID",
"all": "SCHEDULING_UNIT_TYPE_ALL",
"individual": "SCHEDULING_UNIT_TYPE_INDIVIDUAL",
}
StrToSchedulingUnitType refers a map between a string to a UFS defined map.
var StrToUFSDeviceType = map[string]string{
"chromebook": "DEVICE_CHROMEBOOK",
"labstation": "DEVICE_LABSTATION",
"servo": "DEVICE_SERVO",
"unspecified": "CHROME_OS_DEVICE_TYPE_UNSPECIFIED",
}
StrToUFSDeviceType refers a map between a string to a UFS defined map.
var StrToUFSState = map[string]string{
"registered": "STATE_REGISTERED",
"deployed_pre_serving": "STATE_DEPLOYED_PRE_SERVING",
"deployed_testing": "STATE_DEPLOYED_TESTING",
"serving": "STATE_SERVING",
"needs_reset": "STATE_NEEDS_RESET",
"needs_repair": "STATE_NEEDS_REPAIR",
"repair_failed": "STATE_REPAIR_FAILED",
"disabled": "STATE_DISABLED",
"reserved": "STATE_RESERVED",
"decommissioned": "STATE_DECOMMISSIONED",
"deploying": "STATE_DEPLOYING",
"ready": "STATE_READY",
}
StrToUFSState refers a map between a string to a UFS defined state map.
var StrToUFSZone = genStrToUFSZone()
StrToUFSZone refers a map between a string to a UFS defined map.
Functions ¶
func AppendUniqueStrings ¶
AppendUniqueStrings returns a slice with unique elements such that all the des elements are appended to src.
func CheckPermission ¶
CheckPermission checks if the user has permission in the realm
return error if user doesnt have permission or unable to check permission in realm else returns nil
func ContainsAnyStrings ¶
ContainsAnyStrings returns true if at least one of the inputs is in list.
func CurrentUser ¶
CurrentUser returns the current user
func DUTToLSE ¶
func DUTToLSE(dut *lab.DeviceUnderTest, deviceID string, updatedTime *timestamp.Timestamp) *ufspb.MachineLSE
DUTToLSE converts a DUT spec to a UFS machine LSE
func DeviceToAssetMeta ¶
DeviceToAssetMeta creates an asset for the device
func ExecuteRequest ¶
func FormatDHCPHostname ¶
FormatDHCPHostname formats a name which will be a dhcp host
func FormatDHCPHostnames ¶
FormatDHCPHostnames formats a given array of resource names which could be used as dhcp hostnames
func FormatDeploymentRecord ¶
func FormatDeploymentRecord(hostname, serialNumber string) *ufspb.MachineLSEDeployment
FormatDeploymentRecord initialize a MachineLSE deployment record object by hostname and given serial number.
func FormatInputNames ¶
FormatInputNames formats a given array of resource names
func FormatResourceName ¶
FormatResourceName formats the resource name
func GetATLLabName ¶
GetATLLabName returns a resource name with atl prefix and a given user-specified raw name.
func GetBrowserLabName ¶
GetBrowserLabName return a resource name with browser prefix and a given user-specified raw name.
func GetCrOSLabName ¶
GetCrOSLabName returns a resource name with ChromeOS prefix and a given user-specified raw name.
func GetHiveForDut ¶
GetHiveForDut returns the hive value for a DUT.
hive value is derived from the DUT hostname.
func GetHostnameWithNoHostPrefix ¶
GetHostnameWithNoHostPrefix generates a hostname with NoHostPrefix.
func GetNewNicNameForRenameMachine ¶
GetNewNicNameForRenameMachine returns new nic name for new machine name
func GetNicName ¶
GetNicName formats a nic name with its attached machine
func GetOSMachineLSEPrototypes ¶
func GetOSMachineLSEPrototypes() []*ufspb.MachineLSEPrototype
GetOSMachineLSEPrototypes returns the pre-defined machine lse prototypes for ChromeOS machines.
func GetPageSize ¶
GetPageSize gets the correct page size for List pagination
func GetRackHostname ¶
GetRackHostname returns a rack host name.
func GetResourcePrefix ¶
GetResourcePrefix gets the resource prefix given to the proto message.
Returns the resource prefix for a given proto message. See also: https://blog.golang.org/protobuf-apiv2
func GetStateDescription ¶
GetStateDescription returns the description for the state
func GetSuffixAfterSeparator ¶
GetSuffixAfterSeparator extracts the string appearing after the separator
returns the suffix after the first found separator
func GetValidRealmName ¶
GetValidRealmName replaces the older Browser realm with newer realm
func HostnameToLocation ¶
HostnameToLocation convert hostname to location
func IPv4IntToStr ¶
IPv4IntToStr returns a string ip address
func IPv4StrToInt ¶
IPv4StrToInt returns an uint32 address from the given ip address string.
func IsAntennaConnection ¶
IsAntennaConnection checks if a string refers to a valid AntennaConnection.
func IsAssetType ¶
IsAssetType checks if a strings is a valid asset type
func IsCableType ¶
IsCableType checks if a string refers to a valid CableType.
func IsCameraType ¶
IsCameraType checks if a string refers to a valid CameraType.
func IsChameleonType ¶
IsChameleonType checks if a string refers to a valid ChameleonType.
func IsClientNamespace ¶
IsClientNamespace checks if a string refers to a valid client namespace.
func IsInBrowserZone ¶
IsInBrowserZone check if a given name(resource or zone name) indicates it's in browser zone.
func IsInternalError ¶
IsInternalError checks if an error has code INTERNAL
func IsLicenseType ¶
IsLicenseType checks if a string refers to a valid LicenseType.
func IsMacFormatValid ¶
IsMacFormatValid check if the given mac address is in valid format
func IsNotFoundError ¶
IsNotFoundError checks if an error has code NOT_FOUND
func IsSchedulingUnitType ¶
IsSchedulingUnitType checks if a string refers to a valid SchedulingUnitType.
func IsUFSState ¶
IsUFSState checks if a string refers to a valid UFS state.
func LabstationToLSE ¶
func LabstationToLSE(l *lab.Labstation, deviceID string, updatedTime *timestamp.Timestamp) *ufspb.MachineLSE
LabstationToLSE converts a DUT spec to a UFS machine LSE
func ParseATLTopology ¶
ParseATLTopology parse the topology of ATL lab based on a Google sheet
func ParseVlan ¶
func ParseVlan(vlanName, cidr, freeStartIP, freeEndIP string) ([]*ufspb.IP, int, string, string, error)
ParseVlan parses vlan to a list of IPs
vlanName here is a full vlan name, e.g. browser:123 The first 10 and last 1 ip of this cidr block will be reserved and not returned to users for further operations
func ProcessDatacenters ¶
func ProcessDatacenters(dc *crimsonconfig.Datacenter) ([]*ufspb.Rack, []*ufspb.KVM, []*ufspb.Switch, []*ufspb.DHCPConfig)
ProcessDatacenters converts datacenters to several UFS objects
func ProcessNetworkInterfaces ¶
func ProcessNetworkInterfaces(nics []*crimson.NIC, dracs []*crimson.DRAC, machines []*crimson.Machine) ([]*ufspb.Nic, []*ufspb.Drac, []*ufspb.DHCPConfig, map[string][]string, map[string]string)
ProcessNetworkInterfaces converts nics and dracs to several UFS formats for further importing
func ProtoEqual ¶
ProtoEqual compares the given protos i, j and returns true if Type(i) == Type(j) and one of the following holds 1. i == j == nil 2. For each exported field(proto message field) x in Type(i), i.Equal(j) or i.x == j.y. returns false otherwise.
func PublishHaRTAssetInfoRequest ¶
PublishHaRTAssetInfoRequest sends a request for asset info update for given assets
func RemoveGivenPrefix ¶
RemoveGivenPrefix removes the prefix from the string
func RemovePrefix ¶
RemovePrefix extracts string appearing after a "/"
func RemoveStatePrefix ¶
RemoveStatePrefix removes the "state_" prefix from the string
func RemoveStringEntry ¶
RemoveStringEntry removes string entry from the string slice
func RemoveZonePrefix ¶
RemoveZonePrefix removes the "zone_" prefix from the string
func SetupDatastoreNamespace ¶
SetupDatastoreNamespace sets the datastore namespace in the context to access the correct namespace in the datastore
func ToAntennaConnection ¶
func ToAntennaConnection(antennaConnection string) chromeosLab.Wifi_AntennaConnection
ToAntennaConnection converts antennaConnection string to a Wifi_AntennaConnection enum.
func ToAssetType ¶
ToAssetType returns an AssetType object corresponding to string
func ToCableType ¶
func ToCableType(cableType string) chromeosLab.CableType
ToCableType converts cableType string to a Cable type enum.
func ToCameraType ¶
func ToCameraType(cameraType string) chromeosLab.CameraType
ToCameraType converts cameraType string to a Camera type enum.
func ToChameleonType ¶
func ToChameleonType(chameleonType string) chromeosLab.ChameleonType
ToChameleonType converts devicetype string to a Chameleon type enum.
func ToChromeMachines ¶
func ToChromeMachines(old []*crimson.Machine, machineToNics map[string][]string, machineToDracs map[string]string) []*ufspb.Machine
ToChromeMachines converts crimson machines to UFS format.
func ToChromePlatforms ¶
func ToChromePlatforms(oldP *crimsonconfig.Platforms) []*ufspb.ChromePlatform
ToChromePlatforms converts platforms in static file to UFS format.
func ToFacing ¶
func ToFacing(facing string) chromeosLab.Camerabox_Facing
ToFacing converts facing string to a Camerabox_Facing enum.
func ToLicenseType ¶
func ToLicenseType(licenseType string) chromeosLab.LicenseType
ToLicenseType converts licenseType string to a License type enum.
func ToLight ¶
func ToLight(light string) chromeosLab.Camerabox_Light
ToLight converts light string to a Camerabox_Light enum.
func ToMachineLSEs ¶
func ToMachineLSEs(hosts []*crimson.PhysicalHost, vms []*crimson.VM, machines []*crimson.Machine, platforms []*crimson.Platform) ([]*ufspb.MachineLSE, []*ufspb.VM, []*ufspb.IP, []*ufspb.DHCPConfig)
ToMachineLSEs converts crimson data to UFS LSEs.
func ToOSAssets ¶
func ToOSAssets(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig, existingAssetMap map[string]*ufspb.Asset) []*ufspb.Asset
ToOSAssets converts cros inventory data to UFS ChromeOS assets.
func ToOSDutStates ¶
func ToOSDutStates(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig) []*chromeosLab.DutState
ToOSDutStates converts cros inventory data to UFS dut states for ChromeOS machines.
func ToOSMachineLSEs ¶
func ToOSMachineLSEs(labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig) ([]*ufspb.MachineLSE, map[*ufspb.MachineLSE]*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig)
ToOSMachineLSEs converts cros inventory data to UFS LSEs for ChromeOS machines.
func ToRouter ¶
func ToRouter(router string) chromeosLab.Wifi_Router
ToRouter converts router string to a Wifi_Router enum.
func ToSchedulingUnitType ¶
func ToSchedulingUnitType(schedulingUnitType string) ufspb.SchedulingUnitType
ToSchedulingUnitType converts SchedulingUnitType string to a UFS SchedulingUnitType enum.
func ToState ¶
func ToState(state crimsoncommon.State) ufspb.State
ToState converts crimson state to UFS state.
func ToUFSDeploymentEnv ¶
func ToUFSDeploymentEnv(env string) ufspb.DeploymentEnv
ToUFSDeploymentEnv converts string to a UFS DeploymentEnv enum.
func ToUFSDeviceType ¶
func ToUFSDeviceType(devicetype string) ufspb.ChromeOSDeviceType
ToUFSDeviceType converts devicetype string to a UFS devicetype enum.
func ToUFSRealm ¶
ToUFSRealm returns the realm name based on zone string.
func ToUFSState ¶
ToUFSState converts state string to a UFS state enum.
func ValidAntennaConnectionStr ¶
func ValidAntennaConnectionStr() []string
ValidAntennaConnectionStr returns a valid str list for AntennaConnection strings.
func ValidAssetTypeStr ¶
func ValidAssetTypeStr() []string
ValidAssetTypeStr returns a valid str list for AssetTypes
func ValidCableTypeStr ¶
func ValidCableTypeStr() []string
ValidCableTypeStr returns a valid str list for CableType strings.
func ValidCameraTypeStr ¶
func ValidCameraTypeStr() []string
ValidCameraTypeStr returns a valid str list for CameraType strings.
func ValidChameleonTypeStr ¶
func ValidChameleonTypeStr() []string
ValidChameleonTypeStr returns a valid str list for Chameleontype strings.
func ValidClientNamespaceStr ¶
func ValidClientNamespaceStr() []string
ValidClientNamespaceStr returns a valid str list for client namespace(set in incoming context metadata) strings.
func ValidDeploymentEnvStr ¶
func ValidDeploymentEnvStr() []string
ValidDeploymentEnvStr returns a valid str list for DeploymentEnv
func ValidDeviceTypeStr ¶
func ValidDeviceTypeStr() []string
ValidDeviceTypeStr returns a valid str list for devicetype strings.
func ValidFacingStr ¶
func ValidFacingStr() []string
ValidFacingStr returns a valid str list for Facing strings.
func ValidLicenseTypeStr ¶
func ValidLicenseTypeStr() []string
ValidLicenseTypeStr returns a valid str list for LicenseType strings.
func ValidLightStr ¶
func ValidLightStr() []string
ValidLightStr returns a valid str list for Light strings.
func ValidRouterStr ¶
func ValidRouterStr() []string
ValidRouterStr returns a valid str list for Router strings.
func ValidSchedulingUnitTypeStr ¶
func ValidSchedulingUnitTypeStr() []string
ValidSchedulingUnitTypeStr returns a valid str list for SchedulingUnitType strings.
func ValidStateStr ¶
func ValidStateStr() []string
ValidStateStr returns a valid str list for state strings.
func ValidZoneStr ¶
func ValidZoneStr() []string
ValidZoneStr returns a valid str list for zone strings.
func ValidateTags ¶
ValidateTags checks if the tags contain only valid characters
Types ¶
type DHCPConf ¶
type DHCPConf struct { ValidVlans []*ufspb.Vlan ValidIPs []*ufspb.IP ValidDHCPs []*ufspb.DHCPConfig DHCPsWithoutVlan []*ufspb.DHCPConfig MismatchedVlans []*ufspb.Vlan DuplicatedVlans []*ufspb.Vlan DuplicatedIPs []*ufspb.IP }
DHCPConf defines the format of response after parsing a ChromeOS dhcp conf file
type Key ¶
type Key string
Key is a type for use in adding values to context. It is not recommended to use plain string as key.
type PSRequest ¶
type PSRequest struct { Msg struct { Data string `json:"data"` MessageID string `json:"messageId"` } `json:"message"` Sub string `json:"subscription"` }
PSRequest helps to unmarshall json data sent from pubsub
The format of the data sent by PubSub is described in https://cloud.google.com/pubsub/docs/push?hl=en#receiving_push_messages
func NewPSRequest ¶
NewPSRequest returns a PSRequest object constructed from http request
func (*PSRequest) DecodeMessage ¶
DecodeMessage decodes []byte pertaining to the request