Attaching a new volume each time a node group is scaled - cloudify

Can anyone share any reference template to create a new volume and attach to a new instance each time a deployment for that instance is scaled up?
My template looks like:
node_templates:
key_pair:
...
vol:
...
node_host:
...
relationships:
...
- key_pair
- vol
node:
...
relationships:
- type: cloudify.relationships.contained_in
target: node_host
...
groups:
scale_up_group:
members: [node, node_host, vol]
policies:
auto_scale_up:
type: scale_policy_type
properties:
policy_operates_on_group: true
scale_limit: 6
scale_direction: '<'
scale_threshold: 15
service_selector: cpu.total.user
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: 1
scalable_entity_name: node
scale_compute: true

Courtesy of Trammell from cloudify-user group:
node_templates:
key_pair:
type: cloudify.openstack.nodes.KeyPair
...
floating_ip:
type: cloudify.openstack.nodes.FloatingIP
...
vol:
type: cloudify.openstack.nodes.Volume
...
node_host:
type: cloudify.openstack.nodes.Server
...
relationships:
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
- type: cloudify.openstack.server_connected_to_floating_ip
target: floating_ip
- type: cloudify.relationships.depends_on
target: vol
node:
type: custom.node.type
...
relationships:
- type: cloudify.relationships.contained_in
target: node_host
...
groups:
scale_vm:
members: [node, node_host, floating_ip, vol]
scale_up_group:
members: [node, node_host, floating_ip, vol]
policies:
auto_scale_up:
type: scale_policy_type
properties:
policy_operates_on_group: true
scale_limit: 6
scale_direction: '<'
scale_threshold: 15
service_selector: cpu.total.user
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: 1
scalable_entity_name: scale_vm
scale_compute: true
policies:
scale_vm_policy:
type: cloudify.policies.scaling
properties:
default_instances: 1
targets: [scale_vm]
Ref: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/cloudify-users/TPepGofpSBU

Related

How to print specific content over a loop in Ansible

