def dropdownQuery(): if request.method == 'GET': dropdown_json = {} # Regions oci_regions = OCIRegions() dropdown_json["regions"] = sorted(oci_regions.list(), key=lambda k: k['name']) # Services oci_services = OCIServices() dropdown_json["services"] = sorted(oci_services.list(), key=lambda k: k['name']) # Instance Shapes oci_shapes = OCIShapes() dropdown_json["shapes"] = sorted(oci_shapes.list(), key=lambda k: k['sort_key']) # Instance Images oci_images = OCIImages() dropdown_json["images"] = sorted(oci_images.list(), key=lambda k: k['sort_key']) # Database System Shapes db_system_shapes = OCIDatabaseSystemShapes() dropdown_json["db_system_shapes"] = sorted(db_system_shapes.list(), key=lambda k: k['shape']) # Database Versions db_versions = OCIDatabaseVersions() dropdown_json["db_versions"] = sorted(db_versions.list(), key=lambda k: k['version']) # CPE Device Shapes cpe_device_shapes = OCICpeDeviceShapes() dropdown_json["cpe_device_shapes"] = sorted( cpe_device_shapes.list(), key=lambda k: k['cpe_device_info']['vendor']) # Fast Connect Provider Services fast_connect_provider_services = OCIFastConnectProviderServices() dropdown_json["fast_connect_provider_services"] = sorted( fast_connect_provider_services.list(), key=lambda k: k['provider_name']) # MySQL Shapes mysql_shapes = OCIMySQLShapes() dropdown_json["mysql_shapes"] = sorted(mysql_shapes.list(), key=lambda k: k['name']) # Database Versions mysql_versions = OCIMySQLVersions() dropdown_json["mysql_versions"] = sorted( mysql_versions.list(), key=lambda k: k['version_family']) # MySQL Configurations mysql_configurations = OCIMySQLConfigurations() dropdown_json["mysql_configurations"] = sorted( mysql_configurations.list(), key=lambda k: k['display_name']) # Instance Shapes oci_loadbalancer_shapes = OCILoadBalancerShapes() dropdown_json["loadbalancer_shapes"] = sorted( oci_loadbalancer_shapes.list(), key=lambda k: k['name']) # Kubernetes Versions k8_versions = OCIKubernetesVersions() dropdown_json["kubernetes_versions"] = sorted( k8_versions.list(), key=lambda k: k['version'], reverse=True) return dropdown_json else: return 'Unknown Method', 500
def dropdownQuery(): if request.method == 'GET': dropdown_json = {} oci_shapes = OCIShapes() dropdown_json["shapes"] = sorted(oci_shapes.list(), key=lambda k: k['sort_key']) db_system_shapes = OCIDatabaseSystemShapes() dropdown_json["db_system_shapes"] = sorted(db_system_shapes.list(), key=lambda k: k['shape']) db_versions = OCIDatabaseVersions() dropdown_json["db_versions"] = sorted(db_versions.list(), key=lambda k: k['version']) oci_images = OCIImages() dropdown_json["images"] = sorted(oci_images.list(), key=lambda k: k['sort_key']) return dropdown_json else: return 'Unknown Method', 500
def list(self, compartment_id=None, cluster_id=None, filter=None): if compartment_id is None: compartment_id = self.compartment_id if cluster_id is None: cluster_id = self.cluster_id if self.compartment_id is not None: logger.info('Pools for Cluster {0!s:s}'.format(self.cluster_id)) node_pools = oci.pagination.list_call_get_all_results( self.client.list_node_pools, compartment_id=compartment_id, cluster_id=cluster_id).data # Convert to Json object node_pools_json = self.toJson(node_pools) logger.debug(str(node_pools_json)) # Filter results self.node_pools_json = self.filterJsonObjectList( node_pools_json, filter) logger.debug(str(self.node_pools_json)) # Build List of NodePool Objects self.node_pools_obj = [] for node_pool in self.node_pools_json: # If the Source Details are not created then we will need to create the element and transfer across if 'node_source_details' not in node_pool: node_pool['node_source_details'] = {} node_pool['node_source_details']['image_id'] = node_pool[ 'node_image_id'] node_pool['node_source_details']['image'] = node_pool[ 'node_image_name'] node_pool['node_source_details']['source_type'] = 'IMAGE' node_pool['node_source_details'][ 'boot_volume_size_in_gbs'] = 50 # Get OS Details image = OCIImages( config=self.config, configfile=self.configfile, profile=self.profile, compartment_id=compartment_id).get( node_pool['node_source_details']['image_id']) node_pool['node_source_details']['os'] = image[ 'operating_system'] node_pool['node_source_details']['os_version'] = image[ 'operating_system_version'] self.node_pools_obj.append( OCINodePool(self.config, self.configfile, self.profile, node_pool)) else: logger.warn('Compartment Id has not been specified.') logger.info(str(self.node_pools_json)) return self.node_pools_json
def list(self, compartment_id=None, filter=None): if compartment_id is None: compartment_id = self.compartment_id # Add filter to only return "RUNNING", "STARTING", "STOPPING", "STOPPED" Compartments if filter is None: filter = {} if 'lifecycle_state' not in filter: filter['lifecycle_state'] = ["RUNNING", "STARTING", "STOPPING", "STOPPED"] instances = oci.pagination.list_call_get_all_results(self.client.list_instances, compartment_id=compartment_id).data # Convert to Json object instances_json = self.toJson(instances) # Filter results self.instances_json = self.filterJsonObjectList(instances_json, filter) # Get Volume Attachments as a single call and loop through them to see if they are associated with the instance. volume_attachments = OCIVolumeAttachments(config=self.config, configfile=self.configfile, profile=self.profile, compartment_id=compartment_id).list() # Get VNic Attachments as a single call and loop through them to see if they are associated with the instance. vnic_attachments = OCIVnicAttachments(config=self.config, configfile=self.configfile, profile=self.profile, compartment_id=compartment_id).list() for instance in self.instances_json: # Get OS Details image = OCIImages(config=self.config, configfile=self.configfile, profile=self.profile, compartment_id=compartment_id).get(instance['source_details']['image_id']) instance['source_details']['os'] = image['operating_system'] instance['source_details']['version'] = image['operating_system_version'] # Decode Cloud Init Yaml if 'metadata' in instance and 'user_data' in instance['metadata']: instance['metadata']['user_data'] = base64.b64decode(instance['metadata']['user_data']).decode('utf-8') # Add Attached Block Storage Volumes instance['block_storage_volume_ids'] = [va['volume_id'] for va in volume_attachments if va['instance_id'] == instance['id']] # Add Vnic Attachments instance['vnics'] = [va for va in vnic_attachments if va['instance_id'] == instance['id']] if len(instance['vnics']) > 0: instance['primary_vnic'] = instance['vnics'] # Add first vnic as the default subnet instance['subnet_id'] = instance['vnics'][0]['subnet_id'] if len(instance['vnics']) > 0 else '' # Get Volume Attachments as a single call and loop through them to see if they are associated with the instance. boot_volume_attachments = OCIBootVolumeAttachments(config=self.config, configfile=self.configfile, profile=self.profile, compartment_id=compartment_id, availability_domain=instance['availability_domain'], instance_id=instance['id']).list() instance['boot_volume_size_in_gbs'] = boot_volume_attachments[0]['boot_volume']['size_in_gbs'] instance['is_pv_encryption_in_transit_enabled'] = boot_volume_attachments[0]['is_pv_encryption_in_transit_enabled'] # Build object list self.instances_obj.append(OCIInstance(self.config, self.configfile, self.profile, instance)) logJson(self.instances_json) logger.info(str(self.instances_json)) return self.instances_json
def dropdownQuery(): if request.method == 'GET': dropdown_json = {} # Regions oci_regions = OCIRegions() dropdown_json["regions"] = sorted(oci_regions.list(), key=lambda k: k['name']) # Services oci_services = OCIServices() dropdown_json["services"] = sorted(oci_services.list(), key=lambda k: k['name']) # Instance Shapes oci_shapes = OCIShapes() dropdown_json["shapes"] = sorted(oci_shapes.list(), key=lambda k: k['sort_key']) # Instance Images oci_images = OCIImages() dropdown_json["images"] = sorted(oci_images.list(), key=lambda k: k['sort_key']) # Database System Shapes db_system_shapes = OCIDatabaseSystemShapes() dropdown_json["db_system_shapes"] = sorted(db_system_shapes.list(), key=lambda k: k['shape']) # Database Versions db_versions = OCIDatabaseVersions() dropdown_json["db_versions"] = sorted(db_versions.list(), key=lambda k: k['version']) # CPE Device Shapes # TODO: Upgrade OCI Python Module #cpe_device_shapes = OCICpeDeviceShapes() #dropdown_json["cpe_device_shapes"] = sorted(cpe_device_shapes.list(), key=lambda k: k['cpe_device_info']['vendor']) # Fast Connect Provider Services fast_connect_provider_services = OCIFastConnectProviderServices() dropdown_json["fast_connect_provider_services"] = sorted( fast_connect_provider_services.list(), key=lambda k: k['provider_name']) return dropdown_json else: return 'Unknown Method', 500