From 8db397765c6af91ebc1268f83db0e211df769a2c Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 25 May 2017 18:20:20 -0700 Subject: [PATCH] spelling and formatting --- builder/alicloud/ecs/step_attach_keypair.go | 1 + .../alicloud-import/alicloud_import.go | 15 +- .../source/docs/builders/alicloud-ecs.html.md | 225 +++++++++++------- .../post-processors/alicloud-import.html.md | 91 ++++--- 4 files changed, 208 insertions(+), 124 deletions(-) diff --git a/builder/alicloud/ecs/step_attach_keypair.go b/builder/alicloud/ecs/step_attach_keypair.go index 5016b145b..551c74cdf 100644 --- a/builder/alicloud/ecs/step_attach_keypair.go +++ b/builder/alicloud/ecs/step_attach_keypair.go @@ -2,6 +2,7 @@ package ecs import ( "fmt" + "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" "github.com/hashicorp/packer/packer" diff --git a/post-processor/alicloud-import/alicloud_import.go b/post-processor/alicloud-import/alicloud_import.go index 6b519a23c..5bbf591aa 100644 --- a/post-processor/alicloud-import/alicloud_import.go +++ b/post-processor/alicloud-import/alicloud_import.go @@ -2,6 +2,11 @@ package alicloudimport import ( "fmt" + "log" + "strconv" + "strings" + "time" + "github.com/aliyun/aliyun-oss-go-sdk/oss" packercommon "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" @@ -11,10 +16,6 @@ import ( "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "log" - "strconv" - "strings" - "time" ) const ( @@ -69,7 +70,7 @@ type PostProcessor struct { DiskDeviceMapping []ecs.DiskDeviceMapping } -// Entry point for configuration parisng when we've defined +// Entry point for configuration parsing when we've defined func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ Interpolate: true, @@ -95,7 +96,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check we have alicloud access variables defined somewhere errs = packer.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...) - // define all our required paramaters + // define all our required parameters templates := map[string]*string{ "oss_bucket_name": &p.config.OSSBucket, } @@ -125,7 +126,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac return nil, false, fmt.Errorf("Error rendering oss_key_name template: %s", err) } if p.config.OSSKey == "" { - p.config.OSSKey = "Pakcer_" + strconv.Itoa(time.Now().Nanosecond()) + p.config.OSSKey = "Packer_" + strconv.Itoa(time.Now().Nanosecond()) } log.Printf("Rendered oss_key_name as %s", p.config.OSSKey) diff --git a/website/source/docs/builders/alicloud-ecs.html.md b/website/source/docs/builders/alicloud-ecs.html.md index abd0aa62d..ac1450ccc 100644 --- a/website/source/docs/builders/alicloud-ecs.html.md +++ b/website/source/docs/builders/alicloud-ecs.html.md @@ -1,6 +1,7 @@ --- description: | - + The `alicloud-ecs` Packer builder plugin provide the capability to build + customized images based on an existing base images. layout: docs page_title: Alicloud Image Builder ... @@ -9,137 +10,186 @@ page_title: Alicloud Image Builder Type: `alicloud-ecs` -Alicloud Packer builder plugin provide the capability to build customized images based on an existing base images. +The `alicloud-ecs` Packer builder plugin provide the capability to build +customized images based on an existing base images. ## Configuration Reference -The following configuration options are available for building Alicloud images. In addition to the options listed here, a -[communicator](/docs/templates/communicator.html) can be configured for this +The following configuration options are available for building Alicloud images. +In addition to the options listed here, +a [communicator](/docs/templates/communicator.html) can be configured for this builder. ### Required: -* `access_key` - (string) This is the Alicloud access key. It must be provided, but it can also be sourced from the `ALICLOUD_ACCESS_KEY` environment variable. +- `access_key` (string) - This is the Alicloud access key. It must be provided, + but it can also be sourced from the `ALICLOUD_ACCESS_KEY` environment + variable. -* `secret_key` - (string) This is the Alicloud secret key. It must be provided, but it can also be sourced from the `ALICLOUD_SECRET_KEY` environment variable. +- `secret_key` (string) - This is the Alicloud secret key. It must be provided, + but it can also be sourced from the `ALICLOUD_SECRET_KEY` environment + variable. -* `region` - (string) This is the Alicloud region. It must be provided, but it can also be sourced from the `ALICLOUD_REGION` environment variables. +- `region` (string) - This is the Alicloud region. It must be provided, but it + can also be sourced from the `ALICLOUD_REGION` environment variables. -* `instance_type` - (string) Type of the instance. For values, see [Instance Type Table](). You can also obtain the latest instance type table by invoking the [Querying Instance Type Table](https://intl.aliyun.com/help/doc-detail/25620.htm?spm=a3c0i.o25499en.a3.6.Dr1bik) interface.. +- `instance_type` (string) - Type of the instance. For values, see [Instance + Type Table](). You can also obtain the latest instance type table by invoking + the [Querying Instance Type + Table](https://intl.aliyun.com/help/doc-detail/25620.htm?spm=a3c0i.o25499en.a3.6.Dr1bik) + interface. -* `image_name` - (string) The name of the user-defined image, [2, 128] English or Chinese characters. It must begin with an uppercase/lowercase letter or a Chinese character, and may contain numbers, "_" or "-".It cannot begin with http:// or https://. +- `image_name` (string) - The name of the user-defined image, [2, 128] English + or Chinese characters. It must begin with an uppercase/lowercase letter or + a Chinese character, and may contain numbers, `_` or `-`. It cannot begin with + `http://` or `https://`. -* `source_image` - (string) This is the base image id which you want to create your customized images. +- `source_image` (string) - This is the base image id which you want to create + your customized images. ### Optional: -- `skip_region_validation` (bool) The region validation can be skipped if this value is true, the default value is false. +- `skip_region_validation` (bool) - The region validation can be skipped if this + value is true, the default value is false. -- `image_description` (string) The description of the image, with a length limit of 0 to 256 characters. Leaving it blank means null, which is the default value.It cannot begin with http:// or https://. +- `image_description` (string) - The description of the image, with a length + limit of 0 to 256 characters. Leaving it blank means null, which is the + default value. It cannot begin with http:// or https://. -- `image_version` (string) The version number of the image, with a length limit of 1 to 40 English characters. +- `image_version` (string) - The version number of the image, with a length limit + of 1 to 40 English characters. -- `image_share_account` (array of string) The IDs of to-be-added Aliyun accounts to which the image is shared. The number of accounts is 1 to 10. If number of accounts is greater than 10, this parameter is ignored. +- `image_share_account` (array of string) - The IDs of to-be-added Aliyun + accounts to which the image is shared. The number of accounts is 1 to 10. If + number of accounts is greater than 10, this parameter is ignored. -- `image_copy_regions` (array of string) Copy to the destination regionIds. +- `image_copy_regions` (array of string) - Copy to the destination regionIds. -- `image_copy_names` (array of string) The name of the destination image, [2, 128] English or Chinese characters. It must begin with an uppercase/lowercase letter or a Chinese character, and may contain numbers, "_" or "-".It cannot begin with http:// or https://. +- `image_copy_names` (array of string) - The name of the destination image, [2, + 128] English or Chinese characters. It must begin with an uppercase/lowercase + letter or a Chinese character, and may contain numbers, `_` or `-`. It cannot + begin with `http://` or `https://`. -- `image_force_delete` (bool) If this value is true, when the target image name is duplicated with an existing image, it will delete the existing image and then create the target image, otherwise, the creation will fail. The default value is false. - -- `image_force_delete_snapshots` (bool) If this value is true, when delete the duplicated existing image, the source snapshot of this image will be delete either. +- `image_force_delete` (bool) - If this value is true, when the target image name + is duplicated with an existing image, it will delete the existing image and + then create the target image, otherwise, the creation will fail. The default + value is false. -- `disk_name` (string) The value of disk name is blank by default. [2, 128] English or Chinese characters, must begin with an uppercase/lowercase letter or Chinese character. Can contain numbers, “.”, “_“ and “-“. The disk name will appear on the console.It cannot begin with http:// or https://. +- `image_force_delete_snapshots` (bool) - If this value is true, when delete the + duplicated existing image, the source snapshot of this image will be delete + either. -- `disk_category` (string) Category of the data disk. Optional values are: - - Default value:cloud. +- `disk_name` (string) - The value of disk name is blank by default. [2, 128] + English or Chinese characters, must begin with an uppercase/lowercase letter + or Chinese character. Can contain numbers, `.`, `_` and `-`. The disk name + will appear on the console. It cannot begin with http:// or https://. -- `disk_size` (int) Size of the system disk, in GB, values range: - - The value should be equal to or greater than the size of the specific SnapshotId. - -- `disk_snapshot_id` (string) Snapshots are used to create the data disk - After this parameter is specified, Size is ignored. The actual size of the created disk is the size of the specified snapshot -
Snapshots from on or before July 15, 2013 cannot be used to create a disk - -- `disk_description` (string) The value of disk description is blank by default. [2, 256] characters. The disk description will appear on the console.It cannot begin with http:// or https://. +- `disk_category` (string) - Category of the data disk. Optional values are: + - cloud - general cloud disk + - cloud_efficiency - efficiency cloud disk + - cloud_ssd - cloud SSD -- `disk_delete_with_instance` (string) Whether or not the disk is released along with the instance: - + Default value: cloud. -- `disk_device` (string) Device information of the related instance: such as /dev/xvdb - It is null unless the Status is In_use. +- `disk_size` (int) - Size of the system disk, in GB, values range: + - cloud - 5 ~ 2000 + - cloud_efficiency - 20 ~ 2048 + - cloud_ssd - 20 ~ 2048 -- `zone_id` (string) ID of the zone to which the disk belongs. + The value should be equal to or greater than the size of the specific SnapshotId. -- `io_optimized` (string) I/O optimized. Optional values are: - - Default value: none for Generation I instances; optimized for other instances.. +- `disk_snapshot_id` (string) - Snapshots are used to create the data disk + After this parameter is specified, Size is ignored. The actual size of the + created disk is the size of the specified snapshot. -- `force_stop_instance` (bool) Whether to force shutdown upon device restart. Value: - - The default value is “false”.
- If it is set to “false”, the system is shut down normally; if it is set to “true”, the system is forced to shut down.. + Snapshots from on or before July 15, 2013 cannot be used to create a disk. -- `security_group_id` (string) ID of the security group to which a newly created instance belongs. Mutual access is allowed between instances in one security group. If not specified, the newly created instance will be added to the default security group. If the default group doesn’t exist, or the number of instances in it has reached the maximum limit, a new security group will be created automatically. - -- `security_group_name` (string) The security group name. The default value is blank. [2, 128] English or Chinese characters, must begin with an uppercase/lowercase letter or Chinese character. Can contain numbers, ".", "_" or "-". It cannot begin with http:// or https://. +- `disk_description` (string) - The value of disk description is blank by default. [2, 256] characters. The disk description will appear on the console. It cannot begin with http:// or https://. -- `user_data` (string) The UserData of an instance must be encoded in Base64 format, and the maximum size of the raw data is 16 KB. +- `disk_delete_with_instance` (string) - Whether or not the disk is released along with the instance: + - True indicates that when the instance is released, this disk will be released with it + - False indicates that when the instance is released, this disk will be retained. -- `user_data_file` (string) The file name of the userdata. +- `disk_device` (string) - Device information of the related instance: such as + `/dev/xvdb` It is null unless the Status is In_use. -- `vpc_id` (string) VPC ID allocated by the system. +- `zone_id` (string) - ID of the zone to which the disk belongs. -- `vpc_name` (string) The VPC name. The default value is blank. [2, 128] English or Chinese characters, must begin with an uppercase/lowercase letter or Chinese character. Can contain numbers, "_" and "-". The disk description will appear on the console. Cannot begin with http:// or https://. +- `io_optimized` (string) - I/O optimized. Optional values are: + - none: none I/O Optimized + - optimized: I/O Optimized -- `vpc_cidr_block` (string) Value options: 192.168.0.0/16 and 172.16.0.0/16. When not specified, the default value is 172.16.0.0/16. + Default value: none for Generation I instances; optimized for other instances. -- `vswitch_id` (string) The ID of the VSwitch to be used. +- `force_stop_instance` (bool) - Whether to force shutdown upon device restart. + The default value is `false`. -- `instance_name` (string) Display name of the instance, which is a string of 2 to 128 Chinese or English characters. It must begin with an uppercase/lowercase letter or a Chinese character and can contain numerals, “.”, “_“, or “-“. The instance name is displayed on the Alibaba Cloud console. If this parameter is not specified, the default value is InstanceId of the instance. It cannot begin with http:// or https://. + If it is set to `false`, the system is shut down normally; if it is set to + `true`, the system is forced to shut down. -- `internet_charge_type` (string) Internet charge type, which can be PayByTraffic or PayByBandwidth.Optional values: - - If this parameter is not specified, the default value is PayByBandwidth. - - -- `internet_max_bandwith_out` (string) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). -
Value range: -
PayByBandwidth: [0, 100]. If this parameter is not specified, API automatically sets it to 0 Mbps. -
PayByTraffic: [1, 100]. If this parameter is not specified, an error is returned. +- `security_group_id` (string) - ID of the security group to which a newly + created instance belongs. Mutual access is allowed between instances in one + security group. If not specified, the newly created instance will be added to + the default security group. If the default group doesn’t exist, or the number + of instances in it has reached the maximum limit, a new security group will + be created automatically. -- `temporary_key_pair_name` (string) The name of the temporary key pair to generate. By default, Packer generates a name that looks like packer_, where is a 36 character unique identifier. +- `security_group_name` (string) - The security group name. The default value is + blank. [2, 128] English or Chinese characters, must begin with an + uppercase/lowercase letter or Chinese character. Can contain numbers, `.`, + `_` or `-`. It cannot begin with `http://` or `https://`. + +- `user_data` (string) - The UserData of an instance must be encoded in `Base64` + format, and the maximum size of the raw data is `16 KB`. + +- `user_data_file` (string) - The file name of the userdata. + +- `vpc_id` (string) - VPC ID allocated by the system. + +- `vpc_name` (string) - The VPC name. The default value is blank. [2, 128] + English or Chinese characters, must begin with an uppercase/lowercase letter + or Chinese character. Can contain numbers, `_` and `-`. The disk description + will appear on the console. Cannot begin with `http://` or `https://`. + +- `vpc_cidr_block` (string) - Value options: `192.168.0.0/16` and `172.16.0.0/16`. + When not specified, the default value is `172.16.0.0/16`. + +- `vswitch_id` (string) - The ID of the VSwitch to be used. + +- `instance_name` (string) - Display name of the instance, which is a string of + 2 to 128 Chinese or English characters. It must begin with an + uppercase/lowercase letter or a Chinese character and can contain numerals, + `.`, `_`, or `-`. The instance name is displayed on the Alibaba Cloud + console. If this parameter is not specified, the default value is InstanceId + of the instance. It cannot begin with http:// or https://. + +- `internet_charge_type` (string) - Internet charge type, which can be + `PayByTraffic` or `PayByBandwidth`. Optional values: + - PayByBandwidth + - PayByTraffic + + If this parameter is not specified, the default value is `PayByBandwidth`. + + +- `internet_max_bandwith_out` (string) - Maximum outgoing bandwidth to the public + network, measured in Mbps (Mega bit per second). + + Value range: + - PayByBandwidth: [0, 100]. If this parameter is not specified, API automatically sets it to 0 Mbps. + - PayByTraffic: [1, 100]. If this parameter is not specified, an error is returned. + +- `temporary_key_pair_name` (string) - The name of the temporary key pair to + generate. By default, Packer generates a name that looks like `packer_`, + where `` is a 36 character unique identifier. ## Basic Example Here is a basic example for Alicloud. -``` {.javascript} +```json { "variables": { "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}", @@ -168,5 +218,6 @@ Here is a basic example for Alicloud. ``` -See the [examples/alicloud](https://github.com/mitchellh/packer/tree/master/examples/alicloud) folder in the packer project -for more examples. +See the +[examples/alicloud](https://github.com/hashicorp/packer/tree/master/examples/alicloud) +folder in the packer project for more examples. diff --git a/website/source/docs/post-processors/alicloud-import.html.md b/website/source/docs/post-processors/alicloud-import.html.md index 964c48ef3..5e0e645da 100644 --- a/website/source/docs/post-processors/alicloud-import.html.md +++ b/website/source/docs/post-processors/alicloud-import.html.md @@ -1,7 +1,7 @@ --- description: | - The Packer Alicloud Import post-processor takes a RAW or VHD artifact from various builders and - imports it to an Alicloud customized image list. + The Packer Alicloud Import post-processor takes a RAW or VHD artifact from + various builders and imports it to an Alicloud customized image list. layout: docs page_title: 'Alicloud Import Post-Processor' ... @@ -10,58 +10,86 @@ page_title: 'Alicloud Import Post-Processor' Type: `alicloud-import` -The Packer Alicloud Import post-processor takes a RAW or VHD artifact from various builders and imports it to an Alicloud ECS Image. +The Packer Alicloud Import post-processor takes a RAW or VHD artifact from +various builders and imports it to an Alicloud ECS Image. + ## How Does it Work? -The import process operates making a temporary copy of the RAW or VHD to an OSS bucket, and calling an import task in ECS on the RAW or VHD file. Once completed, an Alicloud ECS Image is returned. The temporary RAW or VHD copy in OSS can be discarded after the import is complete. +The import process operates by making a temporary copy of the RAW or VHD to an OSS +bucket, and calling an import task in ECS on the RAW or VHD file. Once +completed, an Alicloud ECS Image is returned. The temporary RAW or VHD copy in +OSS can be discarded after the import is complete. ## Configuration There are some configuration options available for the post-processor. There are two categories: required and optional parameters. -Required: +### Required: -* `access_key` - (string) This is the Alicloud access key. It must be provided, but it can also be sourced from the `ALICLOUD_ACCESS_KEY` environment variable. +- `access_key` (string) - This is the Alicloud access key. It must be provided, + but it can also be sourced from the `ALICLOUD_ACCESS_KEY` environment + variable. -* `secret_key` - (string) This is the Alicloud secret key. It must be provided, but it can also be sourced from the `ALICLOUD_SECRET_KEY` environment variable. +- `secret_key` (string) - This is the Alicloud secret key. It must be provided, + but it can also be sourced from the `ALICLOUD_SECRET_KEY` environment + variable. -* `region` - (string) This is the Alicloud region. It must be provided, but it can also be sourced from the `ALICLOUD_REGION` environment variables. +- `region` (string) - This is the Alicloud region. It must be provided, but it + can also be sourced from the `ALICLOUD_REGION` environment variables. -* `image_name` - (string) The name of the user-defined image, [2, 128] English or Chinese characters. It must begin with an uppercase/lowercase letter or a Chinese character, and may contain numbers, "_" or "-".It cannot begin with http:// or https://. +- `image_name` (string) - The name of the user-defined image, [2, 128] English + or Chinese characters. It must begin with an uppercase/lowercase letter or + a Chinese character, and may contain numbers, `_` or `-`. It cannot begin + with http:// or https://. -* `oss_bucket_name` (string) - The name of the OSS bucket where the RAW or VHD file will be copied to for import. If the Bucket isn't exist, post-process will create it for you. +- `oss_bucket_name` (string) - The name of the OSS bucket where the RAW or VHD + file will be copied to for import. If the Bucket isn't exist, post-process + will create it for you. -* `image_os_type` (string) - Type of the OS linux/windows +- `image_os_type` (string) - Type of the OS linux/windows -* `image_platform` (string) - platform such "CentOS" +- `image_platform` (string) - platform such `CentOS` -* `image_architecture` (string) - Platform type of the image system:i386 | x86_64 +- `image_architecture` (string) - Platform type of the image system:i386 + | x86_64 -* `Format` (string) - The format of the image for import, now alicloud only support RAW and VHD. +- `format` (string) - The format of the image for import, now alicloud only + support RAW and VHD. -Optional: +### Optional: -* `oss_key_name` (string) - The name of the object key in `oss_bucket_name` where the RAW or VHD file will be copied to for import. +- `oss_key_name` (string) - The name of the object key in `oss_bucket_name` + where the RAW or VHD file will be copied to for import. -* `skip_clean` (boolean) - Whether we should skip removing the RAW or VHD file uploaded to OSS after the import process has completed. "true" means that we should leave it in the OSS bucket, "false" means to clean it out. Defaults to `false`. +- `skip_clean` (boolean) - Whether we should skip removing the RAW or VHD file + uploaded to OSS after the import process has completed. `true` means that we + should leave it in the OSS bucket, `false` means to clean it out. Defaults to + `false`. -* `image_description` (string) The description of the image, with a length limit of 0 to 256 characters. Leaving it blank means null, which is the default value.It cannot begin with http:// or https://. +- `image_description` (string) - The description of the image, with a length + limit of 0 to 256 characters. Leaving it blank means null, which is the + default value. It cannot begin with http:// or https://. -* `image_force_delete` (bool) If this value is true, when the target image name is duplicated with an existing image, it will delete the existing image and then create the target image, otherwise, the creation will fail. The default value is false. - -* `image_system_size` (int) Size of the system disk, in GB, values range: -
    -
  • cloud - 5 ~ 2000 -
  • cloud_efficiency - 20 ~ 2048 -
  • cloud_ssd - 20 ~ 2048 -
+- `image_force_delete` (bool) - If this value is true, when the target image + name is duplicated with an existing image, it will delete the existing image + and then create the target image, otherwise, the creation will fail. The + default value is false. + +- `image_system_size` (int) - Size of the system disk, in GB, values range: + - cloud - 5 ~ 2000 + - cloud_efficiency - 20 ~ 2048 + - cloud_ssd - 20 ~ 2048 ## Basic Example -Here is a basic example. This assumes that the builder has produced an RAW artifact. The user must have the role "AliyunECSImageImportDefaultRole" with "AliyunECSImageImportRolePolicy", post-process will automatically configu the role and policy for you if you have the priviledge, otherwise, you have to ask the administer configure for you in advance. +Here is a basic example. This assumes that the builder has produced a RAW +artifact. The user must have the role `AliyunECSImageImportDefaultRole` with +`AliyunECSImageImportRolePolicy`, post-process will automatically configure the +role and policy for you if you have the privilege, otherwise, you have to ask +the administrator configure for you in advance. -``` {.javascript} +```json "post-processors":[ { "access_key":"{{user `access_key`}}", @@ -78,6 +106,9 @@ Here is a basic example. This assumes that the builder has produced an RAW artif ] ``` -This will take the RAW generated by a builder and upload it to OSS. In this case, an existing bucket called `packer` in the `cn-beijing` region will be where the copy is placed. +This will take the RAW generated by a builder and upload it to OSS. In this +case, an existing bucket called `packer` in the `cn-beijing` region will be +where the copy is placed. -Once uploaded, the import process will start, creating an Alicloud ECS image in the "cn-beijing" region with the name you specified in template file. \ No newline at end of file +Once uploaded, the import process will start, creating an Alicloud ECS image in +the `cn-beijing` region with the name you specified in template file.