controller

package
v0.0.0-...-e560ebb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LifeCycleRegistration indicates the registration of a resource.
	LifeCycleRegistration = "REGISTRATION"

	// LifeCycleDeployment indicates the deployment of a device.
	LifeCycleDeployment = "DEPLOYMENT"

	// LifeCycleDecomm indicates the decommission of a device.
	LifeCycleDecomm = "DECOMMISSION"

	// LifeCycleRetire indicates the retirement of a device.
	LifeCycleRetire = "RETIREMENT"

	// LifeCycleRename indicates the renaming of a device.
	LifeCycleRename = "RENAME"
)
View Source
const (
	CannotCreate string = "Cannot create"
)

error msgs used for testing

Variables

View Source
var (
	NotFoundErrorMessage      string = "There is no %s with %sID %s in the system.\n"
	AlreadyExistsErrorMessage string = "%s %s already exists in the system.\n"
)

Generalized error messages for resources in the system

Functions

func AssetRegistration

func AssetRegistration(ctx context.Context, asset *ufspb.Asset) (*ufspb.Asset, error)

AssetRegistration registers the given asset to the datastore after validation

func BatchGetChromePlatforms

func BatchGetChromePlatforms(ctx context.Context, ids []string) ([]*ufspb.ChromePlatform, error)

BatchGetChromePlatforms returns a batch of chrome platforms from datastore.

func BatchGetDhcpConfigs

func BatchGetDhcpConfigs(ctx context.Context, hostnames []string) ([]*ufspb.DHCPConfig, error)

BatchGetDhcpConfigs returns a batch of dhcp records

func BatchGetDracs

func BatchGetDracs(ctx context.Context, ids []string) ([]*ufspb.Drac, error)

BatchGetDracs returns a batch of dracs from datastore.

func BatchGetKVMs

func BatchGetKVMs(ctx context.Context, ids []string) ([]*ufspb.KVM, error)

BatchGetKVMs returns a batch of kvms based on ids.

func BatchGetMachineLSEDeployments

func BatchGetMachineLSEDeployments(ctx context.Context, ids []string) ([]*ufspb.MachineLSEDeployment, error)

BatchGetMachineLSEDeployments returns a batch of deployment records.

func BatchGetMachineLSEPrototypes

func BatchGetMachineLSEPrototypes(ctx context.Context, ids []string) ([]*ufspb.MachineLSEPrototype, error)

BatchGetMachineLSEPrototypes returns a batch of machine lse prototypes from datastore.

func BatchGetMachineLSEs

func BatchGetMachineLSEs(ctx context.Context, ids []string) ([]*ufspb.MachineLSE, error)

BatchGetMachineLSEs returns a batch of machine lses

func BatchGetMachines

func BatchGetMachines(ctx context.Context, ids []string) ([]*ufspb.Machine, error)

BatchGetMachines returns a batch of machines from datastore.

func BatchGetNics

func BatchGetNics(ctx context.Context, ids []string) ([]*ufspb.Nic, error)

BatchGetNics returns a batch of nics from datastore.

func BatchGetRPMs

func BatchGetRPMs(ctx context.Context, ids []string) ([]*ufspb.RPM, error)

BatchGetRPMs returns a batch of rpms from datastore.

func BatchGetRackLSEPrototypes

func BatchGetRackLSEPrototypes(ctx context.Context, ids []string) ([]*ufspb.RackLSEPrototype, error)

BatchGetRackLSEPrototypes returns a batch of rack lse prototypes from datastore.

func BatchGetRacks

func BatchGetRacks(ctx context.Context, ids []string) ([]*ufspb.Rack, error)

BatchGetRacks returns a batch of racks from datastore.

func BatchGetSwitches

func BatchGetSwitches(ctx context.Context, ids []string) ([]*ufspb.Switch, error)

BatchGetSwitches returns a batch of switches from datastore.

func BatchGetVMs

func BatchGetVMs(ctx context.Context, ids []string) ([]*ufspb.VM, error)

BatchGetVMs returns a batch of vms from datastore.

func BatchGetVlans

func BatchGetVlans(ctx context.Context, ids []string) ([]*ufspb.Vlan, error)

BatchGetVlans returns a batch of vlans from datastore.

func CreateCachingService

func CreateCachingService(ctx context.Context, cs *ufspb.CachingService) (*ufspb.CachingService, error)

CreateCachingService creates a new CachingService in datastore.

func CreateChromePlatform

func CreateChromePlatform(ctx context.Context, chromeplatform *ufspb.ChromePlatform) (*ufspb.ChromePlatform, error)

CreateChromePlatform creates a new chromeplatform in datastore.

func CreateDUT

func CreateDUT(ctx context.Context, machinelse *ufspb.MachineLSE) (*ufspb.MachineLSE, error)

CreateDUT creates ChromeOSMachineLSE entities for a DUT.

Creates one MachineLSE for DUT and updates another MachineLSE for the Labstation(with new Servo info from DUT)

func CreateDrac

func CreateDrac(ctx context.Context, drac *ufspb.Drac) (*ufspb.Drac, error)

CreateDrac creates a new drac in datastore.

Checks if the resources referenced by the Drac input already exists in the system before creating a new Drac

func CreateKVM

func CreateKVM(ctx context.Context, kvm *ufspb.KVM) (*ufspb.KVM, error)

CreateKVM creates a new kvm in datastore.

func CreateLabstation

func CreateLabstation(ctx context.Context, lse *ufspb.MachineLSE) (*ufspb.MachineLSE, error)

CreateLabstation creates a new labstation entry in UFS.

func CreateMachineFromAsset

func CreateMachineFromAsset(asset *ufspb.Asset) *ufspb.Machine

CreateMachineFromAsset creates machine from asset

If the asset is either a DUT or Labstation, machine is returned, nil otherwise.

