Skip to content

feat: add IBM Softlayer to enable using IBM Classic Infrastructure #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 27, 2024

Conversation

a-dubs
Copy link
Contributor

@a-dubs a-dubs commented May 7, 2024

IBM Classic Infrastructure actually has quite a robust SDK. Adding IBM CLassic/Softlayer to pycloudlib will provide immediate value to Canonical, and I'm sure this could be useful for other 3rd parties.

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch from 8db9b23 to 11de863 Compare May 7, 2024 19:48
@a-dubs a-dubs marked this pull request as draft May 7, 2024 20:07
@a-dubs a-dubs force-pushed the add-ibm-softlayer branch 6 times, most recently from f850131 to 56ba606 Compare May 14, 2024 14:47
@a-dubs a-dubs marked this pull request as ready for review May 14, 2024 14:47
@a-dubs a-dubs force-pushed the add-ibm-softlayer branch 2 times, most recently from 391ce62 to 981da5c Compare May 23, 2024 02:54
@aciba90 aciba90 self-assigned this May 23, 2024
Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @a-dubs, for adding this feature!

I have left in-line comments / requests. In addition to that, could we please add a documentation section to docs/clouds, explaining at least what configuration is required to use the new cloud (api keys, etc)?

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch 6 times, most recently from e3a0ff3 to 208438f Compare June 4, 2024 15:41
Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @a-dubs, for addressing the concerns and fixing stuff.

Apart from in-line comments, what is still missing is:

could we please add a documentation section to docs/clouds, explaining at least what configuration is required to use the new cloud (api keys, etc)?

Documentation about IBM classic's specificities.

Another question: we refer to IBM classic / softlayer interchangeably, with the code and within log messages and exceptions. I wonder if it would be better to stick to one of the terms globally, or if not, clearly document it somewhere.

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 5, 2024

Another question: we refer to IBM classic / softlayer interchangeably, with the code and within log messages and exceptions. I wonder if it would be better to stick to one of the terms globally, or if not, clearly document it somewhere.

Good question. Unfortunately, at this point, I really think I'd rather refer to it as IBM Classic. This is mostly because despite the IBM provided sdk and api being called softlayer, this is not obvious to an end user, who sees either "IBM VPC" or "IBM Classic" when browsing IBM Cloud Console, with no obvious mention of softlayer. So if you agree, I'll go through and mass rename everything to IBM Classic. I would like the naming to be consistent throughout for sure.

Also, when I write up the docs for this new IBM Softlayer Classic cloud, I'll be sure to have a small preamble in there that explains this naming confusion.

@aciba90
Copy link
Collaborator

aciba90 commented Jun 6, 2024

+1 to the renaming to classic, thanks!

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch 2 times, most recently from ff1dc9e to bcded64 Compare June 17, 2024 20:08
Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, @a-dubs, for the renaming and documentation efforts, this is getting in shape.

I left in-line comments and in addition to that we need to:

  1. Include the new cloud config in pycloudlib.toml.template.
  2. Remove Softlayer from TODO.md.

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 20, 2024

leaving a TODO for myself:
add more config options to pycloudlib.toml such as domain_name since this should not change between instance launches

Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments. I left some minor comments.

leaving a TODO for myself:
add more config options to pycloudlib.toml such as domain_name since this should not change between instance launches

Is this a TODO for this PR or for the future? If for the future, could you please create a GH issue to not forget about it, or let others help with it?

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 25, 2024

@aciba90 regarding the delete_image function, mypy only throws an error when I change the function definition to have image_id be an int. Also if self._image_manager.delete_image(int(image_id)) raises an error on failing to cast an int, then that is good, because the softlayer image id is numeric and should never fail to be cast to an int. Should I wrap this in a try catch and raise a pycloudlib IBMClassicException though?

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch from b7b169e to d6e33de Compare June 25, 2024 12:30
@aciba90
Copy link
Collaborator

aciba90 commented Jun 25, 2024

