instance_template = ListDynamicLayout.set_layouts('Instance Template', layouts=[ instance_template_meta, it_meta_machine, meta_available_policy, it_meta_service_account ]) # TAB - Network # instance_template_meta_network it_meta_network = TableDynamicLayout.set_fields( 'Network Interface', root_path='data.network_interfaces', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Network', 'network_display'), ListDyField.data_source('Access Configs', 'configs'), ListDyField.data_source('Network Tier', 'network_tier'), TextDyField.data_source('Kind', 'network'), ]) # TAB - Disk # instance_template_meta_disk meta_it_disk = TableDynamicLayout.set_fields( 'Disks', root_path='data.disks', fields=[ TextDyField.data_source('Index', 'device_index'), TextDyField.data_source('Device Name', 'device'), TextDyField.data_source('Source Image', 'tags.source_image_display'), SizeField.data_source('Size', 'size'),
}), TextDyField.data_source('Snapshot Type', 'data.incremental_display'), TextDyField.data_source('Subscription ID', 'data.subscription_id'), TextDyField.data_source('Subscription Name', 'data.subscription_name'), TextDyField.data_source('Encryption Type', 'data.encryption.type_display'), TextDyField.data_source('Network Access Policy', 'data.network_access_policy_display'), DateTimeDyField.data_source('Created Time', 'data.time_created') ]) # TAB - tags snapshot_info_tags = TableDynamicLayout.set_fields( 'Tags', 'data.tags', fields=[ TextDyField.data_source('Key', 'key'), TextDyField.data_source('Value', 'value') ]) snapshot_meta = CloudServiceMeta.set_layouts( [snapshot_info_meta, snapshot_info_tags]) class ComputeResource(CloudServiceResource): cloud_service_group = StringType(default='Compute') class SnapshotResource(ComputeResource): cloud_service_type = StringType(default='Snapshots') data = ModelType(Snapshot)
ListDyField.data_source('Vip Ids', 'data.vip_ids', options={'delimiter': '<br>'}) ]) dbsystem_database = TableDynamicLayout.set_fields( 'Databases', root_path='data.list_database', fields=[ TextDyField.data_source('Name', 'db_name'), EnumDyField.data_source('State', 'lifecycle_state', default_state={ 'safe': ['AVAILABLE'], 'warning': [ 'PROVISIONING', 'UPDATING', 'BACKUP_IN_PROGRESS', 'UPGRADING', 'TERMINATING' ], 'alert': ['TERMINATED', 'RESTORE_FAILED', 'FAILED'] }), TextDyField.data_source('Database Unique Name', 'db_unique_name'), TextDyField.data_source('Version', 'db_version'), TextDyField.data_source('Workload Type', 'db_workload'), DateTimeDyField.data_source('Created', 'time_created') ]) dbsystem_node = TableDynamicLayout.set_fields( 'Nodes', root_path='data.list_db_node', fields=[
'safe': ['On'], 'warning': ['Off'], }), TextDyField.data_source('Dynamic Routing mode', 'data.dynamic_routing_mode'), #TextDyField.data_source('DNS Server Policy', 'data.location.location_type'), DateTimeDyField.data_source('Creation Time', 'data.creation_timestamp'), ]) vpc_network_subnets_meta = TableDynamicLayout.set_fields( 'Subnets', root_path='data.subnetwork_data.subnets', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Region', 'region'), TextDyField.data_source('Ip Address Ranges', 'ip_cidr_range'), TextDyField.data_source('Gateway', 'gateway_address'), TextDyField.data_source('Private Google Access', 'google_access'), TextDyField.data_source('Flow logs', 'flow_log'), ]) vpc_network_subnets_ip_address_meta = TableDynamicLayout.set_fields( 'Static Internal IP Addresses', root_path='data.ip_address_data', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Internal Ip Address', 'address'), TextDyField.data_source('Subnetwork', 'subnet_name'), TextDyField.data_source('Region', 'region'), TextDyField.data_source('Version', 'ip_version_display'),
'Access', root_path='data.access', fields=[ TextDyField.data_source('Role', 'role'), TextDyField.data_source('Special Group', 'special_group'), TextDyField.data_source('User by E-mail', 'user_by_email') ]) workspace_dataset_meta = ListDynamicLayout.set_layouts( 'Dataset Details', layouts=[dataset_details_meta, access_table_meta]) workspace_matching_project_meta = TableDynamicLayout.set_fields( 'Project', root_path='data.matching_projects', fields=[ TextDyField.data_source('ID', 'id'), TextDyField.data_source('Numeric Id', 'numeric_id'), TextDyField.data_source('kind', 'kind'), TextDyField.data_source('Friendly Name', 'friendly_name') ]) workspace_table_meta = TableDynamicLayout.set_fields( 'Tables', root_path='data.tables', fields=[ TextDyField.data_source('ID', 'id'), TextDyField.data_source('Name', 'table_reference.table_id'), TextDyField.data_source('Type', 'type'), TextDyField.data_source('Dataset', 'table_reference.dataset_id'), TextDyField.data_source('Number of Rows', 'num_rows'), DateTimeDyField.data_source('Creation Time', 'creation_time'),
TextDyField.data_source('Size', 'data.instance_pool.size') ]) instance = ListDynamicLayout.set_layouts( 'Compute Instance', layouts=[compute_instance, compute_instance_vcn, compute_instance_pool]) disk = TableDynamicLayout.set_fields( 'Disk', root_path='disks', fields=[ TextDyField.data_source('Index', 'device_index'), TextDyField.data_source('Name', 'device'), SizeField.data_source('Size(GB)', 'size', options={ 'display_unit': 'GB', 'source_unit': 'GB' }), TextDyField.data_source('Volume ID', 'tags.volume_id'), TextDyField.data_source('Volume_type', 'disk_type'), TextDyField.data_source('VPUS per GB', 'tags.vpus_per_gb'), TextDyField.data_source('IOPS', 'tags.iops') ]) nic = TableDynamicLayout.set_fields( 'NIC', root_path='nics', fields=[ TextDyField.data_source('Index', 'device_index'), TextDyField.data_source('MAC Address', 'mac_address'),
it_meta_disk = TableDynamicLayout.set_fields( 'Disks', root_path='data.disks', fields=[ TextDyField.data_source('Index', 'device_index'), TextDyField.data_source('Name', 'device'), SizeField.data_source('Size', 'size'), EnumDyField.data_source('Disk Type', 'tags.disk_type', default_outline_badge=[ 'local-ssd', 'pd-balanced', 'pd-ssd', 'pd-standard' ]), EnumDyField.data_source('Mode', 'device_mode', default_badge={ 'indigo.500': ['READ_WRITE'], 'coral.600': ['READ_ONLY'] }), TextDyField.data_source('Boot Image', 'boot_image.name'), EnumDyField.data_source('Encryption', 'encryption', default_badge={ 'primary': ['Google managed'], 'indigo.500': ['Customer managed'], 'coral.600': ['Customer supplied'] }), EnumDyField.data_source('Boot Image', 'is_boot_image', default_badge={ 'indigo.500': ['true'], 'coral.600': ['false'] }), TextDyField.data_source('Read IOPS', 'tags.read_iops'), TextDyField.data_source('Write IOPS', 'tags.write_iops'), TextDyField.data_source('Read Throughput(MB/s)', 'tags.read_throughput'), TextDyField.data_source('Write Throughput(MB/s)', 'tags.write_throughput'), EnumDyField.data_source('Auto Delete', 'tags.auto_delete', default_badge={ 'indigo.500': ['true'], 'coral.600': ['false'] }), ])
options={'delimiter': '<br>'}) ]) # 3 + 4) TAB - Backend Pools load_balancer_info_backend_pools_meta = ListDynamicLayout.set_layouts( 'Backend Pools', layouts=[ load_balancer_info_backend_pools, load_balancer_info_backend_pools_vms ]) # TAB - Health Probes # Name, Protocol, Port load_balancer_info_health_probes = TableDynamicLayout.set_fields( 'Health Probes', 'data.probes', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Protocol', 'protocol'), TextDyField.data_source('Port', 'port'), TextDyField.data_source('Interval', 'interval_in_seconds'), TextDyField.data_source('Unhealthy Threshold', 'number_of_probes') ]) # TAB _ Load Balancing Rules # LB rules Name, Load balancing rule, Health probe -> skip load_balancer_info_load_balancing_rules = TableDynamicLayout.set_fields( 'Load Balancing Rules', 'data.load_balancing_rules', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Frontend IP Address', 'frontend_ip_configuration_display'), TextDyField.data_source('Protocol', 'protocol'),
''' Backup ''' backup_meta = TableDynamicLayout.set_fields('Backup', root_path='data.list_autonomous_backup' , fields=[TextDyField.data_source('Display Name', 'display_name'), EnumDyField.data_source('State','lifecycle_state', default_state={ 'safe': ['ACTIVE'], 'warning': ['CREATING','DELETING'], 'alert': ['DELETED', 'FAILED'] }), EnumDyField.data_source('Type', '_type'), EnumDyField.data_source('Automatic', 'is_automatic', default_badge={ 'indigo.500': ['true'], 'coral.600': ['false'], }), EnumDyField.data_source('Restorable', 'is_restorable', default_badge={ 'indigo.500': ['true'], 'coral.600': ['false'], }), DateTimeDyField.data_source('Started', 'time_started'), DateTimeDyField.data_source('Ended', 'time_ended') ]) ''' Refeshable Clones '''
'data.creation_timestamp'), ]) # instance_template_meta_disk firewall_applicable_inst_meta = TableDynamicLayout.set_fields( 'Applicable to Instances', root_path='data.applicable_instance', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Subnetwork', 'subnetwork'), TextDyField.data_source('Internal IP', 'address'), ListDyField.data_source('Tags', 'tags', default_badge={ 'type': 'outline', 'delimiter': '<br>' }), ListDyField.data_source('Service Accounts', 'service_accounts'), TextDyField.data_source('Project', 'project'), ListDyField.data_source('Label', 'labels_display', default_badge={ 'type': 'outline', 'delimiter': '<br>' }), DateTimeDyField.data_source('Creation Time', 'creation_timestamp') ]) instance_template_meta = CloudServiceMeta.set_layouts( [firewall_detail_meta, firewall_applicable_inst_meta])
DateTimeDyField.data_source('Time Started', 'time_started'), DateTimeDyField.data_source('Time Ended', 'time_ended') ]) exadata_maintenance_meta = ListDynamicLayout.set_layouts( 'Maintenance Run', [exadata_last_maintenance_run, exadata_next_maintenance_run]) exadata_vm_cluster_meta =\ TableDynamicLayout.set_fields('Exadata VM Clusters', root_path='data.list_cloud_vm_cluster', fields=[ TextDyField.data_source('Display Name', 'display_name'), EnumDyField.data_source('State', 'lifecycle_state', default_state={ 'safe': ['AVAILABLE'], 'warning': ['PROVISIONING', 'UPDATING', 'TERMINATING','MAINTENANCE_IN_PROGRESS'], 'alert': ['TERMINATED', 'FAILED'] }), TextDyField.data_source('Compartment', 'compartment_name'), TextDyField.data_source('Availability Domain', 'availability_domain'), TextDyField.data_source('CPU Core Count', 'cpu_core_count'), DateTimeDyField.data_source('Created', 'time_created') ]) exadata_tag = TableDynamicLayout.set_fields( 'Tags', root_path='data.freeform_tags', fields=[ TextDyField.data_source('Key', 'key'), TextDyField.data_source('Value', 'value') ])
TextDyField.data_source('Location', 'data.location'), TextDyField.data_source('Subscription', 'data.subscription_name'), TextDyField.data_source('Subscription ID', 'data.subscription_id'), TextDyField.data_source('Server Admin', 'data.administrator_login'), TextDyField.data_source('Active Directory Admin', 'data.azure_ad_admin_name'), TextDyField.data_source('Server Name', 'data.fully_qualified_domain_name') ]) # TAB - Failover Groups # Name, Primary Server, Secondary Server, Read/Write Failover Policy, Grace Period (minutes), Database count sql_server_failover_group = TableDynamicLayout.set_fields('Failover Groups', 'data.failover_groups', fields=[ TextDyField.data_source('ID', 'id'), TextDyField.data_source('Name', 'name'), TextDyField.data_source('Primary Server', 'primary_server'), TextDyField.data_source('Secondary Server', 'secondary_server'), TextDyField.data_source('Read/Write Failover Policy', 'failover_policy_display'), TextDyField.data_source('Grace Period (minutes)', 'grace_period_display'), # TextDyField.data_source('Database count', ''), ]) # TAB - Backups # Database, Earliest PITR restore point (UTC), Available LTR backups sql_server_backups = TableDynamicLayout.set_fields('Backups', 'data.databases', fields=[ TextDyField.data_source('Database', 'name'), TextDyField.data_source('Earliest PITR Restore Point (UTC)', 'earliest_restore_date'), TextDyField.data_source('Available LTR backups', 'long_term_retention_backup_resource_id'), ]) # TAB - Active Directory Admin # Active Directory Admin
'alert': ['open'] }), TextDyField.data_source('Event Scope Code', 'data.event_scope_code'), TextDyField.data_source('Event Category', 'data.event_type_category'), TextDyField.data_source('Region', 'region_code'), TextDyField.data_source('Description', 'data.description'), DateTimeDyField.data_source('Start Time', 'data.start_time'), DateTimeDyField.data_source('Last Update Time', 'data.last_update_time'), DateTimeDyField.data_source('End Time', 'data.end_time'), ]) affected_resources_meta = TableDynamicLayout.set_fields( 'Affected Resources', 'data.affected_resources', fields=[ TextDyField.data_source('Account ID', 'aws_account_id'), TextDyField.data_source('Event Type', 'entity_type'), TextDyField.data_source('Entity Value', 'entity_value'), ]) metadata = CloudServiceMeta.set_layouts( layouts=[event_meta, affected_resources_meta]) class PersonalHealthDashboardResource(CloudServiceResource): cloud_service_group = StringType(default='PersonalHealthDashboard') class EventResource(PersonalHealthDashboardResource): cloud_service_type = StringType(default='Event') data = ModelType(Event)
'data.write_throughput'), ]) schedule_meta = TableDynamicLayout.set_fields( 'Snapshot Schedule', root_path='data.snapshot_schedule', fields=[ TextDyField.data_source('ID', 'id'), TextDyField.data_source('Name', 'name'), TextDyField.data_source('Region', 'region'), ListDyField.data_source('Schedule Frequency (UTC)', 'snapshot_schedule_policy.schedule_display', default_badge={ 'type': 'outline', 'delimiter': '<br>' }), TextDyField.data_source( 'Auto-delete Snapshots After', 'snapshot_schedule_policy.retention_policy.max_retention_days_display' ), ListDyField.data_source('Storage Locations', 'storage_locations', default_badge={ 'type': 'outline', 'delimiter': '<br>' }), DateTimeDyField.data_source('Creation Time', 'creation_timestamp') ]) meta_disk_template = ListDynamicLayout.set_layouts( 'Disks', layouts=[disk_properties_meta, disk_performance_meta])
# TAB - Private Endpoints virtual_network_private_endpoints = SimpleTableDynamicLayout.set_fields( 'Private Endpoints', 'data.private_endpoints', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Subnet', 'subnet'), TextDyField.data_source('Resource Group', 'resource_group') ]) # TAB - tags virtual_network_tags = TableDynamicLayout.set_fields( 'Tags', 'data.tags', fields=[ TextDyField.data_source('Key', 'key'), TextDyField.data_source('Value', 'value') ]) virtual_network_meta = CloudServiceMeta.set_layouts([ virtual_network_info_meta, virtual_network_connected_devices, virtual_network_subnets, virtual_network_firewall, virtual_network_peerings, virtual_network_service_endpoints, virtual_network_private_endpoints, virtual_network_tags ]) class ComputeResource(CloudServiceResource): cloud_service_group = StringType(default='Network')
'delimiter': '<br>' }), DateTimeDyField.data_source('SSL certificates Creation Time', 'data.server_ca_cert.create_time'), DateTimeDyField.data_source('SSL certificates Expiration Time', 'data.server_ca_cert.expiration_time'), ]) # TAB - Database sql_meta_database = TableDynamicLayout.set_fields( 'Database', 'data.databases', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('charset', 'charset'), TextDyField.data_source('collation', 'collation'), TextDyField.data_source( 'Compatibility Level', 'sql_server_database_details.compatibility_level'), TextDyField.data_source('Recovery Model', 'sql_server_database_details.recovery_model'), TextDyField.data_source('Self Link', 'self_link'), ]) # TAB - User sql_meta_user = TableDynamicLayout.set_fields( 'User', 'data.users', fields=[ TextDyField.data_source('User Name', 'name'), EnumDyField.data_source('State', 'sql_server_user_details.disabled',
'data.virtual_machine_profile.terminate_notification_display'), TextDyField.data_source('OverProvisioning', 'data.overprovision'), TextDyField.data_source('Proximity Placement Group', 'data.proximity_placement_group_display'), TextDyField.data_source('Automatic Repairs', 'data.automatic_repairs_policy.enabled'), TextDyField.data_source('Upgrade Policy', 'data.upgrade_policy.mode'), TextDyField.data_source('Fault Domains', 'data.platform_fault_domain_count'), ]) # TAB - tags vm_scale_set_info_tags = TableDynamicLayout.set_fields( 'Tags', 'data.tags', fields=[ TextDyField.data_source('Key', 'key'), TextDyField.data_source('Value', 'value') ]) # TAB - Instances # name, computer name, location, status, provisioning state, fault domain, # protection policy, and latest model vm_scale_set_instance = TableDynamicLayout.set_fields( 'Instances', 'data.vm_instances', fields=[ TextDyField.data_source('Name', 'name'), TextDyField.data_source('Computer Name', 'os_profile.computer_name'), TextDyField.data_source('Location', 'location'), EnumDyField.data_source(
'CPU Utilization', 'data.auto_scaler.autoscaling_policy.cpu_utilization.utilization_target' ), TextDyField.data_source( 'Load Balancing Utilization', 'data.auto_scaler.autoscaling_policy.loadbalancing_utilization.utilization_target' ), ]) autoscaling_layout = ListDynamicLayout.set_layouts( 'Auto Scaler', layouts=[autoscaler, autoscaling_policy]) autohealing_layout = TableDynamicLayout.set_fields( 'AutoHealing', root_path='data.instance_group_manager.auto_healing_policies', fields=[ TextDyField.data_source('Health Check', 'health_check'), TextDyField.data_source('Initial Delay (Seconds)', 'initial_delay_sec'), ]) instance_layout = TableDynamicLayout.set_fields( 'Instance', root_path='data.instances', fields=[ TextDyField.data_source('Instance', 'instance'), EnumDyField.data_source('Status', 'status', default_state={ 'safe': ['RUNNING'], 'warning': [ 'STAGING', 'PROVISIONING', 'REPAIRING',
'coral.600': ['false'] }), DateTimeDyField.data_source('Effective Date', 'data.retention_policy.effective_time'), EnumDyField.data_source('Default Event-Based Hold Option', 'data.default_event_based_hold', default_badge={ 'indigo.500': ['Enabled'], 'coral.600': ['Disabled'] }), ]) bucket_life_cycle_meta = TableDynamicLayout.set_fields( 'Lifecycle', root_path='data.lifecycle_rule.rule', fields=[ TextDyField.data_source('Action', 'action_display'), TextDyField.data_source('Object Condition', 'condition_display'), ]) bucket_labels_meta = TableDynamicLayout.set_fields( 'Labels', root_path='data.labels', fields=[ TextDyField.data_source('Key', 'key'), TextDyField.data_source('Value', 'value'), ]) instance_template_meta = CloudServiceMeta.set_layouts([ bucket_configuration_meta, bucket_permission_meta, bucket_retention_meta, bucket_life_cycle_meta, bucket_labels_meta
from schematics.types import ModelType, StringType, PolyModelType from spaceone.inventory.model.trusted_advisor.data import Check from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, EnumDyField from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ HTMLDynamicLayout from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta resources = TableDynamicLayout.set_fields('Affected Resources', 'data.flagged_resources') resources.type = 'raw-table' check = ItemDynamicLayout.set_fields( 'Check Information', fields=[ TextDyField.data_source('Name', 'data.name'), TextDyField.data_source('Category', 'data.category'), EnumDyField.data_source('Status', 'data.status', default_state={ 'safe': ['ok'], 'warning': ['warning'], 'alert': ['error'], 'disable': ['not_available'] }), TextDyField.data_source('Checked at', 'data.timestamp'), ]) html_description = HTMLDynamicLayout.set('Description', root_path='data.description')