Search code examples
apiibm-cloud-infrastructure

Can security groups be added to slcli order place command


Can security groups be added to slcli order place command

Original command

slcli order place --verify SUSPEND_CLOUD_SERVER SAOPAULO \
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest \
--preset B1_16X64X100 \
REBOOT_REMOTE_CONSOLE \
100_MBPS_PRIVATE_NETWORK_UPLINK \
BANDWIDTH_0_GB_2 \
1_IP_ADDRESS \
MONITORING_HOST_PING \
NOTIFICATION_EMAIL_AND_TICKET \
AUTOMATED_NOTIFICATION \
--extras '{"virtualGuests": [{"hostname": "suspendable", "domain": 
"test.com"}], "imageTemplateId": 1103351}'

And I want to add security groups when server is created.


Solution

  • Yes, it is possible to add security groups to slcli order place command.

    Try adding the following data to the --extras option:

    --extras "{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com","primaryBackendNetworkComponent":{"securityGroupBindings":[{"securityGroup":{"id":11111}}]},"primaryNetworkComponent": {"securityGroupBindings":[{"securityGroup":{"id":22222}}]}}]}"
    

    With the below slcli command you will be able to get all the security groups ids:

    slcli securitygroup list
    

    The following is the complete slcli command:

        slcli order place --verify SUSPEND_CLOUD_SERVER SAOPAULO \
        --complex-type SoftLayer_Container_Product_Order_Virtual_Guest \
        --preset B1_16X64X100 \
        REBOOT_REMOTE_CONSOLE \
        100_MBPS_PRIVATE_NETWORK_UPLINK \
        BANDWIDTH_0_GB_2 \
        1_IP_ADDRESS \
        MONITORING_HOST_PING \
        NOTIFICATION_EMAIL_AND_TICKET \
        AUTOMATED_NOTIFICATION \ 
        --extras "{"virtualGuests": [{"hostname": "suspendable", "domain": "test.com","primaryBackendNetworkComponent":{"securityGroupBindings":[{"securityGroup":{"id":11111}}]},"primaryNetworkComponent": {"securityGroupBindings":[{"securityGroup":{"id":22222}}]}}]}",
        "imageTemplateId": 1103351}'
    

    To add security group to a virtual server created, you have to select first the security group id to be able to know all the interfaces available for this security group id.

    You can use the following slcli command to retrieve all the interfaces:

    slcli securitygroup interface-list 11111
    

    Replace the security group id=11111 for your id selected.

    Then add a security group to a virtual server with the below slcli command:

    slcli securitygroup interface-add --server 11111 --interface PRIVATE 22222
    

    Replace the server id and the security group id = 22222 for your data selected.

    To add a security group PUBLIC just change the --interface data, like below:

    slcli securitygroup interface-add --server 11111 --interface PUBLIC 22222