def _get_extensions(self, context): """Filter extensions list based on policy.""" discoverable_extensions = dict() for alias, ext in six.iteritems(self.extension_info.get_extensions()): authorize = extensions.os_compute_soft_authorizer(alias) if authorize(context, action='discoverable'): discoverable_extensions[alias] = ext else: LOG.debug("Filter out extension %s from discover list", alias) # Add fake v2 extensions to list extra_exts = {} for alias in discoverable_extensions: if alias in v21_to_v2_extension_list_mapping: for extra_ext in v21_to_v2_extension_list_mapping[alias]: extra_exts[extra_ext["alias"]] = self._create_fake_ext( extra_ext["name"], extra_ext["alias"]) discoverable_extensions.update(extra_exts) # Suppress extensions which we don't want to see in v2 for suppress_ext in v2_extension_suppress_list: try: del discoverable_extensions[suppress_ext] except KeyError: pass # v2.1 to v2 extension name mapping for rename_ext in v21_to_v2_alias_mapping: if rename_ext in discoverable_extensions: new_name = v21_to_v2_alias_mapping[rename_ext] mod_ext = copy.deepcopy( discoverable_extensions.pop(rename_ext)) mod_ext.alias = new_name discoverable_extensions[new_name] = mod_ext return discoverable_extensions
def _get_extensions(self, context): """Filter extensions list based on policy.""" discoverable_extensions = dict() for alias, ext in six.iteritems(self.extension_info.get_extensions()): authorize = extensions.os_compute_soft_authorizer(alias) if authorize(context, action='discoverable'): discoverable_extensions[alias] = ext else: LOG.debug("Filter out extension %s from discover list", alias) # Add fake v2 extensions to list extra_exts = {} for alias in discoverable_extensions: if alias in v21_to_v2_extension_list_mapping: for extra_ext in v21_to_v2_extension_list_mapping[alias]: extra_exts[extra_ext["alias"]] = self._create_fake_ext( extra_ext["name"], extra_ext["alias"]) discoverable_extensions.update(extra_exts) # Suppress extensions which we don't want to see in v2 for suppress_ext in v2_extension_suppress_list: try: del discoverable_extensions[suppress_ext] except KeyError: pass # v2.1 to v2 extension name mapping for rename_ext in v21_to_v2_alias_mapping: if rename_ext in discoverable_extensions: new_name = v21_to_v2_alias_mapping[rename_ext] mod_ext = copy.deepcopy( discoverable_extensions.pop(rename_ext)) mod_ext.alias = new_name discoverable_extensions[new_name] = mod_ext return discoverable_extensions
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """The Extended Volumes API extension.""" from jacket.api.compute.openstack import api_version_request from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.objects import compute as objects ALIAS = "os-extended-volumes" soft_authorize = extensions.os_compute_soft_authorizer(ALIAS) class ExtendedVolumesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedVolumesController, self).__init__(*args, **kwargs) def _extend_server(self, context, server, req, bdms): volumes_attached = [] for bdm in bdms: if bdm.get('volume_id'): volume_attached = {'id': bdm['volume_id']} if api_version_request.is_supported(req, min_version='2.3'): volume_attached['delete_on_termination'] = ( bdm['delete_on_termination']) volumes_attached.append(volume_attached)
"""The flavor access extension.""" import webob from jacket.api.compute.openstack import api_version_request from jacket.api.compute.openstack import common from jacket.api.compute.openstack.compute.schemas import flavor_access from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.api.compute import validation from jacket.compute import exception from jacket.i18n import _ from jacket.objects import compute as objects ALIAS = 'os-flavor-access' soft_authorize = extensions.os_compute_soft_authorizer(ALIAS) authorize = extensions.os_compute_authorizer(ALIAS) def _marshall_flavor_access(flavor): rval = [] for project_id in flavor.projects: rval.append({'flavor_id': flavor.flavorid, 'tenant_id': project_id}) return {'flavor_access': rval} class FlavorAccessController(wsgi.Controller): """The flavor access API controller for the OpenStack API."""
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """The Extended Server Attributes API extension.""" from jacket.api.compute.openstack import api_version_request from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.compute import cloud ALIAS = "os-extended-server-attributes" authorize = extensions.os_compute_soft_authorizer(ALIAS) soft_authorize = extensions.os_compute_soft_authorizer('servers') class ExtendedServerAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedServerAttributesController, self).__init__(*args, **kwargs) self.compute_api = cloud.API(skip_policy_check=True) def _extend_server(self, context, server, instance, req): key = "OS-EXT-SRV-ATTR:hypervisor_hostname" server[key] = instance.node properties = ['host', 'name'] if api_version_request.is_supported(req, min_version='2.3'):
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import webob.exc from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.compute import cloud from jacket.compute import exception from jacket.objects import compute as objects ALIAS = 'os-pci' soft_authorize = extensions.os_compute_soft_authorizer(ALIAS + ':pci_servers') authorize = extensions.os_compute_authorizer(ALIAS) PCI_ADMIN_KEYS = ['id', 'address', 'vendor_id', 'product_id', 'status', 'compute_node_id'] PCI_DETAIL_KEYS = ['dev_type', 'label', 'instance_uuid', 'dev_id', 'extra_info'] class PciServerController(wsgi.Controller): def _extend_server(self, server, instance): dev_id = [] for dev in instance.pci_devices: dev_id.append({'id': dev.id}) server['%s:pci_devices' % Pci.alias] = dev_id
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import webob.exc from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.compute import cloud from jacket.compute import exception from jacket.objects import compute as objects ALIAS = 'os-pci' soft_authorize = extensions.os_compute_soft_authorizer(ALIAS + ':pci_servers') authorize = extensions.os_compute_authorizer(ALIAS) PCI_ADMIN_KEYS = [ 'id', 'address', 'vendor_id', 'product_id', 'status', 'compute_node_id' ] PCI_DETAIL_KEYS = [ 'dev_type', 'label', 'instance_uuid', 'dev_id', 'extra_info' ] class PciServerController(wsgi.Controller): def _extend_server(self, server, instance): dev_id = [] for dev in instance.pci_devices: dev_id.append({'id': dev.id})
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """The Extended Server Attributes API extension.""" from jacket.api.compute.openstack import api_version_request from jacket.api.compute.openstack import extensions from jacket.api.compute.openstack import wsgi from jacket.compute import cloud ALIAS = "os-extended-server-attributes" authorize = extensions.os_compute_soft_authorizer(ALIAS) soft_authorize = extensions.os_compute_soft_authorizer('servers') class ExtendedServerAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedServerAttributesController, self).__init__(*args, **kwargs) self.compute_api = cloud.API(skip_policy_check=True) def _extend_server(self, context, server, instance, req): key = "OS-EXT-SRV-ATTR:hypervisor_hostname" server[key] = instance.node properties = ['host', 'name'] if api_version_request.is_supported(req, min_version='2.3'):