Add per-form validators to services markup.

This allows to implement joint validator for hostname template and number
of instances in all services.

Also:

1) Refactor append_properties function(rename to push_properties
and move to field classes).
2) Change service forms markup so each form has a name.
3) Change yaql-validators syntax to {YAQL: validatorExpression}.

Change-Id: Ia6b32e14213b147881b242710ca130a4dea3cdb2
This commit is contained in:
Timur Sufiev 2013-08-14 17:52:53 +04:00
parent 13edd0406e
commit 0098f86297
12 changed files with 899 additions and 830 deletions

View File

@ -20,16 +20,6 @@ from muranodashboard.panel.services import iterate_over_service_forms, \
log = logging.getLogger(__name__)
# has to be returned to all forms
# def validate_hostname_template(template, instance_count):
# if template and instance_count > 1:
# if not '#' in template:
# raise forms.ValidationError(
# _('Incrementation symbol "#" is '
# 'required in the Hostname template'))
#
#
class WizardFormServiceType(forms.Form):
service = forms.ChoiceField(label=_('Service Type'),

View File

@ -8,107 +8,115 @@ description: >-
unitTemplates:
- isMaster: true
recoveryPassword: $recoveryPassword
recoveryPassword: {YAQL: $.recoveryPassword}
location: west-dc
- isMaster: false
recoveryPassword: $recoveryPassword
recoveryPassword: {YAQL: $.recoveryPassword}
forms:
- - name: configuration
type: string
hidden: true
initial: standalone
- name: name
type: string
label: Domain Name
description: >-
Enter a desired name for a new domain. This name should fit
in standard Windows domain name requirements: it should contain
only A-Z, a-z, 0-9, and (-) and should not end with a dash.
DNS server will be automatically set up on each of the Domain
Controller instances. The domain length is restricted by 15 characters.
attributeNames: [name, domain]
minLength: 2
maxLength: 15
regexpValidator: '^([a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]\.){1,}[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]$'
errorMessages:
invalid: >-
Only letters, numbers and dashes in the middle are
allowed. Period characters are allowed only when they are
used to delimit the components of domain style
names. Single-level domain is not appropriate.
helpText: >-
Just letters, numbers and dashes are allowed.
A dot can be used to create subdomains
- name: dcInstances
type: instance
label: Instance Count
description: >-
You can create several Active Directory instances by setting
instance number larger than one. One primary Domain Controller
and a few secondary DCs will be created.
attributeNames: units
minValue: 1
maxValue: 100
initial: 1
helpText: Enter an integer value between 1 and 100
- name: adminAccountName
type: string
label: Account Name
initial: Administrator
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: 'Just letters, numbers, underscores and hyphens are allowed.'
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
Once you forget your password you won't be able to
operate the service until recovery password would be entered. So it's
better for Recovery and Administrator password to be different.
- name: recoveryPassword
type: password
label: Recovery password
attributeNames: false
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: configuration
type: string
hidden: true
initial: standalone
- name: name
type: string
label: Domain Name
description: >-
Enter a desired name for a new domain. This name should fit
in standard Windows domain name requirements: it should contain
only A-Z, a-z, 0-9, and (-) and should not end with a dash.
DNS server will be automatically set up on each of the Domain
Controller instances. The domain length is restricted by 15 characters.
attributeNames: [name, domain]
minLength: 2
maxLength: 15
regexpValidator: '^([a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]\.){1,}[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]$'
errorMessages:
invalid: >-
Only letters, numbers and dashes in the middle are
allowed. Period characters are allowed only when they are
used to delimit the components of domain style
names. Single-level domain is not appropriate.
helpText: >-
Just letters, numbers and dashes are allowed.
A dot can be used to create subdomains
- name: dcInstances
type: instance
label: Instance Count
description: >-
You can create several Active Directory instances by setting
instance number larger than one. One primary Domain Controller
and a few secondary DCs will be created.
attributeNames: units
minValue: 1
maxValue: 100
initial: 1
helpText: Enter an integer value between 1 and 100
- name: adminAccountName
type: string
label: Account Name
initial: Administrator
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: 'Just letters, numbers, underscores and hyphens are allowed.'
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
Once you forget your password you won't be able to
operate the service until recovery password would be entered. So it's
better for Recovery and Administrator password to be different.
- name: recoveryPassword
type: password
label: Recovery password
attributeNames: false
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
validators:
# if unitNamingPattern is given and dcInstances > 1, then '#' should occur in unitNamingPattern
- expr: {YAQL: $.dcInstances < 2 or not $.unitNamingPattern or '#' in $.unitNamingPattern}
message: Incrementation symbol "#" is required in the Hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -9,79 +9,83 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
required: false
hidden: true
attributeNames: false
description: Standalone IIS Server
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
description: Standalone IIS Server
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -9,88 +9,92 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
required: false
hidden: true
attributeNames: false
description: ASP.NET application will be installed onto one IISWeb Server
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: repository
type: string
label: Git repository
description: >-
URL of a git repository with the application you want to deploy.
regexpValidator: '/(\w+://)(.+@)*([\w\d\.]+)(:[\d]+)?/*(.*)/i'
errorMessages:
invalid: Enter correct git repository url
helpText: Enter a valid git repository URL
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
description: ASP.NET application will be installed onto one IISWeb Server
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: repository
type: string
label: Git repository
description: >-
URL of a git repository with the application you want to deploy.
regexpValidator: '/(\w+://)(.+@)*([\w\d\.]+)(:[\d]+)?/*(.*)/i'
errorMessages:
invalid: Enter correct git repository url
helpText: Enter a valid git repository URL
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -8,98 +8,105 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
hidden: true
required: false
attributeNames: false
description: A load-balanced array of IIS servers
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: username
type: string
hidden: true
initial: Administrator
attributeNames: credentials.username
- name: adminPassword
type: password
attributeNames: [adminPassword, credentials.password]
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: dcInstances
type: instance
minValue: 1
maxValue: 100
attributeNames: [units, instanceCount]
initial: 1
label: Instance Count
description: Several instances with IIS Service can be created at one time.
helpText: Enter an integer value between 1 and 100
- name: loadBalancerPort
type: integer
label: Load Balancer port
minValue: 1
maxValue: 65536
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
hidden: true
required: false
attributeNames: false
description: A load-balanced array of IIS servers
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: username
type: string
hidden: true
initial: Administrator
attributeNames: credentials.username
- name: adminPassword
type: password
attributeNames: [adminPassword, credentials.password]
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: dcInstances
type: instance
minValue: 1
maxValue: 100
attributeNames: [units, instanceCount]
initial: 1
label: Instance Count
description: Several instances with IIS Service can be created at one time.
helpText: Enter an integer value between 1 and 100
- name: loadBalancerPort
type: integer
label: Load Balancer port
minValue: 1
maxValue: 65536
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
validators:
# if unitNamingPattern is given and dcInstances > 1, then '#' should occur in unitNamingPattern
- expr: {YAQL: $.dcInstances < 2 or not $.unitNamingPattern or '#' in $.unitNamingPattern}
message: Incrementation symbol "#" is required in the Hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -9,104 +9,112 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
required: false
hidden: true
attributeNames: false
description: >-
The ASP.NET application will be installed on a number of IIS Web
Servers, and load balancing will be configured.
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: username
type: string
hidden: true
initial: Administrator
attributeNames: credentials.username
- name: adminPassword
type: password
attributeNames: [adminPassword, credentials.password]
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: repository
type: string
label: Git repository
description: >-
URL of a git repository with the application you want to deploy.
regexpValidator: '/(\w+://)(.+@)*([\w\d\.]+)(:[\d]+)?/*(.*)/i'
errorMessages:
invalid: Enter correct git repository url
helpText: Enter a valid git repository URL
- name: loadBalancerPort
type: integer
label: Load Balancer port
minValue: 1
maxValue: 65536
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
description: >-
The ASP.NET application will be installed on a number of IIS Web
Servers, and load balancing will be configured.
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: username
type: string
hidden: true
initial: Administrator
attributeNames: credentials.username
- name: adminPassword
type: password
attributeNames: [adminPassword, credentials.password]
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: repository
type: string
label: Git repository
description: >-
URL of a git repository with the application you want to deploy.
regexpValidator: '/(\w+://)(.+@)*([\w\d\.]+)(:[\d]+)?/*(.*)/i'
errorMessages:
invalid: Enter correct git repository url
helpText: Enter a valid git repository URL
- name: loadBalancerPort
type: integer
label: Load Balancer port
minValue: 1
maxValue: 65536
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
validators:
# if unitNamingPattern is given and dcInstances > 1, then '#' should occur in unitNamingPattern
- expr: {YAQL: $.dcInstances < 2 or not $.unitNamingPattern or '#' in $.unitNamingPattern}
message: Incrementation symbol "#" is required in the Hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -9,99 +9,102 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
required: false
hidden: true
attributeNames: false
description: MS SQL Server
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js]
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: mixedModeAuth
type: boolean
label: Mixed-mode Authentication
initial: true
required: false
description: >-
Mixed authentication mode allows the use of Windows
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
- name: saPassword
type: password
label: SA Password
description: Set system administrator password for the MS SQL Server.
helpText: SQL server System Administrator account
required: $mixedModeAuth
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
description: MS SQL Server
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js]
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: dcInstances
type: instance
hidden: true
attributeNames: units
initial: 1
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: mixedModeAuth
type: boolean
label: Mixed-mode Authentication
initial: true
required: false
description: >-
Mixed authentication mode allows the use of Windows
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
- name: saPassword
type: password
label: SA Password
description: Set system administrator password for the MS SQL Server.
helpText: SQL server System Administrator account
required: {YAQL: $.mixedModeAuth}
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -9,181 +9,192 @@ unitTemplates:
- {}
forms:
- - name: title
type: string
required: false
hidden: true
attributeNames: false
description: MS SQL Failover Cluster
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js, muranodashboard/js/external-ad.js]
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: externalAD
type: boolean
label: Active Directory is configured by the System Administrator
widgetAttrs: # temporary hack
class: external-ad
required: false
- name: domainAdminUserName
type: string
label: Active Directory User
required: $externalAD
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: 'Just letters, numbers, underscores and hyphens are allowed.'
- name: domainAdminPassword
type: password
label: Active Directory Password
required: $externalAD
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: mixedModeAuth
type: boolean
label: Mixed-mode Authentication
initial: true
required: false
description: >-
Mixed authentication mode allows the use of Windows
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
- name: saPassword
type: password
label: SA Password
description: Set system administrator password for the MS SQL Server.
helpText: SQL server System Administrator account
required: $mixedModeAuth
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
#regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
- - name: clusterIP
type: clusterip
label: Cluster Static IP
description: Specify a valid IPv4 fixed IP.
- name: clusterName
type: string
label: Cluster Name
helpText: Service name for new SQL Cluster service
description: >-
Specify a name of a cluster. Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agGroupName
type: string
label: Availability Group Name
helpText: Name of AG during SQL setup
description: >-
Specify a name of an AG. Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agListenerName
type: string
label: Availability Group Listener Name
helpText: FQDN name of a new DNS entry for AG Listener endpoint
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
description: >-
Specify a name of an AG Listener . Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agListenerIP
type: clusterip
label: Availability Group Listener IP
description: Specify a valid IPv4 fixed IP.
- name: sqlServiceUserName
type: string
label: SQL User Name
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
description: User name that will be created to manage cluster instances.
- name: sqlServicePassword
type: password
label: SQL User Password
description: User password that will be created to manage cluster instances.
- name: dcInstances
type: instance
label: Instance Count
minValue: 2
maxValue: 5
initial: 2
attributeNames: units
helpText: Enter an integer value between 2 and 5
description: Microsoft SQL Failover Cluster includes up to 5 instances.
- - name: nodes
type: datagrid
label: Nodes
description: >-
Configure cluster instances. Cluster node quantity can be set
with 'Add' and 'Remove' buttons. Configure Sync mode by
enabling corresponding checkbox. All other nodes will be in
Async mode. Just 2 nodes are allowed to be Sync. Also one
Master node need to be selected. SQL Failover cluster has
limit of 5 instances.
- name: databases
type: databaselist
label: Database list
description: >-
Specify names for new databases which will be created as part
of service installation. Here should come comma-separated list
of database names, where each name has the following syntax:
first symbol should be latin letter or underscore; subsequent
symbols can be latin letter, numeric, underscore, at sign,
number sign or dollar sign.
helpText: Enter comma separated list of databases that will be created
- - name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false
- serviceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
description: MS SQL Failover Cluster
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js, muranodashboard/js/external-ad.js]
- name: name
type: string
label: Service Name
description: >-
Enter a desired name for a service. Just A-Z, a-z, 0-9, dash and
underline are allowed.
minLength: 2
maxLength: 64
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
- name: adminPassword
type: password
label: Administrator password
descriptionTitle: Passwords
description: >-
Windows requires strong password for service administration.
Your password should have at least one letter in each
register, a number and a special character. Password length should be
a minimum of 7 characters.
- name: externalAD
type: boolean
label: Active Directory is configured by the System Administrator
widgetAttrs: # temporary hack
class: external-ad
required: false
- name: domainAdminUserName
type: string
label: Active Directory User
required: {YAQL: $.externalAD}
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: 'Just letters, numbers, underscores and hyphens are allowed.'
- name: domainAdminPassword
type: password
label: Active Directory Password
required: {YAQL: $.externalAD}
- name: domain
type: domain
label: Domain
required: false
description: >-
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: mixedModeAuth
type: boolean
label: Mixed-mode Authentication
initial: true
required: false
description: >-
Mixed authentication mode allows the use of Windows
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
- name: saPassword
type: password
label: SA Password
description: Set system administrator password for the MS SQL Server.
helpText: SQL server System Administrator account
required: {YAQL: $.mixedModeAuth}
- clusterConfiguration:
fields:
- name: clusterIP
type: clusterip
label: Cluster Static IP
description: Specify a valid IPv4 fixed IP.
- name: clusterName
type: string
label: Cluster Name
helpText: Service name for new SQL Cluster service
description: >-
Specify a name of a cluster. Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agGroupName
type: string
label: Availability Group Name
helpText: Name of AG during SQL setup
description: >-
Specify a name of an AG. Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agListenerName
type: string
label: Availability Group Listener Name
helpText: FQDN name of a new DNS entry for AG Listener endpoint
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
description: >-
Specify a name of an AG Listener . Just A-Z, a-z, 0-9, dash and underline are allowed.
- name: agListenerIP
type: clusterip
label: Availability Group Listener IP
description: Specify a valid IPv4 fixed IP.
- name: sqlServiceUserName
type: string
label: SQL User Name
regexpValidator: '^[-\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
description: User name that will be created to manage cluster instances.
- name: sqlServicePassword
type: password
label: SQL User Password
description: User password that will be created to manage cluster instances.
- name: dcInstances
type: instance
label: Instance Count
minValue: 2
maxValue: 5
initial: 2
attributeNames: units
helpText: Enter an integer value between 2 and 5
description: Microsoft SQL Failover Cluster includes up to 5 instances.
- name: unitNamingPattern
type: string
label: Hostname template
description: >-
For your convenience all instance hostnames can be named
in the same way. Enter a name and use # character for incrementation.
For example, host# turns into host1, host2, etc. Please follow Windows
hostname restrictions.
required: false
regexpValidator: '^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$'
helpText: Optional field for a machine hostname template
validators:
# if unitNamingPattern is given and dcInstances > 1, then '#' should occur in unitNamingPattern
- expr: {YAQL: $.dcInstances < 2 or not $.unitNamingPattern or '#' in $.unitNamingPattern}
message: Incrementation symbol "#" is required in the Hostname template
- unitsConfiguration:
fields:
- name: nodes
type: datagrid
label: Nodes
description: >-
Configure cluster instances. Cluster node quantity can be set
with 'Add' and 'Remove' buttons. Configure Sync mode by
enabling corresponding checkbox. All other nodes will be in
Async mode. Just 2 nodes are allowed to be Sync. Also one
Master node need to be selected. SQL Failover cluster has
limit of 5 instances.
- name: databases
type: databaselist
label: Database list
description: >-
Specify names for new databases which will be created as part
of service installation. Here should come comma-separated list
of database names, where each name has the following syntax:
first symbol should be latin letter or underscore; subsequent
symbols can be latin letter, numeric, underscore, at sign,
number sign or dollar sign.
helpText: Enter comma separated list of databases that will be created
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
attributeNames: false
descriptionTitle: Instance Configuration
description: Specify some instance parameters on which service would be created.
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that service performance
depends on this parameter.
required: false
- name: osImage
type: image
label: Instance image
description: >-
Select valid image for a service. Image should already be prepared and
registered in glance.
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where service would be installed.
required: false

