#NEWLINE# def attempt_device( self ) : #NEWLINE# #INDENT# "Attempt to set ``device`` attribute to its ID if hostname was given\n\n        If an ID was provided during init, this happens in init. If a hostname\n        was provided, we need to take care of a couple things.\n\n        1. Attempt to fetch ID for existing device by the hostname. If this\n           works, use this ID\n\n        2. Should #1 fail, set device id to 0 to signify this device doesn't\n           exist yet, hoping this method will be called again when it's time to\n           create. The thought here is if a user is instantiating lots of\n           resources at the same time, there's a chance the device this relates\n           to is going to be created before this one actually gets called upon.\n\n           0 is used instead of a more descriptive message because should the\n           device still not exist when executing this, at least a device\n           doesn't exist error would be returned instead of expecting int not\n           str.\n        " #NEWLINE# rerun = ( isinstance ( self . _original_device , str ) and ( self . device == 0 ) ) #NEWLINE# first_run = isinstance ( self . device , str ) #NEWLINE# if ( rerun or rerun ) : #NEWLINE# #INDENT# d = Device ( client = self . client , site_id = self . _site_id , hostname = self . _original_device ) #NEWLINE# if d . exists ( ) : #NEWLINE# #INDENT# self . device = d . existing_resource ( ) [ 'id' ] #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . device = 0 #NEWLINE# return False