Documentation ¶
Overview ¶
Package cimi contains the implementation of a repository using a CIMI server as backend.
See New() for usage.
Index ¶
- Constants
- type ACL
- type Agent
- type Agreement
- type Href
- type IRepository
- type Interval
- type Principal
- type Repository
- func (r Repository) CreateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r Repository) CreateProvider(provider *model.Provider) (*model.Provider, error)
- func (r Repository) CreateServiceContainerMetric(e *ServiceContainerMetric) (*ServiceContainerMetric, error)
- func (r Repository) CreateServiceInstance(si *ServiceInstance) (*ServiceInstance, error)
- func (r *Repository) CreateServiceOperationReport(e *ServiceOperationReport) (*ServiceOperationReport, error)
- func (r Repository) CreateTemplate(template *model.Template) (*model.Template, error)
- func (r Repository) CreateViolation(v *model.Violation) (*model.Violation, error)
- func (r Repository) DeleteAgreement(agreement *model.Agreement) error
- func (r Repository) DeleteProvider(provider *model.Provider) error
- func (r Repository) DeleteServiceContainerMetric(e *ServiceContainerMetric) error
- func (r Repository) DeleteServiceOperationReport(e *ServiceOperationReport) error
- func (r Repository) GetAgreement(id string) (*model.Agreement, error)
- func (r Repository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
- func (r Repository) GetAllAgreements() (model.Agreements, error)
- func (r Repository) GetAllProviders() (model.Providers, error)
- func (r Repository) GetAllTemplates() (model.Templates, error)
- func (r Repository) GetProvider(id string) (*model.Provider, error)
- func (r Repository) GetServiceContainerMetrics(device string, container string, begin time.Time, end time.Time) ([]ServiceContainerMetric, error)
- func (r Repository) GetServiceInstancesByAgreement(aID string) ([]ServiceInstance, error)
- func (r Repository) GetServiceOperationReportsByDate(serviceInstance string, from time.Time) ([]ServiceOperationReport, error)
- func (r Repository) GetTemplate(id string) (*model.Template, error)
- func (r Repository) GetViolation(id string) (*model.Violation, error)
- func (r Repository) StartAgreement(id string) error
- func (r Repository) StopAgreement(id string) error
- func (r Repository) UpdateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r Repository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)
- type Rule
- type ServiceContainerMetric
- type ServiceInstance
- type ServiceOperationReport
- type ServiceType
- type Template
- type Violation
Constants ¶
const ( // Name is the repository identifier Name = "cimi" InsecureProp = "cimiinsecure" POST = "POST" GET = "GET" PUT = "PUT" DELETE = "DELETE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶ added in v0.8.0
type Agent struct { AppType string `json:"app_type"` URL string `json:"url"` DeviceID string `json:"device_id"` Ports interface{} `json:"ports"` Status string `json:"status"` ContainerID string `json:"container_id"` Allow bool `json:"allow"` MasterCompss bool `json:"master_compss"` }
Agent represents the list of agents running a service instance
type Href ¶
type Href struct {
Href string `json:"href"`
}
Href is the entity that represents a resource link to other entity
type IRepository ¶
IRepository expose the interface to be fulfilled by implementations of CIMI repositories.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository implements the model.Repository interface for a CIMI repository.
func New ¶
func New(config *viper.Viper) (Repository, error)
New creates a Repository according to a configuration, establishing the connection to a CIMI server.
The configuration may have the following values:
- "cimiurl": URL of the CIMI server
- "cimiuser": user to connect to CIMI server. Anonymous access is used if user is "anon"
- "cimipwd": user password. Not used on anonymous access.
- "cimiinsecure": for debugging purposes only!. Do not check certificate.
- "cimifailfast": Only applicable on not anonymous access. If true, it only tries to login on New(); failing should make the program exit.
If any of these values is not provided, a default value will be used. For IT-1, the value of the password will be passed as the value of slipstream-authn-info header for requests to CIMI server.
It returns the Repository struct and an error. The possible errors: - nil if no error - config parameter is nil - could not create http client - could not connect to CIMI server - could not login to CIMI server
func (Repository) CreateAgreement ¶
CreateAgreement (see model.Repository)
func (Repository) CreateProvider ¶
CreateProvider (see model.Repository)
func (Repository) CreateServiceContainerMetric ¶ added in v0.7.2
func (r Repository) CreateServiceContainerMetric(e *ServiceContainerMetric) (*ServiceContainerMetric, error)
CreateServiceContainerMetric creates a ServiceContainerMetric
func (Repository) CreateServiceInstance ¶ added in v0.8.0
func (r Repository) CreateServiceInstance(si *ServiceInstance) (*ServiceInstance, error)
CreateServiceInstance creates a ServiceInstance
func (*Repository) CreateServiceOperationReport ¶
func (r *Repository) CreateServiceOperationReport(e *ServiceOperationReport) (*ServiceOperationReport, error)
CreateServiceOperationReport stores an execution log in the CIMI server
func (Repository) CreateTemplate ¶ added in v0.6.0
CreateTemplate implements model.IRepository.CreateTemplate
func (Repository) CreateViolation ¶
CreateViolation stores a violation in the CIMI server
func (Repository) DeleteAgreement ¶
func (r Repository) DeleteAgreement(agreement *model.Agreement) error
DeleteAgreement (see model.Repository)
func (Repository) DeleteProvider ¶
func (r Repository) DeleteProvider(provider *model.Provider) error
DeleteProvider (see model.Repository)
func (Repository) DeleteServiceContainerMetric ¶ added in v0.7.2
func (r Repository) DeleteServiceContainerMetric(e *ServiceContainerMetric) error
DeleteServiceContainerMetric deletes a ServiceContainerMetric
func (Repository) DeleteServiceOperationReport ¶ added in v0.7.2
func (r Repository) DeleteServiceOperationReport(e *ServiceOperationReport) error
DeleteServiceOperationReport deletes a ServiceOperationReport
func (Repository) GetAgreement ¶
func (r Repository) GetAgreement(id string) (*model.Agreement, error)
GetAgreement (see model.Repository)
func (Repository) GetAgreementsByState ¶ added in v0.4.0
func (r Repository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
GetAgreementsByState (see model.Repository)
func (Repository) GetAllAgreements ¶
func (r Repository) GetAllAgreements() (model.Agreements, error)
GetAllAgreements (see model.Repository)
func (Repository) GetAllProviders ¶
func (r Repository) GetAllProviders() (model.Providers, error)
GetAllProviders (see model.Repository)
func (Repository) GetAllTemplates ¶ added in v0.6.0
func (r Repository) GetAllTemplates() (model.Templates, error)
GetAllTemplates implements model.IRepository.GetAllTemplates
func (Repository) GetProvider ¶
func (r Repository) GetProvider(id string) (*model.Provider, error)
GetProvider (see model.Repository)
func (Repository) GetServiceContainerMetrics ¶ added in v0.7.2
func (r Repository) GetServiceContainerMetrics( device string, container string, begin time.Time, end time.Time) ([]ServiceContainerMetric, error)
GetServiceContainerMetrics retrieves container metrics from specific device and container (if set) where the container is up within the interval (begin, end].
func (Repository) GetServiceInstancesByAgreement ¶
func (r Repository) GetServiceInstancesByAgreement(aID string) ([]ServiceInstance, error)
GetServiceInstancesByAgreement returns the ServiceInstances with a given agreement id.
func (Repository) GetServiceOperationReportsByDate ¶
func (r Repository) GetServiceOperationReportsByDate(serviceInstance string, from time.Time) ([]ServiceOperationReport, error)
GetServiceOperationReportsByDate return the execution logs with creation time newer than a date
func (Repository) GetTemplate ¶ added in v0.6.0
func (r Repository) GetTemplate(id string) (*model.Template, error)
GetTemplate implements model.IRepository.GetTemplate
func (Repository) GetViolation ¶
func (r Repository) GetViolation(id string) (*model.Violation, error)
GetViolation gets a violation from the CIMI server by its ID
func (Repository) StartAgreement ¶
func (r Repository) StartAgreement(id string) error
StartAgreement (see model.Repository)
func (Repository) StopAgreement ¶
func (r Repository) StopAgreement(id string) error
StopAgreement (see model.Repository)
func (Repository) UpdateAgreement ¶
UpdateAgreement (see model.Repository)
func (Repository) UpdateAgreementState ¶ added in v0.4.0
UpdateAgreementState (see model.Repository)
type Rule ¶
type Rule struct { Principal string `json:"principal"` Type string `json:"type"` Right string `json:"right"` }
Rule represents a permission on a CIMI entity
type ServiceContainerMetric ¶ added in v0.7.2
type ServiceContainerMetric struct { Id string `json:"id"` Device Href `json:"device_id"` Container string `json:"container_id"` StartTime time.Time `json:"start_time"` StopTime *time.Time `json:"stop_time,omitempty"` ACL ACL `json:"acl"` }
ServiceContainerMetric stores start and stop times of containers running on a device
func (*ServiceContainerMetric) GetId ¶ added in v0.7.2
func (scm *ServiceContainerMetric) GetId() string
GetId implements model.Identity
type ServiceInstance ¶
type ServiceInstance struct { Id string `json:"id"` ACL ACL `json:"acl"` User string `json:"user"` DeviceID string `json:"device_id"` DeviceIP string `json:"device_ip"` ParentDeviceID string `json:"parent_device_id"` ParentDeviceIP string `json:"parent_device_ip"` Service string `json:"service"` Agreement string `json:"agreement"` Status string `json:"status"` ServiceType ServiceType `json:"service_type"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Agents []Agent `json:"agents"` }
ServiceInstance is the entity that represents the execution of a service
func ReadServiceInstance ¶ added in v0.8.0
func ReadServiceInstance(path string) (ServiceInstance, error)
ReadServiceInstance returns a ServiceInstance read from file
func (*ServiceInstance) GetId ¶ added in v0.6.0
func (si *ServiceInstance) GetId() string
GetId implements model.Identity
type ServiceOperationReport ¶
type ServiceOperationReport struct { Id string `json:"id"` ServiceInstance Href `json:"requesting_application_id"` Invocation string `json:"operation_id"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` ExecutionTime float64 `json:"execution_length"` ComputeNodeID string `json:"compute_node_id"` ExpectedEndTime time.Time `json:"expected_end_time"` Operation string `json:"operation_name"` Result string `json:"result"` StartTime time.Time `json:"start_time"` ACL ACL `json:"acl"` }
ServiceOperationReport represents the execution time of a service operation in DER A ServiceOperationReport is created when an operation is executed, and it is updated periodically until the operation has finished. ExecutionTime holds zero until that time.
func ReadServiceOperationReport ¶ added in v0.8.1
func ReadServiceOperationReport(path string) (ServiceOperationReport, error)
ReadServiceOperationReport returns a ServiceOperationReport read from file
func (*ServiceOperationReport) GetId ¶ added in v0.6.0
func (sor *ServiceOperationReport) GetId() string
GetId implements model.Identity
type ServiceType ¶ added in v0.9.0
type ServiceType string
ServiceType is the type a ServiceInstance can be
const ( // CompssType is the type of a COMPSS serviceInstance CompssType ServiceType = "compss" )
type Violation ¶
type Violation struct { Id string `json:"id"` AgreementId Href `json:"agreement_id"` Guarantee string `json:"guarantee"` Datetime time.Time `json:"datetime"` Constraint string `json:"constraint"` Values map[string]interface{} `json:"values"` ACL ACL `json:"acl"` }
Violation is the repr. of a CIMI violation