View File

@ -45,17 +45,24 @@ def import_all_services():
pass
def extract_form_data(form_data):
form_name = form_data.keys()[0]
return form_name, form_data[form_name]
def iterate_over_services():
import muranodashboard.panel.services.forms as services
import_all_services()
for id, service_data in _all_services.items():
modified_on, service_cls = service_data
forms = []
for fields in service_cls.forms:
class Form(services.ServiceConfigurationForm):
service = service_cls
fields_template = fields
forms.append(Form)
for form_data in service_cls.forms:
form_name, form_data = extract_form_data(form_data)
forms.append(type(form_name,
(services.ServiceConfigurationForm,),
{'service': service_cls,
'fields_template': form_data['fields'],
'validators': form_data.get('validators', [])}))
yield slugify(service_cls.name), service_cls, forms
@ -90,9 +97,9 @@ def get_service_client(slug):
def get_service_field_descriptions(slug, index):
def get_descriptions(Service):
form = Service.forms[index]
form_name, form_data = extract_form_data(Service.forms[index])
descriptions = []
for field in form:
for field in form_data['fields']:
if 'description' in field:
title = field.get('descriptionTitle', field.get('label', ''))
descriptions.append((title, field['description']))

View File

@ -39,7 +39,26 @@ def with_request(func):
return update
class PasswordField(forms.CharField):
class CustomPropertiesField(object):
@classmethod
def push_properties(cls, kwargs):
props = {}
for key, value in kwargs.iteritems():
if isinstance(value, property):
props[key] = value
for key in props.keys():
del kwargs[key]
if props:
return type('cls_with_props', (cls,), props)
else:
return cls
class CharField(forms.CharField, CustomPropertiesField):
pass
class PasswordField(CharField):
special_characters = '!@#$%^&*()_+|\/.,~?><:{}'
password_re = re.compile('^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$'
% special_characters)
@ -97,7 +116,11 @@ class PasswordField(forms.CharField):
return field
class InstanceCountField(forms.IntegerField):
class IntegerField(forms.IntegerField, CustomPropertiesField):
pass
class InstanceCountField(IntegerField):
def clean(self, value):
self.value = super(InstanceCountField, self).clean(value)
return self.value
@ -113,7 +136,7 @@ class InstanceCountField(forms.IntegerField):
return value
class DataGridField(forms.MultiValueField):
class DataGridField(forms.MultiValueField, CustomPropertiesField):
def __init__(self, *args, **kwargs):
kwargs['widget'] = DataGridCompound
super(DataGridField, self).__init__(
@ -136,7 +159,11 @@ class DataGridField(forms.MultiValueField):
self.initial = json.dumps(nodes)
class DomainChoiceField(forms.ChoiceField):
class ChoiceField(forms.ChoiceField, CustomPropertiesField):
pass
class DomainChoiceField(ChoiceField):
@with_request
def update(self, request, initial):
self.choices = [("", "Not in domain")]
@ -149,7 +176,7 @@ class DomainChoiceField(forms.ChoiceField):
[(domain.name, domain.name) for domain in domains])
class FlavorChoiceField(forms.ChoiceField):
class FlavorChoiceField(ChoiceField):
@with_request
def update(self, request, initial):
self.choices = [(flavor.name, flavor.name) for flavor in
@ -160,7 +187,7 @@ class FlavorChoiceField(forms.ChoiceField):
break
class ImageChoiceField(forms.ChoiceField):
class ImageChoiceField(ChoiceField):
@with_request
def update(self, request, initial):
try:
@ -198,7 +225,7 @@ class ImageChoiceField(forms.ChoiceField):
self.choices = image_choices
class AZoneChoiceField(forms.ChoiceField):
class AZoneChoiceField(ChoiceField):
@with_request
def update(self, request, initial):
try:
@ -217,13 +244,13 @@ class AZoneChoiceField(forms.ChoiceField):
self.choices = az_choices
class BooleanField(forms.BooleanField):
class BooleanField(forms.BooleanField, CustomPropertiesField):
def __init__(self, *args, **kwargs):
kwargs['widget'] = forms.CheckboxInput(attrs={'class': 'checkbox'})
super(BooleanField, self).__init__(*args, **kwargs)
class ClusterIPField(forms.CharField):
class ClusterIPField(CharField):
@staticmethod
def validate_cluster_ip(request, ip_ranges):
def perform_checking(ip):
@ -270,7 +297,7 @@ class ClusterIPField(forms.CharField):
'Listener IP and Cluster Static IP should be different'))
class DatabaseListField(forms.CharField):
class DatabaseListField(CharField):
validate_mssql_identifier = RegexValidator(
re.compile(r'^[a-zA-z_][a-zA-Z0-9_$#@]*$'),
_((u'First symbol should be latin letter or underscore. Subsequent ' +

View File

@ -18,6 +18,7 @@ from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
import muranodashboard.panel.services.fields as fields
import muranodashboard.panel.services.helpers as helpers
import yaql
class UpdatableFieldsForm(forms.Form):
@ -45,6 +46,24 @@ class UpdatableFieldsForm(forms.Form):
class ServiceConfigurationForm(UpdatableFieldsForm):
types = {
'string': fields.CharField,
'boolean': fields.BooleanField,
'instance': fields.InstanceCountField,
'clusterip': fields.ClusterIPField,
'domain': fields.DomainChoiceField,
'password': fields.PasswordField,
'integer': fields.IntegerField,
'databaselist': fields.DatabaseListField,
'datagrid': fields.DataGridField,
'flavor': fields.FlavorChoiceField,
'image': fields.ImageChoiceField,
'azone': fields.AZoneChoiceField,
'text': (fields.CharField, forms.Textarea)
}
localizable_keys = set(['label', 'help_text', 'error_messages'])
def __init__(self, *args, **kwargs):
super(ServiceConfigurationForm, self).__init__(*args, **kwargs)
self.attribute_mappings = {}
@ -52,25 +71,9 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
self.initial = kwargs.get('initial', self.initial)
self.update_fields()
EVAL_PREFIX = '$'
types = {
'string': forms.CharField,
'boolean': fields.BooleanField,
'instance': fields.InstanceCountField,
'clusterip': fields.ClusterIPField,
'domain': fields.DomainChoiceField,
'password': fields.PasswordField,
'integer': forms.IntegerField,
'databaselist': fields.DatabaseListField,
'datagrid': fields.DataGridField,
'flavor': fields.FlavorChoiceField,
'image': fields.ImageChoiceField,
'azone': fields.AZoneChoiceField,
'text': (forms.CharField, forms.Textarea)
}
localizable_keys = set(['label', 'help_text', 'error_messages'])
@staticmethod
def get_yaql_expr(expr):
return type(expr) == dict and expr.get('YAQL', None)
def init_attribute_mappings(self, field_name, kwargs):
def set_mapping(name, value):
@ -123,18 +126,6 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
del kwargs['widget_attrs']
return widget
def append_properties(cls, kwargs):
props = {}
for key, value in kwargs.iteritems():
if isinstance(value, property):
props[key] = value
for key in props.keys():
del kwargs[key]
if props:
return type('cls_with_props', (cls,), props)
else:
return cls
def append_field(field_spec):
cls = parse_spec(field_spec['type'], 'type')[1]
widget = None
@ -142,7 +133,7 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
cls, widget = cls
kwargs = parse_spec(field_spec)[1]
kwargs['widget'] = process_widget(kwargs, cls, widget)
cls = append_properties(cls, kwargs)
cls = cls.push_properties(kwargs)
self.init_attribute_mappings(field_spec['name'], kwargs)
self.init_field_descriptions(kwargs)
@ -191,26 +182,14 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
return 'widget', forms.HiddenInput
elif key == 'regexp_validator':
return 'validators', [prepare_regexp(spec)]
elif (type(spec) in (str, unicode) and
spec[0] == self.EVAL_PREFIX):
elif self.get_yaql_expr(spec):
def _get(field):
"""First try to get value from cleaned data, if none
found, use raw data."""
data = getattr(self, 'cleaned_data', None)
value = data and data.get(spec[1:], None)
if value is None:
name = self.add_prefix(spec[1:])
value = self.data.get(name, None)
return value
return self.get_data(spec)
def _set(field, value):
# doesn't work - why?
# super(field.__class__, field).__setattr__(key, value)
field.__dict__[key] = value
def _del(field):
# doesn't work - why?
# super(field.__class__, field).__delattr__(key)
del field.__dict__[key]
return key, property(_get, _set, _del)
@ -220,6 +199,18 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
for spec in field_specs:
append_field(spec)
def get_data(self, expr, data=None):
"""First try to get value from cleaned data, if none
found, use raw data."""
context = yaql.create_context()
data = data or getattr(self, 'cleaned_data', None)
expr = self.get_yaql_expr(expr)
value = data and yaql.parse(expr).evaluate(data, context)
# if value is None:
# name = self.add_prefix(spec[1:])
# value = self.data.get(name, None)
return value
def get_unit_templates(self, data):
def parse_spec(spec):
if type(spec) == list:
@ -228,9 +219,8 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
return dict(
(parse_spec(k), parse_spec(v))
for (k, v) in spec.iteritems())
elif (type(spec) in (str, unicode) and
spec[0] == self.EVAL_PREFIX):
return data.get(spec[1:])
elif self.get_yaql_expr(spec):
return self.get_data(spec, data)
else:
return spec
return [parse_spec(spec) for spec in self.service.unit_templates]
@ -245,15 +235,21 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
attributes[attr_name] = get_data(field_name)
def clean(self):
form_data = self.cleaned_data
cleaned_data = super(ServiceConfigurationForm, self).clean()
context = yaql.create_context()
for validator in self.validators:
expr = self.get_yaql_expr(validator['expr'])
if not yaql.parse(expr).evaluate(cleaned_data, context):
raise forms.ValidationError(_(validator.get('message', '')))
for name, field in self.fields.iteritems():
if isinstance(field, fields.PasswordField):
field.compare(name, form_data)
field.compare(name, cleaned_data)
if hasattr(field, 'postclean'):
value = field.postclean(self, form_data)
value = field.postclean(self, cleaned_data)
if value:
self.cleaned_data[name] = value
cleaned_data[name] = value
return self.cleaned_data
return cleaned_data

View File

@ -21,7 +21,7 @@ PREREQ_PKGS="wget make git python-pip python-dev python-mysqldb libxml2-dev libx
SERVICE_SRV_NAME="murano-dashboard"
GIT_CLONE_DIR=`echo $SERVICE_CONTENT_DIRECTORY | sed -e "s/$SERVICE_SRV_NAME//"`
HORIZON_CONFIGS="/opt/stack/horizon/openstack_dashboard/settings.py,/usr/share/openstack-dashboard/openstack_dashboard/settings.py"
DJBLETS_ZIP_URL=https://github.com/tsufiev/djblets/archive
NON_PIP_PACKAGES_BASE_URL=https://github.com
# Functions
# Logger function
@ -187,25 +187,29 @@ CLONE_FROM_GIT=$1
log "pip install \"$TRBL_FILE\" FAILS, exiting!!!"
exit 1
fi
# DJBLETS INSTALL START
DJBLETS_SUFFIX=master.zip
DJBLETS_OUTARCH_FILENAME=djblets-$DJBLETS_SUFFIX
cd $SERVICE_CONTENT_DIRECTORY/dist && wget $DJBLETS_ZIP_URL/$DJBLETS_SUFFIX -O $DJBLETS_OUTARCH_FILENAME
if [ $? -ne 0 ];then
log " Can't download \"$DJBLETS_OUTARCH_FILENAME\", exiting!!!"
# NON PIP PACKAGES INSTALL START
for pkg in tsufiev.djblets ativelkov.yaql; do
PACKAGE=${pkg##*.}
OWNER=${pkg%.*}
SUFFIX=master.zip
PACKAGE_OUTARCH_FILENAME=$PACKAGE-$SUFFIX
cd $SERVICE_CONTENT_DIRECTORY/dist && wget $NON_PIP_PACKAGES_BASE_URL/$OWNER/$PACKAGE/archive/$SUFFIX -O $PACKAGE_OUTARCH_FILENAME
if [ $? -ne 0 ];then
log " Can't download \"$PACKAGE_OUTARCH_FILENAME\", exiting!!!"
exit 1
fi
cd $SERVICE_CONTENT_DIRECTORY/dist && unzip $DJBLETS_OUTARCH_FILENAME
if [ $? -ne 0 ];then
log " Can't unzip \"$SERVICE_CONTENT_DIRECTORY/dist/$DJBLETS_OUTARCH_FILENAME\", exiting!!!"
fi
cd $SERVICE_CONTENT_DIRECTORY/dist && unzip $PACKAGE_OUTARCH_FILENAME
if [ $? -ne 0 ];then
log " Can't unzip \"$SERVICE_CONTENT_DIRECTORY/dist/$PACKAGE_OUTARCH_FILENAME\", exiting!!!"
exit 1
fi
cd $SERVICE_CONTENT_DIRECTORY/dist/djblets-master && python setup.py install
if [ $? -ne 0 ]; then
log "\"$SERVICE_CONTENT_DIRECTORY/dist/djblets-master/setup.py\" python setup FAILS, exiting!"
exit 1
fi
# DJBLETS INSTALL END
fi
cd $SERVICE_CONTENT_DIRECTORY/dist/$PACKAGE-${SUFFIX%.*} && python setup.py install
if [ $? -ne 0 ]; then
log "\"$SERVICE_CONTENT_DIRECTORY/dist/$PACKAGE-${SUFFIX%.*}/setup.py\" python setup FAILS, exiting!"
exit 1
fi
done
# NON PIP PACKAGES INSTALL END
else
log "$MRN_CND_SPY not found!"
fi