-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved resource group creation to separate model - Added creation of VNET - Fixed env variables Azure with SP login - Fixed some typos
- Loading branch information
Showing
27 changed files
with
118 additions
and
45 deletions.
There are no files selected for viewing
37 changes: 36 additions & 1 deletion
37
core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,48 @@ | ||
from cli.helpers.Step import Step | ||
|
||
from cli.helpers.naming_helpers import resource_name | ||
from cli.helpers.doc_list_helpers import select_single, select_all | ||
from cli.helpers.doc_list_helpers import select_first | ||
from cli.helpers.data_loader import load_yaml_obj, types | ||
|
||
class InfrastructureBuilder(Step): | ||
def __init__(self, docs): | ||
super().__init__(__name__) | ||
self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') | ||
self.cluster_name = self.cluster_model.specification.name.lower() | ||
self.cluster_prefix = self.cluster_model.specification.prefix.lower() | ||
self.resource_group_name = resource_name(self.cluster_prefix, self.cluster_name, 'rg') | ||
self.region = self.cluster_model.specification.cloud.region | ||
self.docs = docs | ||
|
||
def run(self): | ||
infrastructure = [] | ||
|
||
resource_group = self.get_resource_group() | ||
infrastructure.append(resource_group) | ||
|
||
vnet = self.get_virtual_network() | ||
infrastructure.append(vnet) | ||
|
||
return infrastructure | ||
|
||
def get_resource_group(self): | ||
resource_group = self.get_config_or_default(self.docs, 'infrastructure/resource-group') | ||
resource_group.specification.name = self.resource_group_name | ||
resource_group.specification.region = self.cluster_model.specification.cloud.region | ||
return resource_group | ||
|
||
def get_virtual_network(self): | ||
vnet = self.get_config_or_default(self.docs, 'infrastructure/vnet') | ||
vnet.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'vnet') | ||
vnet.specification.address_space = self.cluster_model.specification.cloud.vnet_address_pool | ||
vnet.specification.resource_group_name = self.resource_group_name | ||
vnet.specification.location = self.cluster_model.specification.cloud.region | ||
return vnet | ||
|
||
@staticmethod | ||
def get_config_or_default(docs, kind): | ||
config = select_first(docs, lambda x: x.kind == kind) | ||
if config is None: | ||
return load_yaml_obj(types.DEFAULT, 'azure', kind) | ||
return config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/default-security-group.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/efs-storage.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/internet-gateway.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/launch-configuration.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/public-key.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/resource-group.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/route-table-association.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/route-table.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/security-group-rule.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/security-group.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/epicli/data/aws/terraform/infrastructure/virtual-machine.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
core/src/epicli/data/azure/defaults/infrastructure/network.yml
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
core/src/epicli/data/azure/defaults/infrastructure/resource-group.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
kind: infrastructure/resource-group | ||
version: 0.3.0 | ||
title: "Resource Group" | ||
provider: azure | ||
name: default | ||
specification: | ||
name: SET_BY_AUTOMATION | ||
region: SET_BY_AUTOMATION |
10 changes: 10 additions & 0 deletions
10
core/src/epicli/data/azure/defaults/infrastructure/vnet.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kind: infrastructure/vnet | ||
version: 0.3.0 | ||
title: "VNET Config" | ||
provider: azure | ||
name: default | ||
specification: | ||
name: SET_BY_AUTOMATION | ||
address_space: SET_BY_AUTOMATION | ||
location: SET_BY_AUTOMATION | ||
resource_group_name: SET_BY_AUTOMATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
core/src/epicli/data/azure/terraform/infrastructure/network.j2
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
core/src/epicli/data/azure/terraform/infrastructure/resource-group.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
##################################################### | ||
# DO NOT Modify by hand - Managed by Automation | ||
##################################################### | ||
##################################################### | ||
# This file can be used as a base template to build other Terraform files. It attempts to use as much | ||
# Terraform interprolation as possible by creating Terraform variables instead of changing inline | ||
# this approach provides an easier way to do creative looping, fetch IDs of created resources etc. | ||
##################################################### | ||
##################################################### | ||
# {{ specification.name }} | ||
##################################################### | ||
|
||
|
||
resource "azurerm_resource_group" "rg" { | ||
name = "{{ specification.name }}" | ||
location = "{{ specification.region }}" | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/epicli/data/azure/terraform/infrastructure/vnet.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
##################################################### | ||
# DO NOT Modify by hand - Managed by Automation | ||
##################################################### | ||
##################################################### | ||
# This file can be used as a base template to build other Terraform files. It attempts to use as much | ||
# Terraform interprolation as possible by creating Terraform variables instead of changing inline | ||
# this approach provides an easier way to do creative looping, fetch IDs of created resources etc. | ||
##################################################### | ||
##################################################### | ||
# {{ specification.name }} | ||
##################################################### | ||
|
||
resource "azurerm_virtual_network" "vnet" { | ||
name = "{{ specification.name }}" | ||
address_space = ["{{ specification.address_space }}"] | ||
location = "{{ specification.location }}" | ||
resource_group_name = "{{ specification.resource_group_name }}" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$ref: '#/definitions/unvalidated_specification' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters