Skip to content

Commit

Permalink
ovirt: optionally use a different logical network for instances
Browse files Browse the repository at this point in the history
Motivation
Some installatino may want to use different network to segregate the
installation VMs from other existing workloads and/or to make use of
specific network which are not 'management' network, that has traffic
dedicated to the workload.

Change
installconfig has an optional ovirt_network_name and should be an
existing network name for the selected ovirt_cluster_id.
The default value is 'ovirtmgmt' which is the default network for any
ovirt cluster.

Note: because of lack of support from the terraform provider I had to
use the network name and not ID.

Signed-off-by: Roy Golan <rgolan@redhat.com>
  • Loading branch information
rgolangh committed Jan 9, 2020
1 parent a777d60 commit d77c58a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions data/data/ovirt/main.tf
Expand Up @@ -15,6 +15,7 @@ module "template" {
ovirt_template_cpu = var.ovirt_template_cpu
ovirt_template_mem = var.ovirt_template_mem
disk_size_gib = var.ovirt_template_disk_size_gib
ovirt_network_name = var.ovirt_network_name
}

module "bootstrap" {
Expand Down
6 changes: 3 additions & 3 deletions data/data/ovirt/template/main.tf
Expand Up @@ -22,9 +22,9 @@ data "ovirt_clusters" "clusters" {
}
}

// default vnic profile of ovirtmgmt
// default vnic profile of ovirt's cluster network
data "ovirt_vnic_profiles" "vnic_profiles" {
name_regex = "ovirtmgmt"
name_regex = var.ovirt_network_name
network_id = local.network_id
}

Expand All @@ -34,7 +34,7 @@ locals {
existing_id = [for t in data.ovirt_templates.osImage.templates : t.id if substr(t.name, 0, 5) != "Blank"]
// if we don't find the cluster this should fail
cluster = [for c in data.ovirt_clusters.clusters.clusters : c if c.id == var.ovirt_cluster_id][0]
network_id = [for n in local.cluster.networks : n.id if n.name == "ovirtmgmt"][0]
network_id = [for n in local.cluster.networks : n.id if n.name == var.ovirt_network_name][0]
}

// upload the disk if we don't have an existing template
Expand Down
6 changes: 6 additions & 0 deletions data/data/ovirt/template/variables.tf
Expand Up @@ -28,6 +28,12 @@ variable "openstack_base_image_local_file_path" {
description = "Local file path of the base image file to use for the nodes."
}

variable "ovirt_network_name" {
type = string
default = "ovirtmgmt"
description = "The name of ovirt's logical network for the selected ovirt cluster."
}

variable "ovirt_template_mem" {
type = string
}
Expand Down
6 changes: 6 additions & 0 deletions data/data/ovirt/variables-ovirt.tf
Expand Up @@ -40,6 +40,12 @@ variable "openstack_base_image_local_file_path" {
description = "Local file path of the base image file to use for the nodes."
}

variable "ovirt_network_name" {
type = string
default = "ovirtmgmt"
description = "The name of ovirt's logical network for the selected ovirt cluster."
}

variable "ovirt_master_mem" {
type = string
default = "8192"
Expand Down
1 change: 1 addition & 0 deletions pkg/asset/cluster/tfvars.go
Expand Up @@ -376,6 +376,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
config.CAFile,
installConfig.Config.Platform.Ovirt.ClusterID,
installConfig.Config.Platform.Ovirt.StorageDomainID,
installConfig.Config.Platform.Ovirt.NetworkName,
string(*rhcosImage),
clusterID.InfraID,
)
Expand Down
15 changes: 9 additions & 6 deletions pkg/tfvars/ovirt/ovirt.go
Expand Up @@ -15,6 +15,7 @@ type config struct {
Cafile string `json:"ovirt_cafile,omitempty"`
ClusterID string `json:"ovirt_cluster_id"`
StorageDomainID string `json:"ovirt_storage_domain_id"`
NetworkName string `json:"ovirt_network_name,omitempty"`
BaseImageName string `json:"openstack_base_image_name,omitempty"`
BaseImageLocalFilePath string `json:"openstack_base_image_local_file_path,omitempty"`
}
Expand All @@ -27,17 +28,19 @@ func TFVars(
engineCafile string,
clusterID string,
stoarageDomainID string,
networkName string,
baseImage string,
infraID string) ([]byte, error) {

cfg := config{
URL: engineURL,
Username: engineUser,
Password: enginePass,
Cafile: engineCafile,
ClusterID: clusterID,
URL: engineURL,
Username: engineUser,
Password: enginePass,
Cafile: engineCafile,
ClusterID: clusterID,
StorageDomainID: stoarageDomainID,
BaseImageName: baseImage,
NetworkName: networkName,
BaseImageName: baseImage,
}

imageName, isURL := rhcos.GenerateOpenStackImageName(baseImage, infraID)
Expand Down
3 changes: 3 additions & 0 deletions pkg/types/ovirt/platform.go
Expand Up @@ -7,6 +7,9 @@ type Platform struct {
ClusterID string `json:"ovirt_cluster_id"`
// The target storage domain under which all VM disk would be created.
StorageDomainID string `json:"ovirt_storage_domain_id"`
// The target network of all the network interfaces of the nodes. Omitting defaults to ovirtmgmt
// network which is a default network for evert ovirt cluster.
NetworkName string `json:"ovirt_network_name,omitempty"`
// APIVIP is an IP which will be served by bootstrap and then pivoted masters, using keepalived
APIVIP string `json:"api_vip"`
// DNSVIP is the IP of the internal DNS which will be operated by the cluster
Expand Down

0 comments on commit d77c58a

Please sign in to comment.