Ejemplo n.º 1
0
    def test_workflows_get_nonexistent_workflow(self):

        expected_message = ("Workflow 'nonexistent_workflow' "
                            "not found on management server")
        deployment = Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        self._assert_ex('cfy workflows get -w nonexistent_workflow -d dep_id',
                        expected_message)
Ejemplo n.º 2
0
 def get_deployment(self, name):
     deployment_dir = os.path.join(self._root_storage_dir, 'deployments',
                                   name)
     try:
         with open(os.path.join(deployment_dir, 'deployment.json')) as f:
             return Deployment(json.load(f, object_hook=load_datetime))
     except IOError:
         return None
Ejemplo n.º 3
0
    def _delete_deployment(self, deployment_id, ignore_live_nodes=False):

        ignore_live_nodes = 'true' if ignore_live_nodes else 'false'
        delete_db_mode = 'true'
        params = {'ignore_live_nodes': ignore_live_nodes,
                  'delete_db_mode': delete_db_mode}
        response = self.client._client.delete(
            '/deployments/{0}'.format(deployment_id), params=params)

        return Deployment(response)
Ejemplo n.º 4
0
 def list_deployments(**kwargs):
     tenant_name = self.client._client.headers.get(
         CLOUDIFY_TENANT_HEADER)
     if not tenant_name:
         tenant_name = DEFAULT_TENANT_NAME
     all_node_instances = _topology_filter(lambda x: True, **kwargs)
     deployments = {(x['tenant_name'], x['deployment_id'])
                    for x in all_node_instances}
     deployments = [Deployment({'id': b, 'tenant_name': a}) for a, b in
                    deployments]
     results = list()
     searched_ids = kwargs['id']
     for dep in deployments:
         if (not searched_ids) or dep.id in searched_ids:
             results.append(dep)
     return results
Ejemplo n.º 5
0
    def test_workflows_get(self):
        deployment = Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        cli_runner.run_cli('cfy workflows get -w mock_workflow -d dep_id')
Ejemplo n.º 6
0
 def get_deployment(self, name):
     return Deployment(self._deployments[name])