def get_instance_tags()

in stratozone-aws-export.py [0:0]


def get_instance_tags(vm_id, tag_dictionary, l_vm_instance):
  """Get tags assigned to instance.

  Args:
    vm_id: Instance ID
    tag_dictionary: list of assigned tags
    l_vm_instance: instance dictionary object

  Returns:
      Dictionary object.
  """
  try:
    # if there is no name tag assigned use instance id as name
    l_vm_instance['MachineName'] = vm_id

    for tag in tag_dictionary:
      tmp_tag = stratozonedict.vm_tag.copy()
      tmp_tag['MachineId'] = vm_id
      tmp_tag['Key'] = tag['Key']
      tmp_tag['Value'] = tag['Value']

      if tag['Key'] == 'Name':
        l_vm_instance['MachineName'] = tag['Value']

      vm_tag_list.append(tmp_tag)

    return l_vm_instance

  except Exception as e:
    logging.error('error in get_instance_tags')
    logging.error(e)
    return l_vm_instance