Skip to content
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

Flow io.cloudslang.vmware.vcenter.virtual_machines.get_virtual_machine_details does not retrieve IP address when VM just powered on #1028

Open
pe-pan opened this issue Feb 4, 2018 · 1 comment

Comments

@pe-pan
Copy link
Contributor

pe-pan commented Feb 4, 2018

I've got the following code.

namespace: io.cloudslang.demo
imports:
  base: io.cloudslang.base
  vm: io.cloudslang.vmware.vcenter.virtual_machines
flow:
  name: deploy_tomcat
  inputs:
    - hostname
    - username
    - password
    - image: "Ubuntu"
    - folder: "Students"
  workflow:
    - uuid_generator:
        do:
          base.utils.uuid_generator:
        publish:
          - uuid: '${new_uuid}'
        navigate:
          - SUCCESS: trim
    - trim:
          do:
            base.strings.substring:
              - origin_string: '${"petr-"+uuid}'
              - end_index: '13'
          publish:
            - id: '${new_string}'
          navigate:
            - FAILURE: FAILURE
            - SUCCESS: clone_vm
    - clone_vm:
        do:
          vm.clone_virtual_machine:
            - host: '${hostname}'
            - hostname: 'trnesxi3.eswdc.net'
            - clone_host: 'trnesxi3.eswdc.net'
            - clone_data_store: 'datastore2'
            - username: '${username}'
            - password: '${password}'
            - data_center_name: 'CAPA1 Datacenter'
            - is_template: 'false'
            - virtual_machine_name: '${image}'
            - clone_name: '${id}'
            - folder_name: '${folder}'
        navigate:
          - FAILURE: FAILURE
          - SUCCESS: power_on
    - power_on:
        do:
          vm.power_on_virtual_machine:
            - host: '${hostname}'
            - username: '${username}'
            - password: '${password}'
            - virtual_machine_name: '${id}'
        navigate:
          - FAILURE: FAILURE
          - SUCCESS: get_details
    - get_details:
        do:
          vm.get_virtual_machine_details:
            - host: '${hostname}'
            - username: '${username}'
            - password: '${password}'
            - hostname: 'trnesxi3.swsc.hpe.com'
            - virtual_machine_name: '${id}'
        publish:
            - details : '${return_result}'
        navigate:
          - FAILURE: FAILURE
          - SUCCESS: get_ip
    - get_ip:
        do:
          base.json.get_value:
            - json_input: '${details}'
            - json_path: 'ipAddress'
        publish:
            - ip: '${return_result}'
        navigate:
            - FAILURE: FAILURE
            - SUCCESS: SUCCESS
  results:
      - FAILURE
      - SUCCESS

The trouble is that the get_ip flow gets no value. To make it work, I need to put a sleep operation (for 10-30 seconds) in between power_on and get_details flows.
IMHO, the get_virtual_machine_details flow should return the IP or wait for it when not available yet.

@tethryus
Copy link
Contributor

tethryus commented Feb 5, 2018

@pe-pan The operation runs in async mode (it checks if the VM is up) and setting up a polling interval using the operation sleep.sl is a good approach. You could add an input named polling_interval with a default value and set is as required: false and map assign it to the seconds: input from sleep.sl
Furthermore, if you create a vm without a nic attached, the operation would wait indefinitely for an answer for that IP address, which will never be assigned.

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

No branches or pull requests

2 participants