13 Replies Latest reply: Apr 4, 2012 4:32 AM by Rohit Nayyar RSS

Current Role Using BLCLI

Steven Scarborough

How do you get your current role using BLCLI?

  • 1. Re: Current Role Using BLCLI
    Greg Kullberg

    That's a good question. Are you using a user_info.dat file?

     

    You can specify a Role either by using the -r switch in your BLCLI call, or by echoing the BL_RBAC_ROLE environment variable (if it's been set).

     

    Outside of the BLCLI you can always use the 'blid' command to get your current Role.

  • 2. Re: Current Role Using BLCLI
    Steven Scarborough

    Thanks Greg for responding. The info was helpful. Can you give me the correct syntax to assign the Role value to BL_RBAC_ROLE using BLCLI? If I "chrole role_name" the variable does get set.

     

    Thanks again.

    Steve

  • 3. Re: Current Role Using BLCLI
    Greg Kullberg

    Because it's an environment variable, you wouldn't set BL_RBAC_ROLE using the BLCLI. Take a look at the BladeLogicAdministration.pdf in the "Environment Variables" section under "Administering Security" for info on setting it.

  • 4. Re: Current Role Using BLCLI
    Bill Robinson

    there's 'unreleased' blcli RBACUser getCurrentUser which should do the trick.

  • 5. Re: Current Role Using BLCLI
    James Andrews

    Hi,

     

    If you do import BRProfile:

    from com.bladelogic.client import BRProfile

     

    You can use:

    BRProfile.getCurrentRole()

     

    To output the current role in script.

     

    Don't think you need to enable unreleased commands to use this method.

     

    Thanks,

    James

     

    Message was edited by:

    James Andrews

  • 6. Re: Current Role Using BLCLI
    Steven Scarborough

    Thanks for all of the feedback, it has been helpful. I'm just starting to work with scripting BL and have a lot to learn. I have a question about the last 2 responses;

     

    1) How do you enable 'unreleased' commands?

    2) How do you import BRProfile?

     

    If you could just point me in the right direction I would appreciate it.

     

    Best regards,

    Steve Scarborough

    UMB

  • 7. Re: Current Role Using BLCLI
    Bill Robinson

    on unix run:

     

    blcli -Dcom.bladelogic.cli.debug.release-only="false"

     

    on windows run:

     

    blcli2 -Dcom.bladelogic.cli.debug.release-only="false"

  • 9. Re: Current Role Using BLCLI
    James Andrews

    Hi Steve,

     

    If you are using jythin / jli you just need to include the import statement at the top of your script. Use the line below:

     

    *from com.bladelogic.client import BRProfile

    *

     

    Then call BRProfile.getCurrentRole() to get the current role.

     

    I am not sure how you do it in NSH script to be honest!

     

    Thanks,

    James

  • 10. Re: Current Role Using BLCLI
    Siddu Angadi

    Hi Bill,

     

    How to use from com.bladelogic.client import BRProfile?

     

    When I add this line to my code and get the following error.  Can you please help me on this?

     

    Error          Apr 3, 2012 2:49:16 PM          ImportError: cannot import name BRProfile

    Error          Apr 3, 2012 2:49:16 PM          from com.bladelogic.client import BRProfile

    Error          Apr 3, 2012 2:49:16 PM          File "Program Files\BMC Software\BladeLogic\NSH\share\sensors\changeProp.jli", line 11, in <module>

    Error          Apr 3, 2012 2:49:16 PM          Traceback (most recent call last):

     

     

    My jli code is as below and executing through NSH JOB:

     

    "

    import sys

    import re

    import string as s

    import bladelogic.cli.CLI as blcli

    from com.bladelogic.client import BRProfile

    BRProfile.getCurrentRole()

     

    JOB_GROUP = sys.argv[1]

    JOB_NAME = sys.argv[2]

    jli = blcli.CLI()

    set = jli.setServiceProfileName()

    jli.setRoleName()

    jli.connect()

     

    cmd =["DeployJob","getDBKeyByGroupAndName",JOB_GROUP,JOB_NAME]

    JOB_KEY1 = jli.run(cmd)

    JOB_KEY = JOB_KEY1.returnValue

    cmd2 =["Job","setPropertyValue",JOB_KEY,"QUALITY_APPROVAL","true"]

    changeProp=jli.run(cmd2)

    print changeProp.returnValue

     

    "

  • 11. Current Role Using BLCLI
    Rohit Nayyar

    Which Version of BBSA (BladeLogic are you using) ?

     

    If this is 8.x

    Please note that the internal class heirarchies in BL have changed so

    this

    'com.bladelogic.client'  becomes 'com.bladelogic.om.infra.client.ui'

     

    use this import statement

    from com.bladelogic.om.infra.client.ui import BRProfile

  • 12. Re: Current Role Using BLCLI
    Siddu Angadi

    Yes Rohit. I am using 8.2.

     

    Let me test with this import statement.

     

    Onemore thing, Is there any document internal classes?  How we came to know BMC change the internal class heirarchies?

     

    Thanks

    Siddu

  • 13. Re: Current Role Using BLCLI
    Rohit Nayyar

    I am going to upload a document today, will update you.

    This does not happen often, has happened only in 8.x, I have not seen this since 7.x

     

    here is the document:

     

    https://communities.bmc.com/communities/docs/DOC-18961