func CreateMachineLSE

func CreateMachineLSE(ctx context.Context, machinelse *ufspb.MachineLSE, nwOpt *ufsAPI.NetworkOption) (*ufspb.MachineLSE, error)

CreateMachineLSE creates a new machinelse in datastore.

func CreateMachineLSEPrototype

func CreateMachineLSEPrototype(ctx context.Context, machinelseprototype *ufspb.MachineLSEPrototype) (*ufspb.MachineLSEPrototype, error)

CreateMachineLSEPrototype creates a new machinelseprototype in datastore.

func CreateNic

func CreateNic(ctx context.Context, nic *ufspb.Nic) (*ufspb.Nic, error)

CreateNic creates a new nic in datastore.

Checks if the resources referenced by the Nic input already exists in the system before creating a new Nic

func CreateRPM

func CreateRPM(ctx context.Context, rpm *ufspb.RPM) (*ufspb.RPM, error)

CreateRPM creates a new rpm in datastore.

func CreateRackLSE

func CreateRackLSE(ctx context.Context, racklse *ufspb.RackLSE) (*ufspb.RackLSE, error)

CreateRackLSE creates a new racklse in datastore.

Checks if the resources referenced by the RackLSE input already exists in the system before creating a new RackLSE

func CreateRackLSEPrototype

func CreateRackLSEPrototype(ctx context.Context, racklseprototype *ufspb.RackLSEPrototype) (*ufspb.RackLSEPrototype, error)

CreateRackLSEPrototype creates a new racklseprototype in datastore.

func CreateSchedulingUnit

func CreateSchedulingUnit(ctx context.Context, su *ufspb.SchedulingUnit) (*ufspb.SchedulingUnit, error)

CreateSchedulingUnit creates a new SchedulingUnit in datastore.

func CreateSwitch

func CreateSwitch(ctx context.Context, s *ufspb.Switch) (*ufspb.Switch, error)

CreateSwitch creates switch in datastore.

func CreateVM

func CreateVM(ctx context.Context, vm *ufspb.VM, nwOpt *ufsAPI.NetworkOption) (*ufspb.VM, error)

CreateVM creates a new vm in datastore.

func CreateVlan

func CreateVlan(ctx context.Context, vlan *ufspb.Vlan) (*ufspb.Vlan, error)

CreateVlan creates a new vlan in datastore.

func DeleteAsset

func DeleteAsset(ctx context.Context, name string) error

DeleteAsset deletes an asset from UFS

func DeleteCachingService

func DeleteCachingService(ctx context.Context, id string) error

DeleteCachingService deletes the given CachingService in datastore.

func DeleteChromePlatform

func DeleteChromePlatform(ctx context.Context, id string) error

DeleteChromePlatform deletes the chromeplatform in datastore

For referential data intergrity, Delete if this ChromePlatform is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteDrac

func DeleteDrac(ctx context.Context, id string) error

DeleteDrac deletes the drac in datastore

func DeleteDracHost

func DeleteDracHost(ctx context.Context, dracName string) error

DeleteDracHost deletes the host of a drac in datastore.

func DeleteKVM

func DeleteKVM(ctx context.Context, id string) error

DeleteKVM deletes the kvm in datastore

func DeleteKVMHost

func DeleteKVMHost(ctx context.Context, kvmName string) error

DeleteKVMHost deletes the host of a kvm in datastore.

func DeleteMachine

func DeleteMachine(ctx context.Context, id string) error

DeleteMachine deletes the machine and its associated nics and drac in datastore

For referential data intergrity, Delete if this Machine is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteMachineLSE

func DeleteMachineLSE(ctx context.Context, id string) error

DeleteMachineLSE deletes the machinelse in datastore

For referential data intergrity, Delete if this MachineLSE is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteMachineLSEHost

func DeleteMachineLSEHost(ctx context.Context, machinelseName string) error

DeleteMachineLSEHost deletes the dhcp/ip of a machinelse in datastore.

func DeleteMachineLSEPrototype

func DeleteMachineLSEPrototype(ctx context.Context, id string) error

DeleteMachineLSEPrototype deletes the machinelseprototype in datastore

For referential data intergrity, Delete if this MachineLSEPrototype is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteNic

func DeleteNic(ctx context.Context, id string) error

DeleteNic deletes the nic in datastore

func DeleteRPM

func DeleteRPM(ctx context.Context, id string) error

DeleteRPM deletes the rpm in datastore

For referential data intergrity, Delete if this RPM is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteRPMHost

func DeleteRPMHost(ctx context.Context, rpmName string) error

DeleteRPMHost deletes the host of a rpm in datastore.

func DeleteRack

func DeleteRack(ctx context.Context, id string) error

DeleteRack deletes the rack in datastore

For referential data intergrity, Delete if this Rack is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteRackLSE

func DeleteRackLSE(ctx context.Context, id string) error

DeleteRackLSE deletes the racklse in datastore

For referential data intergrity, Delete if this RackLSE is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteRackLSEPrototype

func DeleteRackLSEPrototype(ctx context.Context, id string) error

DeleteRackLSEPrototype deletes the racklseprototype in datastore

For referential data intergrity, Delete if this RackLSEPrototype is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func DeleteSchedulingUnit

func DeleteSchedulingUnit(ctx context.Context, id string) error

DeleteSchedulingUnit deletes the given SchedulingUnit in datastore.

func DeleteSwitch

func DeleteSwitch(ctx context.Context, id string) error

DeleteSwitch deletes the switch in datastore

For referential data intergrity, 1. Validate if this switch is not referenced by other resources in the datastore. 2. Delete the switch 3. Get the rack associated with this switch 4. Update the rack by removing the association with this switch

func DeleteVM

func DeleteVM(ctx context.Context, id string) error

