Forum Discussion

Steve_Brown_882's avatar
Steve_Brown_882
Historic F5 Account
Jul 13, 2009

more pyControl questions

I am on to a new script and I just can't seem to get the code to work. I am trying to use

 

 

 

Management_KeyCertificate.certificate_request_import_from_file(

 

mode = 0, I think this is correct.

 

key_ids = "Name", I think this is what you want the key to be named when it

 

file_names = , Should this be an OS path or do I need to open the file first as an object?

 

overwrite = 0 I tried 0 'false'

 

)

 

 

 

The problem is I can't for the life of me figure out the syntaxt of the commands. I have tried quite a few things, but no luck. Does anyone have an example of this in python?

 

 

 

  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Ok I think I am close, but still can't get this to work.

     

     

    Here is what I have that doesn't work. I was able to export a key, so I know the "mode = 0" and "['testKey']" portions work.

     

     

     

    b.Management_KeyCertificate.key_import_from_file(

     

    mode = 0,

     

    key_ids = ['testKey'],

     

    file_names = ['c:\\Cert\\test.key'])

     

     

     

     

    I also tried some thing like this, with no luck.

     

     

     

    mycert = open('c:\\Cert\\test.key')

     

    b.Management_KeyCertificate.key_import_from_file(

     

    mode = 0,

     

    key_ids = ['testKey'],

     

    file_names = [mycert.read()])

     

  • Here's an example of some code that works syntax wise:

     

     
     In [20]: b.Management_KeyCertificate.key_import_from_file(mode = 'MANAGEMENT_MODE_DEFAULT', key_ids = ['testKey.key'], file_names = ['/config/ssl/ssl.key/testKey.key'], overwrite = 1) 
     

     

    Notice that the file is located on the LTM, as opposed to the local filesystem. Have a look at some of the import calls that will allow you to do this.

     

     

    HTH,

     

    Matt
  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Ah ok. Well that makes sence then that it wouldn't work the way I was trying it. I liked this way better because it had built in overwrite control, but at least I know I wasn't going crazy! Thanks for the responce.
  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Ok Matt I think I can probably get this with one last question.

     

     

    I started looking at System_ConfigSync.upload_file and it seems like exactly what I need, but I can't figure out for the life of me how to pass the file_context paramaters. I think this is just a case of me being so new to python, but any help you can give me would be really appreciated. I think I need to define an object that has the opened file in it and the chunking info etc in it but I am not sure.

     

     

    c = open("c:\\Cert\\test.crt")

     

    >>> mycert = c.read()

     

     

    b.System_ConfigSync.upload_file(

     

    file_name = ['/config/ssl/ssl.key/test.crt'],

     

    file_context = ????? )
  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Thanks so much for all of you help and the general info on how to figure it out should be helpful.