Merge "Murano bindings to Glance Metadef API"
This commit is contained in:
commit
0fa1b7a006
30
meta/io.murano/Classes/system/MetadefBrowser.yaml
Normal file
30
meta/io.murano/Classes/system/MetadefBrowser.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
Namespaces:
|
||||||
|
=: io.murano.system
|
||||||
|
|
||||||
|
Name: MetadefBrowser
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
canBeAppliedTo:
|
||||||
|
Arguments:
|
||||||
|
- tag:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- resourceType:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
Body:
|
||||||
|
- $nss: $this.getNamespaces($resourceType)
|
||||||
|
- $objects: $nss.select($this.getObjects($.namespace)).flatten()
|
||||||
|
- $keys: $objects.properties.select($.keys()).flatten()
|
||||||
|
- Return: $tag in $keys
|
||||||
|
|
@ -71,6 +71,7 @@ Classes:
|
|||||||
io.murano.system.AwsSecurityGroupManager: system/AwsSecurityGroupManager.yaml
|
io.murano.system.AwsSecurityGroupManager: system/AwsSecurityGroupManager.yaml
|
||||||
io.murano.system.DummySecurityGroupManager: system/DummySecurityGroupManager.yaml
|
io.murano.system.DummySecurityGroupManager: system/DummySecurityGroupManager.yaml
|
||||||
io.murano.system.MistralClient: system/MistralClient.yaml
|
io.murano.system.MistralClient: system/MistralClient.yaml
|
||||||
|
io.murano.system.MetadefBrowser: system/MetadefBrowser.yaml
|
||||||
|
|
||||||
io.murano.metadata.Description: metadata/Description.yaml
|
io.murano.metadata.Description: metadata/Description.yaml
|
||||||
io.murano.metadata.HelpText: metadata/HelpText.yaml
|
io.murano.metadata.HelpText: metadata/HelpText.yaml
|
||||||
|
@ -290,6 +290,28 @@ glare_opts = [
|
|||||||
deprecated_group='glance')
|
deprecated_group='glance')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
glance_opts = [
|
||||||
|
cfg.StrOpt('url', help='Optional glance endpoint override'),
|
||||||
|
|
||||||
|
cfg.BoolOpt('insecure', default=False,
|
||||||
|
help='This option explicitly allows Murano to perform '
|
||||||
|
'"insecure" SSL connections and transfers with Glance API.'),
|
||||||
|
|
||||||
|
cfg.StrOpt('ca_file',
|
||||||
|
help='(SSL) Tells Murano to use the specified certificate file '
|
||||||
|
'to verify the peer running Glance API.'),
|
||||||
|
|
||||||
|
cfg.StrOpt('cert_file',
|
||||||
|
help='(SSL) Tells Murano to use the specified client '
|
||||||
|
'certificate file when communicating with Glance.'),
|
||||||
|
|
||||||
|
cfg.StrOpt('key_file', help='(SSL/SSH) Private key file name to '
|
||||||
|
'communicate with Glance API.'),
|
||||||
|
|
||||||
|
cfg.StrOpt('endpoint_type', default='publicURL',
|
||||||
|
help='Glance endpoint type.')
|
||||||
|
]
|
||||||
|
|
||||||
file_server = [
|
file_server = [
|
||||||
cfg.StrOpt('file_server', default='',
|
cfg.StrOpt('file_server', default='',
|
||||||
help='Set a file server.')
|
help='Set a file server.')
|
||||||
@ -315,6 +337,7 @@ CONF.register_cli_opts(metadata_dir)
|
|||||||
CONF.register_opts(stats_opts, group='stats')
|
CONF.register_opts(stats_opts, group='stats')
|
||||||
CONF.register_opts(networking_opts, group='networking')
|
CONF.register_opts(networking_opts, group='networking')
|
||||||
CONF.register_opts(glare_opts, group='glare')
|
CONF.register_opts(glare_opts, group='glare')
|
||||||
|
CONF.register_opts(glance_opts, group='glance')
|
||||||
|
|
||||||
|
|
||||||
def parse_args(args=None, usage=None, default_config_files=None):
|
def parse_args(args=None, usage=None, default_config_files=None):
|
||||||
|
69
murano/engine/system/metadef_browser.py
Normal file
69
murano/engine/system/metadef_browser.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Copyright (c) 2016 Mirantis Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import glanceclient.v2.client as gclient
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from murano.common import auth_utils
|
||||||
|
from murano.dsl import dsl
|
||||||
|
from murano.dsl import helpers
|
||||||
|
from murano.dsl import session_local_storage
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
|
@dsl.name('io.murano.system.MetadefBrowser')
|
||||||
|
class MetadefBrowser(object):
|
||||||
|
def __init__(self, this, region_name=None, cache=True):
|
||||||
|
session = helpers.get_execution_session()
|
||||||
|
self._project_id = session.project_id
|
||||||
|
self._region = this.find_owner('io.murano.CloudRegion')
|
||||||
|
self._region_name = region_name
|
||||||
|
self._cache = cache
|
||||||
|
self._namespaces = {}
|
||||||
|
self._objects = {}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@session_local_storage.execution_session_memoize
|
||||||
|
def _get_client(region_name):
|
||||||
|
glance_settings = CONF.glance
|
||||||
|
return gclient.Client(**auth_utils.get_session_client_parameters(
|
||||||
|
service_type='image', region=region_name, conf=glance_settings
|
||||||
|
))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _client(self):
|
||||||
|
region = self._region_name or (
|
||||||
|
None if self._region is None else self._region['name'])
|
||||||
|
return self._get_client(region)
|
||||||
|
|
||||||
|
def get_namespaces(self, resource_type):
|
||||||
|
if not self._cache or resource_type not in self._namespaces:
|
||||||
|
nss = list(self._client.metadefs_namespace.list(
|
||||||
|
resource_type=resource_type))
|
||||||
|
self._namespaces[resource_type] = nss
|
||||||
|
return nss
|
||||||
|
else:
|
||||||
|
return self._namespaces[resource_type]
|
||||||
|
|
||||||
|
def get_objects(self, namespace):
|
||||||
|
if not self._cache or namespace not in self._objects:
|
||||||
|
objects = list(self._client.metadefs_object.list(
|
||||||
|
namespace=namespace))
|
||||||
|
self._objects[namespace] = objects
|
||||||
|
return objects
|
||||||
|
else:
|
||||||
|
return self._objects[namespace]
|
@ -18,6 +18,7 @@ from murano.engine.system import agent_listener
|
|||||||
from murano.engine.system import heat_stack
|
from murano.engine.system import heat_stack
|
||||||
from murano.engine.system import instance_reporter
|
from murano.engine.system import instance_reporter
|
||||||
from murano.engine.system import logger
|
from murano.engine.system import logger
|
||||||
|
from murano.engine.system import metadef_browser
|
||||||
from murano.engine.system import net_explorer
|
from murano.engine.system import net_explorer
|
||||||
from murano.engine.system import resource_manager
|
from murano.engine.system import resource_manager
|
||||||
from murano.engine.system import status_reporter
|
from murano.engine.system import status_reporter
|
||||||
@ -36,3 +37,4 @@ def register(package):
|
|||||||
package.register_class(logger.Logger)
|
package.register_class(logger.Logger)
|
||||||
package.register_class(test_fixture.TestFixture)
|
package.register_class(test_fixture.TestFixture)
|
||||||
package.register_class(workflowclient.MistralClient)
|
package.register_class(workflowclient.MistralClient)
|
||||||
|
package.register_class(metadef_browser.MetadefBrowser)
|
||||||
|
Loading…
Reference in New Issue
Block a user