DeleteVM deletes a vm in datastore.

func DeleteVMHost

func DeleteVMHost(ctx context.Context, vmName string) error

DeleteVMHost deletes the dhcp/ip of a vm in datastore.

func DeleteVlan

func DeleteVlan(ctx context.Context, id string) error

DeleteVlan deletes the vlan in datastore

For referential data intergrity, Delete if this Vlan is not referenced by other resources in the datastore. If there are any references, delete will be rejected and an error will be returned.

func GetAllMachines

func GetAllMachines(ctx context.Context) (*ufsds.OpResults, error)

GetAllMachines returns all machines in datastore.

func GetAsset

func GetAsset(ctx context.Context, name string) (*ufspb.Asset, error)

GetAsset returns asset for the given name from datastore

func GetCachingService

func GetCachingService(ctx context.Context, id string) (*ufspb.CachingService, error)

GetCachingService returns CachingService for the given id from datastore.

func GetChromeOSDeviceData

func GetChromeOSDeviceData(ctx context.Context, id, hostname string) (*ufspb.ChromeOSDeviceData, error)

GetChromeOSDeviceData returns ChromeOSDeviceData for the given id/hostname from InvV2 and UFS.

func GetChromePlatform

func GetChromePlatform(ctx context.Context, id string) (*ufspb.ChromePlatform, error)

GetChromePlatform returns chromeplatform for the given id from datastore.

func GetDHCPConfig

func GetDHCPConfig(ctx context.Context, hostname string) (*ufspb.DHCPConfig, error)

GetDHCPConfig returns a dhcp reecord based on hostname from datastore.

func GetDUTConnectedToServo

func GetDUTConnectedToServo(ctx context.Context, servo *chromeosLab.Servo) (*ufspb.MachineLSE, error)

GetDUTConnectedToServo returns machineLSE of DUT connected to the servo

func GetDrac

func GetDrac(ctx context.Context, id string) (*ufspb.Drac, error)

GetDrac returns drac for the given id from datastore.

func GetDutState

func GetDutState(ctx context.Context, id, hostname string) (*chromeosLab.DutState, error)

GetDutState returns the DutState for the ChromeOS device.

func GetKVM

func GetKVM(ctx context.Context, id string) (*ufspb.KVM, error)

GetKVM returns kvm for the given id from datastore.

func GetMachine

func GetMachine(ctx context.Context, id string) (*ufspb.Machine, error)

GetMachine returns machine for the given id from datastore.

func GetMachineLSE

func GetMachineLSE(ctx context.Context, id string) (*ufspb.MachineLSE, error)

GetMachineLSE returns machinelse for the given id from datastore.

func GetMachineLSEDeployment

func GetMachineLSEDeployment(ctx context.Context, id string) (*ufspb.MachineLSEDeployment, error)

GetMachineLSEDeployment returns the deployment record for the given id.

func GetMachineLSEPrototype

func GetMachineLSEPrototype(ctx context.Context, id string) (*ufspb.MachineLSEPrototype, error)

GetMachineLSEPrototype returns machinelseprototype for the given id from datastore.

func GetNic

func GetNic(ctx context.Context, id string) (*ufspb.Nic, error)

GetNic returns nic for the given id from datastore.

func GetRPM

func GetRPM(ctx context.Context, id string) (*ufspb.RPM, error)

GetRPM returns rpm for the given id from datastore.

func GetRack

func GetRack(ctx context.Context, id string) (*ufspb.Rack, error)

GetRack returns rack for the given id from datastore.

func GetRackLSE

func GetRackLSE(ctx context.Context, id string) (*ufspb.RackLSE, error)

GetRackLSE returns racklse for the given id from datastore.

func GetRackLSEPrototype

func GetRackLSEPrototype(ctx context.Context, id string) (*ufspb.RackLSEPrototype, error)

GetRackLSEPrototype returns racklseprototype for the given id from datastore.

func GetSchedulingUnit

func GetSchedulingUnit(ctx context.Context, id string) (*ufspb.SchedulingUnit, error)

GetSchedulingUnit returns SchedulingUnit for the given id from datastore.

func GetState

func GetState(ctx context.Context, resourceName string) (*ufspb.StateRecord, error)

GetState returns state record for a resource.

func GetSwitch

func GetSwitch(ctx context.Context, id string) (*ufspb.Switch, error)

GetSwitch returns switch for the given id from datastore.

func GetVM

func GetVM(ctx context.Context, id string) (*ufspb.VM, error)

GetVM returns vm for the given id from datastore.

func GetVlan

func GetVlan(ctx context.Context, id string) (*ufspb.Vlan, error)

GetVlan returns vlan for the given id from datastore.

func ImportChromePlatforms

func ImportChromePlatforms(ctx context.Context, platforms []*ufspb.ChromePlatform, pageSize int) (*ufsds.OpResults, error)

ImportChromePlatforms inserts chrome platforms to datastore.

func ImportDatacenter

func ImportDatacenter(ctx context.Context, dcs []*crimsonconfig.Datacenter, pageSize int) (*datastore.OpResults, error)

ImportDatacenter imports the datacenters and the related resources.

The function will return:

  • all of the results of the operations that already run
  • the first error that it meets

The function will stop at the very first error.

func ImportDracs

func ImportDracs(ctx context.Context, dracs []*ufspb.Drac) (*ufsds.OpResults, error)

ImportDracs creates or updates a batch of dracs in datastore

func ImportMachineLSEs

func ImportMachineLSEs(ctx context.Context, hosts []*crimson.PhysicalHost, vms []*crimson.VM, machines []*crimson.Machine, platforms []*crimson.Platform, pageSize int) (*ufsds.OpResults, error)

ImportMachineLSEs implements the logic of importing machine lses and related info to backend storage.

