mds_plugin/compute.py
def update_instance(instance_name=None, **kwargs):
    """Updates a compute instance with the new values

    If no name is given, it will prompt the user for the name.

    Args:
        instance_name (str): The name of the instance.
        **kwargs: Additional options.

    Keyword Args:
        instance_id (str): The OCID of the instance.
        name (str): The new name to use
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        interactive (bool): Whether user input is required.

    Returns:
       None
    """
    instance_id = kwargs.get("instance_id")
    compartment_id = kwargs.get("compartment_id")
    config = kwargs.get("config")
    new_name = kwargs.get("name")
    interactive = kwargs.get("interactive", True)

    # Get the active config and compartment
    try:
        config = configuration.get_current_config(config=config)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)

        import oci.core.models
        import oci.exceptions
        import mysqlsh

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

        if instance_id is None or instance_id == "":
            instance = get_instance(
                instance_name=instance_name, compartment_id=compartment_id,
                config=config, interactive=interactive,
                return_python_object=True)
        else:
            instance = get_instance_by_id(
                instance_id=instance_id, config=config,
                interactive=interactive,
                return_python_object=True)

        if new_name is None and interactive:
            new_name = mysqlsh.globals.shell.prompt(
                "Please enter a new name for the instance "
                f"[{instance.display_name}]: ",
                {'defaultValue': instance.display_name}).strip()

        if new_name == instance.display_name:
            print("Operation cancelled.")
            return

        update_details = oci.core.models.UpdateInstanceDetails(
            display_name=new_name
        )
        compute.update_instance(instance_id=instance.id,
                                update_instance_details=update_details)

        print(f"Compute instance {instance.display_name} was updated.\n")
    except oci.exceptions.ServiceError as e:
        if e.code == "NotAuthorizedOrNotFound":
            print(f'You do not have privileges to delete this instance.\n')
        else:
            print(
                f'Could not delete the instance {instance.display_name}\n')
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
    except Exception as e:
        print(f"ERROR: {str(e)}")
Updates a compute instance with the new values

    If no name is given, it will prompt the user for the name.

    Args:
        instance_name (str): The name of the instance.
        **kwargs: Additional options.

    Keyword Args:
        instance_id (str): The OCID of the instance.
        name (str): The new name to use
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        interactive (bool): Whether user input is required.

    Returns:
       None
    
Updates a compute instance with the new values
If no name is given, it will prompt the user for the name.
Updates a compute instance with the new values If no name is given it will prompt the user for the name .
def update_instance(instance_name=None, **kwargs):
    instance_id = kwargs.get("instance_id")
    compartment_id = kwargs.get("compartment_id")
    config = kwargs.get("config")
    new_name = kwargs.get("name")
    interactive = kwargs.get("interactive", True)
    try:
        config = configuration.get_current_config(config=config)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)
        import oci.core.models
        import oci.exceptions
        import mysqlsh
        compute = core.get_oci_compute_client(config=config)
        if instance_id is None or instance_id == "":
            instance = get_instance(
                instance_name=instance_name, compartment_id=compartment_id,
                config=config, interactive=interactive,
                return_python_object=True)
        else:
            instance = get_instance_by_id(
                instance_id=instance_id, config=config,
                interactive=interactive,
                return_python_object=True)
        if new_name is None and interactive:
            new_name = mysqlsh.globals.shell.prompt(
                "Please enter a new name for the instance "
                f"[{instance.display_name}]: ",
                {'defaultValue': instance.display_name}).strip()
        if new_name == instance.display_name:
            print("Operation cancelled.")
            return
        update_details = oci.core.models.UpdateInstanceDetails(
            display_name=new_name
        )
        compute.update_instance(instance_id=instance.id,
                                update_instance_details=update_details)
        print(f"Compute instance {instance.display_name} was updated.\n")
    except oci.exceptions.ServiceError as e:
        if e.code == "NotAuthorizedOrNotFound":
            print(f'You do not have privileges to delete this instance.\n')
        else:
            print(
                f'Could not delete the instance {instance.display_name}\n')
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
    except Exception as e:
        print(f"ERROR: {str(e)}")
def update_instance ( instance_name = None , ** kwargs ) : instance_id = kwargs . get ( "instance_id" ) compartment_id = kwargs . get ( "compartment_id" ) config = kwargs . get ( "config" ) new_name = kwargs . get ( "name" ) interactive = kwargs . get ( "interactive" , True ) try : config = configuration . get_current_config ( config = config ) compartment_id = configuration . get_current_compartment_id ( compartment_id = compartment_id , config = config ) import oci . core . models import oci . exceptions import mysqlsh compute = core . get_oci_compute_client ( config = config ) if instance_id is None or instance_id == "" : instance = get_instance ( instance_name = instance_name , compartment_id = compartment_id , config = config , interactive = interactive , return_python_object = True ) else : instance = get_instance_by_id ( instance_id = instance_id , config = config , interactive = interactive , return_python_object = True ) if new_name is None and interactive : new_name = mysqlsh . globals . shell . prompt ( "Please enter a new name for the instance " f"[{instance.display_name}]: " , { 'defaultValue' : instance . display_name } ) . strip ( ) if new_name == instance . display_name : print ( "Operation cancelled." ) return update_details = oci . core . models . UpdateInstanceDetails ( display_name = new_name ) compute . update_instance ( instance_id = instance . id , update_instance_details = update_details ) print ( f"Compute instance {instance.display_name} was updated.\n" ) except oci . exceptions . ServiceError as e : if e . code == "NotAuthorizedOrNotFound" : print ( f'You do not have privileges to delete this instance.\n' ) else : print ( f'Could not delete the instance {instance.display_name}\n' ) print ( f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})' ) except Exception as e : print ( f"ERROR: {str(e)}" )
Updates a compute instance with the new values
If no name is given, it will prompt the user for the name.
Updates a compute instance with the new values If no name is given it will prompt the user for the name .
"""Updates a compute instance with the new values

    If no name is given, it will prompt the user for the name.

    Args:
        instance_name (str): The name of the instance.
        **kwargs: Additional options.

    Keyword Args:
        instance_id (str): The OCID of the instance.
        name (str): The new name to use
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        interactive (bool): Whether user input is required.

    Returns:
       None
    """ # Get the active config and compartment
 # Initialize the compute client

None
instance_name
The name of the instance.
The name of the instance .
**kwargs
None