@aciba90 regarding the delete_image function, mypy only throws an error when I change the function definition to have image_id be an int. Also if self._image_manager.delete_image(int(image_id)) raises an error on failing to cast an int, then that is good, because the softlayer image id is numeric and should never fail to be cast to an int. Should I wrap this in a try catch and raise a pycloudlib IBMClassicException though?

Ahh, I see your point now, then I guess it does not matter that much. We could:

  1. self._image_manager.delete_image(int(image_id)) (as-is) with or without exception handling
  2. Use https://docs.python.org/3/library/typing.html#typing.cast and self._image_manager.delete_image(image_id)
  3. self._image_manager.delete_image(image_id)
  4. Modify the parent and children types associated to image_id to Union[str, int]

(1) does a superfluous type conversion at runtime
(2) is type-checking the softlayer API / SDK
(3) is probably obscure
(4) unnecessarily complex

I leave it up to you to decide.

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 25, 2024

I'll go for (1) I guess then! Feels like the better solution among the rest. Thanks for your input!

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 25, 2024

I'm doing one final round of testing to make sure everything functions as desired. I will report back when done.

Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the long work here!

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 26, 2024

IT FINALLY WORKED RAHHHH LETS GOOOO

                                 #@@@@@@@@@@@@@@@#                                                  
                           *@@@*.........::::::::::-%@@@*                                           
                        %@@:..........:**=:::::::::::::::=@@%                                       
                     @@+.....-@@@#:....::::::*@%::=@:::::::::+@@                                    
                  #@-....@%:..........:::::::::::-@=:#-:::::::::%@@                                 
              +@@@%...*@..............::::-+%%#=:::::#:#:-:::::::::@@#                              
           #@#.....%@@...........+@@@@@@@@#:::::::::-::::%@::::::::::-@#                            
    #@@@@%@@@*..#..%:.......:@@@@@@@*:::::::::::::-@:::::::@:::::::::::-@+                          
  #@......%.....:.@......*@@@@@@#.::::::::::::::@@%@::#@#:::::-*+-:::::-:-:-                        
  @@@:........:%.-.........@@@@...:-%@@@@@@@@@@@+*@@@-:@:-@::..+*=...++--+.#%                       
  @.@*:......*#..........:@@@@@@@#:::::::::::::::-:::-@:*::::.:::::::-%+-#---@                      
  @..@:......@*.........@@@@*...::::-:::::::+%#=---:=-:@:::+.+::::::::::------@                     
  @...@......++....%%@@@@@:....:::::::::::::::::--:::::#:::=.::::::::::--------@#                   
  @=..-@.....:@......*@@@@@@@@@@@@@@@@@*#@::::::*#:::-*::::.=:::%::::::---------@*                  
  @.@%:.#@....@@@@@@*:.......:::::::::::+@@@-::::-+=%@%::::.+::::-::::-----------@#                 
  @.......*@@@-....+@@@@@@%##########%%@@@#@@@:::::@@@:::::.+::::-+::-------------@                 
 @.....@@#..:%@@@##########################%@#@%::::@@:::::::::::::#---------------@                
