Skip to content

Server creation impossible due to improper handling of repeatable parameters #37

@teeptoo

Description

@teeptoo

Versions used

StackStorm version used: st2 3.4.1, on Python 3.6.9
stackstorm-openstackversion used: 1.0.1

Bug description

I'm unable to create a server using the "openstack.server.create" action due the improper handling of repeatable parameters.

Firstly, parameters network, port, nic and hint are included in the generated command even if no value is set. Those parameters interact with each other (network is a wrapper for nic, according to OpenStack documentation) and by sending all of them independently of user input makes a conflict and the result is not what is expected. (Examples 1 & 2 below)

The second problem concerns type conversion of repeatable list parameters like network. Indeed, when forcing dummy or null values for nic, hint and port, the given network parameter is still incorrectly interpreted during the conversion from ST2 array to Python list to repeated openstack args.

Errors output

Example 1

Trying to create a server with only one NIC on the "Ext-Net" network, using the network parameter

~$ st2 run openstack.server.create flavor=s1-2 server_name=Test network=Ext-Net image="Debian 10"
..
id: 608aa296c25e5f8822520b56
action.ref: openstack.server.create
context.user: st2admin
parameters: 
  flavor: s1-2
  image: Debian 10
  network:
  - Ext-Net
  server_name: Test
status: failed
start_timestamp: Thu, 29 Apr 2021 12:12:06 UTC
end_timestamp: Thu, 29 Apr 2021 12:12:10 UTC
result: 
  exit_code: 1
  result: None
  stderr: "/opt/stackstorm/packs/openstack/actions/src/lib/base.py:84: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  command_cls = entry_point.load(require=False)
st2.actions.python.WrapperAction: DEBUG    Generated command ". /root/openstackrc.sh && openstack server create -f json Test --flavor s1-2 --image 'Debian 10' --network '['"'"'Ext-Net'"'"']' --port None --nic None --hint '[]'"
Invalid argument None; argument must be of form 'net-id=net-uuid,port-id=port-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,tag=tag'
"
  stdout: ''

Example 2

Trying to create a server with only one NIC on the "Ext-Net" network, using the nic parameter

~$ st2 run openstack.server.create flavor=s1-2 server_name=Test nic="net-id=393d06cc-a82c-4dc4-a576-c79e8dd67ba3" image="Debian 10"
..
id: 608aa2d4c25e5f8822520b59
action.ref: openstack.server.create
context.user: st2admin
parameters: 
  flavor: s1-2
  image: Debian 10
  nic:
  - net-id=393d06cc-a82c-4dc4-a576-c79e8dd67ba3
  server_name: Test
status: failed
start_timestamp: Thu, 29 Apr 2021 12:13:08 UTC
end_timestamp: Thu, 29 Apr 2021 12:13:11 UTC
result: 
  exit_code: 1
  result: None
  stderr: "/opt/stackstorm/packs/openstack/actions/src/lib/base.py:84: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  command_cls = entry_point.load(require=False)
st2.actions.python.WrapperAction: DEBUG    Generated command ". /root/openstackrc.sh && openstack server create -f json Test --flavor s1-2 --image 'Debian 10' --network None --port None --nic '['"'"'net-id=393d06cc-a82c-4dc4-a576-c79e8dd67ba3'"'"']' --hint '[]'"
Invalid argument ['net-id=393d06cc-a82c-4dc4-a576-c79e8dd67ba3']; argument must be of form 'net-id=net-uuid,port-id=port-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,tag=tag'
"
  stdout: ''

Example 3

Trying to create a server with only one NIC on the "Ext-Net" network using the network parameter while providing dummy or null values for other buggy parameters.

~$ st2 run openstack.server.create flavor=s1-2 server_name=Test image="Debian 10" hint='[dummy=value]' port='[]' nic='[]' network='["Ext-Net"]'
..
id: 608aa3e6c25e5f8822520b65
action.ref: openstack.server.create
context.user: st2admin
parameters: 
  flavor: s1-2
  hint:
  - '[dummy=value]'
  image: Debian 10
  network:
  - Ext-Net
  nic: []
  port: []
  server_name: Test
status: failed
start_timestamp: Thu, 29 Apr 2021 12:17:42 UTC
end_timestamp: Thu, 29 Apr 2021 12:17:46 UTC
result: 
  exit_code: 1
  result: None
  stderr: "/opt/stackstorm/packs/openstack/actions/src/lib/base.py:84: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  command_cls = entry_point.load(require=False)
st2.actions.python.WrapperAction: DEBUG    Generated command ". /root/openstackrc.sh && openstack server create -f json Test --flavor s1-2 --image 'Debian 10' --network '['"'"'Ext-Net'"'"']' --hint '['"'"'[dummy=value]'"'"']'"
No Network found for ['Ext-Net']
"
  stdout: ''


I've been trying to fix this bug but I can't understand why those parameters does not work properly for the specific "openstack.server.create" action. Any hint on this would be greatly appreciated!
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions