From f8889650fa7e7bd3ca75587a1c5da70cc1cfe3f5 Mon Sep 17 00:00:00 2001 From: Andrew Hopkinson Date: Fri, 8 Oct 2021 16:28:13 +0100 Subject: [PATCH 1/7] Add alternative icon for Autonomous DW --- okitweb/static/okit/palette/palette.json | 5 +++++ ...essing-ATP.svg => AutonomousTransactionProcessingATP.svg} | 0 .../palette/svg/{NoSQL-Database.svg => NoSQLDatabase.svg} | 0 .../okit/view/designer/js/artefacts/autonomous_database.js | 1 + 4 files changed, 6 insertions(+) rename okitweb/static/okit/palette/svg/{Autonomous-Transaction-Processing-ATP.svg => AutonomousTransactionProcessingATP.svg} (100%) rename okitweb/static/okit/palette/svg/{NoSQL-Database.svg => NoSQLDatabase.svg} (100%) diff --git a/okitweb/static/okit/palette/palette.json b/okitweb/static/okit/palette/palette.json index 310b5a9e0..1077e763f 100644 --- a/okitweb/static/okit/palette/palette.json +++ b/okitweb/static/okit/palette/palette.json @@ -57,6 +57,11 @@ "targets": ["oci"], "svg": "MySQLDatabaseServiceMDS.svg" }, + { + "title": "Autonomous Data Warehouse Cloud Service", + "targets": ["hidden"], + "svg": "AutonomousDataWarehouseCloudService.svg" + }, { "title": "Exadata Database System", "targets": ["hidden"], diff --git a/okitweb/static/okit/palette/svg/Autonomous-Transaction-Processing-ATP.svg b/okitweb/static/okit/palette/svg/AutonomousTransactionProcessingATP.svg similarity index 100% rename from okitweb/static/okit/palette/svg/Autonomous-Transaction-Processing-ATP.svg rename to okitweb/static/okit/palette/svg/AutonomousTransactionProcessingATP.svg diff --git a/okitweb/static/okit/palette/svg/NoSQL-Database.svg b/okitweb/static/okit/palette/svg/NoSQLDatabase.svg similarity index 100% rename from okitweb/static/okit/palette/svg/NoSQL-Database.svg rename to okitweb/static/okit/palette/svg/NoSQLDatabase.svg 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 e57af310f..d0f07ec79 100644 --- a/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js +++ b/okitweb/static/okit/view/designer/js/artefacts/autonomous_database.js @@ -13,6 +13,7 @@ class AutonomousDatabaseView extends OkitDesignerArtefactView { } // -- Reference + get icon_definition_id() {return this.db_workload.startsWith('DW') ? OkitJsonView.toSvgIconDef('AutonomousDataWarehouseCloudService') : super.icon_definition_id;} get parent_id() { let subnet = this.getJsonView().getSubnet(this.artefact.subnet_id); if (subnet && subnet.compartment_id === this.artefact.compartment_id) { From 136dd53f6094a48afc6109891674ed64a32bd82c Mon Sep 17 00:00:00 2001 From: Stephen Cross Date: Wed, 13 Oct 2021 10:45:09 -0400 Subject: [PATCH 2/7] get full Bastion details --- visualiser/discovery/oci_discovery_client.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/visualiser/discovery/oci_discovery_client.py b/visualiser/discovery/oci_discovery_client.py index 239a500a9..c2048bd6d 100755 --- a/visualiser/discovery/oci_discovery_client.py +++ b/visualiser/discovery/oci_discovery_client.py @@ -20,6 +20,8 @@ class OciResourceDiscoveryClient(object): # methods. Creates a map of: # { resource_name -> (Client, list_method) } get_resource_client_methods = { + # oci.bastion.BastionClient + "BastionDetails": (oci.bastion.BastionClient, "get_bastion"), # used to get full details # oci.core.BlockstorageClient "VolumeBackupPolicyAssignment": (oci.core.BlockstorageClient, "get_volume_backup_policy_asset_assignment"), # oci.core.ComputeClient @@ -32,7 +34,7 @@ class OciResourceDiscoveryClient(object): # oci.database.DatabaseClient "ExadataIormConfig": (oci.database.DatabaseClient, "get_cloud_vm_cluster_iorm_config"), # oci.mysql.DbSystemClient - "MySQLDbSystemDetails": (oci.mysql.DbSystemClient, "get_db_system"), # used to get full details of the result and list_db_systems does not include all attributes + "MySQLDbSystemDetails": (oci.mysql.DbSystemClient, "get_db_system"), # used to get full details of the result as list_db_systems does not include all attributes # oci.mysql.MysqlaasClient "MySQLConfiguration": (oci.mysql.MysqlaasClient, "get_configuration"), # used to get details of the Default configurations # oci.os_management.OsManagementClient @@ -600,12 +602,17 @@ def submit_list_resource_worker_requests(self, executor, regional_resources_comp logger.warn(f"unsupported resource type {resource_type}") continue + # do a get for resources that need full details or don't have a list method if resource_type in self.get_resource_client_methods and item[2]: klass, method_name = self.get_resource_client_methods[resource_type] if method_name == "get_application": # DataFlowApplicationDetails application_id = item[2] future = executor.submit(self.list_resources, klass, method_name, region, application_id=application_id) futures_list.update({(region, resource_type, compartment_id, application_id):future}) + if method_name == "get_bastion": # BastionDetails + bastion_id = item[2] + future = executor.submit(self.list_resources, klass, method_name, region, bastion_id=bastion_id) + futures_list.update({(region, resource_type, None, bastion_id):future}) elif method_name == "get_cloud_vm_cluster_iorm_config": # CloudExadataInfrastrcture cloud_vm_cluster_id = item[2] future = executor.submit(self.list_resources, klass, method_name, region, cloud_vm_cluster_id=cloud_vm_cluster_id) @@ -640,6 +647,7 @@ def submit_list_resource_worker_requests(self, executor, regional_resources_comp future = executor.submit(self.list_resources, klass, method_name, region, asset_id=asset_id) futures_list.update({(region, resource_type, compartment_id, asset_id):future}) + # do a list for other resources, which is more efficient than separate get requests if resource_type in self.static_resource_client_methods: klass, method_name = self.static_resource_client_methods[resource_type] if method_name == "get_cluster_options": @@ -993,6 +1001,7 @@ def process_list_resource_worker_reponses(self, futures_list): new_result = [ExtendedVirtualCircuitBandwidthShape(fastconnect_provider_id, shape) for shape in result] result = new_result elif resource_type in [ + "BastionDetails", "ClusterOptions", "DataFlowApplicationDetails", "DataFlowRunDetails", "Image", @@ -1017,15 +1026,12 @@ def process_list_resource_worker_reponses(self, futures_list): except oci.exceptions.ConnectTimeout as ct: logger.warn(("get_resources()", future, ct)) failed_requests.append(future) - # TODO retry except oci.exceptions.RequestException as re: logger.warn(("get_resources()", future, re)) failed_requests.append(future) - # TODO retry except TimeoutError as te: logger.error(("get_resources()", future, te, self.timeout)) failed_requests.append(future) - # TODO retry except Exception as e: logger.error(("get_resources()", future, e)) @@ -1342,6 +1348,10 @@ def get_all_resources(self): if "DataFlowRun" in resources_by_region[region]: for resource in resources_by_region[region]["DataFlowRun"]: regional_resource_requests.add(("DataFlowRunDetails", resource.compartment_id, resource.id)) + # get extra details for Bastion + if "Bastion" in resources_by_region[region]: + for resource in resources_by_region[region]["Bastion"]: + regional_resource_requests.add(("BastionDetails", resource.compartment_id, resource.id)) extra_resource_requests.update({region:regional_resource_requests}) @@ -1394,6 +1404,7 @@ def get_all_resources(self): self.replace_resource_details(resources_by_region, region, "MySQLDbSystem", "MySQLDbSystemDetails") self.replace_resource_details(resources_by_region, region, "DataFlowApplication", "DataFlowApplicationDetails") self.replace_resource_details(resources_by_region, region, "DataFlowRun", "DataFlowRunDetails") + self.replace_resource_details(resources_by_region, region, "Bastion", "BastionDetails") # remove duplicate shapes # For multi-AD regions the list_shapes method returns shapes per AD, but does not distinguish which shape From b87765fb02a7ae61db4d4c5212bcdd752b8c3d93 Mon Sep 17 00:00:00 2001 From: Stephen Cross Date: Wed, 13 Oct 2021 12:32:04 -0400 Subject: [PATCH 3/7] fix details result merge --- visualiser/discovery/oci_discovery_client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/visualiser/discovery/oci_discovery_client.py b/visualiser/discovery/oci_discovery_client.py index c2048bd6d..0b5df45b3 100755 --- a/visualiser/discovery/oci_discovery_client.py +++ b/visualiser/discovery/oci_discovery_client.py @@ -1397,14 +1397,14 @@ def get_all_resources(self): # add resources_by_region[region][resource_type] = final_resources_by_region[region][resource_type] - if len(resources_by_region) == 0: - logger.warn("Resource discovery results are empty") - else: - # replace summary result with resource details - self.replace_resource_details(resources_by_region, region, "MySQLDbSystem", "MySQLDbSystemDetails") - self.replace_resource_details(resources_by_region, region, "DataFlowApplication", "DataFlowApplicationDetails") - self.replace_resource_details(resources_by_region, region, "DataFlowRun", "DataFlowRunDetails") - self.replace_resource_details(resources_by_region, region, "Bastion", "BastionDetails") + if len(resources_by_region) == 0: + logger.warn("Resource discovery results are empty") + else: + # replace summary result with resource details + self.replace_resource_details(resources_by_region, region, "MySQLDbSystem", "MySQLDbSystemDetails") + self.replace_resource_details(resources_by_region, region, "DataFlowApplication", "DataFlowApplicationDetails") + self.replace_resource_details(resources_by_region, region, "DataFlowRun", "DataFlowRunDetails") + self.replace_resource_details(resources_by_region, region, "Bastion", "BastionDetails") # remove duplicate shapes # For multi-AD regions the list_shapes method returns shapes per AD, but does not distinguish which shape From 42e5d7c8f197d81f3e4bdfa5ff08a193d8cd0482 Mon Sep 17 00:00:00 2001 From: Andrew Hopkinson Date: Thu, 14 Oct 2021 12:59:07 +0100 Subject: [PATCH 4/7] Add User/Groups to Markdown --- okitweb/templates/okit/okit_designer.html | 11 +++++++--- .../templates/markdown/common_macros.jinja2 | 18 +++++++++++++++++ visualiser/templates/markdown/group.jinja2 | 14 +++++++++++++ visualiser/templates/markdown/markdown.jinja2 | 20 ++++++++++++++++++- visualiser/templates/markdown/policy.jinja2 | 14 +++++++++++++ visualiser/templates/markdown/user.jinja2 | 9 +++++++++ visualiser/templates/markdown/users.jinja2 | 9 +++++++++ 7 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 visualiser/templates/markdown/group.jinja2 create mode 100644 visualiser/templates/markdown/policy.jinja2 create mode 100644 visualiser/templates/markdown/user.jinja2 create mode 100644 visualiser/templates/markdown/users.jinja2 diff --git a/okitweb/templates/okit/okit_designer.html b/okitweb/templates/okit/okit_designer.html index ac1f709ee..876b3c78f 100644 --- a/okitweb/templates/okit/okit_designer.html +++ b/okitweb/templates/okit/okit_designer.html @@ -401,9 +401,14 @@ diff --git a/visualiser/templates/markdown/common_macros.jinja2 b/visualiser/templates/markdown/common_macros.jinja2 index df8a0bc84..5e4dd72e7 100644 --- a/visualiser/templates/markdown/common_macros.jinja2 +++ b/visualiser/templates/markdown/common_macros.jinja2 @@ -305,3 +305,21 @@ {%- endif -%} {%- endfor -%} {%- endmacro -%} + + +{%- macro user_property(id, title="User") -%} + {{ document_property(title, user_link(id)) }} +{%- endmacro -%} + +{%- macro user_link(id) -%} + {{ property_link(user_name(id)) }} +{%- endmacro -%} + +{%- macro user_name(id) -%} + {%- for user in users -%} + {%- if user.id == id -%} + {{ user.display_name }} + {%- endif -%} + {%- endfor -%} +{%- endmacro -%} + diff --git a/visualiser/templates/markdown/group.jinja2 b/visualiser/templates/markdown/group.jinja2 new file mode 100644 index 000000000..6066b6e71 --- /dev/null +++ b/visualiser/templates/markdown/group.jinja2 @@ -0,0 +1,14 @@ +{% import "common_macros.jinja2" as common with context %} +{% macro document_group(resource) -%} +{{ common.document_common_details(resource) }} +| Property | Value | +| -------- | -------- | +{{ common.document_property("Description", resource.description) }} + {% for user_id in resource.user_ids -%} + {{ common.user_property(user_id) }} + {% endfor %} +{{ common.document_tags(resource) }} +{%- endmacro %} +{% for group in groups -%} + {{ document_group(group) }} +{%- endfor %} \ No newline at end of file diff --git a/visualiser/templates/markdown/markdown.jinja2 b/visualiser/templates/markdown/markdown.jinja2 index 5dcda12af..26bd53409 100644 --- a/visualiser/templates/markdown/markdown.jinja2 +++ b/visualiser/templates/markdown/markdown.jinja2 @@ -157,8 +157,26 @@ {%- endif %} +{% if (groups is defined and groups|length > 0) or (users is defined and users|length > 0) or (policys is defined and policys|length > 0) -%} +## Identity +{% if (users is defined and users|length > 0) -%} +### Users + {% include "user.jinja2" ignore missing with context %} +{%- endif %} + +{% if (groups is defined and groups|length > 0) -%} +### User Groups + {% include "group.jinja2" ignore missing with context %} +{%- endif %} + +{% if (policys is defined and policys|length > 0) -%} +### Policies + {% include "policy.jinja2" ignore missing with context %} +{%- endif %} +{%- endif %} + {% if user_defined is defined and user_defined.terraform is defined and user_defined.terraform|length > 0 -%} -### User Defined Terraform +## User Defined Terraform ```terraform {{ user_defined.terraform|safe }} ``` diff --git a/visualiser/templates/markdown/policy.jinja2 b/visualiser/templates/markdown/policy.jinja2 new file mode 100644 index 000000000..0e5768f97 --- /dev/null +++ b/visualiser/templates/markdown/policy.jinja2 @@ -0,0 +1,14 @@ +{% import "common_macros.jinja2" as common with context %} +{% macro document_policy(resource) -%} +{{ common.document_common_details(resource) }} +{{ common.document_common_properties(resource) }} +{{ common.document_property("Description", resource.description) }} +{{ common.document_property("Version Date", resource.version_date) }} + {% for statement in resource.statements -%} + {{ common.document_property("Statement", statement) }} + {% endfor %} +{{ common.document_tags(resource) }} +{%- endmacro %} +{% for policy in policys -%} + {{ document_policy(policy) }} +{%- endfor %} \ No newline at end of file diff --git a/visualiser/templates/markdown/user.jinja2 b/visualiser/templates/markdown/user.jinja2 new file mode 100644 index 000000000..cf264c998 --- /dev/null +++ b/visualiser/templates/markdown/user.jinja2 @@ -0,0 +1,9 @@ +{% import "common_macros.jinja2" as common with context %} +{% macro document_user(resource) -%} +{{ "| %-15s | %-15s | %s |" | format(resource.display_name, resource.email, resource.description) }} +{%- endmacro %} +| User Name | Email | Description | +| --------- | -------------- | -------------- | +{% for user in users -%} + {{ document_user(user) }} +{% endfor %} \ No newline at end of file diff --git a/visualiser/templates/markdown/users.jinja2 b/visualiser/templates/markdown/users.jinja2 new file mode 100644 index 000000000..b8bad0973 --- /dev/null +++ b/visualiser/templates/markdown/users.jinja2 @@ -0,0 +1,9 @@ +{% import "common_macros.jinja2" as common with context %} +{% macro document_user(resource) -%} +{{ common.document_property(resource.display_name, resource.description) }} +{%- endmacro %} +| User Name | Description | +| --------- | -------------- | +{% for user in users -%} + {{ document_user(user) }} +{% endfor %} \ No newline at end of file From b6a028ca147742547f29ea7b1a2fc08da2f61944 Mon Sep 17 00:00:00 2001 From: Andrew Hopkinson Date: Thu, 14 Oct 2021 12:59:40 +0100 Subject: [PATCH 5/7] Generate code for next batch of resources --- okitweb/static/okit/css/okit_console.css | 4 +- .../static/okit/model/js/artefacts/bastion.js | 72 ++++++++ okitweb/static/okit/model/js/artefacts/key.js | 72 ++++++++ .../js/artefacts/network_load_balancer.js | 72 ++++++++ .../okit/model/js/artefacts/nosql_database.js | 72 ++++++++ .../static/okit/model/js/artefacts/vault.js | 72 ++++++++ okitweb/static/okit/palette/palette.json | 25 +++ okitweb/static/okit/palette/svg/Bastion.svg | 59 +++++++ .../view/designer/js/artefacts/bastion.js | 163 ++++++++++++++++++ .../okit/view/designer/js/artefacts/key.js | 163 ++++++++++++++++++ .../js/artefacts/network_load_balancer.js | 163 ++++++++++++++++++ .../designer/js/artefacts/nosql_database.js | 163 ++++++++++++++++++ .../okit/view/designer/js/artefacts/vault.js | 163 ++++++++++++++++++ .../okit/propertysheets/bastion.html | 9 + .../templates/okit/propertysheets/key.html | 9 + .../propertysheets/network_load_balancer.html | 9 + .../okit/propertysheets/nosql_database.html | 9 + .../templates/okit/propertysheets/vault.html | 9 + .../okit/valueproposition/bastion.html | 5 + .../templates/okit/valueproposition/key.html | 5 + .../network_load_balancer.html | 5 + .../okit/valueproposition/nosql_database.html | 5 + .../okit/valueproposition/vault.html | 5 + skeletons/templates/artefact_model.js.jinja2 | 2 +- visualiser/facades/ociBastion.py | 52 ++++++ visualiser/facades/ociKey.py | 52 ++++++ visualiser/facades/ociNetworkLoadBalancer.py | 52 ++++++ visualiser/facades/ociNoSQL.py | 52 ++++++ visualiser/facades/ociNoSQLDatabase.py | 52 ++++++ visualiser/facades/ociVault.py | 52 ++++++ visualiser/query/ociQuery.py | 4 + 31 files changed, 1649 insertions(+), 2 deletions(-) create mode 100644 okitweb/static/okit/model/js/artefacts/bastion.js create mode 100644 okitweb/static/okit/model/js/artefacts/key.js create mode 100644 okitweb/static/okit/model/js/artefacts/network_load_balancer.js create mode 100644 okitweb/static/okit/model/js/artefacts/nosql_database.js create mode 100644 okitweb/static/okit/model/js/artefacts/vault.js create mode 100644 okitweb/static/okit/palette/svg/Bastion.svg create mode 100644 okitweb/static/okit/view/designer/js/artefacts/bastion.js create mode 100644 okitweb/static/okit/view/designer/js/artefacts/key.js create mode 100644 okitweb/static/okit/view/designer/js/artefacts/network_load_balancer.js create mode 100644 okitweb/static/okit/view/designer/js/artefacts/nosql_database.js create mode 100644 okitweb/static/okit/view/designer/js/artefacts/vault.js create mode 100644 okitweb/templates/okit/propertysheets/bastion.html create mode 100644 okitweb/templates/okit/propertysheets/key.html create mode 100644 okitweb/templates/okit/propertysheets/network_load_balancer.html create mode 100644 okitweb/templates/okit/propertysheets/nosql_database.html create mode 100644 okitweb/templates/okit/propertysheets/vault.html create mode 100644 okitweb/templates/okit/valueproposition/bastion.html create mode 100644 okitweb/templates/okit/valueproposition/key.html create mode 100644 okitweb/templates/okit/valueproposition/network_load_balancer.html create mode 100644 okitweb/templates/okit/valueproposition/nosql_database.html create mode 100644 okitweb/templates/okit/valueproposition/vault.html create mode 100644 visualiser/facades/ociBastion.py create mode 100644 visualiser/facades/ociKey.py create mode 100644 visualiser/facades/ociNetworkLoadBalancer.py create mode 100644 visualiser/facades/ociNoSQL.py create mode 100644 visualiser/facades/ociNoSQLDatabase.py create mode 100644 visualiser/facades/ociVault.py diff --git a/okitweb/static/okit/css/okit_console.css b/okitweb/static/okit/css/okit_console.css index 0ff0b79bb..9e1b36fe4 100644 --- a/okitweb/static/okit/css/okit_console.css +++ b/okitweb/static/okit/css/okit_console.css @@ -108,9 +108,11 @@ summary:focus { } .hidden { - visibility: hidden; + position: absolute; display: none; + visibility: hidden; max-height: 0; + max-width: 0; } .okit-pointer-cursor { diff --git a/okitweb/static/okit/model/js/artefacts/bastion.js b/okitweb/static/okit/model/js/artefacts/bastion.js new file mode 100644 index 000000000..789647d9b --- /dev/null +++ b/okitweb/static/okit/model/js/artefacts/bastion.js @@ -0,0 +1,72 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded Bastion Javascript'); + +/* +** Define Bastion Class +*/ +class Bastion extends OkitArtifact { + /* + ** Create + */ + constructor (data={}, okitjson={}) { + super(okitjson); + // Configure default values + this.display_name = this.generateDefaultName(okitjson.bastions.length + 1); + this.compartment_id = data.parent_id; + /* + ** TODO: Add Resource / Artefact specific parameters and default + */ + // Update with any passed data + this.merge(data); + this.convert(); + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Expose subnet_id at the top level + Object.defineProperty(this, 'subnet_id', {get: function() {return this.primary_mount_target.subnet_id;}, set: function(id) {this.primary_mount_target.subnet_id = id;}, enumerable: false }); + } + /* + ** Clone Functionality + */ + clone() { + return new Bastion(JSON.clone(this), this.getOkitJson()); + } + /* + ** Name Generation + */ + getNamePrefix() { + return super.getNamePrefix() + 'b'; + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return 'Bastion'; + } +} +/* +** Dynamically Add Model Functions +*/ +OkitJson.prototype.newBastion = function(data) { + this.getBastions().push(new Bastion(data, this)); + return this.getBastions()[this.getBastions().length - 1]; +} +OkitJson.prototype.getBastions = function() { + if (!this.bastions) { + this.bastions = []; + } + return this.bastions; +} +OkitJson.prototype.getBastion = function(id='') { + for (let artefact of this.getBastions()) { + if (artefact.id === id) { + return artefact; + } + } +return undefined; +} +OkitJson.prototype.deleteBastion = function(id) { + this.bastions = this.bastions ? this.bastions.filter((r) => r.id !== id) : [] +} + diff --git a/okitweb/static/okit/model/js/artefacts/key.js b/okitweb/static/okit/model/js/artefacts/key.js new file mode 100644 index 000000000..c427e1f54 --- /dev/null +++ b/okitweb/static/okit/model/js/artefacts/key.js @@ -0,0 +1,72 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded Key Javascript'); + +/* +** Define Key Class +*/ +class Key extends OkitArtifact { + /* + ** Create + */ + constructor (data={}, okitjson={}) { + super(okitjson); + // Configure default values + this.display_name = this.generateDefaultName(okitjson.keys.length + 1); + this.compartment_id = data.parent_id; + /* + ** TODO: Add Resource / Artefact specific parameters and default + */ + // Update with any passed data + this.merge(data); + this.convert(); + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Expose subnet_id at the top level + Object.defineProperty(this, 'subnet_id', {get: function() {return this.primary_mount_target.subnet_id;}, set: function(id) {this.primary_mount_target.subnet_id = id;}, enumerable: false }); + } + /* + ** Clone Functionality + */ + clone() { + return new Key(JSON.clone(this), this.getOkitJson()); + } + /* + ** Name Generation + */ + getNamePrefix() { + return super.getNamePrefix() + 'k'; + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return 'Key'; + } +} +/* +** Dynamically Add Model Functions +*/ +OkitJson.prototype.newKey = function(data) { + this.getKeys().push(new Key(data, this)); + return this.getKeys()[this.getKeys().length - 1]; +} +OkitJson.prototype.getKeys = function() { + if (!this.keys) { + this.keys = []; + } + return this.keys; +} +OkitJson.prototype.getKey = function(id='') { + for (let artefact of this.getKeys()) { + if (artefact.id === id) { + return artefact; + } + } +return undefined; +} +OkitJson.prototype.deleteKey = function(id) { + this.keys = this.keys ? this.keys.filter((r) => r.id !== id) : [] +} + diff --git a/okitweb/static/okit/model/js/artefacts/network_load_balancer.js b/okitweb/static/okit/model/js/artefacts/network_load_balancer.js new file mode 100644 index 000000000..3f51fb7d8 --- /dev/null +++ b/okitweb/static/okit/model/js/artefacts/network_load_balancer.js @@ -0,0 +1,72 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded Network Load Balancer Javascript'); + +/* +** Define Network Load Balancer Class +*/ +class NetworkLoadBalancer extends OkitArtifact { + /* + ** Create + */ + constructor (data={}, okitjson={}) { + super(okitjson); + // Configure default values + this.display_name = this.generateDefaultName(okitjson.network_load_balancers.length + 1); + this.compartment_id = data.parent_id; + /* + ** TODO: Add Resource / Artefact specific parameters and default + */ + // Update with any passed data + this.merge(data); + this.convert(); + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Expose subnet_id at the top level + Object.defineProperty(this, 'subnet_id', {get: function() {return this.primary_mount_target.subnet_id;}, set: function(id) {this.primary_mount_target.subnet_id = id;}, enumerable: false }); + } + /* + ** Clone Functionality + */ + clone() { + return new NetworkLoadBalancer(JSON.clone(this), this.getOkitJson()); + } + /* + ** Name Generation + */ + getNamePrefix() { + return super.getNamePrefix() + 'nlb'; + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return 'Network Load Balancer'; + } +} +/* +** Dynamically Add Model Functions +*/ +OkitJson.prototype.newNetworkLoadBalancer = function(data) { + this.getNetworkLoadBalancers().push(new NetworkLoadBalancer(data, this)); + return this.getNetworkLoadBalancers()[this.getNetworkLoadBalancers().length - 1]; +} +OkitJson.prototype.getNetworkLoadBalancers = function() { + if (!this.network_load_balancers) { + this.network_load_balancers = []; + } + return this.network_load_balancers; +} +OkitJson.prototype.getNetworkLoadBalancer = function(id='') { + for (let artefact of this.getNetworkLoadBalancers()) { + if (artefact.id === id) { + return artefact; + } + } +return undefined; +} +OkitJson.prototype.deleteNetworkLoadBalancer = function(id) { + this.network_load_balancers = this.network_load_balancers ? this.network_load_balancers.filter((r) => r.id !== id) : [] +} + diff --git a/okitweb/static/okit/model/js/artefacts/nosql_database.js b/okitweb/static/okit/model/js/artefacts/nosql_database.js new file mode 100644 index 000000000..07354c27d --- /dev/null +++ b/okitweb/static/okit/model/js/artefacts/nosql_database.js @@ -0,0 +1,72 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded NoSQL Database Javascript'); + +/* +** Define NoSQL Database Class +*/ +class NoSQLDatabase extends OkitArtifact { + /* + ** Create + */ + constructor (data={}, okitjson={}) { + super(okitjson); + // Configure default values + this.display_name = this.generateDefaultName(okitjson.nosql_databases.length + 1); + this.compartment_id = data.parent_id; + /* + ** TODO: Add Resource / Artefact specific parameters and default + */ + // Update with any passed data + this.merge(data); + this.convert(); + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Expose subnet_id at the top level + Object.defineProperty(this, 'subnet_id', {get: function() {return this.primary_mount_target.subnet_id;}, set: function(id) {this.primary_mount_target.subnet_id = id;}, enumerable: false }); + } + /* + ** Clone Functionality + */ + clone() { + return new NoSQLDatabase(JSON.clone(this), this.getOkitJson()); + } + /* + ** Name Generation + */ + getNamePrefix() { + return super.getNamePrefix() + 'nd'; + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return 'NoSQL Database'; + } +} +/* +** Dynamically Add Model Functions +*/ +OkitJson.prototype.newNoSQLDatabase = function(data) { + this.getNoSQLDatabases().push(new NoSQLDatabase(data, this)); + return this.getNoSQLDatabases()[this.getNoSQLDatabases().length - 1]; +} +OkitJson.prototype.getNoSQLDatabases = function() { + if (!this.nosql_databases) { + this.nosql_databases = []; + } + return this.nosql_databases; +} +OkitJson.prototype.getNoSQLDatabase = function(id='') { + for (let artefact of this.getNoSQLDatabases()) { + if (artefact.id === id) { + return artefact; + } + } +return undefined; +} +OkitJson.prototype.deleteNoSQLDatabase = function(id) { + this.nosql_databases = this.nosql_databases ? this.nosql_databases.filter((r) => r.id !== id) : [] +} + diff --git a/okitweb/static/okit/model/js/artefacts/vault.js b/okitweb/static/okit/model/js/artefacts/vault.js new file mode 100644 index 000000000..46c4691a8 --- /dev/null +++ b/okitweb/static/okit/model/js/artefacts/vault.js @@ -0,0 +1,72 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded Vault Javascript'); + +/* +** Define Vault Class +*/ +class Vault extends OkitArtifact { + /* + ** Create + */ + constructor (data={}, okitjson={}) { + super(okitjson); + // Configure default values + this.display_name = this.generateDefaultName(okitjson.vaults.length + 1); + this.compartment_id = data.parent_id; + /* + ** TODO: Add Resource / Artefact specific parameters and default + */ + // Update with any passed data + this.merge(data); + this.convert(); + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Expose subnet_id at the top level + Object.defineProperty(this, 'subnet_id', {get: function() {return this.primary_mount_target.subnet_id;}, set: function(id) {this.primary_mount_target.subnet_id = id;}, enumerable: false }); + } + /* + ** Clone Functionality + */ + clone() { + return new Vault(JSON.clone(this), this.getOkitJson()); + } + /* + ** Name Generation + */ + getNamePrefix() { + return super.getNamePrefix() + 'v'; + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return 'Vault'; + } +} +/* +** Dynamically Add Model Functions +*/ +OkitJson.prototype.newVault = function(data) { + this.getVaults().push(new Vault(data, this)); + return this.getVaults()[this.getVaults().length - 1]; +} +OkitJson.prototype.getVaults = function() { + if (!this.vaults) { + this.vaults = []; + } + return this.vaults; +} +OkitJson.prototype.getVault = function(id='') { + for (let artefact of this.getVaults()) { + if (artefact.id === id) { + return artefact; + } + } +return undefined; +} +OkitJson.prototype.deleteVault = function(id) { + this.vaults = this.vaults ? this.vaults.filter((r) => r.id !== id) : [] +} + diff --git a/okitweb/static/okit/palette/palette.json b/okitweb/static/okit/palette/palette.json index 1077e763f..747729b9e 100644 --- a/okitweb/static/okit/palette/palette.json +++ b/okitweb/static/okit/palette/palette.json @@ -57,6 +57,11 @@ "targets": ["oci"], "svg": "MySQLDatabaseServiceMDS.svg" }, + { + "title": "NoSQL Database", + "targets": ["oci", "hidden"], + "svg": "NoSQLDatabase.svg" + }, { "title": "Autonomous Data Warehouse Cloud Service", "targets": ["hidden"], @@ -78,6 +83,11 @@ "targets": ["oci"], "svg": "LoadBalancerLB.svg" }, + { + "title": "NetworkLoad Balancer", + "targets": ["oci", "hidden"], + "svg": "NetworkLoadBalancerLB.svg" + }, { "title": "Virtual Cloud Network", "targets": ["oci", "free tier", "pca"], @@ -181,10 +191,25 @@ "title": "Identity", "svg": "identity.svg", "resources": [ + { + "title": "Bastion", + "targets": ["oci", "pca"], + "svg": "Bastion.svg" + }, { "title": "Policy", "targets": ["oci", "pca"], "svg": "Policies.svg" + }, + { + "title": "Vault", + "targets": ["oci", "pca", "hidden"], + "svg": "KeyVault.svg" + }, + { + "title": "Key", + "targets": ["oci", "pca", "hidden"], + "svg": "KeyManagement.svg" } ] } diff --git a/okitweb/static/okit/palette/svg/Bastion.svg b/okitweb/static/okit/palette/svg/Bastion.svg new file mode 100644 index 000000000..db39be846 --- /dev/null +++ b/okitweb/static/okit/palette/svg/Bastion.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/okitweb/static/okit/view/designer/js/artefacts/bastion.js b/okitweb/static/okit/view/designer/js/artefacts/bastion.js new file mode 100644 index 000000000..a96c93e16 --- /dev/null +++ b/okitweb/static/okit/view/designer/js/artefacts/bastion.js @@ -0,0 +1,163 @@ +/* +** Copyright (c) 2020, 2021, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +*/ +console.info('Loaded Bastion View Javascript'); + +/* +** Define Bastion View Class +*/ +class BastionView extends OkitArtefactView { + constructor(artefact=null, json_view) { + if (!json_view.bastions) json_view.bastions = []; + super(artefact, json_view); + } + // TODO: Return Artefact Parent id e.g. vcn_id for a Internet Gateway + get parent_id() {return this.artefact.vcn_id;} + // TODO: Return Artefact Parent Object e.g. VirtualCloudNetwork for a Internet Gateway + get parent() {return this.getJsonView().getVirtualCloudNetwork(this.parent_id);} + // TODO: If the Resource is within a Subnet but the subnet_iss is not at the top level then raise it with the following functions if not required delete them. + // Direct Subnet Access + get subnet_id() {return this.artefact.primary_mount_target.subnet_id;} + set subnet_id(id) {this.artefact.primary_mount_target.subnet_id = id;} + /* + ** SVG Processing + */ + /* + ** Property Sheet Load function + */ + loadProperties() { + const self = this; + $(jqId(PROPERTIES_PANEL)).load("propertysheets/bastion.html", () => {loadPropertiesSheet(self.artefact);}); + } + /* + ** Load and display Value Proposition + */ + loadValueProposition() { + $(jqId(VALUE_PROPOSITION_PANEL)).load("valueproposition/bastion.html"); + } + /* + ** Static Functionality + */ + static getArtifactReference() { + return Bastion.getArtifactReference(); + } + static getDropTargets() { + // TODO: Return List of Artefact Drop Targets Parent Object Reference Names e.g. VirtualCloudNetwork for a Internet Gateway + return [VirtualCloudNetwork.getArtifactReference()]; + } +} +/* +** Dynamically Add View Functions +*/ +OkitJsonView.prototype.dropBastionView = function(target) { + let view_artefact = this.newBastion(); + if (target.type === Compartment.getArtifactReference()) { + view_artefact.artefact.compartment_id = target.id; + } else { + view_artefact.artefact.compartment_id = target.compartment_id; + } + view_artefact.recalculate_dimensions = true; + return view_artefact; +} +OkitJsonView.prototype.newBastion = function(obj) { + this.getBastions().push(obj ? new BastionView(obj, this) : new BastionView(this.okitjson.newBastion(), this)); + return this.getBastions()[this.getBastions().length - 1]; +} +OkitJsonView.prototype.getBastions = function() { + if (!this.bastions) { + this.bastions = []; + } + return this.bastions; +} +OkitJsonView.prototype.getBastion = function(id='') { + for (let artefact of this.getBastions()) { + if (artefact.id === id) { + return artefact; + } + } + return undefined; +} +OkitJsonView.prototype.loadBastions = function(bastions) { + for (const artefact of bastions) { + this.getBastions().push(new BastionView(new Bastion(artefact, this.okitjson), this)); + } +} +OkitJsonView.prototype.moveBastion = function(id) { + // Build Dialog + const self = this; + let bastion = this.getBastion(id); + $(jqId('modal_dialog_title')).text('Move ' + bastion.display_name); + $(jqId('modal_dialog_body')).empty(); + $(jqId('modal_dialog_footer')).empty(); + const table = d3.select(d3Id('modal_dialog_body')).append('div') + .attr('class', 'table okit-table'); + const tbody = table.append('div') + .attr('class', 'tbody'); + // Subnet + let tr = tbody.append('div') + .attr('class', 'tr'); + tr.append('div') + .attr('class', 'td') + .text('Subnet'); + tr.append('div') + .attr('class', 'td') + .append('select') + .attr('id', 'move_bastion_subnet_id'); + // Load Subnets + this.loadSubnetsSelect('move_bastion_subnet_id'); + $(jqId("move_bastion_subnet_id")).val(bastion.artefact.subnet_id); + // Submit Button + const submit = d3.select(d3Id('modal_dialog_footer')).append('div').append('button') + .attr('id', 'submit_query_btn') + .attr('type', 'button') + .text('Move') + .on('click', function () { + $(jqId('modal_dialog_wrapper')).addClass('hidden'); + if (bastion.artefact.subnet_id !== $(jqId("move_bastion_subnet_id")).val()) { + self.getSubnet(bastion.artefact.subnet_id).recalculate_dimensions = true; + self.getSubnet($(jqId("move_bastion_subnet_id")).val()).recalculate_dimensions = true; + bastion.artefact.subnet_id = $(jqId("move_bastion_subnet_id")).val(); + bastion.artefact.compartment_id = self.getSubnet(bastion.artefact.subnet_id).artefact.compartment_id; + } + self.update(this.okitjson); + }); + $(jqId('modal_dialog_wrapper')).removeClass('hidden'); +} +OkitJsonView.prototype.pasteBastion = function(drop_target) { + const clone = this.copied_artefact.artefact.clone(); + clone.display_name += 'Copy'; + if (this.paste_count) {clone.display_name += `-${this.paste_count}`;} + this.paste_count += 1; + clone.id = clone.okit_id; + if (drop_target.getArtifactReference() === Subnet.getArtifactReference()) { + clone.subnet_id = drop_target.id; + clone.compartment_id = drop_target.compartment_id; + } + this.okitjson.bastions.push(clone); + this.update(this.okitjson); +} +OkitJsonView.prototype.loadBastionsSelect = function(select_id, empty_option=false) { + $(jqId(select_id)).empty(); + const bastion_select = $(jqId(select_id)); + if (empty_option) { + bastion_select.append($('