Last active
August 14, 2018 14:00
-
-
Save rplevka/ea8ef457bb7bbc88fa77b218caa7c8a4 to your computer and use it in GitHub Desktop.
satellite webui login + compute profile creation
This file contains hidden or 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
import re | |
import requests | |
#from robottelo.config import settings | |
#settings.configure() | |
# hostname = settings.server.hostname | |
hostname = 'foo.bar.com' | |
def extract_token(input): | |
token = re.search( | |
r"authenticity_token\" value=\"[^\"]+", | |
input | |
)[0].split('value="')[-1] | |
return(token) | |
sat_session = requests.Session() | |
init_request = sat_session.get( | |
'https://{0}'.format(hostname), | |
verify=False | |
) | |
login_request = sat_session.post( | |
'https://{0}/users/login'.format(hostname), | |
data={ | |
'authenticity_token': extract_token(init_request.text), | |
'login[login]': 'admin', | |
'login[password]': 'changeme', | |
'commit': 'Log In' | |
}, | |
verify=False | |
) | |
# let's create a compute profile: | |
cp_request = sat_session.get( | |
'https://{0}/compute_profiles/new'.format(hostname) | |
) | |
cp_create_request = sat_session.post( | |
'https://{0}/compute_profiles'.format(hostname), | |
data={ | |
'authenticity_token': extract_token(cp_request.text), | |
'compute_profile[name]': 'my_new_cp', | |
'commit': 'Submit' | |
} | |
) | |
print(cp_create_request.text) | |
# let's create a RHV compute resource with CA cert | |
cr_request = sat_session.get( | |
'https://{0}/compute_resources/new'.format(hostname) | |
) | |
cr_create_request = sat_session.post( | |
'https://{0}/compute_resources'.format(hostname), | |
data={ | |
'authenticity_token': extract_token(cr_request.text), | |
'compute_resource[name]': 'my_rhv_cr', | |
'compute_resource[provider]': 'Ovirt', | |
'compute_resource[user]': 'admin@internal', | |
'compute_resource[password]': 'passwd', | |
'compute_resource[url]': 'https://RHV.url/api', | |
'compute_resource[public_key]': | |
'''-----BEGIN CERTIFICATE----- | |
... | |
RxNEp7yHoXcwn+fXna+t5JWh1gxUZty3 | |
-----END CERTIFICATE----- | |
''', | |
'compute_resource[use_v4]': '0', | |
'commit': 'Submit' | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment