Add fields from manifest to ui forms

Add ui forms to separate directory for each service

Change-Id: Id49510755b9db5468de99a414d0a9e548af765b2
This commit is contained in:
Ekaterina Fedorova 2013-12-03 12:05:43 +04:00
parent bcbb86fd32
commit e1ff9579dd
13 changed files with 35 additions and 73 deletions

View File

@ -30,8 +30,9 @@ heat = heat_templates
agent = agent_templates
scripts = scripts
# Configure archive structure
# data_type = desired folder
# Configure client archive structure
# Format: data_type = desired folder
# ui parameter is not actually used, but is kept to not break things apart
[output]
ui = service_forms
workflows = workflows

View File

@ -1,11 +1,3 @@
name: Active Directory
type: activeDirectory
description: >-
<strong> The Active Directory Service </strong>
includes one primary and optionally a few secondary
Domain Controllers, with DNS
unitTemplates:
- isMaster: true
recoveryPassword: {YAQL: $.serviceConfiguration.recoveryPassword}

View File

@ -1,10 +1,3 @@
name: ASP.NET Application
type: aspNetApp
description: >-
<strong> The ASP.NET Application Service </strong> installs
custom application onto one IIS Web Server
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: ASP.NET Application Web Farm
type: aspNetAppFarm
description: >-
<strong> The ASP.NET Farm Service </strong> installs a custom application
on a load-balanced array of IIS servers
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: Demo Service
type: demoService
description: >-
<strong> Demo Service </strong>
shows how Murano is working.
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: Linux Apache
type: linuxApacheService
description: >-
<strong> Linux Apache Service </strong>
Demonstrates a linux agent, which installs Apache web server.
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: Linux Telnet
type: linuxTelnetService
description: >-
<strong> Linux Telnet Service </strong>
Demonstrates a simple linux agent, which installs Telnet if required.
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: MS SQL Server Cluster
type: msSqlClusterServer
description: >-
<strong> The MS SQL Failover Cluster </strong> installs
Microsoft SQL Failover Cluster Server
unitTemplates:
- isMaster: true
isSync: true

View File

@ -1,10 +1,3 @@
name: MS SQL Server
type: msSqlServer
description: >-
<strong> The MS SQL Service </strong> installs an instance of
Microsoft SQL Server
unitTemplates:
- {}

View File

@ -1,10 +1,3 @@
name: Internet Information Services
type: webServer
description: >-
<strong> The Internet Information Service </strong>
sets up an IIS server and joins it into an existing domain
unitTemplates:
- {}

View File

@ -1,9 +1,3 @@
name: Internet Information Services Web Farm
type: webServerFarm
description: >-
<strong> The IIS Farm Service </strong> sets up a load-balanced set of IIS servers
unitTemplates:
- {}

View File

@ -26,3 +26,7 @@ CLIENTS_DICT = {'conductor': (WORKFLOW, HEAT, AGENT, SCRIPTS),
'ui': (UI,)}
ARCHIVE_PKG_NAME = 'data.tar.gz'
UI_FIELDS_IN_MANIFEST = {'description': 'description',
'type': 'full_service_name',
'name': 'service_display_name'}

View File

@ -17,9 +17,12 @@ import tarfile
import tempfile
import shutil
import hashlib
import yaml
import logging as log
from oslo.config import cfg
from .parser import serialize
from muranorepository.consts import DATA_TYPES, ARCHIVE_PKG_NAME
from muranorepository.consts import UI, UI_FIELDS_IN_MANIFEST
CONF = cfg.CONF
CHUNK_SIZE = 1 << 20 # 1MB
@ -138,6 +141,24 @@ class Archiver(object):
os.mkdir(pkg_dir)
return pkg_dir
def _compose_ui_forms(self, manifest, ui_definitions, src, dst):
"""
Extends ui_forms before sending to client.
Some parameters defined UI_FIELDS_IN_MANIFEST that are required
for ui forms are specified in manifest.
"""
new_dst = os.path.join(os.path.dirname(dst),
manifest.full_service_name)
if not os.path.exists(new_dst):
os.makedirs(new_dst)
for file in ui_definitions:
with open(os.path.join(src, file)) as ui_form:
content = yaml.load(ui_form)
for ui_name, manifest_name in UI_FIELDS_IN_MANIFEST.iteritems():
content[ui_name] = getattr(manifest, manifest_name)
with open(os.path.join(new_dst, file), 'w') as ui_form:
ui_form.write(serialize(content))
def get_existing_hash(self, cache_dir):
existing_caches = os.listdir(cache_dir)
if not len(existing_caches):
@ -190,7 +211,13 @@ class Archiver(object):
CONF.manifests, self.src_directories[data_type])
dst_directory = os.path.join(
temp_dir, self.dst_directories[data_type])
self._copy_data(file_list, scr_directory, dst_directory)
if data_type == UI:
self._compose_ui_forms(manifest, file_list,
scr_directory, dst_directory)
else:
self._copy_data(file_list,
scr_directory,
dst_directory)
else:
log.info(
'Manifest for {0} service has no file definitions for '