How to pass the instance_id and ip address from

27 views
Skip to first unread message

RBK

unread,
May 14, 2018, 11:40:04 AM5/14/18
to cloudify-users
Hi All

I need to pass the instance_id and IP address created from aws.ec2.Interface and aws.ec2.Instance back to cloudify.terminal.raw, but I am not sure how I can do that,

please help

- RBK

  nic:
    type: cloudify.nodes.aws.ec2.Interface
    properties:
      client_config: *client_config
      resource_config:
        kwargs:
          Description: est
          SubnetId: { get_attribute: [ public_subnet, aws_resource_id] }
          Groups:
          - { get_attribute: [ security_group, aws_resource_id ] }
    relationships:
    - type: cloudify.relationships.depends_on
      target: public_subnet
    - type: cloudify.relationships.depends_on
      target: security_group
    - type: cloudify.relationships.depends_on
      target: security_group_rules
    interfaces:
      cloudify.interfaces.lifecycle:
        configure:
          inputs:
            resource_config: { get_property: [ SELF, resource_config, kwargs] }

  cloudify_host:
    type: cloudify.nodes.aws.ec2.Instances
    properties:
      agent_config:
        install_method: none
      resource_config:
        kwargs:
          MinCount: 1
          MaxCount: 1
          ImageId: { get_input: ami }
          InstanceType: { get_input: instance_type }
          KeyName: { get_input: key_name }
          BlockDeviceMappings:
          - DeviceName: '/dev/sda1'
            Ebs:
              DeleteOnTermination: True
          Placement:
            AvailabilityZone: { get_input: availability_zone }
          UserData: { get_attribute: [ cloudify_host_cloud_config, cloud_config ] }
    relationships:
      - type: cloudify.relationships.depends_on
        target: cloudify_host_cloud_config
      - type: cloudify.relationships.depends_on
        target: nic


  vm_config:
    type: cloudify.terminal.raw
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          inputs:
            terminal_auth: &terminal_auth
              user: { get_input: admin_user }
              password: { get_attribute: [ instanceId, aws_resource_id ] } <----- how to pass the instance_id back to here?
              ip: { get_attribute: [ nic, aws_resource_id ] } <----- how to pass the NIC IP back to here?
              promt_check:
                - '#'
              calls:
                - action: exit
        start:
          inputs:
            terminal_auth: *terminal_auth
            calls:
              - template: text1.txt
    relationships:
    - type: cloudify.relationships.depends_on
      target: cloudify_host
    - type: cloudify.relationships.depends_on
      target: nic


Trammell -

unread,
May 14, 2018, 3:06:07 PM5/14/18
to cloudify-users
if you are using only one nic, you can do

For IP, put: { get_attribute: [ cloudify_host, ip ] }
For ID, put: { get_attribute: [ cloudify_host, aws_resource_id ] }

You can get a list of all runtime properties, by running

cfy node-instances get node-instance-id (in a manager profile)
or
cfy node-instances (in a local profile)

RBK

unread,
May 14, 2018, 7:09:44 PM5/14/18
to cloudify-users
Hi Trammell

I have issue on using the cfy command. either in local or localhost profile, it is either failed or nothing is shown.

any idea?

- RBK

# cfy profiles use local
Using local environment...
Initializing local profile ...
Initialization completed successfully

# cfy node-instances 
Usage: cfy node-instances [OPTIONS] [NODE_ID]

Error: Missing option "-b" / "--blueprint-id".None


# cfy profiles use localhost
Using manager localhost


# cfy node-instances list
Listing all instances...

Node-instances:
+----+---------------+---------+---------+-------+------------+-------------+------------+
| id | deployment_id | host_id | node_id | state | visibility | tenant_name | created_by |
+----+---------------+---------+---------+-------+------------+-------------+------------+
+----+---------------+---------+---------+-------+------------+-------------+------------+

Showing 0 of 0 node-instances




Trammell -於 2018年5月15日星期二 UTC+8上午3時06分07秒寫道:

RBK

unread,
May 14, 2018, 9:24:44 PM5/14/18
to cloudify-users
I am not able to pass the instance_id as a password in my blueprint

can help?

user: { get_input: forti_user }
             password: { get_attribute: [ cloudify_host, aws_resource_id ] }
             ip: { get_attribute: [ ip, aws_resource_id ] }
             port: { get_input: forti_port }

-05-15 01:05:26.589  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34] Starting node
2018-05-15 01:05:26.647  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Sending task 'cloudify_terminal.tasks.run'
2018-05-15 01:05:26.653  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Task started 'cloudify_terminal.tasks.run'
2018-05-15 01:05:31.669  LOG <cloudify-environment-setup-latest> [forti_config_rvlb34.start] INFO: Can't connect to:u'x.x.x.x' with exception:timed out and type:<class 'socket.timeout'>
2018-05-15 01:05:31.671  CFY <cloudify-environment-setup-latest> [tags_ec2_instance_6hww3i] Starting node
2018-05-15 01:05:31.766  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Task rescheduled 'cloudify_terminal.tasks.run' -> Let's try one more time?
2018-05-15 01:06:01.866  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Sending task 'cloudify_terminal.tasks.run' [retry 1/1]
2018-05-15 01:06:01.911  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Task started 'cloudify_terminal.tasks.run' [retry 1/1]
2018-05-15 01:06:06.931  LOG <cloudify-environment-setup-latest> [forti_config_rvlb34.start] INFO: Can't connect to:u'x.x.x.x' with exception:timed out and type:<class 'socket.timeout'>
2018-05-15 01:06:06.983  CFY <cloudify-environment-setup-latest> [forti_config_rvlb34.start] Task rescheduled 'cloudify_terminal.tasks.run' -> Let's try one more time? [retry 1/1]
2018-05-15 01:06:07.098  CFY <cloudify-environment-setup-latest> 'install' workflow execution failed: Workflow failed: Task failed 'cloudify_terminal.tasks.run' -> Let's try one more time?
Workflow failed: Task failed 'cloudify_terminal.tasks.run' -> Let's try one more time?

RBK

unread,
May 15, 2018, 12:47:41 AM5/15/18
to cloudify-users
the problem is resolved. it is due to time is required to wait for the startup of the instance before executing terminal commands

RBK

unread,
May 15, 2018, 2:41:54 AM5/15/18
to cloudify-users
whatif I have multiple nic in the instance, and I want to get the IP address from the 2nd interface and pass to the IP?

I tried to use { get_attribute: [ nic, aws_resource_id ] }, but the aws_resource_id  is the "eni-..."

how I can extract the corresponded IP address?

- RBK
Reply all
Reply to author
Forward
0 new messages