コード例 #1
0
ファイル: api.py プロジェクト: x-ion-de/rally
    def create(cls, config, name):
        """Create a deployment.

        :param config: a dict with deployment configuration
        :param name: a str represents a name of the deployment
        :returns: Deployment object
        """

        try:
            deployment = objects.Deployment(name=name, config=config)
        except exceptions.DeploymentNameExists as e:
            if logging.is_debug():
                LOG.exception(e)
            raise

        deployer = deploy.EngineFactory.get_engine(
            deployment["config"]["type"], deployment)
        try:
            deployer.validate()
        except jsonschema.ValidationError:
            LOG.error(
                _("Deployment %(uuid)s: Schema validation error.") %
                {"uuid": deployment["uuid"]})
            deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
            raise

        with deployer:
            endpoints = deployer.make_deploy()
            deployment.update_endpoints(endpoints)
            return deployment
コード例 #2
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
    def test_update_endpoints(self, mock_update):
        mock_update.return_value = self.deployment
        deploy = objects.Deployment(deployment=self.deployment)
        endpoints = {
            "admin":
            objects.Endpoint("url", "user", "pwd", "tenant",
                             consts.EndpointPermission.ADMIN),
            "users": [
                objects.Endpoint("url1", "user1", "pwd1", "tenant1",
                                 consts.EndpointPermission.USER),
                objects.Endpoint("url2", "user2", "pwd2", "tenant2",
                                 consts.EndpointPermission.USER),
            ]
        }

        expected_users = [
            u.to_dict(include_permission=True) for u in endpoints["users"]
        ]

        deploy.update_endpoints(endpoints)
        mock_update.assert_called_once_with(
            self.deployment["uuid"], {
                "admin": endpoints["admin"].to_dict(include_permission=True),
                "users": expected_users
            })
コード例 #3
0
 def _deploy_node(self, config):
     deployment = objects.Deployment(config=config,
                                     parent_uuid=self.deployment['uuid'])
     deployer = engine.EngineFactory.get_engine(config['type'], deployment)
     with deployer:
         endpoints = deployer.make_deploy()
     return deployer, endpoints
コード例 #4
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update_name(self, mock_update):
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_name('new_name')
     mock_update.assert_called_once_with(
         self.deployment['uuid'],
         {'name': 'new_name'},
     )
コード例 #5
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update_empty_endpoints(self, mock_update):
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_endpoints({})
     mock_update.assert_called_once_with(self.deployment["uuid"], {
         "admin": {},
         "users": []
     })
コード例 #6
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_update_name(self, mock_deployment_update):
     mock_deployment_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_name("new_name")
     mock_deployment_update.assert_called_once_with(
         self.deployment["uuid"],
         {"name": "new_name"},
     )
コード例 #7
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update(self, mock_create, mock_update):
     mock_create.return_value = self.deployment
     mock_update.return_value = {'opt': 'val2'}
     deploy = objects.Deployment(opt='val1')
     deploy._update({'opt': 'val2'})
     mock_update.assert_called_once_with(self.deployment['uuid'],
                                         {'opt': 'val2'})
     self.assertEqual(deploy['opt'], 'val2')
コード例 #8
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update_status(self, mock_update):
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_status(consts.DeployStatus.DEPLOY_FAILED)
     mock_update.assert_called_once_with(
         self.deployment['uuid'],
         {'status': consts.DeployStatus.DEPLOY_FAILED},
     )
コード例 #9
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_update(self, mock_deployment_create, mock_deployment_update):
     mock_deployment_create.return_value = self.deployment
     mock_deployment_update.return_value = {"opt": "val2"}
     deploy = objects.Deployment(opt="val1")
     deploy._update({"opt": "val2"})
     mock_deployment_update.assert_called_once_with(self.deployment["uuid"],
                                                    {"opt": "val2"})
     self.assertEqual(deploy["opt"], "val2")
コード例 #10
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update_config(self, mock_update):
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_config({'opt': 'val'})
     mock_update.assert_called_once_with(
         self.deployment['uuid'],
         {'config': {
             'opt': 'val'
         }},
     )
コード例 #11
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_update_config(self, mock_deployment_update):
     mock_deployment_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.update_config({"opt": "val"})
     mock_deployment_update.assert_called_once_with(
         self.deployment["uuid"],
         {"config": {
             "opt": "val"
         }},
     )
コード例 #12
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_update_set_completed(self, mock_deployment_update, mock_datetime):
     mock_datetime.now = mock.Mock(return_value="fake_time")
     mock_deployment_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.set_completed()
     mock_deployment_update.assert_called_once_with(
         self.deployment["uuid"], {
             "completed_at": "fake_time",
             "status": consts.DeployStatus.DEPLOY_FINISHED
         })
コード例 #13
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_update_set_completed(self, mock_update, mock_datetime):
     mock_datetime.now = mock.Mock(return_value='fake_time')
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     deploy.set_completed()
     mock_update.assert_called_once_with(
         self.deployment['uuid'], {
             'completed_at': 'fake_time',
             'status': consts.DeployStatus.DEPLOY_FINISHED
         })
コード例 #14
0
 def test_update_endpoints(self, mock_update):
     mock_update.return_value = self.deployment
     deploy = objects.Deployment(deployment=self.deployment)
     endpoints = [
         objects.Endpoint("url", "user", "pwd", "tenant",
                          consts.EndpointPermission.ADMIN)
     ]
     deploy.update_endpoints(endpoints)
     mock_update.assert_called_once_with(
         self.deployment["uuid"],
         {"endpoints": [endpoints[0].to_dict(include_permission=True)]})
コード例 #15
0
ファイル: api.py プロジェクト: kambiz-aghaiepour/rally
def create_deploy(config, name):
    """Create a deployment.

    :param config: a dict with deployment configuration
    :param name: a str represents a name of the deployment
    """
    deployment = objects.Deployment(name=name, config=config)
    deployer = deploy.EngineFactory.get_engine(deployment['config']['type'],
                                               deployment)
    with deployer:
        endpoints = deployer.make_deploy()
        deployment.update_endpoints(endpoints)
        return deployment
コード例 #16
0
 def _deploy_first(self, lxc_host, name, distribution, release):
     lxc_host.prepare()
     lxc_host.create_container(name, distribution, release)
     lxc_host.start_containers()
     items = lxc_host.get_server_object(name).get_credentials().iteritems()
     # filter out all keys where value is None
     credentials = dict(filter(lambda x: x[1] is not None, items))
     engine_config = self.config['engine'].copy()
     engine_config['provider'] = {'type': 'DummyProvider',
                                  'credentials': [credentials]}
     deployment = objects.Deployment(config=engine_config,
                                     parent_uuid=self.deployment['uuid'])
     deployer = engine.EngineFactory.get_engine(engine_config['name'],
                                                deployment)
     deployer.deploy()
     lxc_host.stop_containers()
コード例 #17
0
ファイル: lxc.py プロジェクト: x-ion-de/rally
 def _deploy_first(self, lxc_host, name, distribution, release):
     lxc_host.prepare()
     lxc_host.create_container(name, distribution, release)
     lxc_host.start_containers()
     items = six.iteritems(
         lxc_host.get_server_object(name).get_credentials())
     # filter out all keys where value is None
     credentials = dict(filter(lambda x: x[1] is not None, items))
     engine_config = self.config["engine"].copy()
     engine_config["provider"] = {"type": "DummyProvider",
                                  "credentials": [credentials]}
     deployment = objects.Deployment(config=engine_config,
                                     parent_uuid=self.deployment["uuid"])
     deployer = engine.EngineFactory.get_engine(engine_config["name"],
                                                deployment)
     deployer.deploy()
     lxc_host.stop_containers()
コード例 #18
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_add_resource(self, mock_resource_create):
     mock_resource_create.return_value = self.resource
     deploy = objects.Deployment(deployment=self.deployment)
     resource = deploy.add_resource("provider",
                                    type="some",
                                    info={"key": "value"})
     self.assertEqual(resource["id"], self.resource["id"])
     mock_resource_create.assert_called_once_with({
         "deployment_uuid":
         self.deployment["uuid"],
         "provider_name":
         "provider",
         "type":
         "some",
         "info": {
             "key": "value"
         },
     })
コード例 #19
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_add_resource(self, mock_create):
     mock_create.return_value = self.resource
     deploy = objects.Deployment(deployment=self.deployment)
     resource = deploy.add_resource('provider',
                                    type='some',
                                    info={'key': 'value'})
     self.assertEqual(resource['id'], self.resource['id'])
     mock_create.assert_called_once_with({
         'deployment_uuid':
         self.deployment['uuid'],
         'provider_name':
         'provider',
         'type':
         'some',
         'info': {
             'key': 'value'
         },
     })
コード例 #20
0
ファイル: api.py プロジェクト: sahanasj/rally
def create_deploy(config, name):
    """Create a deployment.

    :param config: a dict with deployment configuration
    :param name: a str represents a name of the deployment
    """
    deployment = objects.Deployment(name=name, config=config)
    deployer = deploy.EngineFactory.get_engine(deployment['config']['type'],
                                               deployment)
    try:
        deployer.validate()
    except jsonschema.ValidationError:
        LOG.error(
            _('Deployment %(uuid)s: Schema validation error.') %
            {'uuid': deployment['uuid']})
        deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
        raise

    with deployer:
        endpoints = deployer.make_deploy()
        deployment.update_endpoints(endpoints)
        return deployment
コード例 #21
0
ファイル: test_deploy.py プロジェクト: yongfengdu/rally
 def test_get_resources(self, mock_resource_get_all):
     mock_resource_get_all.return_value = [self.resource]
     deploy = objects.Deployment(deployment=self.deployment)
     resources = deploy.get_resources(provider_name="provider", type="some")
     self.assertEqual(len(resources), 1)
     self.assertEqual(resources[0]["id"], self.resource["id"])
コード例 #22
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_create_and_delete(self, mock_create, mock_delete):
     mock_create.return_value = self.deployment
     deploy = objects.Deployment()
     deploy.delete()
     mock_delete.assert_called_once_with(self.deployment['uuid'])
コード例 #23
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_init_without_create(self, mock_create):
     deploy = objects.Deployment(deployment=self.deployment)
     self.assertFalse(mock_create.called)
     self.assertEqual(deploy['uuid'], self.deployment['uuid'])
コード例 #24
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_init_with_create(self, mock_create):
     mock_create.return_value = self.deployment
     deploy = objects.Deployment()
     mock_create.assert_called_once_with({})
     self.assertEqual(deploy['uuid'], self.deployment['uuid'])
コード例 #25
0
ファイル: test_deploy.py プロジェクト: sahanasj/rally
 def test_get_resources(self, mock_get_all):
     mock_get_all.return_value = [self.resource]
     deploy = objects.Deployment(deployment=self.deployment)
     resources = deploy.get_resources(provider_name='provider', type='some')
     self.assertEqual(len(resources), 1)
     self.assertEqual(resources[0]['id'], self.resource['id'])