~ibmcharmers/charms/trusty/ibm-glance-spectrumscale/trunk

« back to all changes in this revision

Viewing changes to tests/basic_deployment.py

  • Committer: Suchitra Venugopal
  • Date: 2017-01-27 11:21:55 UTC
  • Revision ID: suchvenu@in.ibm.com-20170127112155-crrgnwmavhqnu93n
IBM Glance SpectrumScale charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# limitations under the License.
16
16
 
17
17
"""
18
 
Basic cinder-ceph functional test.
 
18
Basic glance-spectrumscale functional test.
19
19
"""
20
20
# import amulet
21
21
# import json
22
22
# import time
 
23
import yaml
 
24
import os
23
25
 
24
26
from charmhelpers.contrib.openstack.amulet.deployment import (
25
27
    OpenStackAmuletDeployment
26
28
)
27
29
 
28
30
 
29
 
seconds_to_wait = 100000
30
 
 
31
 
 
32
 
class CinderCephBasicDeployment(OpenStackAmuletDeployment):
 
31
seconds_to_wait = 2000
 
32
 
 
33
 
 
34
class GlanceSpectrumscaleBasicDeployment(OpenStackAmuletDeployment):
33
35
    """Amulet tests on a basic heat deployment."""
34
 
 
35
36
    def __init__(self, series=None, openstack=None, source=None, git=False,
36
37
                 stable=True):
37
38
        """Deploy the entire test environment."""
38
 
        super(CinderCephBasicDeployment, self).__init__(series, openstack,
39
 
                                                        source, stable)
 
39
        super(GlanceSpectrumscaleBasicDeployment, self).__init__(series,
 
40
                                                                 openstack,
 
41
                                                                 source,
 
42
                                                                 stable)
40
43
        self.git = git
41
44
        self._add_services()
42
45
        self._add_relations()
47
50
 
48
51
        # Wait for deployment ready msgs, except exclusions
49
52
        self._auto_wait_for_status(exclude_services=exclude_services)
50
 
 
51
 
        self._check_cinderconffile()
 
53
        self._check_glancedriver()
52
54
        self.d.sentry.wait(seconds_to_wait)
53
55
 
54
56
    def _add_services(self):
57
59
        are compatible with the local charm (e.g. stable or next).
