1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 from snaps.domain.creator import CloudObject
16 from snaps.openstack.utils import (
17 nova_utils, neutron_utils, keystone_utils, cinder_utils, magnum_utils)
19 __author__ = 'spisarski'
22 class OpenStackCloudObject(CloudObject):
24 Abstract class for all OpenStack object creators
27 def __init__(self, os_creds):
30 :param os_creds: the OpenStack credentials object
32 # super(self.__class__, self, os_creds)
33 self._os_creds = os_creds
36 raise NotImplementedError('Do not override abstract method')
39 raise NotImplementedError('Do not override abstract method')
42 raise NotImplementedError('Do not override abstract method')
45 class OpenStackComputeObject(OpenStackCloudObject):
47 Abstract class for all OpenStack compute creators
50 def __init__(self, os_creds):
53 :param os_creds: the OpenStack credentials object
55 super(OpenStackComputeObject, self).__init__(os_creds)
59 self._nova = nova_utils.nova_client(self._os_creds)
62 raise NotImplementedError('Do not override abstract method')
65 raise NotImplementedError('Do not override abstract method')
68 class OpenStackNetworkObject(OpenStackCloudObject):
70 Abstract class for all OpenStack compute creators
73 def __init__(self, os_creds):
76 :param os_creds: the OpenStack credentials object
78 super(OpenStackNetworkObject, self).__init__(os_creds)
82 self._neutron = neutron_utils.neutron_client(self._os_creds)
85 raise NotImplementedError('Do not override abstract method')
88 raise NotImplementedError('Do not override abstract method')
91 class OpenStackIdentityObject(OpenStackCloudObject):
93 Abstract class for all OpenStack compute creators
96 def __init__(self, os_creds):
99 :param os_creds: the OpenStack credentials object
101 super(OpenStackIdentityObject, self).__init__(os_creds)
102 self._keystone = None
104 def initialize(self):
105 self._keystone = keystone_utils.keystone_client(self._os_creds)
108 raise NotImplementedError('Do not override abstract method')
111 raise NotImplementedError('Do not override abstract method')
114 class OpenStackVolumeObject(OpenStackCloudObject):
116 Abstract class for all OpenStack compute creators
119 def __init__(self, os_creds):
122 :param os_creds: the OpenStack credentials object
124 super(OpenStackVolumeObject, self).__init__(os_creds)
127 def initialize(self):
128 self._cinder = cinder_utils.cinder_client(self._os_creds)
131 raise NotImplementedError('Do not override abstract method')
134 raise NotImplementedError('Do not override abstract method')
137 class OpenStackMagnumObject(OpenStackCloudObject):
139 Abstract class for all OpenStack compute creators
142 def __init__(self, os_creds):
145 :param os_creds: the OpenStack credentials object
147 super(OpenStackMagnumObject, self).__init__(os_creds)
150 def initialize(self):
151 self._magnum = magnum_utils.magnum_client(self._os_creds)
154 raise NotImplementedError('Do not override abstract method')
157 raise NotImplementedError('Do not override abstract method')