Last active
          October 2, 2016 08:23 
        
      - 
      
- 
        Save pramodshinde/def0c0824d46019e033457ea3e50558b to your computer and use it in GitHub Desktop. 
Revisions
- 
        Pramod Shinde revised this gist Oct 2, 2016 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ class LinodeService #Replace following contacts as per your needs PLAN_ID = 1 API_KEY = 'xyz' DATACENTERS = { newark: 6, london: 7 @@ -68,7 +68,6 @@ def delete private def linode_client @client ||= Linode.new(api_key: API_KEY) end end 
- 
        Pramod Shinde created this gist Oct 1, 2016 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ #If you are refering this gist, I would suggest to refer my blog post and Linode gem documentation # post url: https://pramodbshinde.wordpress.com/2016/10/01/spot-instances-with-linode # gem url: https://github.com/rick/linode class LinodeService #Replace following contacts as per your needs PLAN_ID = 1 DATACENTERS = { newark: 6, london: 7 } SOURCE_LINODES = { london: 5679, newark: 1234 } def initialize linode_client end #Clone new linode and boot def launch_linode @linode = clone boot end #Launching instance def clone @client.linode.clone( linodeid: SOURCE_LINODES[:london], datacenterid: DATACENTERS[:london], planid: PLAN_ID ) end #Booting instance def boot @linode.boot(linodeid: @linode.linodeid) end ##Updating instance def update @client.linode.update( linodeid: @linode.linodeid, label: 'Instance' + '-' + @linode.linodeid.to_s, lpm_displaygroup: 'My Linodes' ) end #Listing instances def list @client.linode.list end #Getting IP address of linode def ip_address data = @client.linode.ip.list(linodeid: @linode.linodeid) data.first.ipaddress end #Deleting instance def delete @linode.delete(linodeid: linodeid, skipChecks: true) end private def linode_client API_KEY = 'xyz' @client ||= Linode.new(api_key: API_KEY) end end service = LinodeService.new service.launch_linode service.ip_address => 209.123.234.161 
 Pramod Shinde
              revised
            
            this gist
            
              Pramod Shinde
              revised
            
            this gist