58
60
        """
59
61
        # Note: cinder-ceph becomes a cinder subordinate unit.
60
 
        this_service = {'name': 'ibm-cinder-spectrumscale'}
 
62
        this_service = {'name': 'ibm-glance-spectrumscale'}
61
63
        other_services = [
62
64
            {'name': 'percona-cluster', 'constraints': {'mem': '3072M'}},
63
65
            {'name': 'keystone'},
64
66
            {'name': 'rabbitmq-server'},
65
 
            {'name': 'cinder'},
 
67
            {'name': 'glance'},
66
68
            {'name': 'ubuntu'},
67
69
            {'name': 'ibm-spectrum-scale-client', 'location': 'cs:~ibmcharmers/ \
68
 
             xenial/ibm-spectrum-scale-client'},
 
70
             xenial/ibm-spectrum-scale-client-4'},
69
71
            {'name': 'ibm-spectrum-scale-manager', 'location': 'cs:~ibmcharmers/ \
70
 
             ibm-spectrum-scale-manager'},
 
72
             ibm-spectrum-scale-manager-5', 'units': 2},
71
73
        ]
72
 
        super(CinderCephBasicDeployment, self)._add_services(this_service,
73
 
                                                             other_services)
 
74
        super(GlanceSpectrumscaleBasicDeployment, self)._add_services(
 
75
            this_service, other_services)
74
76
 
75
77
    def _add_relations(self):
76
78
        """Add all of the relations for the services."""
77
79
 
78
80
        relations = {
79
 
            'cinder:storage-backend':
80
 
                'ibm-cinder-spectrumscale:storage-backend',
 
81
            'glance:storage-backend':
 
82
                'ibm-glance-spectrumscale:storage-backend',
 
83
            'glance:identity-service': 'keystone:identity-service',
 
84
            'glance:shared-db': 'percona-cluster:shared-db',
81
85
            'keystone:shared-db': 'percona-cluster:shared-db',
82
 
            'cinder:shared-db': 'percona-cluster:shared-db',
83
 
            'cinder:identity-service': 'keystone:identity-service',
84
 
            'cinder:amqp': 'rabbitmq-server:amqp',
 
86
            'glance:amqp': 'rabbitmq-server:amqp',
85
87
            'ubuntu:juju-info': 'ibm-spectrum-scale-client:juju-info',
86
88
            'ibm-spectrum-scale-manager:gpfsmanager':
87
89
                'ibm-spectrum-scale-client:gpfsmanager',
88
90
            'ibm-spectrum-scale-client:client':
89
 
                'ibm-cinder-spectrumscale:spectrumscale',
 
91
                'ibm-glance-spectrumscale:spectrumscale'
90
92
        }
91
 
        super(CinderCephBasicDeployment, self)._add_relations(relations)
 
93
        super(GlanceSpectrumscaleBasicDeployment, self)._add_relations(
 
94
            relations)
92
95
 
93
96
    def _configure_services(self):
94
97
        """Configure all of the services."""
 
98
        glance_config = {}
 
99
        if self.git:
 
100
            amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY')
 
101
 
 
102
            reqs_repo = 'git://github.com/openstack/requirements'
 
103
            glance_repo = 'git://github.com/openstack/glance'
 
104
            if self._get_openstack_release() == self.trusty_icehouse:
 
105
                reqs_repo = 'git://github.com/coreycb/requirements'
 
106
                glance_repo = 'git://github.com/coreycb/glance'
 
107
 
 
108
            branch = 'stable/' + self._get_openstack_release_string()
 
109
 
 
110
            openstack_origin_git = {
 
111
                'repositories': [
 
112
                    {'name': 'requirements',
 
113
                     'repository': reqs_repo,
 
114
                     'branch': branch},
 
115
                    {'name': 'glance',
 
116
                     'repository': glance_repo,
 
117
                     'branch': branch},
 
118
                ],
 
119
                'directory': '/mnt/openstack-git',
 
120
                'http_proxy': amulet_http_proxy,
 
121
                'https_proxy': amulet_http_proxy,
 
122
            }
 
123
            glance_config['openstack-origin-git'] = \
 
124
                yaml.dump(openstack_origin_git)
 
125
 
95
126
        keystone_config = {
96
127
            'admin-password': 'openstack',
97
128
            'admin-token': 'ubuntutesting'
102
133
            'root-password': 'ChangeMe123',
103
134
            'sst-password': 'ChangeMe123',
104
135
        }
105
 
        cinder_config = {
106
 
            'block-device': 'None',
107
 
            'glance-api-version': '2'
108
 
        }
109
 
 
110
 
        cinder_spectrumscale_config = {
111
 
            'gpfs_mount_point_base': '/ibm/gpfs0/openstack/cinder/volumes/',
112
 
        }
113
 
 
114
136
        configs = {
115
137
            'keystone': keystone_config,
116
138
            'percona-cluster': pxc_config,
117
 
            'cinder': cinder_config,
118
 
            'ibm-cinder-spectrumscale': cinder_spectrumscale_config,
119
 
            # 'nova-compute': nova_config,
120
 
            # 'ceph': ceph_config,
121
 
            # 'cinder-ceph': cinder_ceph_config
 
139
            'glance': glance_config,
 
140
            # 'ibm-cinder-spectrumscale': cinder_spectrumscale_config,
122
141
        }
123
 
        super(CinderCephBasicDeployment, self)._configure_services(configs)
124
 
 
125
 
    def _check_cinderconffile(self):
126
 
        filepath = file('/etc/cinder/cinder.conf')
127
 
        searchtext = "enabled_backends = ibm-cinder-spectrumscale"
128
 
        print("Checking cinder conf file")
129
 
        for line in filepath:
130
 
            if searchtext in line:
131
 
                print("Cinder conf file updated for GPFS storage")
132
 
                break
 
142
        super(GlanceSpectrumscaleBasicDeployment, self)._configure_services(
 
143
            configs)
 
144
 
 
145
    def _check_glancedriver(self):
 
146
        unit = self.d.sentry['ibm-glance-spectrumscale'][0]
 
147
        hostname, code = unit.run('hostname')
 
148
        unit_client = self.d.sentry['ibm-spectrum-scale-client'][0]
 
149
        host_name, code = unit_client.run("grep %s /etc/hosts | cut -d' ' -f2"
 
150
                                          % hostname)
 
151
 
 
152
        # To check whether host name of driver is added to /etc/hosts file of
 
153
        # client. This is to test the interface between driver and client
 
154
        if str(host_name) == str(hostname):
 
155
            self.log.debug('Host name in client /etc/hosts file ... OK')
 
156
        else:
 
157
            self.log.debug('Host name in client /etc/hosts file ... Failed')