-
Notifications
You must be signed in to change notification settings - Fork 13
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
upload iso to datastore #120
Open
OrrBG
wants to merge
1
commit into
redhat-cop:main
Choose a base branch
from
OrrBG:feature/upload_iso_to_datastore
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- upload_iso_to_datastore - Created role intended for uploading local ISO files to a Datastore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: Upload local ISO file to Datastore | ||
hosts: all | ||
gather_facts: false | ||
|
||
roles: | ||
- role: cloud.vmware_ops.upload_iso_to_datastore |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
upload_iso_to_datastore_hostname: "{{ vmware_ops_collection_hostname }}" | ||
upload_iso_to_datastore_username: "{{ vmware_ops_collection_username }}" | ||
upload_iso_to_datastore_password: "{{ vmware_ops_collection_password }}" | ||
upload_iso_to_datastore_validate_certs: "{{ vmware_ops_collection_validate_certs }}" | ||
upload_iso_to_datastore_port: "{{ vmware_ops_collection_port }}" | ||
|
||
upload_iso_to_datastore_proxy_host: "{{ vmware_ops_collection_proxy_host }}" | ||
upload_iso_to_datastore_proxy_port: "{{ vmware_ops_collection_proxy_port }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
galaxy_info: | ||
author: Ansible Cloud Content Team (@redhat-cop) | ||
description: Upload an ISO file to a Datastore in vCenter | ||
company: Red Hat, Inc. | ||
license: GPL-3.0-or-later | ||
min_ansible_version: "2.13" | ||
galaxy_tags: | ||
- infrastructure | ||
- vmware | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: Import Collection Level Vars | ||
ansible.builtin.include_vars: | ||
file: "{{ role_path }}/../../vars/main.yml" | ||
|
||
- name: Check Mandatory Variables Are Defined | ||
ansible.builtin.assert: | ||
that: | ||
- upload_iso_to_datastore_hostname is defined | ||
- upload_iso_to_datastore_username is defined | ||
- upload_iso_to_datastore_password is defined | ||
- upload_iso_to_datastore_src is defined | ||
- upload_iso_to_datastore_datastore is defined | ||
quiet: true | ||
fail_msg: Variable must be set when using this role. | ||
|
||
- name: Upload local ISO file to Datastore | ||
community.vmware.vsphere_copy: | ||
hostname: "{{ upload_iso_to_datastore_hostname }}" | ||
username: "{{ upload_iso_to_datastore_username }}" | ||
password: "{{ upload_iso_to_datastore_password }}" | ||
src: "{{ upload_iso_to_datastore_src }}" | ||
datacenter: "{{ upload_iso_to_datastore_datacenter }}" | ||
datastore: "{{ upload_iso_to_datastore_datastore }}" | ||
path: "{{ upload_iso_to_datastore_dst}}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe here we can add an option to upload a file to a specific directory inside the datastore? |
||
validate_certs: "{{ upload_iso_to_datastore_validate_certs }}" |
15 changes: 15 additions & 0 deletions
15
tests/integration/targets/vmware_ops_upload_iso_to_datastore_test/run.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- hosts: localhost | ||
gather_facts: no | ||
|
||
tasks: | ||
- name: Import eco-vcenter credentials | ||
ansible.builtin.include_vars: | ||
file: ../../integration_config.yml | ||
tags: eco-vcenter-ci | ||
|
||
- name: Import Upload ISO to Datastore role | ||
ansible.builtin.import_role: | ||
name: vmware_ops_upload_iso_to_datastore_test | ||
tags: | ||
- eco-vcenter-ci |
57 changes: 57 additions & 0 deletions
57
tests/integration/targets/vmware_ops_upload_iso_to_datastore_test/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
- name: Import common vars | ||
ansible.builtin.include_vars: | ||
file: ../group_vars.yml | ||
|
||
- name: Create ISO Mocks | ||
block: | ||
- name: Mock VCSA Binary | ||
ansible.builtin.include_tasks: mock_vcsa_binary.yml | ||
always: | ||
- name: Clean Up Temp Files | ||
ansible.builtin.file: | ||
path: "{{ upload_iso_to_datastore_test_mock_binary_root }}" | ||
state: absent | ||
|
||
- name: Test ISO Upload to Datastore | ||
block: | ||
- name: Upload ISO to Datastore | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.upload_iso_to_datastore | ||
|
||
- name: Attempt to recreate ISO file | ||
community.vmware.vsphere_file: | ||
hostname: '{{ upload_iso_to_datastore_hostname }}' | ||
username: '{{ upload_iso_to_datastore_username }}' | ||
password: '{{ upload_iso_to_datastore_password }}' | ||
datacenter: "{{ upload_iso_to_datastore_datacenter }}" | ||
datastore: "{{ upload_iso_to_datastore_datastore }}" | ||
path: "{{ upload_iso_to_datastore_dst }}" | ||
state: file | ||
validate_certs: false | ||
ignore_errors: true | ||
register: file_result | ||
|
||
- name: Check ISO was copied to Datastore | ||
ansible.builtin.assert: | ||
that: | ||
- file_result is not changed | ||
quiet: true | ||
fail_msg: Copy of ISO was unsuccessful | ||
|
||
always: | ||
- name: Clean Up Temp ISO | ||
ansible.builtin.file: | ||
path: "{{ upload_iso_to_datastore_src }}" | ||
state: absent | ||
|
||
- name: Delete ISO file from Datastore | ||
community.vmware.vsphere_file: | ||
hostname: "{{ upload_iso_to_datastore_hostname }}" | ||
username: "{{ upload_iso_to_datastore_username }}" | ||
password: "{{ upload_iso_to_datastore_password }}" | ||
state: absent | ||
datacenter: "{{ upload_iso_to_datastore_datacenter }}" | ||
datastore: "{{ upload_iso_to_datastore_datastore }}" | ||
path: "{{ upload_iso_to_datastore_dst}}" | ||
validate_certs: false |
12 changes: 12 additions & 0 deletions
12
tests/integration/targets/vmware_ops_upload_iso_to_datastore_test/tasks/mock_vcsa_binary.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Create Mock VCSA Deployment Binary Path | ||
ansible.builtin.file: | ||
path: "{{ upload_iso_to_datastore_test_mock_binary_root }}/lin64" | ||
state: directory | ||
|
||
- name: Create Mock VCSA ISO file | ||
community.general.iso_create: | ||
src_files: | ||
- "{{ upload_iso_to_datastore_test_mock_binary_root }}" | ||
dest_iso: "{{ upload_iso_to_datastore_src }}" | ||
interchange_level: 4 |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/vmware_ops_upload_iso_to_datastore_test/vars/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
run_on_simulator: false | ||
|
||
upload_iso_to_datastore_datacenter: "{{ vcenter_datacenter }}" | ||
upload_iso_to_datastore_datastore: "{{ shared_storage_01 }}" | ||
upload_iso_to_datastore_src: "/tmp/test.iso" | ||
upload_iso_to_datastore_dst: "/test.iso" | ||
|
||
upload_iso_to_datastore_test_mock_binary_root: /tmp/vcsa-cli-installer |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upload_iso_to_datastore_src is also required