The function will return:

  • all of the results of the operations that already run
  • the first error that it meets

The function will stop at the very first error.

func ImportMachines

func ImportMachines(ctx context.Context, machines []*ufspb.Machine, pageSize int) (*ufsds.OpResults, error)

ImportMachines creates or updates a batch of machines in datastore

func ImportNetworkInterfaces

func ImportNetworkInterfaces(ctx context.Context, nics []*crimson.NIC, dracs []*crimson.DRAC, machines []*crimson.Machine, pageSize int) (*ufsds.OpResults, error)

ImportNetworkInterfaces creates or updates a batch of nics, dracs, and dhcps in datastore

func ImportOSMachineLSEs

func ImportOSMachineLSEs(ctx context.Context, labConfigs []*invV2Api.ListCrosDevicesLabConfigResponse_LabConfig, pageSize int) (*ufsds.OpResults, error)

ImportOSMachineLSEs implements the logic of importing ChromeOS machine lses and related info to backend storage.

The function will return:

  • all of the results of the operations that already run
  • the first error that it meets

The function will stop at the very first error.

func ImportOSVlans

func ImportOSVlans(ctx context.Context, sheetClient sheet.ClientInterface, gitClient git.ClientInterface, pageSize int) (*ufsds.OpResults, error)

ImportOSVlans imports the logic of parse and save network infos.

func ImportOSes

func ImportOSes(ctx context.Context, oses []*ufspb.OSVersion, pageSize int) (*ufsds.OpResults, error)

ImportOSes inserts chrome os_version to datastore.

func ImportStates

func ImportStates(ctx context.Context, machines []*crimson.Machine, racks []*crimson.Rack, hosts []*crimson.PhysicalHost, vms []*crimson.VM, vlans []*crimson.VLAN, kvms []*crimson.KVM, switches []*crimson.Switch, pageSize int) (*ufsds.OpResults, error)

ImportStates imports states of UFS resources.

func ImportVlans

func ImportVlans(ctx context.Context, vlans []*crimsonconfig.VLAN, pageSize int) (*ufsds.OpResults, error)

ImportVlans implements the logic of importing vlans and related info to backend storage.

The function will return:

  • all of the results of the operations that already run
  • the first error that it meets

The function will stop at the very first error.

func ListAssets

func ListAssets(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.Asset, string, error)

ListAssets lists the assets

func ListCachingServices

func ListCachingServices(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.CachingService, string, error)

ListCachingServices lists the CachingServices in datastore.

func ListChromePlatforms

func ListChromePlatforms(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.ChromePlatform, string, error)

ListChromePlatforms lists the chromeplatforms

func ListDracs

func ListDracs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.Drac, string, error)

ListDracs lists the dracs

func ListDutStates

func ListDutStates(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*chromeosLab.DutState, string, error)

ListDutStates lists the DutStates in datastore.

func ListKVMs

func ListKVMs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.KVM, string, error)

ListKVMs lists the kvms

func ListMachineLSEDeployments

func ListMachineLSEDeployments(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.MachineLSEDeployment, string, error)

ListMachineLSEDeployments returns a batch of deployment records by filters

func ListMachineLSEPrototypes

func ListMachineLSEPrototypes(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.MachineLSEPrototype, string, error)

ListMachineLSEPrototypes lists the machinelseprototypes

func ListMachineLSEs

func ListMachineLSEs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly, full bool) ([]*ufspb.MachineLSE, string, error)

ListMachineLSEs lists the machinelses

func ListMachines

func ListMachines(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly, full bool) ([]*ufspb.Machine, string, error)

ListMachines lists the machines

func ListNics

func ListNics(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.Nic, string, error)

ListNics lists the nics

func ListOSes

func ListOSes(ctx context.Context, pageSize int32, pageToken string, filter string, keysOnly bool) ([]*ufspb.OSVersion, string, error)

ListOSes lists the chrome os_version

func ListRPMs

func ListRPMs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.RPM, string, error)

ListRPMs lists the rpms

func ListRackLSEPrototypes

func ListRackLSEPrototypes(ctx context.Context, pageSize int32, pageToken string, filter string, keysOnly bool) ([]*ufspb.RackLSEPrototype, string, error)

ListRackLSEPrototypes lists the racklseprototypes

func ListRackLSEs

func ListRackLSEs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.RackLSE, string, error)

ListRackLSEs lists the racklses

func ListRacks

func ListRacks(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly, full bool) ([]*ufspb.Rack, string, error)

ListRacks lists the racks

func ListSchedulingUnits

func ListSchedulingUnits(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.SchedulingUnit, string, error)

ListSchedulingUnits lists the SchedulingUnits in datastore.

func ListSwitches

func ListSwitches(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.Switch, string, error)

ListSwitches lists the switches

func ListVMs

func ListVMs(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.VM, string, error)

ListVMs lists the vms

func ListVlans

func ListVlans(ctx context.Context, pageSize int32, pageToken, filter string, keysOnly bool) ([]*ufspb.Vlan, string, error)

ListVlans lists the vlans

func LogDHCPChanges

func LogDHCPChanges(oldData, newData *ufspb.DHCPConfig) ([]*ufspb.ChangeEvent, *history.SnapshotMsgEntity)

LogDHCPChanges logs the change of the given dhcp.

func LogIPChanges

func LogIPChanges(oldData, newData *ufspb.IP) []*ufspb.ChangeEvent

LogIPChanges logs the change of the given ip.

func LogStateChanges

func LogStateChanges(oldData, newData *ufspb.StateRecord) ([]*ufspb.ChangeEvent, *history.SnapshotMsgEntity)

LogStateChanges logs the change of the given state record.

func MachineRegistration

func MachineRegistration(ctx context.Context, machine *ufspb.Machine) (*ufspb.Machine, error)