#-...@..:@@%#######@..@@###@. .@%##@..@##@: .@%#@::::@:::::+.::-:::-----------------@               
@..#-.@@#@@@######@.  ..@%=    .%@@.  .%@.   .@#@@::::@::::= =-:::------------------@               
@.:+%@#%@. ..@%#%@.     .+.     .=.    :.     @. .@::::*::::.*:::----#--*-----------=@              
 @%@###@.    ..#*.       %.     ..     #.    ..   .@-:::::::*.-:------=--@-----------@              
  @@.#@=                 %.     .            ..  .*.@-::-@::-.*:------%---@----------@%             
   @. .:                 ..    .#     :.   ..   .%. :@-::=@-:=.--------@--+@---------%@             
   @. .@                 =.    :.    .=  .::  .:...%@@@-::*@--.*-------*---@=--------+@             
    @. ..             ...--. .*%@@#@@@@@@@@@@@@@@@@@@@@@-::#@**.--------@---@---------@             
    *#.        .+@@@%#@@:..%+.  .@%%@@@@@@@%@@@@@@@@@@@@@:::@=*-.-------%---@---------@             
      @.  .@#-...+.   .+   =.  .@@@@@@@@@@@@@@@@@@@@@@@@@@---@-=.=------=@---%----**+-@             
       %@.@.     .   .:. .:=..:@@@%%%%%%%%%@@@@@@@@@@%%%@@@---@-=.#------@---%--#.#=#. +            
          @@#...#=..=@@%%%%%%%@@@@@@@@@@@@@@@@@@@%%%%%%%%@@@---@-%.+-----@+---==.*---=@             
           @@@@@@@@@@@@@@@@@@@@@@@@@%%%@@%%%%%@%%%%%%%%%%%@@@---@@*.=----+@---=:.----+@             
            @-.=@%#%@@@@@@%%%%%%%@@@@@%##%%%@%%%%%%%%%%%%%@@@@---@@#.*----@----.*----@@             
             @.:#@%#%%%@%@@@@@@@@%%@%#####%@%%%%%%%%%%%%%@@@@@@--=@--..---@=--=.-----@              
             #@::@%@%%%%@@%%%%@@@@@#######@%%%%%%%%%%%%@@@@@@@@@--=---*..=%%-*.+----#@              
              @=::@#@%%%%%@@@@%%@@#######%##%%%%%%%%%%@@@@@@@@@@@-------=.....=--#--@               
               @:::@#%#%%%%@@@@@%#######%####%%%%%%%@@@@@%@@@@@@@@--#------@-----@-@                
               *@::-%%#%%%%@@@@##############%%%%%@@@=.    .#@@@@@---=-----@-----@@*                
                @=::#%@#%%%@@@###############%%%@%.--.       .%@@@+--------@----@@%                 
                 @:::%@@@@@.=@###########%@@#@..       .      .-@@---*-----@----@@                  
                @@+:@@%*.. .@##%%..+@@*.                #-... .=@----@-----@---@@                   
                @+@@    ..:                   .*.        @####%#----@------@--@%                    
               %-%@.                   .       #@@@=.  .:@##@#----@#@-----#@@@                      
               @*@                     #       :%####%@@%@@----@@*+@-----=@@#                       
              @#*.                     .+.    .@#####@@#-%=*%#*+@=#-----%@%                         
             #@*@. .+%.         .@+.   .@%@%:.@#%@@%+==+@%==++@-------+@%                           
             @:@@..@%@%  .@@.  .%%##@#*@###@@@*-%=++==+%+@@#==+%--%@@@*                             
             @::@@%###@%-@###@:%%####@@@@+---=-----+===============+*%                              
             #@:::@@%######%@@@@@@*-:-:::--+#*=-=-+%=%+===+*%#====++++*%%%%                         
               @@:::::::-:::::::+%@@@-::------------------%#+%#  #%#++++%+                          
                  *@@@@@@@@@@@@@@*@=@+@=**----------%@@@@*             ##+++%*                      
                                #%@@@@@@@@@@@@@@%#*                        +%*++%#                  
                                                                                 #%#%               
                                                                                                    
                                                                                          %%%       
                                                                                             %+*%   
                                                                                                #%*#

@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 26, 2024

Proof of working run (in case i gaslight myself and forget if it worked or not):
ibm-classic-example-successful-run.log

@aciba90
Copy link
Collaborator

aciba90 commented Jun 26, 2024

Sweet @a-dubs, could you please resolve conflicts in VERSION?

@aciba90
Copy link
Collaborator

aciba90 commented Jun 26, 2024

Latest commit: 50089ec contains commented code and non-trivial changes. Is that all required?

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch from 50089ec to df5e4f2 Compare June 26, 2024 15:08
@a-dubs
Copy link
Contributor Author

a-dubs commented Jun 26, 2024

@aciba90 fixed version

@a-dubs a-dubs force-pushed the add-ibm-softlayer branch from df5e4f2 to 5a13a2c Compare June 26, 2024 15:13
@a-dubs a-dubs force-pushed the add-ibm-softlayer branch from f7b6a89 to ab9c09b Compare June 26, 2024 17:06
@aciba90 aciba90 merged commit 86c02b8 into canonical:main Jun 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants