
Both properties and methods can be marked as Usage: Static Statics can be accessed using ns:Class.property / ns:Class.method(), :Class.property / :Class.method() to access class from current namespace or type('full.name').property / type('full.name').method() to use full type name. In static method $ / $this are referencing current class rather than object. Static properties are not loaded from object model. Also methods of io.murano.configuration.Linux class are now static. Since static methods can be called on the instance it doesn't break backward compatibility. Implements blueprint: muranopl-statics Change-Id: Ic7c6beed9222f4bca118877a60fdabfdd9d65e5a
87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
# 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.configuration
|
|
std: io.murano
|
|
sys: io.murano.system
|
|
|
|
Name: Linux
|
|
|
|
Methods:
|
|
runCommand:
|
|
Usage: Static
|
|
Arguments:
|
|
- agent:
|
|
Contract: $.class(sys:Agent)
|
|
- command:
|
|
Contract: $.string().notNull()
|
|
- helpText:
|
|
Contract: $.string()
|
|
Default: null
|
|
- captureStderr:
|
|
Contract: $.bool().notNull()
|
|
Default: true
|
|
- captureStdout:
|
|
Contract: $.bool().notNull()
|
|
Default: true
|
|
- ignoreErrors:
|
|
Contract: $.bool().notNull()
|
|
Default: false
|
|
|
|
Body:
|
|
- $resources: new(sys:Resources)
|
|
- If: $helpText != null
|
|
Then:
|
|
- $planName: $helpText
|
|
Else:
|
|
- $planName: format('Execute {0}', $command)
|
|
- $template: $resources.yaml('RunCommand.template').bind(dict(
|
|
command => $command,
|
|
planName => $planName,
|
|
captureStderr => $captureStderr,
|
|
captureStdout => $captureStdout,
|
|
verifyExitcode => not $ignoreErrors
|
|
))
|
|
- Return: $agent.call($template, $resources)
|
|
|
|
putFile:
|
|
Usage: Static
|
|
Arguments:
|
|
- agent:
|
|
Contract: $.class(sys:Agent)
|
|
- fileContent:
|
|
Contract: $.string().notNull()
|
|
- path:
|
|
Contract: $.string().notNull()
|
|
- helpText:
|
|
Contract: $.string()
|
|
Default: null
|
|
- ignoreErrors:
|
|
Contract: $.bool().notNull()
|
|
Default: false
|
|
|
|
Body:
|
|
- $data: base64encode($fileContent)
|
|
- $resources: new(sys:Resources)
|
|
- If: $helpText != null
|
|
Then:
|
|
- $planName: $helpText
|
|
Else:
|
|
- $planName: format('Put to {0}', $path)
|
|
- $template: $resources.yaml('PutFile.template').bind(dict(
|
|
path => $path,
|
|
fileContent => $data,
|
|
planName => $planName,
|
|
verifyExitcode => not $ignoreErrors
|
|
))
|
|
- Return: $agent.call($template, $resources) |