MachineRegistration creates a new machine, new nic and a new drac in datastore.

func RackRegistration

func RackRegistration(ctx context.Context, rack *ufspb.Rack) (*ufspb.Rack, error)

RackRegistration creates a new rack, switches, kvms and rpms in datastore.

func RenameAsset

func RenameAsset(ctx context.Context, oldName, newName string) (res *ufspb.Asset, err error)

RenameAsset renames a given asset (and corresponding machine if available) with new name.

func RenameMachine

func RenameMachine(ctx context.Context, oldMachineName, newMachineName string) (machine *ufspb.Machine, err error)

RenameMachine renames the machine and updates the associated nics, drac and machinelse in datastore

func RenameMachineLSE

func RenameMachineLSE(ctx context.Context, oldName, newName string) (*ufspb.MachineLSE, error)

RenameMachineLSE renames the machineLSE to the new hostname.

func RenameNic

func RenameNic(ctx context.Context, oldNicName, newNicName string) (*ufspb.Nic, error)

RenameNic renames the nic and updates the associated machinelse in datastore

func RenameSwitch

func RenameSwitch(ctx context.Context, oldSwitchName, newSwitchName string) (*ufspb.Switch, error)

RenameSwitch renames the switch and updates the associated machinelse in datastore

func ReplaceChromePlatform

func ReplaceChromePlatform(ctx context.Context, oldChromePlatform *ufspb.ChromePlatform, newChromePlatform *ufspb.ChromePlatform) (*ufspb.ChromePlatform, error)

ReplaceChromePlatform replaces an old ChromePlatform with new ChromePlatform in datastore

It does a delete of old chromeplatform and create of new ChromePlatform. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old ChromePlatform, it will get all the resources referencing the old ChromePlatform. It will update all the resources which were referencing the old ChromePlatform(got in the last step) with new ChromePlatform. Deletes the old ChromePlatform. Creates the new ChromePlatform. This will preserve data integrity in the system.

func ReplaceDrac

func ReplaceDrac(ctx context.Context, oldDrac *ufspb.Drac, newDrac *ufspb.Drac) (*ufspb.Drac, error)

ReplaceDrac replaces an old Drac with new Drac in datastore

It does a delete of old drac and create of new Drac. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Drac, it will get all the resources referencing the old Drac. It will update all the resources which were referencing the old Drac(got in the last step) with new Drac. Deletes the old Drac. Creates the new Drac. This will preserve data integrity in the system.

func ReplaceKVM

func ReplaceKVM(ctx context.Context, oldKVM *ufspb.KVM, newKVM *ufspb.KVM) (*ufspb.KVM, error)

ReplaceKVM replaces an old KVM with new KVM in datastore

It does a delete of old kvm and create of new KVM. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old KVM, it will get all the resources referencing the old KVM. It will update all the resources which were referencing the old KVM(got in the last step) with new KVM. Deletes the old KVM. Creates the new KVM. This will preserve data integrity in the system.

func ReplaceMachine

func ReplaceMachine(ctx context.Context, oldMachine *ufspb.Machine, newMachine *ufspb.Machine) (*ufspb.Machine, error)

ReplaceMachine replaces an old Machine with new Machine in datastore

It does a delete of old machine and create of new Machine. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Machine, it will get all the resources referencing the old Machine. It will update all the resources which were referencing the old Machine(got in the last step) with new Machine. Deletes the old Machine. Creates the new Machine. This will preserve data integrity in the system.

func ReplaceMachineLSEPrototype

func ReplaceMachineLSEPrototype(ctx context.Context, oldMachineLSEPrototype *ufspb.MachineLSEPrototype, newMachineLSEPrototype *ufspb.MachineLSEPrototype) (*ufspb.MachineLSEPrototype, error)

ReplaceMachineLSEPrototype replaces an old MachineLSEPrototype with new MachineLSEPrototype in datastore

It does a delete of old machinelseprototype and create of new MachineLSEPrototype. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old MachineLSEPrototype, it will get all the resources referencing the old MachineLSEPrototype. It will update all the resources which were referencing the old MachineLSEPrototype(got in the last step) with new MachineLSEPrototype. Deletes the old MachineLSEPrototype. Creates the new MachineLSEPrototype. This will preserve data integrity in the system.

func ReplaceNic

func ReplaceNic(ctx context.Context, oldNic *ufspb.Nic, newNic *ufspb.Nic) (*ufspb.Nic, error)

ReplaceNic replaces an old Nic with new Nic in datastore

It does a delete of old nic and create of new Nic. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Nic, it will get all the resources referencing the old Nic. It will update all the resources which were referencing the old Nic(got in the last step) with new Nic. Deletes the old Nic. Creates the new Nic. This will preserve data integrity in the system.

func ReplaceRPM

func ReplaceRPM(ctx context.Context, oldRPM *ufspb.RPM, newRPM *ufspb.RPM) (*ufspb.RPM, error)

ReplaceRPM replaces an old RPM with new RPM in datastore

It does a delete of old rpm and create of new RPM. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old RPM, it will get all the resources referencing the old RPM. It will update all the resources which were referencing the old RPM(got in the last step) with new RPM. Deletes the old RPM. Creates the new RPM. This will preserve data integrity in the system.

func ReplaceRack

func ReplaceRack(ctx context.Context, oldRack *ufspb.Rack, newRack *ufspb.Rack) (*ufspb.Rack, error)

ReplaceRack replaces an old Rack with new Rack in datastore

It does a delete of old rack and create of new Rack. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Rack, it will get all the resources referencing the old Rack. It will update all the resources which were referencing the old Rack(got in the last step) with new Rack. Deletes the old Rack. Creates the new Rack. This will preserve data integrity in the system.

func ReplaceRackLSEPrototype

