Ejemplo n.º 1
0
    def get(self, name):
        resource_type = self.client.get_resource_type(name=name).data
        # Convert to Json object
        self.resource_type_json = self.toJson(resource_type)
        logger.debug(jsonToFormattedString(self.resource_type_json))

        return self.resource_type_json
Ejemplo n.º 2
0
def resourceTypes(profile):
    if request.method == 'GET':
        resource_types = OCIResourceTypes(profile=profile)
        resource_types_json = resource_types.list()
        return jsonToFormattedString(resource_types_json)
    else:
        return 'Unknown Method', 500
 def executeQuery(self, regions=None, **kwargs):
     logger.info(f'Querying Dropdowns - Region: {regions}')
     if self.instance_principal:
         self.config['tenancy'] = self.getTenancy()
     if regions is None:
         regions = [self.config['region']]
         logger.info(f'No Region Specified using - Region: {regions}')
     discovery_client = OciResourceDiscoveryClient(self.config, self.signer, regions=regions, include_resource_types=self.SUPPORTED_RESOURCES, compartments=[self.config['tenancy']])
     # Get Supported Resources
     response = self.response_to_json(discovery_client.get_all_resources())
     logger.debug('Response JSON : {0!s:s}'.format(jsonToFormattedString(response)))
     response_json = self.convert(response)
     return response_json
Ejemplo n.º 4
0
    def list(self, filter=None):
        if filter is None:
            filter = {}

        resource_types = oci.pagination.list_call_get_all_results(
            self.client.list_resource_types).data

        # Convert to Json object
        resource_types_json = self.toJson(resource_types)
        logger.debug(str(resource_types_json))

        # Filter results
        self.resource_types_json = self.filterJsonObjectList(
            resource_types_json, filter)
        logger.debug(jsonToFormattedString(self.resource_types_json))

        return self.resource_types_json
Ejemplo n.º 5
0
 def file_storage_systems(self, file_storage_systems, resources):
     for fs in file_storage_systems:
         fs["exports"] = [
             e for e in resources.get("Export", [])
             if e["file_system_id"] == fs["id"]
         ]
         export_set_ids = [e["export_set_id"] for e in fs["exports"]]
         export_sets = [
             e for e in resources["ExportSet"] if e["id"] in export_set_ids
         ]
         fs["mount_targets"] = [
             m for m in resources["MountTarget"]
             if m["export_set_id"] in export_set_ids
         ]
         for mt in fs["mount_targets"]:
             ess = [
                 e for e in export_sets if e["id"] == mt["export_set_id"]
             ]
             mt["export_set"] = ess[0] if len(ess) else {}
     logger.info(jsonToFormattedString(file_storage_systems))
     return file_storage_systems
    def parse(self, cd3_excel=None):
        if cd3_excel is not None:
            self.cd3_excel = cd3_excel

        self.okit_json = self.initialiseOkitJson()
        result_json = {"okit_json": {}, "warnings": {}}

        if self.cd3_excel is not None:
            logger.info("Excel File  {0!s:s}".format(cd3_excel))
            wb = load_workbook(cd3_excel, read_only=True)
            logger.info(wb.sheetnames)
            # Set Root Compartment Id
            self.okit_json["compartments"][0]["id"] = self.ROOT_COMPARTMENT_ID
            self.parseCompartments(wb[self.COMPARTMENT_SHEET])
            self.parseVirtualCloudNetworks(wb[self.VCN_SHEET])
            self.parseSubnets(wb[self.SUBNET_SHEET])
            logger.info(jsonToFormattedString(self.okit_json))
            result_json["okit_json"] = self.okit_json
            wb.close()

        return result_json
Ejemplo n.º 7
0
def load_json(filename):
    # print(filename)
    # print(type(filename))
    # OCI_resources
    resources = []
    # data = filename
    # for item in data:

    # Get all resource names
    for item in filename:
        resources.append(item)
    # remove non-OCI resources
    del resources[0:3]
    all_resources = resources[:-1]

    # Call pricing calculator
    OKIT_RESULTS = price_calculator(filename, all_resources)
    logger.debug(jsonToFormattedString(OKIT_RESULTS[0]))
    logger.debug("BoM")
    logger.debug(OKIT_RESULTS[1])

    return OKIT_RESULTS[0]
Ejemplo n.º 8
0
def ociRegions(profile):
    oci_region_query = OCIRegionQuery(profile=profile)
    regions = oci_region_query.executeQuery()
    response = jsonToFormattedString(regions)
    logger.debug(">>>>>>>>> Regions: {0!s:s}".format(response))
    return response