OpenStack虚拟机的用户客制化方法(User Data) Gzip Compressed Content content found to be gzip compressed will be uncompressed. Theuncompressed data will then be used as if it were not compressed.Compression of data is useful because user-data is limited to 16384bytes1 Mime Multi Part archive User-Data Script begins with: "#!" or"Content-Type: Include File begins with "#include" or"Content-Type: Cloud Config Data begins with "#cloud-config" or"Content-Type: Upstart Job begins with "#upstart-job" or"Content-Type: Cloud Boothook begins with "#cloud-boothook" or"Content-Type: This content is "boothook" data. It is stored in a file under/var/lib/cloud and then executed immediately. Part Handler begins with "#part-handler" or"Content-Type: This is a 'part-handler'. It will be written to a file in/var/lib/cloud/data based on its filename. This must be python codethat contains a list_types method and a handle_type method. Oncethe section is read the 'list_types' method will be called. It mustreturn a list of mime-types that this part-handler handlers. 非UEC镜像的问题实际上是cloud-init这个包的安装需要进行配置,详见OpenStack解决非UEC镜像的虚拟机cloud-init不工作不能自动修改主机名称不能注入userdata
盛大云的用户信息定制界面
很多成熟的公有云产品在申请虚拟机资源的时候,都可以定制客制化的用户信息,如盛大云、阿里云等可以定制虚拟机的服务器名称,用户名及密码口令等。特别是用户口令,虽然OpenStack有非常成熟的公私钥KeyPairs登陆体系,但是对于国内大多开发者还是习惯于用户名口令的登陆方式。某些场景下,服务器管理员在客户现场需要对服务器进行某些简单操作,也许没有SSH环境等,这时如果通过VNC的方式就比较简单,然而KeyPair的登陆方式还不支持VNC模式。
script will be executed at "rc.local-like" level during first boot.rc.local-like means "very late in the boot sequence"
This content is a "include" file. The file contains a list of urls,one per line. Each of the URLs will be read, and their content willbe passed through this same set of rules. Ie, the content read fromthe URL can be gzipped, mime-multi-part, or plain text
This content is "cloud-config" data. See the examples for acommented example of supported config formats.
Content is placed into a file in /etc/init, and will be consumed byupstart as any other upstart job.
This is the earliest "hook" available. Note, that there is nomechanism provided for running only once. The boothook must takecare of this itself. It is provided with the instance id in theenvironment variable "INSTANCE_ID". This could be made use of toprovide a 'once-per-instance'
Only available in 10.10 or later (cloud-init 0.5.12 andlater)
The 'handle_type' method must be like: