Beispiel #1
0
def create_symp_client(i_url, i_domain, i_username, i_password, i_project, i_insecure, i_cert_file=None):
    my_session = requests.Session()
    # disable Proxy
    my_session.trust_env = False
    if i_insecure is True:
        my_session.verify = False
    elif i_cert_file is not None:
        my_session.cert = i_cert_file
    sympclient = symphony_client.Client(url=i_url, session=my_session)
    sympclient.login(domain=i_domain, username=i_username, password=i_password,
                     project=i_project)
    return sympclient
                        help='Domain used to retrieve date')
    parser.add_argument('--username',
                        required=True,
                        help='User name used to retrieve date')
    parser.add_argument('--password',
                        required=True,
                        help='Password used to retrieve date')
    parser.add_argument('--project', default="default", help='Project to use')
    return parser.parse_args()


if __name__ == "__main__":
    my_args = get_args()
    my_session = requests.Session()
    my_session.verify = False
    client = symphony_client.Client(url='https://%s' % my_args.cluster_ip,
                                    session=my_session)
    client.login(domain=my_args.domain,
                 username=my_args.username,
                 password=my_args.password,
                 project=my_args.project)
    for user in client.users.list():
        if user['name'] == my_args.username:
            userID = user['id']
    for project in client.projects.list():
        if project['name'] == my_args.project:
            projectID = project['id']
    ec2_credentials = client.users.create_ec2_credentials(userID, projectID)
    botoclient = boto3.Session.client(
        boto3.session.Session(),
        service_name="ec2",
        region_name="symphony",
    UNDERLINE = '\033[4m'


# In[5]:

# Configure Stratoscale API connection
symp_url = "https://" + config["region_access"]["ipaddress"]
symp_domain = config["region_access"]["cloud_domain"]
symp_user = config["region_access"]["cloud_user"]
symp_password = config["region_access"]["cloud_password"]
symp_project = config["region_access"]["project"],
my_session = requests.Session()
my_session.verify = False

try:
    client = symphony_client.Client(url=symp_url, session=my_session)
    client_login = client.login(domain=symp_domain,
                                username=symp_user,
                                password=symp_password,
                                project=symp_project)
    print(
        u" [\u2713] Stratoscale user region [{}] session established.".format(
            symp_url))
except:
    print(
        u" [\u2717] Could not connect to the Stratosacle region [{}] as user".
        format(symp_url))
    exit()

# In[6]:
Beispiel #4
0
# Configure Stratoscale API connection (Source Region)
symp_url = "https://" + config["region_access"]["ipaddress"]
symp_domain = config["region_access"]["cloud_domain"]
symp_user = config["region_access"]["cloud_user"]
symp_password = config["region_access"]["cloud_password"]
symp_cloud_admin_password = config["region_access"]["cloud_admin_password"]
symp_project = config["region_access"]["project"]

my_session = requests.Session()
my_admin_session = requests.Session()
my_session.verify = False
my_admin_session.verify = False

try:
    client = symphony_client.Client(url=symp_url, session=my_session)
    client_login = client.login(domain=symp_domain, username=symp_user, password=symp_password,project=symp_project)
    print(u" [\u2713] Stratoscale user source region [{}] session established.".format(symp_url)).encode('utf-8')
except:
    print(u" [\u2717] Could not connect to the Stratosacle source region [{}] as user".format(symp_url)).encode('utf-8')
    exit()

try:
    client_admin = symphony_client.Client(url=symp_url, session=my_admin_session)
    client_admin_login = client_admin.login(domain="cloud_admin", username="******", password=symp_cloud_admin_password,project="default")
    print(u" [\u2713] Stratoscale cloud admin source region [{}] session established.".format(symp_url)).encode('utf-8')
except:
    print(u" [\u2717] Could not connect to the Stratosacle source region [{}] as cloud admin".format(symp_url)).encode('utf-8')
    exit()