mds_plugin/compute.py
def list_instances(**kwargs):
    """Lists instances

    This function will list all instances of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment.
        config (object): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned.

    Returns:
        A list of dicts representing the compartments
    """

    compartment_id = kwargs.get("compartment_id")
    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")

    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)
    return_formatted = kwargs.get("return_formatted", interactive)

    import oci.exceptions
    import oci.util
    import oci.pagination

    try:
        config = configuration.get_current_config(
            config=config, config_profile=config_profile,
            interactive=interactive)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)
        current_instance_id = configuration.get_current_instance_id(
            config=config)

        # Initialize the identity client
        compute = core.get_oci_compute_client(config=config)

        # List the compute instances
        instances = compute.list_instances(
            compartment_id=compartment_id).data

        # Filter out all deleted compartments
        instances = [c for c in instances if c.lifecycle_state != "DELETED" and
                     c.lifecycle_state != "TERMINATED"]

        if return_formatted:
            # Get all VNICs of the compartment
            vnics = oci.pagination.list_call_get_all_results(
                compute.list_vnic_attachments,
                compartment_id=compartment_id).data

            return format_instance_listing(
                items=instances, vnics=vnics,
                current=current_instance_id, config=config)
        else:
            return oci.util.to_dict(instances)
    except oci.exceptions.ServiceError as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
        return
    except Exception as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e}')
        return
Lists instances

    This function will list all instances of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment.
        config (object): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned.

    Returns:
        A list of dicts representing the compartments
    
Lists instances
This function will list all instances of the compartment with the
given compartment_id.
Lists instances This function will list all instances of the compartment with the given compartment_id .
def list_instances(**kwargs):
    compartment_id = kwargs.get("compartment_id")
    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)
    return_formatted = kwargs.get("return_formatted", interactive)
    import oci.exceptions
    import oci.util
    import oci.pagination
    try:
        config = configuration.get_current_config(
            config=config, config_profile=config_profile,
            interactive=interactive)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)
        current_instance_id = configuration.get_current_instance_id(
            config=config)
        compute = core.get_oci_compute_client(config=config)
        instances = compute.list_instances(
            compartment_id=compartment_id).data
        instances = [c for c in instances if c.lifecycle_state != "DELETED" and
                     c.lifecycle_state != "TERMINATED"]
        if return_formatted:
            vnics = oci.pagination.list_call_get_all_results(
                compute.list_vnic_attachments,
                compartment_id=compartment_id).data
            return format_instance_listing(
                items=instances, vnics=vnics,
                current=current_instance_id, config=config)
        else:
            return oci.util.to_dict(instances)
    except oci.exceptions.ServiceError as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
        return
    except Exception as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e}')
        return
def list_instances ( ** kwargs ) : compartment_id = kwargs . get ( "compartment_id" ) config = kwargs . get ( "config" ) config_profile = kwargs . get ( "config_profile" ) interactive = kwargs . get ( "interactive" , core . get_interactive_default ( ) ) raise_exceptions = kwargs . get ( "raise_exceptions" , not interactive ) return_formatted = kwargs . get ( "return_formatted" , interactive ) import oci . exceptions import oci . util import oci . pagination try : config = configuration . get_current_config ( config = config , config_profile = config_profile , interactive = interactive ) compartment_id = configuration . get_current_compartment_id ( compartment_id = compartment_id , config = config ) current_instance_id = configuration . get_current_instance_id ( config = config ) compute = core . get_oci_compute_client ( config = config ) instances = compute . list_instances ( compartment_id = compartment_id ) . data instances = [ c for c in instances if c . lifecycle_state != "DELETED" and c . lifecycle_state != "TERMINATED" ] if return_formatted : vnics = oci . pagination . list_call_get_all_results ( compute . list_vnic_attachments , compartment_id = compartment_id ) . data return format_instance_listing ( items = instances , vnics = vnics , current = current_instance_id , config = config ) else : return oci . util . to_dict ( instances ) except oci . exceptions . ServiceError as e : if raise_exceptions : raise print ( f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})' ) return except Exception as e : if raise_exceptions : raise print ( f'ERROR: {e}' ) return
Lists instances
This function will list all instances of the compartment with the
given compartment_id.
Lists instances This function will list all instances of the compartment with the given compartment_id .
"""Lists instances

    This function will list all instances of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment.
        config (object): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned.

    Returns:
        A list of dicts representing the compartments
    """ # Initialize the identity client
 # List the compute instances
 # Filter out all deleted compartments
 # Get all VNICs of the compartment

A list of dicts representing the compartments
A list of dicts representing the compartments
**kwargs
None