I'm a bit stuck with Ansible trying to print some variables from a return of F5.
I'm trying to print which nodes are configured in a determinated pool. I can get all the result:
TASK [f5_getpoolmembers : Ver IPs de un pool] ***********************************************************************************
ok: [localhost] => (item=[u'pool_createdby_ansible_f5']) =>
msg:
- pool_createdby_ansible_f5
- - address: 10.10.10.34
connection_limit: 0
description: prova_ansible_pool
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'yes'
full_path: /Common/10.10.10.34:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.10.10.34:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
- address: 10.100.250.5
connection_limit: 0
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'no'
full_path: /Common/10.100.250.5:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.100.250.5:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
with that code:
- name: "Ver IPs de un pool"
debug:
msg:
- "{{item.name}}"
- "{{item.members}}"
loop: "{{pool_facts.ltm_pools}}"
loop_control:
label:
- "{{item.name}}"
when: item.name is search "ansible"
The problem is when I try to print only the name for every node in the pool. I can't find the way to do it. Tried many options like nested or subelements, but didn't work. If i try to print only the name, I just get the first node:
TASK [f5_getpoolmembers : Ver IPs de un pool] ***********************************************************************************
ok: [localhost] => (item=[u'pool_createdby_ansible_f5']) =>
msg:
- pool_createdby_ansible_f5
- 10.10.10.34:80
Doing this:
- name: "Ver IPs de un pool"
debug:
msg:
- "{{item.name}}"
- "{{item.members[0].name}}"
I know that it's wrong, so that's why I'm here to get some advices.
Edit: Added the complete structure of the pool:
ltm_pools:
- active_member_count: 0
all_avg_queue_entry_age: 0
all_max_queue_entry_age_ever: 0
all_max_queue_entry_age_recently: 0
all_num_connections_queued_now: 0
all_num_connections_serviced: 0
all_queue_head_entry_age: 0
allow_nat: 'yes'
allow_snat: 'yes'
availability_status: unknown
available_member_count: 3
client_ip_tos: pass-through
client_link_qos: pass-through
current_sessions: 0
enabled_status: enabled
full_path: /Common/pool_createdby_ansible_f5
ignore_persisted_weight: 'no'
lb_method: ratio-member
member_count: 3
members:
- address: 10.10.10.34
connection_limit: 0
description: prova_ansible_pool
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'yes'
full_path: /Common/10.10.10.34:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.10.10.34:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
- address: 10.100.250.5
connection_limit: 0
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'no'
full_path: /Common/10.100.250.5:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.100.250.5:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
- address: 10.55.55.4
connection_limit: 0
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'no'
full_path: /Common/10.55.55.4:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.55.55.4:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
minimum_active_members: 0
minimum_up_members: 0
minimum_up_members_action: failover
minimum_up_members_checking: 'no'
name: pool_createdby_ansible_f5
pool_avg_queue_entry_age: 0
pool_max_queue_entry_age_ever: 0
pool_max_queue_entry_age_recently: 0
pool_num_connections_queued_now: 0
pool_num_connections_serviced: 0
pool_queue_head_entry_age: 0
priority_group_activation: 0
queue_depth_limit: 0
queue_on_connection_limit: 'no'
queue_time_limit: 0
reselect_tries: 0
server_ip_tos: pass-through
server_link_qos: pass-through
server_side_bits_in: 0
server_side_bits_out: 0
server_side_current_connections: 0
server_side_max_connections: 0
server_side_pkts_in: 0
server_side_pkts_out: 0
server_side_total_connections: 0
service_down_action: none
slow_ramp_time: 10
status_reason: The children pool member(s) either don't have service checking enabled, or service check results are not available yet
total_requests: 0
You will have to use subelements, indeed.
When you are using the subelements('dictionary_key') filter, then you end up with:
item.0: an item from the list of your loop
item.1: an item from the nested list inside dictionary_key of each item.0 item
Given the playbook:
- hosts: all
gather_facts: no
tasks:
- debug:
msg:
- "{{ item.0.name }}"
- "{{ item.1.name }}"
loop_control:
label:
- "{{ item.0.name }}"
loop: "{{ pools_facts.ltm_pools | subelements('members') }}"
when: "'ansible' in item.0.name"
vars:
pools_facts:
ltm_pools:
- active_member_count: 0
all_avg_queue_entry_age: 0
all_max_queue_entry_age_ever: 0
all_max_queue_entry_age_recently: 0
all_num_connections_queued_now: 0
all_num_connections_serviced: 0
all_queue_head_entry_age: 0
allow_nat: 'yes'
allow_snat: 'yes'
availability_status: unknown
available_member_count: 3
client_ip_tos: pass-through
client_link_qos: pass-through
current_sessions: 0
enabled_status: enabled
full_path: /Common/pool_createdby_ansible_f5
ignore_persisted_weight: 'no'
lb_method: ratio-member
member_count: 3
members:
- address: 10.10.10.34
connection_limit: 0
description: prova_ansible_pool
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'yes'
full_path: /Common/10.10.10.34:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.10.10.34:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
- address: 10.100.250.5
connection_limit: 0
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'no'
full_path: /Common/10.100.250.5:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.100.250.5:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
- address: 10.55.55.4
connection_limit: 0
dynamic_ratio: 1
ephemeral: 'no'
fqdn_autopopulate: 'no'
full_path: /Common/10.55.55.4:80
inherit_profile: 'yes'
logging: 'no'
monitors: []
name: 10.55.55.4:80
partition: Common
priority_group: 0
rate_limit: 'no'
ratio: 1
real_session: user-enabled
real_state: unchecked
state: present
minimum_active_members: 0
minimum_up_members: 0
minimum_up_members_action: failover
minimum_up_members_checking: 'no'
name: pool_createdby_ansible_f5
pool_avg_queue_entry_age: 0
pool_max_queue_entry_age_ever: 0
pool_max_queue_entry_age_recently: 0
pool_num_connections_queued_now: 0
pool_num_connections_serviced: 0
pool_queue_head_entry_age: 0
priority_group_activation: 0
queue_depth_limit: 0
queue_on_connection_limit: 'no'
queue_time_limit: 0
reselect_tries: 0
server_ip_tos: pass-through
server_link_qos: pass-through
server_side_bits_in: 0
server_side_bits_out: 0
server_side_current_connections: 0
server_side_max_connections: 0
server_side_pkts_in: 0
server_side_pkts_out: 0
server_side_total_connections: 0
service_down_action: none
slow_ramp_time: 10
status_reason: The children pool member(s) either don't have service checking enabled, or service check results are not available yet
total_requests: 0
This gives the output:
PLAY [all] *********************************************************************************************************
TASK [debug] *******************************************************************************************************
ok: [localhost] => (item=['pool_createdby_ansible_f5']) => {
"msg": [
"pool_createdby_ansible_f5",
"10.10.10.34:80"
]
}
ok: [localhost] => (item=['pool_createdby_ansible_f5']) => {
"msg": [
"pool_createdby_ansible_f5",
"10.100.250.5:80"
]
}
ok: [localhost] => (item=['pool_createdby_ansible_f5']) => {
"msg": [
"pool_createdby_ansible_f5",
"10.55.55.4:80"
]
}
PLAY RECAP *********************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I have built a successful playbook. I chose to list more options than names of the members though. You could modify this to spit out just their names. As a note my playbokk has the variable poolName for a survey. Here is my playbook:
- hosts: localhost
tasks:
- name: collect device info
bigip_device_info:
gather_subset:
- ltm-pools
delegate_to: localhost
register: f5pools
- name: Display Config for a specific pool using a variable
debug:
var: item
loop: "{{ f5pools | json_query(pool_name) }}"
vars:
pool_name: "ltm_pools[?name=='{{ poolName }}'].{name: name, Method: lb_method, Members: members[*].{name: name, state:real_state }, Monitors: monitors}"
You could modify it for just the names using:
- hosts: localhost
tasks:
- name: collect device info
bigip_device_info:
gather_subset:
- ltm-pools
delegate_to: localhost
register: f5pools
- name: Display Config for a specific pool using a variable
debug:
var: item
loop: "{{ f5pools | json_query(pool_name) }}"
vars:
pool_name: "ltm_pools[?name=='{{ poolName }}'].members[*].name"
Which worked see output:
{
"ansible_loop_var": "item",
"_ansible_no_log": false,
"item": [
"1.1.1.2:443",
"1.1.1.3:443"
],
"changed": false,
"_ansible_verbose_always": true,
"_ansible_item_label": [
"1.1.1.2:443",
"1.1.1.3:443"
]
}

API Platform: Change embedded sub-resources to theirs #id

I'm using Symfony 4.3 and API Platform 2.4.
In my API there are resource 'groups' and related sub-resource 'phones':
{
"#context": "/contexts/groups",
"#id": "/groups/7116",
"#type": "groups",
"id": 7116,
"name": "Standard Test",
"description": "",
"phones": {
"7848412": {
"#id": "/phones/7848412",
"#type": "phones",
"id": 7848412,
"phone": "+412344545656",
"a": "o2",
"b": "",
"c": "",
"d": "",
"e": ""
}
}
Resources YAMLs:
entities\ClientPhoneGroup:
shortName: 'groups'
description: "Phone's group"
collectionOperations:
post:
denormalization_context:
groups: ['write']
itemOperations:
get: ~
put:
denormalization_context:
groups: ['write']
delete: ~
attributes:
normalization_context:
groups: ['read']
security: "is_granted('IS_AUTHENTICATED_FULLY')"
subresource_operations:
phone_get_subresource:
method: 'GET'
properties:
id:
identifier: true
phones:
subresource:
resourceClass: 'entities\ClientPhone'
collection: false
and
entities\ClientPhone:
shortName: 'phones'
description: "Phones list by group"
collectionOperations:
post:
path: /groups/{group_id}/phones
requirements:
group_id: '\d+'
denormalization_context:
groups: ['write']
itemOperations:
get: ~
put:
denormalization_context:
groups: ['write']
delete: ~
attributes:
normalization_context:
groups: ['read']
security: "is_granted('IS_AUTHENTICATED_FULLY') "
serializers YAMLs:
entities\ClientPhoneGroup:
attributes:
id:
groups: ['read']
name:
groups: ['read', 'write']
description:
groups: ['read', 'write']
phones:
groups: ['read']
and
entities\ClientPhone:
attributes:
id:
groups: ['read']
phone:
groups: ['read', 'write', 'edit']
a:
groups: ['read', 'write', 'edit']
b:
groups: ['read', 'write', 'edit']
c:
groups: ['read', 'write', 'edit']
d:
groups: ['read', 'write', 'edit']
e:
groups: ['read', 'write', 'edit']
How to change embeded phones list to '/groups/7116/phones' in groups
resource?
How to add link to 'group' resource (e.g. /groups/7116) to
the phone sub-resource?
Answer Question 2.
Remove normalization_context:groups: ['read'] from entities\ClientPhone so when you will call a GET group resource api, phone sub-resource will have IRI instead of all fields.

Can't select JCheckBoxMenuItem, components in context not recognized

I've started working in robot framework's swing library, gui testing a java application in swing.
I have to select the jcheckboxmenuitem "waveMenu" from a jpopupmenu "menu" on a jtextarea "showText". Running the keyword:
Select From Popup Menu showText menu|waveMenu
Results in a very unhelpful error.
Fail: Popup menu
If I try to right click on the component showText, it simply passes without bringing up the menu associated with it. The menu is attached by a regular mouselistener.
showText.addMouseListener(new MouseAdapter() {
#Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
menu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
Listing components in context from the top results in this
Level: 0 Component: ca.acme.myApplication
Index: 0 Name: the name I select when I run Select Window
Level: 1 Component: javax.swing.JRootPane Index: 0 Name: null
Level: 2 Component: javax.swing.JPanel Index: 0 Name: null.glassPane
Level: 2 Component: javax.swing.JLayeredPane Index: 0 Name: null.layeredPane
Level: 3 Component: javax.swing.JPanel Index: 1 Name: null.contentPane
Level: 4 Component: javax.swing.JPanel Index: 2 Name: null
Level: 5 Component: javax.swing.JButton Index: 0 Name: fileOpenButton
Level: 5 Component: javax.swing.JTextField Index: 0 Name: fileText
Level: 5 Component: javax.swing.JButton Index: 1 Name: fileSendButton
Level: 5 Component: javax.swing.JLabel Index: 0 Name: null
Level: 5 Component: javax.swing.JTextField Index: 1 Name: hostText
Level: 5 Component: javax.swing.JComboBox Index: 0 Name: formatSelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 2 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 0 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 1 Name: null
Level: 5 Component: javax.swing.JComboBox Index: 1 Name: voiceSelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 3 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 1 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 2 Name: null
Level: 5 Component: javax.swing.JComboBox Index: 2 Name: delaySelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 4 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 2 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 3 Name: null
Level: 5 Component: javax.swing.JTextField Index: 2 Name: messageText
Level: 5 Component: javax.swing.JButton Index: 5 Name: messageSendButton
Level: 5 Component: javax.swing.JLabel Index: 4 Name: portLabel
Level: 5 Component: javax.swing.JTextField Index: 3 Name: portText
Level: 5 Component: javax.swing.JComboBox Index: 3 Name: requestSelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 6 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 3 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 5 Name: null
Level: 5 Component: javax.swing.JComboBox Index: 4 Name: speedSelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 7 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 4 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 6 Name: null
Level: 5 Component: javax.swing.JComboBox Index: 5 Name: siteSelect
Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 8 Name: null
Level: 6 Component: javax.swing.CellRendererPane Index: 5 Name: null
Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 7 Name: null
Level: 5 Component: javax.swing.JScrollPane Index: 0 Name: null
Level: 6 Component: javax.swing.JViewport Index: 0 Name: null
Level: 7 Component: javax.swing.JTextArea Index: 4 Name: showText
Level: 6 Component: javax.swing.JScrollPane$ScrollBar Index: 0 Name: null
Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 9 Name: null
Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 10 Name: null
Level: 6 Component: javax.swing.JScrollPane$ScrollBar Index: 1 Name: null
Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 11 Name: null
Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 12 Name: null
Going down a level and attempting even the most basic interactions with the application results in failure
I don't mind providing more detail if needed. I've been stuck on this problem for ages.
I've found the issue.
if (e.isPopupTrigger()) {
menu.show(e.getComponent(), e.getX(), e.getY());
}
Javadoc:
Returns whether or not this mouse event is the popup menu trigger event for the platform.
I think the windows popup menu trigger is different from the one that the robot framework swing library sends. Right clicking on the component passed and did nothing because it did, in fact, pass; it just got negated by the if statement.

Ansible - math operation, substract

Trying to substract a number for a variable, which is an int in Ansible.
var:
number: 30
tasks:
- set_fact: me={{ number -1 }}
- debug: var=me
Expectation: me = 29
Result:
fatal: [node1]: FAILED! => {"failed": true, "msg": "Unexpected templating type error occurred on ({{ number - 1 }}): unsupported operand type(s) for -: 'AnsibleUnicode' and 'int'"}
It is a known issue with Ansible/Jinja that you can't preserve numeric type after templating.
Use int filter inside {{..}} expression:
- set_fact: me={{ number | int - 1 }}

how to solve netCDF library : Attempt to convert between text & numbers

I like to hear your suggestions for solving the netCDF library problem. When I use a program netcdf merge to combine several small netcdf files, I get the following messages:
The netCDF library has reported the following problem:
NetCDF: Attempt to convert between text & numbers
I stuck~~ Please let me know any suggestions. Thanks a lot.
The following is my log file:
imerge: Merging 61 npptot*.nc files, using 1 buffers
Number of dimensions: 4
Dimension id: 0 Name: longitude Length: 4
Dimension id: 1 Name: latitude Length: 1
Dimension id: 2 Name: time Length: 60
Dimension id: 3 Name: lengthd Length: 10
Number of variables: 6
Number of global attributes: 5
Global attribute: 0 Attribute: title Type: NC_CHAR, string Length: 25 Value: monthly total NPP carbon
Global attribute: 1 Attribute: source Type: NC_CHAR, string Length: 14 Value: ibis wmonthly
Global attribute: 2 Attribute: history Type: NC_CHAR, string Length: 12 Value: 14-May-2012
Global attribute: 3 Attribute: calendar Type: NC_CHAR, string Length: 10 Value: gregorian
Global attribute: 4 Attribute: conventions Type: NC_CHAR, string Length: 9 Value: NCAR-CSM
Variable: longitude Attribute: long_name Type: NC_CHAR, string Length: 10 Value: longitude
Variable: longitude Attribute: units Type: NC_CHAR, string Length: 13 Value: degrees_east
Attention: NetCDF attribute 'missing_value' does not exist for the selected variable.
Variable: latitude Attribute: long_name Type: NC_CHAR, string Length: 9 Value: latitude
Variable: latitude Attribute: units Type: NC_CHAR, string Length: 14 Value: degrees_north
Attention: NetCDF attribute 'missing_value' does not exist for the selected variable.
Variable: time Attribute: long_name Type: NC_CHAR, string Length: 5 Value: time
Variable: time Attribute: units Type: NC_CHAR, string Length: 22 Value: days since 1500-12-31
Attention: NetCDF attribute 'missing_value' does not exist for the selected variable.
Variable: time_weights Attribute: long_name Type: NC_CHAR, string Length: 29 Value: number of days per time step
Variable: time_weights Attribute: units Type: NC_CHAR, string Length: 5 Value: days
Attention: NetCDF attribute 'missing_value' does not exist for the selected variable.
Variable: date Attribute: long_name Type: NC_CHAR, string Length: 25 Value: label for each time step
Variable: date Attribute: units Type: NC_CHAR, string Length: 1 Value:
Attention: NetCDF attribute 'missing_value' does not exist for the selected variable.
Variable: npptot Attribute: long_name Type: NC_CHAR, string Length: 16 Value: total NPP carbon
Variable: npptot Attribute: units Type: NC_CHAR, string Length: 14 Value: kg-C/m^2/month
Variable: npptot Attribute: missing_value Type: NC_FLOAT, 4 bytes Length: 1 Value: 9e+20
Value of netCDF attribute 'missing_value' is: 9e+20
In file npptot0.nc there is 1 nlat line for a running total of 1 latitude lines.
:
:
:
variable 0: longitude, rank 1, size 4
variable 1: latitude, rank 1, size 61
variable 2: time, rank 1, size 60
variable 3: time_weights, rank 1, size 60
variable 4: date, rank 2, size 600

Resources