2019独角兽企业重金招聘Python工程师标准>>>
Before You Start
开发之前,应有以下准备
- Apache Maven
- Cloudify
- 调用云API的安全凭证,使用SSH访问你的机器,如果需要访问您的云的存储。
例如,通过以下步骤获得OpenStack的安全凭证:
- Request a login, and its corresponding access key and secret key, from your Openstack administrator. In the
user
section of the cloud driver configuration file, the access key and secret key correspond to theuser
and theapiKey
attributes respectively. - Generate a SSL key pair file (required for bootstrapping machines) using HybridFox, and save it in the cloud driver’s
upload
folder. In theuser
section of the cloud driver configuration file, thekeyFile
attribute is set to the path of the SSL key pair file.
- Request a login, and its corresponding access key and secret key, from your Openstack administrator. In the
- Create cloud images
配置Maven pom
文件
添加依赖的jar
<dependency>
<groupId>org.cloudifysource</groupId>
<artifactId>esc</artifactId>
<version>2.3.1-RELEASE</version>
</dependency>
view rawpom_dependency.xmlThis Gist brought to you by GitHub.
- 添加Cloudify的Maven仓库
<repository>
<id>org.cloudifysource</id>
<url>http://maven-repository.cloudifysource.org</url>
</repository>
view rawrepo.xmlThis Gist brought to you by GitHub.
创建Cloud Driver
You are now ready to develop your cloud driver. Create a new Java class that implements theorg.cloudifysource.esc.driver.provisioning.ProvisioningDriver interface. For examples, see Default Cloud Driver andOpenstack Cloud Driver.
配置Cloud Driver Configuration File
Next, configure the user
and management templates
sections of your cloud driver configuration file.
配置 user
section
配置user, apiKey, and keyFile for your cloud.
user {
user Your_User_Here
apiKey Your_API_Key_Here
keyFile Your_PEM_File_Name_Here
}
view rawdriver_user.groovyThis Gist brought to you by GitHub.
配置 templates
section
配置 management machines 各它相应的镜像
templates ([
SMALL_LINUX_32 : template {
imageId "221"
machineMemoryMB 1600
hardwareId "100"
}
])
view rawtemplates.groovyThis Gist brought to you by GitHub.
下一步, 配置managementMachineTemplate
属性,在recipe中用于manage machine的template:
cloud {
name = "openstack"
configuration {
className "org.cloudifysource.clouds.openstack.OpenstackProvisioningDriver"
managementMachineTemplate "SMALL_LINUX_32"
connectToPrivateIp true
}
view rawdriver.groovyThis Gist brought to you by GitHub.
打包并添加到Cloudify
最后, 打包你的cloud driver class, 并添加依赖的相应classes和resources。形成一个jar文件并放置到<cloudifyRoot>/lib/platform/esm
文件夹. 另外,放置你的cloud driver configuration文件各安全凭证到<cloudifyRoot>/tools/cli/plugins/esc
文件夹。
为了使cloud driver在你的云环境的机器中可用, 执行以下操作:
- 将你的cloud driver文件各Cloudify distribution文件一起共同重新打包。并将其保存到一个cloud maine可用的地方。
- 在已安装了Cloudify的机器中,编辑cloud driver configuration 文件, 在
provider
section, 指定cloudifyUrl
属性(Cloudify安装源)作为Cloudify distribution 文件的位置。当你启动你的cloud, Cloudify会使用本地的cloud driver configuration文件,并将它传递给 bootstrapped cloud 以供应machines.
Overrides
在cloud driver的“upload”目录可能包含一个可选的”cloudify-overrides”子目录.如果存在,这个orerrides目录的内容会被拷贝到Cloudify的安装目录。这允许cloud管理员重写指定的Cloudify文件。例如,一个特定的日志配置文件可以放置在“upload/cloudify-overrides/config/gs_logging.properties”。这gs_logging.properties 文件将被拷贝到management machine并且会重写默认的Cloudify日志配置。这个文件也会被拷贝到其它任何的template中使用相同upload目录的服务machine(如果是启动的)。