func ReplaceRackLSEPrototype(ctx context.Context, oldRackLSEPrototype *ufspb.RackLSEPrototype, newRackLSEPrototype *ufspb.RackLSEPrototype) (*ufspb.RackLSEPrototype, error)

ReplaceRackLSEPrototype replaces an old RackLSEPrototype with new RackLSEPrototype in datastore

It does a delete of old racklseprototype and create of new RackLSEPrototype. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old RackLSEPrototype, it will get all the resources referencing the old RackLSEPrototype. It will update all the resources which were referencing the old RackLSEPrototype(got in the last step) with new RackLSEPrototype. Deletes the old RackLSEPrototype. Creates the new RackLSEPrototype. This will preserve data integrity in the system.

func ReplaceSwitch

func ReplaceSwitch(ctx context.Context, oldSwitch *ufspb.Switch, newSwitch *ufspb.Switch) (*ufspb.Switch, error)

ReplaceSwitch replaces an old Switch with new Switch in datastore

It does a delete of old switch and create of new Switch. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Switch, it will get all the resources referencing the old Switch. It will update all the resources which were referencing the old Switch(got in the last step) with new Switch. Deletes the old Switch. Creates the new Switch. This will preserve data integrity in the system.

func ReplaceVlan

func ReplaceVlan(ctx context.Context, oldVlan *ufspb.Vlan, newVlan *ufspb.Vlan) (*ufspb.Vlan, error)

ReplaceVlan replaces an old Vlan with new Vlan in datastore

It does a delete of old vlan and create of new Vlan. All the steps are in done in a transaction to preserve consistency on failure. Before deleting the old Vlan, it will get all the resources referencing the old Vlan. It will update all the resources which were referencing the old Vlan(got in the last step) with new Vlan. Deletes the old Vlan. Creates the new Vlan. This will preserve data integrity in the system.

func ResourceExist

func ResourceExist(ctx context.Context, resources []*Resource, errorMsg *strings.Builder) error

ResourceExist checks if the given resources exists in the datastore

Returns error if any one resource does not exist in the system. Appends error messages to the the given error message for resources that does not exist in the datastore.

func UpdateAsset

func UpdateAsset(ctx context.Context, asset *ufspb.Asset, mask *field_mask.FieldMask) (*ufspb.Asset, error)

UpdateAsset updates the asset record to the datastore after validation

func UpdateAssetMeta

func UpdateAssetMeta(ctx context.Context, meta *ufspb.DutMeta) error

UpdateAssetMeta updates only dut meta data portion of the Asset.

It's a temporary method to correct Serial number, HWID and Sku. Will remove once HaRT could provide us the correct info.

func UpdateCachingService

func UpdateCachingService(ctx context.Context, cs *ufspb.CachingService, mask *field_mask.FieldMask) (*ufspb.CachingService, error)

UpdateCachingService updates existing CachingService in datastore.

func UpdateChromePlatform

func UpdateChromePlatform(ctx context.Context, chromeplatform *ufspb.ChromePlatform, mask *field_mask.FieldMask) (*ufspb.ChromePlatform, error)

UpdateChromePlatform updates chromeplatform in datastore.

func UpdateConfigBundle

func UpdateConfigBundle(ctx context.Context, cb []byte, mask *field_mask.FieldMask, allowMissing bool) ([]byte, error)

UpdateConfigBundle updates ConfigBundle in datastore.

func UpdateDUT

func UpdateDUT(ctx context.Context, machinelse *ufspb.MachineLSE, mask *field_mask.FieldMask) (*ufspb.MachineLSE, error)

UpdateDUT updates a chrome OS DUT.

updates one MachineLSE for DUT and updates Labstation MachineLSE (with new Servo info from DUT). If DUT is connected to the same Labstation but different port, The servo entry in Labstation is updated. If DUT is connected to a different labstation, then old servo info of DUT is removed from old Labstation and new servo info from the DUT is added to the new labstation.

func UpdateDrac

func UpdateDrac(ctx context.Context, drac *ufspb.Drac, mask *field_mask.FieldMask) (*ufspb.Drac, error)

UpdateDrac updates drac in datastore.

Checks if the resources referenced by the Drac input already exists in the system before updating a Drac

func UpdateDracHost

func UpdateDracHost(ctx context.Context, drac *ufspb.Drac, nwOpt *ufsAPI.NetworkOption) error

UpdateDracHost updates the drac host in datastore.

func UpdateDutMeta

func UpdateDutMeta(ctx context.Context, meta *ufspb.DutMeta) error

UpdateDutMeta updates only duta meta data for a given ChromeOS DUT.

It's a temporary method to correct serial number & HWID. Will remove once HaRT could provide us the correct info.

func UpdateDutState

func UpdateDutState(ctx context.Context, ds *chromeosLab.DutState) (*chromeosLab.DutState, error)

UpdateDutState updates the dut state for a ChromeOS DUT

func UpdateKVM

func UpdateKVM(ctx context.Context, kvm *ufspb.KVM, mask *field_mask.FieldMask) (*ufspb.KVM, error)

UpdateKVM updates kvm in datastore.

func UpdateKVMHost

func UpdateKVMHost(ctx context.Context, kvm *ufspb.KVM, nwOpt *ufsAPI.NetworkOption) error

UpdateKVMHost updates the kvm host in datastore.

func UpdateLabMeta

func UpdateLabMeta(ctx context.Context, meta *ufspb.LabMeta) error

UpdateLabMeta updates only lab meta data for a given ChromeOS DUT.

func UpdateLabstation

func UpdateLabstation(ctx context.Context, machinelse *ufspb.MachineLSE, mask *field_mask.FieldMask) (*ufspb.MachineLSE, error)

UpdateLabstation validates and updates the given labstation machine LSE.

func UpdateMachine

func UpdateMachine(ctx context.Context, machine *ufspb.Machine, mask *field_mask.FieldMask) (*ufspb.Machine, error)

UpdateMachine updates machine in datastore.

Checks if the resources referenced by the Machine input already exists in the system before updating a Machine

func UpdateMachineLSE

func UpdateMachineLSE(ctx context.Context, machinelse *ufspb.MachineLSE, mask *field_mask.FieldMask) (*ufspb.MachineLSE, error)

UpdateMachineLSE updates machinelse in datastore.

func UpdateMachineLSEDeployment

func UpdateMachineLSEDeployment(ctx context.Context, dr *ufspb.MachineLSEDeployment, mask *field_mask.FieldMask) (*ufspb.MachineLSEDeployment, error)

UpdateMachineLSEDeployment updates a machine lse deployment to datastore

func UpdateMachineLSEHost

func UpdateMachineLSEHost(ctx context.Context, machinelseName string, nwOpt *ufsAPI.NetworkOption) (*ufspb.MachineLSE, error)

UpdateMachineLSEHost updates the machinelse host(update ip assignment).

func UpdateMachineLSEPrototype

func UpdateMachineLSEPrototype(ctx context.Context, machinelseprototype *ufspb.MachineLSEPrototype) (*ufspb.MachineLSEPrototype, error)

UpdateMachineLSEPrototype updates machinelseprototype in datastore.

func UpdateNic

func UpdateNic(ctx context.Context, nic *ufspb.Nic, mask *field_mask.FieldMask) (*ufspb.Nic, error)

UpdateNic updates nic in datastore.

Checks if the resources referenced by the Nic input already exists in the system before updating a Nic

func UpdateRPM

func UpdateRPM(ctx context.Context, rpm *ufspb.RPM, mask *field_mask.FieldMask) (*ufspb.RPM, error)

UpdateRPM updates rpm in datastore.

func UpdateRPMHost

func UpdateRPMHost(ctx context.Context, rpm *ufspb.RPM, nwOpt *ufsAPI.NetworkOption) error

UpdateRPMHost updates the rpm host in datastore.

func UpdateRack

func UpdateRack(ctx context.Context, rack *ufspb.Rack, mask *field_mask.FieldMask) (*ufspb.Rack, error)

UpdateRack updates rack in datastore.

func UpdateRackLSE

func UpdateRackLSE(ctx context.Context, racklse *ufspb.RackLSE) (*ufspb.RackLSE, error)

UpdateRackLSE updates racklse in datastore.

Checks if the resources referenced by the RackLSE input already exists in the system before updating a RackLSE

func UpdateRackLSEPrototype

func UpdateRackLSEPrototype(ctx context.Context, racklseprototype *ufspb.RackLSEPrototype) (*ufspb.RackLSEPrototype, error)

UpdateRackLSEPrototype updates racklseprototype in datastore.

func UpdateSchedulingUnit

func UpdateSchedulingUnit(ctx context.Context, su *ufspb.SchedulingUnit, mask *field_mask.FieldMask) (*ufspb.SchedulingUnit, error)

UpdateSchedulingUnit updates existing SchedulingUnit in datastore.

func UpdateState

func UpdateState(ctx context.Context, stateRecord *ufspb.StateRecord) (*ufspb.StateRecord, error)

UpdateState updates state record for a resource.

func UpdateSwitch

func UpdateSwitch(ctx context.Context, s *ufspb.Switch, mask *field_mask.FieldMask) (*ufspb.Switch, error)

UpdateSwitch updates switch in datastore.

func UpdateVM

func UpdateVM(ctx context.Context, vm *ufspb.VM, mask *field_mask.FieldMask) (*ufspb.VM, error)

UpdateVM updates an existing vm in datastore.

func UpdateVMHost

func UpdateVMHost(ctx context.Context, vmName string, nwOpt *ufsAPI.NetworkOption) (*ufspb.VM, error)

UpdateVMHost updates the vm host(update ip assignment).

func UpdateVlan

func UpdateVlan(ctx context.Context, vlan *ufspb.Vlan, mask *field_mask.FieldMask) (*ufspb.Vlan, error)

UpdateVlan updates vlan in datastore.

Types

type HWIDClient

type HWIDClient struct {
	// contains filtered or unexported fields
}

func InitHWIDClient

func InitHWIDClient(ctx context.Context) (*HWIDClient, error)

func (*HWIDClient) QueryHWID

func (c *HWIDClient) QueryHWID(ctx context.Context, hwid string) (*map[string]string, error)

type HistoryClient

type HistoryClient struct {
	// contains filtered or unexported fields
}

HistoryClient is a client for managing change histories

func GetMachineHistoryClient

func GetMachineHistoryClient(m *ufspb.Machine) *HistoryClient

func (*HistoryClient) LogAddMachineChanges

func (hc *HistoryClient) LogAddMachineChanges(machine *ufspb.Machine, nics []*ufspb.Nic, drac *ufspb.Drac)

LogAddMachineChanges logs the changes for adding machine

func (*HistoryClient) LogAddRackChanges

func (hc *HistoryClient) LogAddRackChanges(rack *ufspb.Rack, switches []*ufspb.Switch, kvms []*ufspb.KVM, rpms []*ufspb.RPM)

LogAddRackChanges logs the changes for adding rack

func (*HistoryClient) LogAssetChanges

func (hc *HistoryClient) LogAssetChanges(oldData, newData *ufspb.Asset)

LogAssetChanges logs the change of the given asset.

func (*HistoryClient) LogAssetInfoChanges

func (hc *HistoryClient) LogAssetInfoChanges(resName string, oldInfo, newInfo *ufspb.AssetInfo)

LogAssetInfoChanges logs the change of a give asset info

func (*HistoryClient) LogDracChanges

func (hc *HistoryClient) LogDracChanges(oldData, newData *ufspb.Drac)

