Commit 264ef456 authored by 许湘南's avatar 许湘南
Browse files

华三云module封装

No related merge requests found
Showing with 672 additions and 2 deletions
+672 -2
# terraform-cloudoscas-ecs-instance
terraform-cloudoscas-modules
============
供服务目录使用的华三云资源创建 module
华三CAS创建虚拟机实例Module
\ No newline at end of file
- modules 目录下为 bases module 和 instance module
\ No newline at end of file
resource "cloudoscas_instance" "this" {
count = var.instance_count
tmp_id = var.tmp_id
title = element(split(",", var.title), count.index)
target_host_id = var.target_host_id
target_cluster_id = var.target_cluster_id
sys_name = element(split(",", var.sys_name), count.index)
storage_src = var.storage_src
storage_dest = element(split(",", var.storage_dest), count.index)
storage_pool = var.storage_pool
#可选参数
power_off_compute = var.power_off_compute
start_compute = var.start_compute
uselocal_storage_flag = var.uselocal_storage_flag
deploy_mode = var.deploy_mode
protect_mode = var.protect_mode
deploy_type = var.deploy_type
disk_format = var.disk_format
login_account = var.osinfo_login_account
login_password = var.osinfo_login_password
init_type = var.osinfo_init_type
desc = var.desc
cpu_socket = var.cpu_socket
cpu_cores = var.cpu_cores
cpu_shares = var.cpu_shares
memory_size = var.memory_size
memory_init = var.memory_init
memory_unit = var.memory_unit
network_mac = var.network_mac
network_vs_name = var.network_vs_name
network_ip = element(split(",", var.network_ip), count.index)
network_profile_name = var.network_profile_name
network_sys_mask = var.network_sys_mask
network_sys_ip_type = var.network_sys_ip_type
}
resource "cloudoscas_disk" "test" {
count = var.disk_count
vm_id = cloudoscas_instance.foo[ element([for key,value in var.vm_disk_count : key if contains(value,count.index + 1 )],0) - 1 ].vm_id
read_bytes_sec = var.read_bytes_sec
write_bytes_sec = var.write_bytes_sec
read_iops_sec = var.read_iops_sec
write_iops_sec = var.write_iops_sec
size = element(split(",", var.size), count.index)
#可选参数
target_bus = element(split(",", var.target_bus), count.index)
device = var.device
file_type = var.file_type
mode = var.mode
format = var.format
path_type = var.path_type
cache_type = var.cache_type
hot_pluggable = var.hot_pluggable
disk_mode = var.disk_mode
io_threads = var.io_threads
l2_cache = var.l2_cache
}
\ No newline at end of file
output "instance_name" {
description = "实例名称"
value = cloudoscas_instance.this.sys_name
}
output "public_ip" {
description = "公网IP"
value = cloudoscas_instance.this.network_ip
}
\ No newline at end of file
variable "tmp_id" {
description = "模版id"
type = number
}
variable "title" {
description = "部署虚拟机显示名称"
type = string
}
variable "target_host_id" {
description = "目标主机id"
type = string
}
variable "target_cluster_id" {
description = "目标集群id"
type = number
}
variable "sys_name" {
description = "主机名称"
type = string
}
variable "storage_src" {
description = "源存储文件"
type = string
}
variable "storage_dest" {
description = "目的存储文件"
type = string
}
variable "storage_pool" {
description = "目的存储池"
type = string
}
variable "power_off_compute" {
description = "虚拟机关闭电源"
type = bool
}
variable "start_compute" {
description = "虚拟机启动"
type = bool
}
variable "uselocal_storage_flag" {
description = "是否允许使用本地存储"
type = number
}
variable "deploy_mode" {
description = "部署模式 1:快速部署,0:正常部署"
type = number
}
variable "protect_mode" {
description = "1:保护模式,0:非保护模式"
type = number
}
variable "deploy_type" {
description = "部署类型 1:表示从模板列表中部署,2:表示从组织内部署"
type = number
}
variable "disk_format" {
description = "磁盘格式raw,qcow2"
type = string
}
variable "osinfo_login_account" {
description = "虚拟机登陆账号"
type = string
}
variable "osinfo_login_password" {
description = "虚拟机登陆密码"
type = string
}
variable "osinfo_init_type" {
description = "虚拟机初始化类型 0:快速初始化,1:全部初始化"
type = string
}
variable "desc" {
description = "部署虚拟机的描述"
type = string
}
variable "cpu_socket" {
description = "cpu socket"
type = number
}
variable "cpu_cores" {
description = "cpu 核心数"
type = number
}
variable "cpu_shares" {
description = "cpu shares"
type = number
}
variable "memory_size" {
description = "内存大小"
type = number
}
variable "memory_init" {
description = "内存初始化大小"
type = number
}
variable "memory_unit" {
description = "内存单位"
type = string
}
variable "network_mac" {
description = "network mac地址"
type = string
}
variable "network_vs_name" {
description = "network vswitch 名称"
type = string
}
variable "network_ip" {
description = "network ip"
type = string
}
variable "network_profile_name" {
description = "network profile 名称"
type = string
}
variable "network_sys_mask" {
description = "network sys 掩码"
type = string
}
variable "network_sys_ip_type" {
description = "network sys ip 类型"
type = number
}
variable "read_bytes_sec" {
description = "限制I/O速率,读,单位KB/s"
type = string
}
variable "write_bytes_sec" {
description = "限制I/O速率,写,单位KB/s"
type = string
}
variable "read_iops_sec" {
description = "限制IOPS,读"
type = string
}
variable "write_iops_sec" {
description = "限制IOPS,写"
type = string
}
variable "size" {
description = "分配存储容量"
type = string
}
variable "target_bus" {
description = "存储设备类型"
type = string
}
variable "device" {
description = "设备驱动类型"
type = string
}
variable "file_type" {
description = "存储卷类型"
type = string
}
variable "mode" {
description = "分配存储容量"
type = string
}
variable "format" {
description = "存储格式"
type = string
}
variable "path_type" {
description = "创建类型"
type = string
}
variable "cache_type" {
description = "磁盘缓存方式"
type = string
}
variable "hot_pluggable" {
description = "热拔"
type = string
}
variable "disk_mode" {
description = "磁盘模式"
type = string
}
variable "io_threads" {
description = "io threads"
type = string
}
variable "l2_cache" {
description = "cpu二级缓存(处理器)"
type = string
}
variable "instance_count" {
description = "虚机个数"
type = number
}
variable "disk_count" {
description = "磁盘个数"
type = number
}
variable "vm_disk_count" {
description = "每台虚机对应的挂载磁盘"
type = map
}
\ No newline at end of file
terraform {
required_providers {
cloudoscas = {
source = "idcos/cloudoscas"
}
}
}
\ No newline at end of file
module "instance" {
source = "../bases/instance"
count = var.instance_count
tmp_id = var.tmp_id
title = element(split(",", var.title), count.index)
target_host_id = var.target_host_id
target_cluster_id = var.target_cluster_id
sys_name = element(split(",", var.sys_name), count.index)
storage_src = var.storage_src
storage_dest = element(split(",", var.storage_dest), count.index)
storage_pool = var.storage_pool
#可选参数
power_off_compute = var.power_off_compute
start_compute = var.start_compute
uselocal_storage_flag = var.uselocal_storage_flag
deploy_mode = var.deploy_mode
protect_mode = var.protect_mode
deploy_type = var.deploy_type
disk_format = var.disk_format
login_account = var.osinfo_login_account
login_password = var.osinfo_login_password
init_type = var.osinfo_init_type
desc = var.desc
cpu_socket = var.cpu_socket
cpu_cores = var.cpu_cores
cpu_shares = var.cpu_shares
memory_size = var.memory_size
memory_init = var.memory_init
memory_unit = var.memory_unit
network_mac = var.network_mac
network_vs_name = var.network_vs_name
network_ip = element(split(",", var.network_ip), count.index)
network_profile_name = var.network_profile_name
network_sys_mask = var.network_sys_mask
network_sys_ip_type = var.network_sys_ip_type
disk_count = var.disk_count
read_bytes_sec = var.read_bytes_sec
write_bytes_sec = var.write_bytes_sec
read_iops_sec = var.read_iops_sec
write_iops_sec = var.write_iops_sec
size = element(split(",", var.size), count.index)
#可选参数
target_bus = element(split(",", var.target_bus), count.index)
device = var.device
file_type = var.file_type
mode = var.mode
format = var.format
path_type = var.path_type
cache_type = var.cache_type
hot_pluggable = var.hot_pluggable
disk_mode = var.disk_mode
io_threads = var.io_threads
l2_cache = var.l2_cache
}
\ No newline at end of file
output "instance" {
value = module.instance
}
\ No newline at end of file
variable "instance_count" {
description = "虚机个数"
type = number
}
variable "tmp_id" {
description = "模版id"
type = number
}
variable "title" {
description = "部署虚拟机显示名称"
type = string
}
variable "target_host_id" {
description = "目标主机id"
type = string
}
variable "target_cluster_id" {
description = "目标集群id"
type = number
}
variable "sys_name" {
description = "主机名称"
type = string
}
variable "storage_src" {
description = "源存储文件"
type = string
}
variable "storage_dest" {
description = "目的存储文件"
type = string
}
variable "storage_pool" {
description = "目的存储池"
type = string
}
variable "power_off_compute" {
description = "虚拟机关闭电源"
type = bool
default = false
}
variable "start_compute" {
description = "虚拟机启动"
type = bool
default = true
}
variable "uselocal_storage_flag" {
description = "是否允许使用本地存储"
type = number
default = 0
}
variable "deploy_mode" {
description = "部署模式 1:快速部署,0:正常部署"
type = number
default = 0
}
variable "protect_mode" {
description = "1:保护模式,0:非保护模式"
type = number
default = 0
}
variable "deploy_type" {
description = "部署类型 1:表示从模板列表中部署,2:表示从组织内部署"
type = number
default = 1
}
variable "disk_format" {
description = "磁盘格式raw,qcow2"
type = string
default = "raw"
}
variable "osinfo_login_account" {
description = "虚拟机登陆账号"
type = string
}
variable "osinfo_login_password" {
description = "虚拟机登陆密码"
type = string
}
variable "osinfo_init_type" {
description = "虚拟机初始化类型 0:快速初始化,1:全部初始化"
type = string
default = "0"
}
variable "desc" {
description = "部署虚拟机的描述"
type = string
default = "虚拟机描述"
}
variable "cpu_socket" {
description = "cpu socket"
type = number
default = 2
}
variable "cpu_cores" {
description = "cpu 核心数"
type = number
}
variable "cpu_shares" {
description = "cpu shares"
type = number
default = 512
}
variable "memory_size" {
description = "内存大小"
type = number
}
variable "memory_init" {
description = "内存初始化大小"
type = number
default = 2
}
variable "memory_unit" {
description = "内存单位"
type = string
default = "GB"
}
variable "network_mac" {
description = "network mac地址"
type = string
default = "0c:da:41:1d:2a:bb"
}
variable "network_vs_name" {
description = "network vswitch 名称"
type = string
default = "vswitch0"
}
variable "network_ip" {
description = "network ip"
type = string
}
variable "network_profile_name" {
description = "network profile 名称"
type = string
default = "Default"
}
variable "network_sys_mask" {
description = "network sys 掩码"
type = string
default = "255.255.255.0"
}
variable "network_sys_ip_type" {
description = "network sys ip 类型"
type = number
default = 2
}
variable "read_bytes_sec" {
description = "限制I/O速率,读,单位KB/s"
type = string
default = "13"
}
variable "write_bytes_sec" {
description = "限制I/O速率,写,单位KB/s"
type = string
default = "13"
}
variable "read_iops_sec" {
description = "限制IOPS,读"
type = string
default = "13"
}
variable "write_iops_sec" {
description = "限制IOPS,写"
type = string
default = "13"
}
variable "size" {
description = "分配存储容量"
type = string
}
variable "target_bus" {
description = "存储设备类型"
type = string
}
variable "device" {
description = "设备驱动类型"
type = string
default = "disk"
}
variable "file_type" {
description = "存储卷类型"
type = string
default = "file"
}
variable "mode" {
description = "分配存储容量"
type = string
default = "0"
}
variable "format" {
description = "存储格式"
type = string
default = "qcow2"
}
variable "path_type" {
description = "创建类型"
type = string
default = "2"
}
variable "cache_type" {
description = "磁盘缓存方式"
type = string
default = "directsync"
}
variable "hot_pluggable" {
description = "热拔"
type = string
default = "true"
}
variable "disk_mode" {
description = "磁盘模式"
type = string
default = "subordinate"
}
variable "io_threads" {
description = "io threads"
type = string
default = "true"
}
variable "l2_cache" {
description = "cpu二级缓存(处理器)"
type = string
default = "true"
}
variable "disk_count" {
description = "磁盘个数"
type = number
}
variable "vm_disk_count" {
description = "每台虚机对应的挂载磁盘"
type = map
}
\ No newline at end of file
terraform {
required_providers {
cloudoscas = {
source = "idcos/cloudoscas"
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment