~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/cloudimagemetadata/interface.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package cloudimagemetadata
 
5
 
 
6
import (
 
7
        jujutxn "github.com/juju/txn"
 
8
 
 
9
        "github.com/juju/juju/mongo"
 
10
)
 
11
 
 
12
// MetadataAttributes contains cloud image metadata attributes.
 
13
type MetadataAttributes struct {
 
14
        // Stream contains reference to a particular stream,
 
15
        // for e.g. "daily" or "released"
 
16
        Stream string
 
17
 
 
18
        // Region is the name of cloud region associated with the image.
 
19
        Region string
 
20
 
 
21
        // Version is OS version, for e.g. "12.04".
 
22
        Version string
 
23
 
 
24
        // Series is OS series, for e.g. "trusty".
 
25
        Series string
 
26
 
 
27
        // Arch is the architecture for this cloud image, for e.g. "amd64"
 
28
        Arch string
 
29
 
 
30
        // VirtType contains virtualisation type of the cloud image, for e.g. "pv", "hvm". "kvm".
 
31
        VirtType string
 
32
 
 
33
        // RootStorageType contains type of root storage, for e.g. "ebs", "instance".
 
34
        RootStorageType string
 
35
 
 
36
        // RootStorageSize contains size of root storage in gigabytes (GB).
 
37
        RootStorageSize *uint64
 
38
 
 
39
        // Source describes where this image is coming from: is it public? custom?
 
40
        Source string
 
41
}
 
42
 
 
43
// Metadata describes a cloud image metadata.
 
44
type Metadata struct {
 
45
        MetadataAttributes
 
46
 
 
47
        // Priority is an importance factor for image metadata.
 
48
        // Higher number means higher priority.
 
49
        // This will allow to sort metadata by importance.
 
50
        Priority int
 
51
 
 
52
        // ImageId contains image identifier.
 
53
        ImageId string
 
54
}
 
55
 
 
56
// Storage provides methods for storing and retrieving cloud image metadata.
 
57
type Storage interface {
 
58
        // SaveMetadata adds cloud images metadata into state if it's new or
 
59
        // updates metadata if it already exists.
 
60
        SaveMetadata([]Metadata) error
 
61
 
 
62
        // DeleteMetadata deletes cloud image metadata from state.
 
63
        DeleteMetadata(imageId string) error
 
64
 
 
65
        // FindMetadata returns all Metadata that match specified
 
66
        // criteria or a "not found" error if none match.
 
67
        // Empty criteria will return all cloud image metadata.
 
68
        // Returned result is grouped by source type and ordered by date created.
 
69
        FindMetadata(criteria MetadataFilter) (map[string][]Metadata, error)
 
70
 
 
71
        // SupportedArchitectures returns collection of unique architectures
 
72
        // that stored metadata contains.
 
73
        SupportedArchitectures(criteria MetadataFilter) ([]string, error)
 
74
}
 
75
 
 
76
// DataStore exposes data store operations for use by the cloud image metadata package.
 
77
type DataStore interface {
 
78
 
 
79
        // RunTransaction runs desired transactions against this data source..
 
80
        RunTransaction(jujutxn.TransactionSource) error
 
81
 
 
82
        // GetCollection retrieves desired collection from this data source.
 
83
        GetCollection(name string) (collection mongo.Collection, closer func())
 
84
}