LogDracChanges logs the change of the given drac.

func (*HistoryClient) LogDutStateChanges

func (hc *HistoryClient) LogDutStateChanges(oldData, newData *chromeosLab.DutState)

LogDutStateChanges logs the change of a dut state record.

func (*HistoryClient) LogKVMChanges

func (hc *HistoryClient) LogKVMChanges(oldData, newData *ufspb.KVM)

LogKVMChanges logs the change of the given kvm.

func (*HistoryClient) LogMachineChanges

func (hc *HistoryClient) LogMachineChanges(oldData *ufspb.Machine, newData *ufspb.Machine)

LogMachineChanges logs the change of the given machine.

func (*HistoryClient) LogMachineLSEChanges

func (hc *HistoryClient) LogMachineLSEChanges(oldData *ufspb.MachineLSE, newData *ufspb.MachineLSE)

LogMachineLSEChanges logs the change of the given machine lse.

func (*HistoryClient) LogMachineLSEDeploymentChanges

func (hc *HistoryClient) LogMachineLSEDeploymentChanges(oldData, newData *ufspb.MachineLSEDeployment)

LogMachineLSEDeploymentChanges logs the change of a given machine lse deployment record.

func (*HistoryClient) LogMachineLocationChanges

func (hc *HistoryClient) LogMachineLocationChanges(lses []*ufspb.MachineLSE, nics []*ufspb.Nic, dracs []*ufspb.Drac, vms []*ufspb.VM, indexMap, oldIndexMap map[string]string)

LogMachineLocationChanges logs the changes for changing locations of a machine

func (*HistoryClient) LogNicChanges

func (hc *HistoryClient) LogNicChanges(oldData, newData *ufspb.Nic)

LogNicChanges logs the change of the given nic.

func (*HistoryClient) LogRPMChanges

func (hc *HistoryClient) LogRPMChanges(oldData, newData *ufspb.RPM)

LogRPMChanges logs the change of the given rpms.

func (*HistoryClient) LogRackChanges

func (hc *HistoryClient) LogRackChanges(oldData *ufspb.Rack, newData *ufspb.Rack)

LogRackChanges logs the change of the given rack.

func (*HistoryClient) LogRackLocationChanges

func (hc *HistoryClient) LogRackLocationChanges(kvms []*ufspb.KVM, switches []*ufspb.Switch, rpms []*ufspb.RPM, indexMap, oldIndexMap map[string]string)

LogRackLocationChanges logs the changes for changing locations of a rack

func (*HistoryClient) LogSwitchChanges

func (hc *HistoryClient) LogSwitchChanges(oldData, newData *ufspb.Switch)

LogSwitchChanges logs the change of the given switch.

func (*HistoryClient) LogVLANChanges

func (hc *HistoryClient) LogVLANChanges(oldData, newData *ufspb.Vlan)

LogVLANChanges logs the change of the given vlan.

func (*HistoryClient) LogVMChanges

func (hc *HistoryClient) LogVMChanges(oldData *ufspb.VM, newData *ufspb.VM)

LogVMChanges logs the change of the given vms.

func (*HistoryClient) SaveChangeEvents

func (hc *HistoryClient) SaveChangeEvents(ctx context.Context) error

SaveChangeEvents saves change events to database

type Resource

type Resource struct {
	Kind   string
	ID     string
	Entity ufsds.FleetEntity
}

Resource contains the fleet entity to be checked and the ID and Kind

func GetAssetResource

func GetAssetResource(assetID string) *Resource

GetAssetResource returns a Resource with AssetEntity

func GetCachingServiceResource

func GetCachingServiceResource(cachingServiceID string) *Resource

GetCachingServiceResource returns a Resource with CSEntity.

func GetChromePlatformResource

func GetChromePlatformResource(chromePlatformID string) *Resource

GetChromePlatformResource returns a Resource with ChromePlatformEntity

func GetDracResource

func GetDracResource(dracID string) *Resource

GetDracResource returns a Resource with DracEntity

func GetKVMResource

func GetKVMResource(kvmID string) *Resource

GetKVMResource returns a Resource with KVMEntity

func GetMachineLSEProtoTypeResource

func GetMachineLSEProtoTypeResource(machineLSEProtoTypeID string) *Resource

GetMachineLSEProtoTypeResource returns a Resource with MachineLSEProtoTypeEntity

func GetMachineLSEResource

func GetMachineLSEResource(machinelseID string) *Resource

GetMachineLSEResource returns a Resource with MachineLSEEntity

func GetMachineResource

func GetMachineResource(machineID string) *Resource

GetMachineResource returns a Resource with MachineEntity

func GetNicResource

func GetNicResource(nicID string) *Resource

GetNicResource returns a Resource with NicEntity

func GetRPMResource

func GetRPMResource(rpmID string) *Resource

GetRPMResource returns a Resource with RPMEntity

func GetRackLSEProtoTypeResource

func GetRackLSEProtoTypeResource(rackLSEProtoTypeID string) *Resource

GetRackLSEProtoTypeResource returns a Resource with RackLSEProtoTypeEntity

func GetRackResource

func GetRackResource(rackID string) *Resource

GetRackResource returns a Resource with RackEntity

func GetSchedulingUnitResource

func GetSchedulingUnitResource(schedulingUnitID string) *Resource

GetSchedulingUnitResource returns a Resource with SchedulingUnitEntity.

func GetSwitchResource

func GetSwitchResource(switchID string) *Resource

GetSwitchResource returns a Resource with SwitchEntity

func GetVMResource

func GetVMResource(vmID string) *Resource

GetVMResource returns a Resource with VMEntity

func GetVlanResource

func GetVlanResource(vlanID string) *Resource

GetVlanResource returns a Resource with VlanEntity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL