diff --git a/containers/docker/Dockerfile b/containers/docker/Dockerfile index 86157ab19..7f153f36e 100644 --- a/containers/docker/Dockerfile +++ b/containers/docker/Dockerfile @@ -43,7 +43,9 @@ RUN yum install -y \ oci==2.6.0 \ pyyaml==5.2 \ # Create Workspace - && mkdir -p /okit/{config,log,visualiser,okitweb,workspace} + && mkdir -p /okit/{config,log,visualiser,okitweb,workspace,templates} \ + && mkdir -p /okit/okitweb/static/okit/templates \ + && ln -s /okit/templates /okit/okitweb/static/okit/templates/user # Copy source code COPY okitweb /okit/okitweb COPY visualiser /okit/visualiser diff --git a/containers/docker/docker-compose.yml b/containers/docker/docker-compose.yml index ac4958f88..420c99f51 100644 --- a/containers/docker/docker-compose.yml +++ b/containers/docker/docker-compose.yml @@ -13,4 +13,6 @@ services: ports: - 443:443/tcp - 80:80/tcp + volumes: + - "~/okit/user/templates:/okit/templates" ... \ No newline at end of file diff --git a/containers/vagrant/Vagrantfile b/containers/vagrant/Vagrantfile index c2290b876..e54ce081c 100644 --- a/containers/vagrant/Vagrantfile +++ b/containers/vagrant/Vagrantfile @@ -33,6 +33,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Disable Audio to prevent CPU spikes v.customize ["modifyvm", :id, "--audio", "none"] end + # This will expose the local OKIT Template folder within the VM + config.vm.synced_folder "~/okit/user/templates", "/okit/templates" # VM hostname config.vm.hostname = NAME diff --git a/documentation/Installation.md b/documentation/Installation.md index 714ff8b60..f0dda5c82 100644 --- a/documentation/Installation.md +++ b/documentation/Installation.md @@ -103,6 +103,7 @@ cd oci-designer-toolkit docker run -d --rm -p 443:443 -p 80:80 \ --name okit \ --hostname okit \ + --volume ~/okit/user/templates:/okit/templates \ okit ``` diff --git a/documentation/Usage.md b/documentation/Usage.md index d4079608f..a0140fe1b 100644 --- a/documentation/Usage.md +++ b/documentation/Usage.md @@ -56,6 +56,7 @@ cd oci-designer-toolkit docker run -d --rm -p 443:443 -p 80:80 \ --name okit \ --hostname okit \ + --volume ~/okit/user/templates:/okit/templates \ okit ``` The __/containers/scripts__ contains helper scripts for Linux/Mac and Windows PowerShell. diff --git a/okitweb/okitOci.py b/okitweb/okitOci.py index e146a06da..398f8c9a7 100644 --- a/okitweb/okitOci.py +++ b/okitweb/okitOci.py @@ -38,6 +38,7 @@ from facades.ociFileStorageSystems import OCIFileStorageSystems from facades.ociImage import OCIImages from facades.ociInstance import OCIInstances +from facades.ociInstancePool import OCIInstancePools from facades.ociInternetGateway import OCIInternetGateways from facades.ociLoadBalancer import OCILoadBalancers from facades.ociLocalPeeringGateway import OCILocalPeeringGateways @@ -229,6 +230,10 @@ def ociArtifacts(artifact): logger.info('---- Processing Instances') oci_instances = OCIInstances(config=config, profile=config_profile, compartment_id=query_json['compartment_id']) response_json = oci_instances.list(filter=query_json.get('instance_filter', None)) + elif artifact == 'InstancePool': + logger.info('---- Processing Instance Pools') + oci_instance_pools = OCIInstancePools(config=config, profile=config_profile, compartment_id=query_json['compartment_id']) + response_json = oci_instance_pools.list(filter=query_json.get('instance_filter', None)) elif artifact == 'InternetGateway': logger.info('---- Processing Internet Gateways') oci_internet_gateways = OCIInternetGateways(config=config, profile=config_profile, compartment_id=query_json['compartment_id'], vcn_id=query_json['vcn_id']) diff --git a/okitweb/static/okit/fragments/json/bastion_server.json b/okitweb/static/okit/fragments/json/bastion_server.json index 6cb2869b3..e4666e245 100644 --- a/okitweb/static/okit/fragments/json/bastion_server.json +++ b/okitweb/static/okit/fragments/json/bastion_server.json @@ -44,7 +44,7 @@ ], "source_details": { "os": "Oracle Linux", - "version": "7.7", + "version": "", "boot_volume_size_in_gbs": "50", "source_type": "image" }, diff --git a/okitweb/static/okit/fragments/json/load_balanced_nginx.json b/okitweb/static/okit/fragments/json/load_balanced_nginx.json index b0ea42341..6119ea39e 100644 --- a/okitweb/static/okit/fragments/json/load_balanced_nginx.json +++ b/okitweb/static/okit/fragments/json/load_balanced_nginx.json @@ -44,7 +44,7 @@ ], "source_details": { "os": "Oracle Linux", - "version": "7.7", + "version": "", "boot_volume_size_in_gbs": "50", "source_type": "image" }, @@ -93,7 +93,7 @@ ], "source_details": { "os": "Oracle Linux", - "version": "7.7", + "version": "", "boot_volume_size_in_gbs": "50", "source_type": "image" }, @@ -142,7 +142,7 @@ ], "source_details": { "os": "Oracle Linux", - "version": "7.7", + "version": "", "boot_volume_size_in_gbs": "50", "source_type": "image" }, @@ -191,7 +191,7 @@ ], "source_details": { "os": "Oracle Linux", - "version": "7.7", + "version": "", "boot_volume_size_in_gbs": "50", "source_type": "image" }, diff --git a/okitweb/static/okit/js/okit_designer.js b/okitweb/static/okit/js/okit_designer.js index 43a74ef5d..2b6538e83 100644 --- a/okitweb/static/okit/js/okit_designer.js +++ b/okitweb/static/okit/js/okit_designer.js @@ -194,6 +194,7 @@ function handleSaveAs(evt) { .attr('id', 'save_as_template_table') .attr('class', 'table okit-table okit-modal-dialog-table'); let tbody = table.append('div').attr('class', 'tbody'); + // Title let tr = tbody.append('div').attr('class', 'tr'); tr.append('div').attr('class', 'td').text('Title'); tr.append('div').attr('class', 'td').append('input') @@ -201,6 +202,7 @@ function handleSaveAs(evt) { .attr('id', 'template_title') .attr('name', 'template_title') .attr('type', 'text'); + // Description tr = tbody.append('div').attr('class', 'tr'); tr.append('div').attr('class', 'td').text('Description'); tr.append('div').attr('class', 'td').append('input') @@ -208,6 +210,8 @@ function handleSaveAs(evt) { .attr('id', 'template_description') .attr('name', 'template_description') .attr('type', 'text'); + // Type + /* TODO: Reinstate when sub template types are implemented tr = tbody.append('div').attr('class', 'tr'); tr.append('div').attr('class', 'td').text('Type'); tr.append('div').attr('class', 'td').append('input') @@ -215,6 +219,8 @@ function handleSaveAs(evt) { .attr('id', 'template_type') .attr('name', 'template_type') .attr('type', 'text'); + */ + // Save let save_button = d3.select(d3Id('modal_dialog_footer')).append('div').append('button') .attr('id', 'save_as_button') .attr('type', 'button') @@ -225,7 +231,8 @@ function handleSaveAs(evt) { function handleSaveAsTemplate(e) { okitJsonModel.title = $(jqId('template_title')).val(); okitJsonModel.description = $(jqId('template_description')).val(); - okitJsonModel.template_type = $(jqId('template_type')).val(); + //okitJsonModel.template_type = $(jqId('template_type')).val(); + okitJsonModel.template_type = 'User'; $.ajax({ type: 'post', url: 'saveas/template', diff --git a/okitweb/static/okit/js/okit_designer_properties.js b/okitweb/static/okit/js/okit_designer_properties.js index 7f3742b66..f8ef04fc3 100644 --- a/okitweb/static/okit/js/okit_designer_properties.js +++ b/okitweb/static/okit/js/okit_designer_properties.js @@ -89,6 +89,7 @@ function loadPropertiesSheet(json_element) { $(jqId(key)).find("input:checkbox").each(function() { if ($(this).prop('checked')) {json_element[key].push($(this).val());} }); + redrawSVGCanvas(); }); if (val.includes($(this).val())) {$(this).prop("checked", true);} }); diff --git a/okitweb/static/okit/json/dropdown.json b/okitweb/static/okit/json/dropdown.json index e4779405f..62f101a41 100644 --- a/okitweb/static/okit/json/dropdown.json +++ b/okitweb/static/okit/json/dropdown.json @@ -593,9 +593,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-16.04-Gen2-GPU-2020.05.20-0", + "display_name": "Canonical-Ubuntu-16.04-GPU-2020.08.26-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaalvh6kr662y336bpie6ejv3drvfgzgoah4pbddl4vtzjmjs5mu3fq", + "id": "ocid1.image.oc1.phx.aaaaaaaaxpucjbl7qexlbxnzdk6bwjcj2hgbw2sk5jmhssnm5xzb5wzolfia", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -611,7 +611,7 @@ "shapes": [], "size_in_mbs": 47694, "sort_key": "Canonical Ubuntu 16.04", - "time_created": "2020-05-28T23:06:37.873000+00:00" + "time_created": "2020-09-01T19:26:06.498000+00:00" }, { "agent_features": null, @@ -639,6 +639,32 @@ "sort_key": "Canonical Ubuntu 16.04", "time_created": "2020-07-22T20:24:11.371000+00:00" }, + { + "agent_features": null, + "base_image_id": null, + "compartment_id": null, + "create_image_allowed": true, + "defined_tags": {}, + "display_name": "Canonical-Ubuntu-16.04-2020.08.22-0", + "freeform_tags": {}, + "id": "ocid1.image.oc1.phx.aaaaaaaaiwnf6fs4kepafusmchvrvm7g2fiv4rehk5hodkl24bcupk46s2ra", + "launch_mode": "NATIVE", + "launch_options": { + "boot_volume_type": "PARAVIRTUALIZED", + "firmware": "UEFI_64", + "is_consistent_volume_naming_enabled": true, + "is_pv_encryption_in_transit_enabled": true, + "network_type": "PARAVIRTUALIZED", + "remote_data_volume_type": "PARAVIRTUALIZED" + }, + "lifecycle_state": "AVAILABLE", + "operating_system": "Canonical Ubuntu", + "operating_system_version": "16.04", + "shapes": [], + "size_in_mbs": 47694, + "sort_key": "Canonical Ubuntu 16.04", + "time_created": "2020-09-01T18:53:54.900000+00:00" + }, { "agent_features": null, "base_image_id": null, @@ -697,9 +723,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-16.04-2020.05.14-0", + "display_name": "Canonical-Ubuntu-16.04-Minimal-2020.08.21-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaa2peprayqh5fdqlkq2dnggk6nfjs6zh5oovupqvdkkcagh6rtimjq", + "id": "ocid1.image.oc1.phx.aaaaaaaarou4zixzafitlt3deatqlerle2fxgdwmit4pcniinaqf3444scta", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -711,11 +737,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Canonical Ubuntu", - "operating_system_version": "16.04", + "operating_system_version": "16.04 Minimal", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 16.04", - "time_created": "2020-05-28T23:18:24.692000+00:00" + "sort_key": "Canonical Ubuntu 16.04 Minimal", + "time_created": "2020-09-01T19:26:11.531000+00:00" }, { "agent_features": null, @@ -775,9 +801,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-16.04-Minimal-2020.05.18-0", + "display_name": "Canonical-Ubuntu-18.04-2020.08.21-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaaz5xh626t6uchmdnx7gc3jqwghzpsa2acdd6txoqvg44ch7bfj3cq", + "id": "ocid1.image.oc1.phx.aaaaaaaamhfsprw4mmclsybts333m6qmnvj3t35czxe6iboxukx4butltr5q", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -789,11 +815,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Canonical Ubuntu", - "operating_system_version": "16.04 Minimal", + "operating_system_version": "18.04", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 16.04 Minimal", - "time_created": "2020-05-28T23:20:56.427000+00:00" + "sort_key": "Canonical Ubuntu 18.04", + "time_created": "2020-09-01T19:26:07.014000+00:00" }, { "agent_features": null, @@ -853,9 +879,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-18.04-2020.05.06-0", + "display_name": "Canonical-Ubuntu-18.04-Minimal-2020.08.25-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaakgt35lyfplkaitq2v23fj4ixoeu2vsfsazaemdwhailydl6wyiia", + "id": "ocid1.image.oc1.phx.aaaaaaaasit6dalhenmeijklokta5qg2ga62ycuxkugjpwwep6lsvjrycunq", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -867,11 +893,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Canonical Ubuntu", - "operating_system_version": "18.04", + "operating_system_version": "18.04 Minimal", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 18.04", - "time_created": "2020-05-28T23:05:40.949000+00:00" + "sort_key": "Canonical Ubuntu 18.04 Minimal", + "time_created": "2020-09-01T19:26:33.362000+00:00" }, { "agent_features": null, @@ -931,9 +957,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-18.04-Minimal-2020.05.20-0", + "display_name": "Canonical-Ubuntu-20.04-2020.08.21-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaafqdiu6rijxo6phdk3pnc5furdx7uhzi5ix5chfzcoi5fpvgpsctq", + "id": "ocid1.image.oc1.phx.aaaaaaaarkstoxktdg67crt7nwvtfw3mtxugfjp3pvqkcqbf5g3gwlvuoteq", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -945,11 +971,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Canonical Ubuntu", - "operating_system_version": "18.04 Minimal", + "operating_system_version": "20.04", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 18.04 Minimal", - "time_created": "2020-05-28T23:07:33.901000+00:00" + "sort_key": "Canonical Ubuntu 20.04", + "time_created": "2020-09-01T19:20:25.291000+00:00" }, { "agent_features": null, @@ -1009,9 +1035,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-20.04-2020.05.18-0", + "display_name": "Canonical-Ubuntu-20.04-Minimal-2020.08.24-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaarfsrzy573557mj4gcrl2ddhzba3s2sn2anwta5c4xeuwtp4oka5q", + "id": "ocid1.image.oc1.phx.aaaaaaaa5onv7ve7uxvdfianceufk3fzoi4emgbn74kritgdtwuezdscvmza", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -1023,11 +1049,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Canonical Ubuntu", - "operating_system_version": "20.04", + "operating_system_version": "20.04 Minimal", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 20.04", - "time_created": "2020-05-28T23:05:53.340000+00:00" + "sort_key": "Canonical Ubuntu 20.04 Minimal", + "time_created": "2020-09-01T19:26:11.046000+00:00" }, { "agent_features": null, @@ -1087,9 +1113,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Canonical-Ubuntu-20.04-Minimal-2020.05.19-0", + "display_name": "CentOS-6.10-2020.08.25-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaabrsxasb7lpykfx5hzfss6n644ffx25m5ymy3najhoyebemfofsba", + "id": "ocid1.image.oc1.phx.aaaaaaaajsmivftoqhtadcipo43fwg4e5hqyoe5obacjbffn2f5ybkxpioga", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -1100,12 +1126,12 @@ "remote_data_volume_type": "PARAVIRTUALIZED" }, "lifecycle_state": "AVAILABLE", - "operating_system": "Canonical Ubuntu", - "operating_system_version": "20.04 Minimal", + "operating_system": "CentOS", + "operating_system_version": "6.10", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Canonical Ubuntu 20.04 Minimal", - "time_created": "2020-05-28T23:07:25.802000+00:00" + "sort_key": "CentOS 6.10", + "time_created": "2020-08-31T20:28:41.680000+00:00" }, { "agent_features": null, @@ -1165,9 +1191,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "CentOS-6.10-2020.05.21-0", + "display_name": "CentOS-7-2020.08.27-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaaqjlmsltxacd77mywgurt2iz3yv2rgacbhemhqmyjeian65k2fb3a", + "id": "ocid1.image.oc1.phx.aaaaaaaadjoixa3e3ma5mq7ycs5n7zd7xg2nlrs35n6eyce7w53mgmq5qiwa", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -1179,11 +1205,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "CentOS", - "operating_system_version": "6.10", + "operating_system_version": "7", "shapes": [], "size_in_mbs": 47694, - "sort_key": "CentOS 6.10", - "time_created": "2020-05-26T17:34:48.714000+00:00" + "sort_key": "CentOS 7", + "time_created": "2020-08-31T19:31:59.978000+00:00" }, { "agent_features": null, @@ -1237,32 +1263,6 @@ "sort_key": "CentOS 7", "time_created": "2020-06-19T16:31:02.199000+00:00" }, - { - "agent_features": null, - "base_image_id": null, - "compartment_id": null, - "create_image_allowed": true, - "defined_tags": {}, - "display_name": "CentOS-7-2020.05.20-0", - "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaauqugguwaackbg7rpg5fafqyttsbqhciglus5o47occm4ojvidb6q", - "launch_mode": "NATIVE", - "launch_options": { - "boot_volume_type": "PARAVIRTUALIZED", - "firmware": "UEFI_64", - "is_consistent_volume_naming_enabled": true, - "is_pv_encryption_in_transit_enabled": true, - "network_type": "PARAVIRTUALIZED", - "remote_data_volume_type": "PARAVIRTUALIZED" - }, - "lifecycle_state": "AVAILABLE", - "operating_system": "CentOS", - "operating_system_version": "7", - "shapes": [], - "size_in_mbs": 47694, - "sort_key": "CentOS 7", - "time_created": "2020-05-26T17:35:53.117000+00:00" - }, { "agent_features": null, "base_image_id": null, @@ -1419,6 +1419,32 @@ "sort_key": "Oracle Linux 6.10", "time_created": "2020-05-28T21:32:50.936000+00:00" }, + { + "agent_features": null, + "base_image_id": null, + "compartment_id": null, + "create_image_allowed": true, + "defined_tags": {}, + "display_name": "Oracle-Linux-7.8-Gen2-GPU-2020.08.27-0", + "freeform_tags": {}, + "id": "ocid1.image.oc1.phx.aaaaaaaaniwbhubt6dccgp6tkh3ybvxs3ygzdhflkdohohzafkb2xcw77hsa", + "launch_mode": "NATIVE", + "launch_options": { + "boot_volume_type": "PARAVIRTUALIZED", + "firmware": "UEFI_64", + "is_consistent_volume_naming_enabled": true, + "is_pv_encryption_in_transit_enabled": true, + "network_type": "PARAVIRTUALIZED", + "remote_data_volume_type": "PARAVIRTUALIZED" + }, + "lifecycle_state": "AVAILABLE", + "operating_system": "Oracle Linux", + "operating_system_version": "7.8", + "shapes": [], + "size_in_mbs": 47694, + "sort_key": "Oracle Linux 7.8", + "time_created": "2020-09-02T22:51:28.464000+00:00" + }, { "agent_features": null, "base_image_id": null, @@ -1503,9 +1529,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Oracle-Linux-7.8-Gen2-GPU-2020.05.26-0", + "display_name": "Oracle-Linux-7.8-2020.08.26-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaaxtjclfbjwrzyhednihub4ghns2l7zzoerc5ffhklahvs7k5lrbgq", + "id": "ocid1.image.oc1.phx.aaaaaaaalj7pqrxkq7qad4m7i6umvfz3lffkugaapwfllfuhaw33nqp2ed4a", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -1521,7 +1547,7 @@ "shapes": [], "size_in_mbs": 47694, "sort_key": "Oracle Linux 7.8", - "time_created": "2020-05-28T22:53:17.377000+00:00" + "time_created": "2020-09-02T22:51:26.413000+00:00" }, { "agent_features": null, @@ -1633,9 +1659,9 @@ "compartment_id": null, "create_image_allowed": true, "defined_tags": {}, - "display_name": "Oracle-Linux-7.8-2020.04.17-0", + "display_name": "Oracle-Linux-8.2-2020.08.27-0", "freeform_tags": {}, - "id": "ocid1.image.oc1.phx.aaaaaaaav3isrmykdh6r3dwicrdgpmfdv3fb3jydgh4zqpgm6yr5x3somuza", + "id": "ocid1.image.oc1.phx.aaaaaaaack6wlu7smv5rrk3lofsmzgnc2a42isfchpui555lewm2irlaj6gq", "launch_mode": "NATIVE", "launch_options": { "boot_volume_type": "PARAVIRTUALIZED", @@ -1647,11 +1673,11 @@ }, "lifecycle_state": "AVAILABLE", "operating_system": "Oracle Linux", - "operating_system_version": "7.8", + "operating_system_version": "8", "shapes": [], "size_in_mbs": 47694, - "sort_key": "Oracle Linux 7.8", - "time_created": "2020-04-20T23:27:33.912000+00:00" + "sort_key": "Oracle Linux 8", + "time_created": "2020-09-02T22:51:32.471000+00:00" }, { "agent_features": null, diff --git a/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js b/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js index b3a40f7ea..b856ee027 100644 --- a/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js +++ b/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js @@ -114,10 +114,20 @@ class AutonomousDatabaseView extends OkitDesignerArtefactView { } // Load Reference Ids // Network Security Groups - let network_security_groups_select = $(jqId('nsg_ids')); + this.loadNetworkSecurityGroups('nsg_ids', this.subnet_id); + /* + let network_security_groups_select = d3.select(d3Id('nsg_ids')); for (let network_security_group of okitJson.network_security_groups) { - network_security_groups_select.append($('
Cluster Name
-
Fault Domain
-
Network Security Groups
+
Fault Domain
+
+
+
+
+
Network Security Groups
{% endblock %} {% block optional_properties_block %}{% endblock %} diff --git a/okitweb/templates/okit/propertysheets/file_storage_system.html b/okitweb/templates/okit/propertysheets/file_storage_system.html index 42088a00c..d409e61cf 100644 --- a/okitweb/templates/okit/propertysheets/file_storage_system.html +++ b/okitweb/templates/okit/propertysheets/file_storage_system.html @@ -27,7 +27,7 @@
Hostname
-
Network Security Groups
+
Network Security Groups
Max FS Stat Bytes
Max FS Stat Files
diff --git a/okitweb/templates/okit/propertysheets/instance.html b/okitweb/templates/okit/propertysheets/instance.html index 061bbd43d..5419fc1e0 100644 --- a/okitweb/templates/okit/propertysheets/instance.html +++ b/okitweb/templates/okit/propertysheets/instance.html @@ -41,7 +41,7 @@
Hostname
-
Network Security Groups
+
Network Security Groups
diff --git a/okitweb/templates/okit/propertysheets/load_balancer.html b/okitweb/templates/okit/propertysheets/load_balancer.html index 3a0901d29..820d1331e 100644 --- a/okitweb/templates/okit/propertysheets/load_balancer.html +++ b/okitweb/templates/okit/propertysheets/load_balancer.html @@ -17,9 +17,9 @@ {% endblock %} {% block optional_properties_table_rows_block %} -
Backend Instances
+
Backend Instances
Private
-
Network Security Groups
+
Network Security Groups
IP Mode
Route Table
-
Security List
+
Security List
IPv6 CIDR
{% endblock %} diff --git a/visualiser/facades/ociAutoScalingConfiguration.py b/visualiser/facades/ociAutoScalingConfiguration.py new file mode 100644 index 000000000..3c1a0489d --- /dev/null +++ b/visualiser/facades/ociAutoScalingConfiguration.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + +# Copyright (c) 2020, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +"""Provide Module Description +""" + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +__author__ = ["Andrew Hopkinson (Oracle Cloud Solutions A-Team)"] +__version__ = "1.0.0" +__module__ = "ociAutoScalingConfigurations" +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# + + +import oci + +from common.okitLogging import getLogger +from facades.ociConnection import OCIAutoScalingConnection + +# Configure logging +logger = getLogger() + + +class OCIAutoScalingConfigurations(OCIAutoScalingConnection): + def __init__(self, config=None, configfile=None, profile=None, compartment_id=None): + self.compartment_id = compartment_id + self.auto_scaling_configurations_json = [] + self.auto_scaling_configurations_obj = [] + super(OCIAutoScalingConfigurations, self).__init__(config=config, configfile=configfile, profile=profile) + + def list(self, compartment_id=None, filter=None): + if compartment_id is None: + compartment_id = self.compartment_id + + # Add filter to only return AVAILABLE Compartments + if filter is None: + filter = {} + + if 'lifecycle_state' not in filter: + filter['lifecycle_state'] = 'AVAILABLE' + + auto_scaling_configurations = oci.pagination.list_call_get_all_results(self.client.list_auto_scaling_configurations, compartment_id=compartment_id).data + + # Convert to Json object + auto_scaling_configurations_json = self.toJson(auto_scaling_configurations) + logger.debug(str(auto_scaling_configurations_json)) + + # Filter results + self.auto_scaling_configurations_json = self.filterJsonObjectList(auto_scaling_configurations_json, filter) + logger.debug(str(self.auto_scaling_configurations_json)) + + return self.auto_scaling_configurations_json + + +class OCIAutoScalingConfiguration(object): + def __init__(self, config=None, configfile=None, profile=None, data=None, **kwargs): + self.config = config + self.configfile = configfile + self.profile = profile + self.data = data + diff --git a/visualiser/facades/ociAutoScalingPolicies.py b/visualiser/facades/ociAutoScalingPolicies.py new file mode 100644 index 000000000..9be30723b --- /dev/null +++ b/visualiser/facades/ociAutoScalingPolicies.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + +# Copyright (c) 2020, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +"""Provide Module Description +""" + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +__author__ = ["Andrew Hopkinson (Oracle Cloud Solutions A-Team)"] +__version__ = "1.0.0" +__module__ = "ociAutoScalingPolicies" +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# + + +import oci + +from common.okitLogging import getLogger +from facades.ociConnection import OCIAutoScalingConnection + +# Configure logging +logger = getLogger() + + +class OCIAutoScalingPolicies(OCIAutoScalingConnection): + def __init__(self, config=None, configfile=None, profile=None, compartment_id=None): + self.compartment_id = compartment_id + self.auto_scaling_policies_json = [] + self.auto_scaling_policies_obj = [] + super(OCIAutoScalingPolicies, self).__init__(config=config, configfile=configfile, profile=profile) + + def list(self, compartment_id=None, filter=None): + if compartment_id is None: + compartment_id = self.compartment_id + + # Add filter to only return AVAILABLE Compartments + if filter is None: + filter = {} + + if 'lifecycle_state' not in filter: + filter['lifecycle_state'] = 'AVAILABLE' + + auto_scaling_policies = oci.pagination.list_call_get_all_results(self.client.list_auto_scaling_policies, compartment_id=compartment_id).data + + # Convert to Json object + auto_scaling_policies_json = self.toJson(auto_scaling_policies) + logger.debug(str(auto_scaling_policies_json)) + + # Filter results + self.auto_scaling_policies_json = self.filterJsonObjectList(auto_scaling_policies_json, filter) + logger.debug(str(self.auto_scaling_policies_json)) + + return self.auto_scaling_policies_json + + +class OCIAutoScalingPolicie(object): + def __init__(self, config=None, configfile=None, profile=None, data=None, **kwargs): + self.config = config + self.configfile = configfile + self.profile = profile + self.data = data + diff --git a/visualiser/facades/ociConnection.py b/visualiser/facades/ociConnection.py index d4b3c6f90..070787ce9 100644 --- a/visualiser/facades/ociConnection.py +++ b/visualiser/facades/ociConnection.py @@ -86,6 +86,15 @@ def filterJsonObjectList(self, json_list=[], filter={}): return json_list +class OCIAutoScalingConnection(OCIConnection): + def __init__(self, config=None, configfile=None, profile=None): + super(OCIAutoScalingConnection, self).__init__(config=config, configfile=configfile, profile=profile) + + def connect(self): + self.client = oci.autoscaling.AutoScalingClient(config=self.config, signer=self.signer) + return + + class OCIBlockStorageVolumeConnection(OCIConnection): def __init__(self, config=None, configfile=None, profile=None): super(OCIBlockStorageVolumeConnection, self).__init__(config=config, configfile=configfile, profile=profile) @@ -104,6 +113,15 @@ def connect(self): return +class OCIComputeManagementConnection(OCIConnection): + def __init__(self, config=None, configfile=None, profile=None): + super(OCIComputeManagementConnection, self).__init__(config=config, configfile=configfile, profile=profile) + + def connect(self): + self.client = oci.core.ComputeManagementClient(config=self.config, signer=self.signer) + return + + class OCIContainerConnection(OCIConnection): def __init__(self, config=None, configfile=None, profile=None): super(OCIContainerConnection, self).__init__(config=config, configfile=configfile, profile=profile) diff --git a/visualiser/facades/ociInstanceConfiguration.py b/visualiser/facades/ociInstanceConfiguration.py new file mode 100644 index 000000000..279c87693 --- /dev/null +++ b/visualiser/facades/ociInstanceConfiguration.py @@ -0,0 +1,75 @@ +#!/usr/bin/python + +# Copyright (c) 2020, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +"""Provide Module Description +""" + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +__author__ = ["Andrew Hopkinson (Oracle Cloud Solutions A-Team)"] +__version__ = "1.0.0" +__module__ = "ociInstanceConfigurations" +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# + + +import oci + +from common.okitLogging import getLogger +from common.okitCommon import logJson +from facades.ociConnection import OCIComputeManagementConnection + +# Configure logging +logger = getLogger() + + +class OCIInstanceConfigurations(OCIComputeManagementConnection): + def __init__(self, config=None, configfile=None, profile=None, compartment_id=None): + self.compartment_id = compartment_id + self.instance_configurations_json = [] + self.instance_configurations_obj = [] + super(OCIInstanceConfigurations, self).__init__(config=config, configfile=configfile, profile=profile) + + def get(self, instance_configuration_id=None): + try: + instance_configuration = self.client.get_instance_configuration(instance_configuration_id=instance_configuration_id).data + logger.debug(str(instance_configuration)) + # Convert to Json object + instance_configuration_json = self.toJson(instance_configuration) + logJson(instance_configuration_json) + return instance_configuration_json + except oci.exceptions.ServiceError as e: + logger.exception(e) + return {} + + def list(self, compartment_id=None, filter=None): + if compartment_id is None: + compartment_id = self.compartment_id + + # Add filter to only return AVAILABLE Compartments + if filter is None: + filter = {} + + if 'lifecycle_state' not in filter: + filter['lifecycle_state'] = 'AVAILABLE' + + instance_configurations = oci.pagination.list_call_get_all_results(self.client.list_instance_configurations, compartment_id=compartment_id).data + + # Convert to Json object + instance_configurations_json = self.toJson(instance_configurations) + logger.debug(str(instance_configurations_json)) + + # Filter results + self.instance_configurations_json = self.filterJsonObjectList(instance_configurations_json, filter) + logger.debug(str(self.instance_configurations_json)) + + return self.instance_configurations_json + + +class OCIInstanceConfiguration(object): + def __init__(self, config=None, configfile=None, profile=None, data=None, **kwargs): + self.config = config + self.configfile = configfile + self.profile = profile + self.data = data + diff --git a/visualiser/facades/ociInstancePool.py b/visualiser/facades/ociInstancePool.py new file mode 100644 index 000000000..37e46aeee --- /dev/null +++ b/visualiser/facades/ociInstancePool.py @@ -0,0 +1,82 @@ +#!/usr/bin/python + +# Copyright (c) 2020, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +"""Provide Module Description +""" + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +__author__ = ["Andrew Hopkinson (Oracle Cloud Solutions A-Team)"] +__version__ = "1.0.0" +__module__ = "ociInstancePools" +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# + + +import oci + +from common.okitLogging import getLogger +from common.okitCommon import logJson +from facades.ociConnection import OCIComputeManagementConnection +from facades.ociInstanceConfiguration import OCIInstanceConfigurations + +# Configure logging +logger = getLogger() + + +class OCIInstancePools(OCIComputeManagementConnection): + def __init__(self, config=None, configfile=None, profile=None, compartment_id=None): + self.compartment_id = compartment_id + self.instance_pools_json = [] + self.instance_pools_obj = [] + super(OCIInstancePools, self).__init__(config=config, configfile=configfile, profile=profile) + + def get(self, instance_pool_id=None): + try: + instance_pool = self.client.get_instance_pool(instance_pool_id=instance_pool_id).data + logger.debug(str(instance_pool)) + # Convert to Json object + instance_pool_json = self.toJson(instance_pool) + logJson(instance_pool_json) + return instance_pool_json + except oci.exceptions.ServiceError as e: + logger.exception(e) + return {} + + def list(self, compartment_id=None, filter=None): + if compartment_id is None: + compartment_id = self.compartment_id + + # Add filter to only return AVAILABLE Compartments + if filter is None: + filter = {} + + if 'lifecycle_state' not in filter: + filter['lifecycle_state'] = 'RUNNING' + + instance_pools = oci.pagination.list_call_get_all_results(self.client.list_instance_pools, compartment_id=compartment_id).data + + # Convert to Json object + instance_pools_json = self.toJson(instance_pools) + logger.debug(str(instance_pools_json)) + + # Filter results + self.instance_pools_json = self.filterJsonObjectList(instance_pools_json, filter) + logger.debug(str(self.instance_pools_json)) + + # Instance Configuration + oci_instance_configurations = OCIInstanceConfigurations(config=self.config, configfile=self.configfile, profile=self.profile) + for instance_pool in self.instance_pools_json: + instance_pool.update(self.get(instance_pool["id"])) + instance_pool["instance_configuration"] = oci_instance_configurations.get(instance_pool["instance_configuration_id"]) + + return self.instance_pools_json + + +class OCIInstancePool(object): + def __init__(self, config=None, configfile=None, profile=None, data=None, **kwargs): + self.config = config + self.configfile = configfile + self.profile = profile + self.data = data + diff --git a/visualiser/templates/terraform/instance_pool.jinja2 b/visualiser/templates/terraform/instance_pool.jinja2 new file mode 100644 index 000000000..ab572587a --- /dev/null +++ b/visualiser/templates/terraform/instance_pool.jinja2 @@ -0,0 +1,151 @@ + +# ------ Create Instance Pool +# ------- Instance Configuration +resource "oci_core_instance_configuration" "{{ resource_name }}Config" { + # Required + compartment_id = {{ compartment_id }} + + # Optional + display_name = {{ display_name | safe }} +{% if instance_details is defined %} + instance_details { + # Required + instance_type = {{ instance_details.instance_type | safe }} + } +{% endif %} + +{% if defined_tags is defined %} + defined_tags = {{ defined_tags | safe }} +{% endif %} +{% if freeform_tags is defined %} + freeform_tags = {{ freeform_tags | safe }} +{% endif %} +} + +locals { + {{ resource_name }}Config_id = oci_core_instance.{{ resource_name }}Config.id +} + +# ------- Instance Pool +resource "oci_core_instance_pool" "{{ resource_name }}" { + # Required + compartment_id = {{ compartment_id }} + instance_configuration_id = local.{{ resource_name }}Config_id + display_name = {{ display_name | safe }} +{% for placement_configuration in placement_configurations %} + placement_configurations { + #Required + availability_domain = lookup(data.oci_identity_availability_domains.AvailabilityDomains.availability_domains[{{ availability_domain.placement_configuration | safe }} - 1], "name") + primary_subnet_id = {{ placement_configuration.primary_subnet_id }} + #Optional +{% if placement_configuration.fault_domains is defioned %} + fault_domains = [{% for fd in placement_configuration.fault_domains %}{{ fd }}{% if not loop.last %},{% endif %}{% endfor %}] +{% endif %} +{% if placement_configuration.secondary_vnic_subnets is defioned %} + {% for vinc in placement_configuration.secondary_vnic_subnets %} + secondary_vnic_subnets { + #Required + subnet_id = {{ vnic.subnet_id | safe }} + #Optional + display_name = {{ display_name | safe }} + } + {% endfor %} +{% endif %} + } +{ + size = {{ size }} + # Optional +{% if load_balancers is defined %} + {% for load_balancer in load_balancers %} + load_balancers { + #Required + backend_set_name = {{ load_balancer.backend_set_name | safe }} + load_balancer_id = {{ load_balancer.load_balancer_id | safe }} + port = {{ load_balancer.port | safe }} + vnic_selection = {{ load_balancer.vnic_selection | safe }} + } + {% endfor %} +{% endif %} +{% if defined_tags is defined %} + defined_tags = {{ defined_tags | safe }} +{% endif %} +{% if freeform_tags is defined %} + freeform_tags = {{ freeform_tags | safe }} +{% endif %} +} + +locals { + {{ resource_name }}_id = oci_core_instance.{{ resource_name }}.id +} + +# ------- Auto Scaling +resource "oci_autoscaling_auto_scaling_configuration" "{{ resource_name }}AutoScaling" { + # Required + compartment_id = {{ compartment_id }} + auto_scaling_resources { + #Required + id = local.{{ resource_name }}_id + type = "instancePool" + } + policies { + # Required + capacity { + #Optional +{% if policies.capacity.initial is defined %} + initial = {{ policies.capacity.initial | safe }} +{% endif %} +{% if policies.capacity.max is defined %} + max = {{ policies.capacity.max | safe }} +{% endif %} +{% if policies.capacity.min is defined %} + min = {{ policies.capacity.min | safe }} +{% endif %} + } + policy_type = {{ policies.policy_type | safe }} + + #Optional + display_name = {{ display_name | safe }} +{% if policies.execution_schedule is defined %} + execution_schedule { + #Required + expression = {{ policies.execution_schedule.expression | safe }} + timezone = {{ policies.execution_schedule.timezone | safe }} + type = {{ policies.execution_schedule.type | safe }} + } +{% endif %} +{% if policies.is_enabled is defined %} + is_enabled = {{ policies.is_enabled | safe }} +{% endif %} +{% if policies.rules is defined %} + {% for rule in policies.rules %} + rules { + #Optional + action { + #Optional + type = {{ rule.type | safe }} + value = {{ rule.value | safe }} + } + display_name = {{ display_name | safe }} + metric { + #Optional + metric_type = {{ rule.metric.metric_type }} + threshold { + #Optional + operator = {{ rule.metric.threshold.operator }} + value = {{ rule.metric.threshold.operator }} + } + } + } + {% endfor %} +{% endif %} + } + # Optional + display_name = {{ display_name | safe }} + +{% if defined_tags is defined %} + defined_tags = {{ defined_tags | safe }} +{% endif %} +{% if freeform_tags is defined %} + freeform_tags = {{ freeform_tags | safe }} +{% endif %} +}