Exemple #1
0
 def test_from_environment_variables_is_passing_right_arguments_to_the_constructor(self, mock_cls):
     mock_cls.return_value = None
     OVC.from_environment_variables()
     mock_cls.assert_called_once_with({'timeout': '-1',
                                       'ip': '10.30.4.245',
                                       'ssl_certificate': 'certificate',
                                       'credentials': {'username': '******',
                                                       'password': '******'}})
    def test_missing_required_environment_variables_missing(self, mock_login):
        with self.assertRaises(exceptions.HPESimpliVityException) as error:
            OVC.from_environment_variables()

        self.assertEqual(
            error.exception.msg,
            "Make sure you have set mandatory env variables \
            (SIMPLIVITYSDK_OVC_IP, SIMPLIVITYSDK_USERNAME, SIMPLIVITYSDK_PASSWORD)"
        )
Exemple #3
0
    def _create_simplivity_client(self):
        """
        Creates Simplivity client object using module prams/env variables/config file
        """
        if self.module.params.get('ovc_ip'):
            config = dict(ip=self.module.params['ovc_ip'],
                          credentials=dict(
                              username=self.module.params['username'],
                              password=self.module.params['password']))
            self.ovc_client = OVC(config)

        elif not self.module.params['config']:
            self.ovc_client = OVC.from_environment_variables()
        else:
            self.ovc_client = OVC.from_json_file(self.module.params['config'])
    def test_credentials_not_provided(self, mock_login):
        print("targeted test")
        config = {"ip": "172.0.0.1"}

        with self.assertRaises(exceptions.HPESimpliVityException) as error:
            OVC(config)

        self.assertEqual(error.exception.msg, "Credentials not provided")
Exemple #5
0
    def setUp(self, mock_login):
        super(OVCTest, self).setUp()

        config = {"ip": "10.30.4.245",
                  "credentials": {
                      "username": "******",
                      "password": "******"}}

        self._ovc = OVC(config)
Exemple #6
0
    def test_from_json_file(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "10.30.4.245",
          "credentials": {
            "username": "******",
            "password": "******"
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        ovc_client = OVC.from_json_file("config.json")

        self.assertIsInstance(ovc_client, OVC)
        self.assertEqual("10.30.4.245", ovc_client.connection._ovc_ip)
import time
from simplivity.ovc_client import OVC
from simplivity.exceptions import HPESimpliVityException
import pprint

config = {
    "ip": "<ovc_ip>",
    "credentials": {
        "username": "******",
        "password": "******"
    }
}

pp = pprint.PrettyPrinter(indent=4)

ovc = OVC(config)
backups = ovc.backups
machines = ovc.virtual_machines
datastores = ovc.datastores

# variable declaration
test_vm_name = "test_MySql-VM_restore"
remote_datastore = "remoteDS"
cluster1_name = "CC_Virt_0001"
cluster2_name = "CC_Virt_0000"

print("\n\nget_all with default params")
all_backups = backups.get_all()
count = len(all_backups)
for backup in all_backups:
    print(f"{backup}")
Exemple #8
0
 def test_from_environment_variables(self, mock_login):
     OVC.from_environment_variables()
     mock_login.assert_called_once_with('simplicity', 'root')