Documentation ¶
Index ¶
- Constants
- Variables
- func LoggerCreate(logFile string) *log.Logger
- type API
- type APIInitialyser
- type APIMeta
- type APITooler
- type APIer
- type AirDrumResourcesAPI
- func (apier AirDrumResourcesAPI) CreateResource(d *schema.ResourceData, clientTooler *ClientTooler, ...) (map[string]interface{}, error)
- func (apier AirDrumResourcesAPI) DeleteResource(d *schema.ResourceData, clientTooler *ClientTooler, ...) error
- func (apier AirDrumResourcesAPI) ReadResource(d *schema.ResourceData, clientTooler *ClientTooler, ...) (map[string]interface{}, error)
- func (apier AirDrumResourcesAPI) UpdateResource(d *schema.ResourceData, clientTooler *ClientTooler, ...) error
- type ClientTooler
- type Clienter
- type HTTPClienter
- type Initialyser
- func (initialyser Initialyser) CheckCloudDcStatus(api *API, clientTooler *ClientTooler, resourceTooler *ResourceTooler) error
- func (initialyser Initialyser) GetClouddcEnvMeta(api *API, clientTooler *ClientTooler) (*APIMeta, error)
- func (initialyser Initialyser) New(token string, url string, enterprise string) *API
- type ResourceResourceer
- type ResourceTooler
- type Resourceer
- type SchemaSchemaer
- func (schemaer SchemaSchemaer) DeleteTerraformResource(d *schema.ResourceData)
- func (schemaer SchemaSchemaer) ReadElement(key interface{}, value interface{}) (interface{}, error)
- func (schemaer SchemaSchemaer) UpdateLocalResourceState(resourceState map[string]interface{}, d *schema.ResourceData, ...) error
- type SchemaTooler
- type Schemaer
- type TemplateTemplater
- type Templater
- type TemplatesTooler
Constants ¶
const ( ResourceCosField = "cos" MonoResourceType = "Mono" NameField = "name" EnterpriseField = "enterprise" DataCenterField = "datacenter" VdcResourceField = "vdc_resources" ResourceField = "resource" TotalField = "total" UsedField = "used" SlugField = "slug" StateField = "state" OsField = "os" RAMField = "ram" CPUField = "cpu" DisksField = "disks" VDiskField = "v_disk" SizeField = "size" StorageClassField = "storage_class" NicsField = "nics" VlanNameField = "vlan" MacAdressField = "mac_address" ConnectedField = "connected" VdcField = "vdc" BootField = "boot" TokenField = "token" BackupField = "backup" IsoField = "disk_image" PlatformNameField = "platform_name" BackupSizeField = "backup_size" CommentField = "comment" TemplateField = "template" IDField = "id" DynamicField = "dynamic_field" OutsourcingField = "outsourcing" InstanceNumberField = "instance_number" VMResourceType = "vm" VdcResourceType = VdcField )
Exported constants are resource field names
Variables ¶
var (
//ErrResourceNotExist provide message for unexisting resource case
ErrResourceNotExist = errResourceNotExist("", "")
)
Functions ¶
func LoggerCreate ¶
LoggerCreate is a wrapper used only for plugin development debug purpose, it must be removed at the end of the develpment cycle, before delivery to prod. It creates a logger that write logs to files in sdk-logs/ folder, stored in current folder.
Types ¶
type APIInitialyser ¶ added in v0.1.2
type APIInitialyser interface { New(token string, url string, enterprise string) *API CheckCloudDcStatus(api *API, clientTooler *ClientTooler, resourceTooler *ResourceTooler) error GetClouddcEnvMeta(api *API, clientTooler *ClientTooler) (*APIMeta, error) }
APIInitialyser interface is responsible of initializing an API client
type APIMeta ¶ added in v0.1.2
type APIMeta struct { EnterpriseResourceList []interface{} EnterpriseVdcList []interface{} DataCenterList []interface{} TemplateList []interface{} VlanList []interface{} SnapshotList []interface{} IsoList []interface{} OvaList []interface{} BackupPlanList []interface{} }
APIMeta stores specific meta data about a clouddc environment
type APITooler ¶
type APITooler struct { Implementer APIer Initialyser APIInitialyser }
APITooler contains implementation of APIer and APIInitialyser interfaces
type APIer ¶
type APIer interface { CreateResource(d *schema.ResourceData, clientTooler *ClientTooler, templatesTooler *TemplatesTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) (map[string]interface{}, error) ReadResource(d *schema.ResourceData, clientTooler *ClientTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) (map[string]interface{}, error) UpdateResource(d *schema.ResourceData, clientTooler *ClientTooler, templatesTooler *TemplatesTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) error DeleteResource(d *schema.ResourceData, clientTooler *ClientTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) error }
APIer interface is responsible of CRUD operations on Sewan's clouddc resources, they are done through AirDrumAPI consumption.
type AirDrumResourcesAPI ¶
type AirDrumResourcesAPI struct{}
AirDrumResourcesAPI implements APIer interface
func (AirDrumResourcesAPI) CreateResource ¶
func (apier AirDrumResourcesAPI) CreateResource(d *schema.ResourceData, clientTooler *ClientTooler, templatesTooler *TemplatesTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) (map[string]interface{}, error)
CreateResource creates Sewan clouddc resource
* input data : schema.ResourceData (godoc.org/github.com/hashicorp/terraform/helper/schema#ResourceData)
* return map of created resource or eventual creation error
func (AirDrumResourcesAPI) DeleteResource ¶
func (apier AirDrumResourcesAPI) DeleteResource(d *schema.ResourceData, clientTooler *ClientTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) error
DeleteResource deletes a Sewan clouddc resource
* input data : schema.ResourceData (with existing id) (godoc.org/github.com/hashicorp/terraform/helper/schema#ResourceData)
* return eventual deletion error
func (AirDrumResourcesAPI) ReadResource ¶
func (apier AirDrumResourcesAPI) ReadResource(d *schema.ResourceData, clientTooler *ClientTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) (map[string]interface{}, error)
ReadResource reads Sewan clouddc resource's state and update terraform's resource's state
* input data : schema.ResourceData (with existing id) (godoc.org/github.com/hashicorp/terraform/helper/schema#ResourceData)
* return map of read resource or eventual read error
func (AirDrumResourcesAPI) UpdateResource ¶
func (apier AirDrumResourcesAPI) UpdateResource(d *schema.ResourceData, clientTooler *ClientTooler, templatesTooler *TemplatesTooler, resourceTooler *ResourceTooler, resourceType string, sewan *API) error
UpdateResource update Sewan clouddc resource's
* input data : schema.ResourceData (with existing id) (godoc.org/github.com/hashicorp/terraform/helper/schema#ResourceData)
* return map of updated resource or eventual update error
type ClientTooler ¶
type ClientTooler struct {
Client Clienter
}
ClientTooler contains implementation of Clienter interface
type Clienter ¶
type Clienter interface {
// contains filtered or unexported methods
}
Clienter interface is responsible of HTTP operations
type Initialyser ¶ added in v0.1.2
type Initialyser struct{}
Initialyser implements APIInitialyser interface
func (Initialyser) CheckCloudDcStatus ¶ added in v0.1.2
func (initialyser Initialyser) CheckCloudDcStatus(api *API, clientTooler *ClientTooler, resourceTooler *ResourceTooler) error
CheckCloudDcStatus checks availability of clouddc through its API
func (Initialyser) GetClouddcEnvMeta ¶ added in v0.1.2
func (initialyser Initialyser) GetClouddcEnvMeta(api *API, clientTooler *ClientTooler) (*APIMeta, error)
GetClouddcEnvMeta gets Clouddc environnements meta data : * physical clouddc resource lists :
- non critical resource list
- critical resource list (redondant resource for critic uses)
- other resource list (Windows server license, RedHat licenses, etc.)
type ResourceResourceer ¶
type ResourceResourceer struct{}
ResourceResourceer implements Resourceer interface
type ResourceTooler ¶
type ResourceTooler struct {
Resource Resourceer
}
ResourceTooler contains implementation of Resourceer interface
type Resourceer ¶
type Resourceer interface {
// contains filtered or unexported methods
}
Resourceer interface is responsible of operations on terraform resource
type SchemaSchemaer ¶
type SchemaSchemaer struct{}
SchemaSchemaer implements Schemaer interface
func (SchemaSchemaer) DeleteTerraformResource ¶
func (schemaer SchemaSchemaer) DeleteTerraformResource(d *schema.ResourceData)
DeleteTerraformResource deletes a resource from terraform state file (.tfstate)
func (SchemaSchemaer) ReadElement ¶
func (schemaer SchemaSchemaer) ReadElement(key interface{}, value interface{}) (interface{}, error)
ReadElement formats Element(key,value) value type to a type accepted by terraform :
* value type -> terraform accepted type
* string -> string
* bool -> bool
* float64 -> int (rounded to nearest int)
* int -> int
* map -> map (recursive call of function for each map element)
* slice -> slice (recursive call of function for each slice element)
* other types -> return error
func (SchemaSchemaer) UpdateLocalResourceState ¶
func (schemaer SchemaSchemaer) UpdateLocalResourceState(resourceState map[string]interface{}, d *schema.ResourceData, schemaTools *SchemaTooler) error
UpdateLocalResourceState updates resource state in .tfstate file through schema update
- *schema.ResourceData Set error are not handled to ignore possible change of data structure got from clouddc environment, and to ignore non-relevant resource data.
type SchemaTooler ¶
type SchemaTooler struct {
SchemaTools Schemaer
}
SchemaTooler contains implementation of Schemaer interface
type Schemaer ¶
type Schemaer interface { DeleteTerraformResource(d *schema.ResourceData) UpdateLocalResourceState(resourceState map[string]interface{}, d *schema.ResourceData, schemaTools *SchemaTooler) error //UpdateVdcResourcesNames(d *schema.ResourceData) error ReadElement(key interface{}, value interface{}) (interface{}, error) }
Schemaer interface is responsible of operations on : * github.com/hashicorp/terraform/helper/schema * terraform state file (.tfstate)
type TemplateTemplater ¶
type TemplateTemplater struct{}
TemplateTemplater implements Templater interface
func (TemplateTemplater) FetchTemplateFromList ¶
func (templater TemplateTemplater) FetchTemplateFromList(templateSlug string, templateList []interface{}) (map[string]interface{}, error)
FetchTemplateFromList extracts a template from the received list Known implementation limitation :
- Redmine ticket #35489/#36874
type Templater ¶
type Templater interface { FetchTemplateFromList(templateName string, templateList []interface{}) (map[string]interface{}, error) // contains filtered or unexported methods }
Templater interface is responsible of operations on : * Sewan's clouddc managed templates (see user doc : https://github.com/SewanDevs/terraform-provider-sewan/blob/github_release/website/docs/r/vm.html.md)
type TemplatesTooler ¶
type TemplatesTooler struct {
TemplatesTools Templater
}
TemplatesTooler contains implementation of Templater interface