@@ -1591,26 +1591,27 @@ def rebuild(
15911591
15921592 :param image: The Image to deploy to this Instance
15931593 :type image: str or Image
1594- :param root_pass: The root password for the newly rebuilt Instance. If
1595- omitted, a password will be generated and returned.
1594+ :param root_pass: The root password for the newly rebuilt Instance.
1595+ At least one of root_pass or authorized_keys is
1596+ required. Both may be provided.
15961597 :type root_pass: str
15971598 :param authorized_keys: The ssh public keys to install in the linode's
15981599 /root/.ssh/authorized_keys file. Each entry may
15991600 be a single key, or a path to a file containing
1600- the key.
1601+ the key. At least one of authorized_keys or
1602+ root_pass is required.
16011603 :type authorized_keys: list or str
16021604 :param disk_encryption: The disk encryption policy for this Linode.
16031605 NOTE: Disk encryption may not currently be available to all users.
16041606 :type disk_encryption: InstanceDiskEncryptionType or str
16051607
1606- :returns: The newly generated password, if one was not provided
1607- (otherwise True)
1608- :rtype: str or bool
1608+ :returns: True if the rebuild was successful.
1609+ :rtype: bool
16091610 """
1610- ret_pass = None
1611- if not root_pass :
1612- ret_pass = Instance . generate_root_password ()
1613- root_pass = ret_pass
1611+ if not root_pass and not authorized_keys :
1612+ raise ValueError (
1613+ "At least one of root_pass or authorized_keys is required."
1614+ )
16141615
16151616 authorized_keys = load_and_validate_keys (authorized_keys )
16161617
@@ -1639,10 +1640,7 @@ def rebuild(
16391640 # update ourself with the newly-returned information
16401641 self ._populate (result )
16411642
1642- if not ret_pass :
1643- return True
1644- else :
1645- return ret_pass
1643+ return True
16461644
16471645 def rescue (self , * disks ):
16481646 """
0 commit comments