Yeela Kaplan has uploaded a new change for review.
Change subject: [WIP]configurators: move configurator functions into conf_utils
......................................................................
[WIP]configurators: move configurator functions into conf_utils
Change-Id: Id67a0f51adb2d543c0542a48c020d34a13d1f2ed
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M lib/vdsm/tool/Makefile.am
A lib/vdsm/tool/conf_utils.py
M vdsm.spec.in
3 files changed, 110 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/44286/1
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index c8979ca..c3ed0cc 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -35,7 +35,8 @@
dump_bonding_defaults.py \
dump_volume_chains.py \
nwfilter.py \
- configfile.py \
+ conf_utils.py \
+ configfile.py \
configurator.py \
register.py \
restore_nets.py \
diff --git a/lib/vdsm/tool/conf_utils.py b/lib/vdsm/tool/conf_utils.py
new file mode 100644
index 0000000..1308097
--- /dev/null
+++ b/lib/vdsm/tool/conf_utils.py
@@ -0,0 +1,107 @@
+# Copyright 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+import os
+
+from .. configfile import (
+ ConfigFile,
+)
+
+from ... import utils
+
+if utils.isOvirtNode():
+ from ovirt.node.utils.fs import Config as NodeCfg
+
+
+def get_file(fname, files):
+ return files[fname]['path']
+
+
+def remove_conf(files, version):
+ for cfile, content in files.items():
+ content['removeConf'](content['path'], version)
+
+
+def add_section(content, version, vdsmConfiguration={}):
+ """
+ Add a 'configuration section by vdsm' part to a config file.
+ This section contains only keys not originally defined
+ The section headers will include the current configuration version.
+ """
+ configuration = {}
+ for fragment in content['fragments']:
+ if vdsmConfiguration:
+ if is_applicable(fragment, vdsmConfiguration):
+ configuration.update(fragment['content'])
+ else:
+ configuration.update(fragment['content'])
+ if configuration:
+ with open_config(content['path'], version) as conff:
+ for key, val in configuration.items():
+ conff.addEntry(key, val)
+
+
+def remove_section(path, version):
+ """
+ remove entire 'configuration section by vdsm' section.
+ section is removed regardless of it's version.
+ """
+ if os.path.exists(path):
+ with open_config(path, version) as conff:
+ conff.removeConf()
+
+
+def remove_file(content, vdsmConfiguration):
+ """
+ delete a file if it exists.
+ """
+ if utils.isOvirtNode():
+ NodeCfg().delete(content['path'])
+ else:
+ try:
+ os.unlink(content['path'])
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+
+
+def get_persisted_files(files):
+ """
+ get files where vdsm is expected to add a section.
+ """
+ return [
+ cfile['path'] for cfile in files.values()
+ if cfile['persisted']
+ ]
+
+
+def open_config(path, conf_version):
+ return ConfigFile(path, conf_version)
+
+
+def is_applicable(fragment, vdsmConfiguration):
+ """
+ Return true if 'fragment' should be included for current
+ configuration. An applicable fragment is a fragment who's list
+ of conditions are met according to vdsmConfiguration.
+ """
+ applyFragment = True
+ for key, booleanValue in fragment['conditions'].items():
+ if vdsmConfiguration[key] != booleanValue:
+ applyFragment = False
+ return applyFragment
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 5020d8b..21e1b50 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1094,6 +1094,7 @@
%{python_sitelib}/%{vdsm_name}/tool/dummybr.py*
%{python_sitelib}/%{vdsm_name}/tool/dump_bonding_defaults.py*
%{python_sitelib}/%{vdsm_name}/tool/nwfilter.py*
+%{python_sitelib}/%{vdsm_name}/tool/conf_utils.py*
%{python_sitelib}/%{vdsm_name}/tool/configurator.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/__init__*
%{python_sitelib}/%{vdsm_name}/tool/configurators/certificates.py*
--
To view, visit https://gerrit.ovirt.org/44286
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id67a0f51adb2d543c0542a48c020d34a13d1f2ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
Piotr Kliczewski has uploaded a new change for review.
Change subject: yml: return type fixes for StoragePool.getInfo
......................................................................
yml: return type fixes for StoragePool.getInfo
Signed-off-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Change-Id: Ifeadf2323d2a3535a5777d0cc16027cfb9e42f0e
---
M lib/api/vdsm-api.yml
M tests/vdsmapi_test.py
2 files changed, 72 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/59707/1
diff --git a/lib/api/vdsm-api.yml b/lib/api/vdsm-api.yml
index 7dd95d1..2c139ea 100644
--- a/lib/api/vdsm-api.yml
+++ b/lib/api/vdsm-api.yml
@@ -5607,6 +5607,21 @@
7: The Storage Domain uses glusterfs
8: The Storage Domain uses cinder
+ StorageType: &StorageType
+ added: '3.1'
+ description: An enumeration of Storage Domain types.
+ name: StorageType
+ type: enum
+ values:
+ CIFS: The Storage Domain uses CIFS/SMB based storage
+ FCP: The Storage Domain uses FibreChannel based storage
+ ISCSI: The Storage Domain uses iSCSI based storage
+ LOCALFS: The Storage Domain uses storage on the local file system
+ NFS: The Storage Domain uses Network File System based storage
+ SHAREDFS: The Storage Domain uses storage from a Linux VFS file
+ system
+ UNKNOWN: The type is not known
+
StorageDomainInfo: &StorageDomainInfo
added: '3.1'
description: Information about a Storage Domain.
@@ -5666,6 +5681,18 @@
unattached: The domain is not attached to a Storage Pool
unknown: The status of the Storage Domain is not known
+ StorageStatus: &StorageStatus
+ added: '3.1'
+ description: An enumeration of Storage Domain statuses.
+ name: StorageDomainStatus
+ type: enum
+ values:
+ Active: The domain is attached to a Storage Pool and is activated
+ Attached: The domain is attached to a Storage Pool but is
+ deactivated
+ Unattached: The domain is not attached to a Storage Pool
+ Unknown: The status of the Storage Domain is not known
+
StorageDomainStatusMap: &StorageDomainStatusMap
added: '3.1'
description: A mapping of Storage Domain statuses indexed by Storage
@@ -5698,7 +5725,8 @@
properties:
- description: The remaining free disk space in bytes
name: diskfree
- type: int
+ type: string
+ datatype: int
- description: A list of alerts for this Storage Domain
name: alerts
@@ -5708,15 +5736,21 @@
- description: The total amount of disk space in the Storage
Domain in bytes
name: disktotal
- type: int
+ type: string
+ datatype: int
- description: Current Storage Domain status
name: status
- type: *StorageDomainStatus
+ type: *StorageStatus
- description: Indicates the Storage Domain version
name: version
type: int
+
+ - description: The filesystem path from where ISO images may
+ be referenced
+ name: isoprefix
+ type: string
type: object
StoragePoolDomainInfoMap: &StoragePoolDomainInfoMap
@@ -5749,15 +5783,16 @@
- description: The Storage Pool lock version
name: lver
- type: int
+ type: long
- description: The Storage Pool version
name: version
- type: int
+ type: string
+ datatype: int
- description: The type of storage managed by this Storage Pool
- name: domainType
- type: *StorageDomainType
+ name: type
+ type: *StorageType
- description: The Storage Pool name
name: name
diff --git a/tests/vdsmapi_test.py b/tests/vdsmapi_test.py
index eddb735..1f319b1 100644
--- a/tests/vdsmapi_test.py
+++ b/tests/vdsmapi_test.py
@@ -607,3 +607,33 @@
_schema.schema().verify_retval(
vdsmapi.MethodRep('StoragePool', 'getSpmStatus'), ret)
+
+ def test_info_storage(self):
+ ret = {'info':
+ {'name': 'No Description',
+ 'isoprefix': '',
+ 'pool_status': 'connected',
+ 'lver': 10,
+ 'domains': u'0900c0cd-8422-497a-85c5-1bb34b2b6b65:Active,794d',
+ 'master_uuid': '3d4accf7-74af-4ea0-b59b-eb9f10eedb83',
+ 'version': '3',
+ 'spm_id': 1,
+ 'type': 'ISCSI',
+ 'master_ver': 33},
+ 'dominfo': {u'0900c0cd-8422-497a-85c5-1bb34b2b6b65':
+ {'status': u'Active',
+ 'diskfree': '48855252992',
+ 'isoprefix': '',
+ 'alerts': [],
+ 'disktotal': '53284438016',
+ 'version': 3},
+ u'794dc113-315f-43e3-ae47-0b7b1bf56427':
+ {'status': u'Active',
+ 'diskfree': '48855252992',
+ 'isoprefix': '',
+ 'alerts': [],
+ 'disktotal': '53284438016',
+ 'version': 3}}}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('StoragePool', 'getInfo'), ret)
--
To view, visit https://gerrit.ovirt.org/59707
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifeadf2323d2a3535a5777d0cc16027cfb9e42f0e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Piotr Kliczewski has uploaded a new change for review.
Change subject: yml: parameter type fixes for StoragePool.connect
......................................................................
yml: parameter type fixes for StoragePool.connect
Change-Id: I19b6f25c17e697702ec61eba6b11f256c1df4d83
Signed-off-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
---
M lib/api/vdsm-api.yml
M tests/vdsmapi_test.py
2 files changed, 18 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/59702/1
diff --git a/lib/api/vdsm-api.yml b/lib/api/vdsm-api.yml
index 5eb091c..6cb6c9a 100644
--- a/lib/api/vdsm-api.yml
+++ b/lib/api/vdsm-api.yml
@@ -5599,11 +5599,11 @@
name: StorageDomainStatus
type: enum
values:
- Active: The domain is attached to a Storage Pool and is activated
- Attached: The domain is attached to a Storage Pool but is
+ active: The domain is attached to a Storage Pool and is activated
+ attached: The domain is attached to a Storage Pool but is
deactivated
- Unattached: The domain is not attached to a Storage Pool
- Unknown: The status of the Storage Domain is not known
+ unattached: The domain is not attached to a Storage Pool
+ unknown: The status of the Storage Domain is not known
StorageDomainStatusMap: &StorageDomainStatusMap
added: '3.1'
diff --git a/tests/vdsmapi_test.py b/tests/vdsmapi_test.py
index 38f5449..fac3bf4 100644
--- a/tests/vdsmapi_test.py
+++ b/tests/vdsmapi_test.py
@@ -502,3 +502,17 @@
_schema.schema().verify_args(
vdsmapi.MethodRep('StoragePool', 'connectStorageServer'),
params)
+
+ def test_sp_connect(self):
+ params = {u'masterVersion': 33,
+ u'domainDict':
+ {u'0900c0cd-8422-497a-85c5-1bb34b2b6b65': u'active',
+ u'794dc113-315f-43e3-ae47-0b7b1bf56427': u'active',
+ u'1d8235ee-c2ce-4c06-abd5-63b655fd66c5': u'active'},
+ u'storagepoolID': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'scsiKey': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'masterSdUUID': u'3d4accf7-74af-4ea0-b59b-eb9f10eedb83',
+ u'hostID': 1}
+
+ _schema.schema().verify_args(
+ vdsmapi.MethodRep('StoragePool', 'connect'), params)
--
To view, visit https://gerrit.ovirt.org/59702
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I19b6f25c17e697702ec61eba6b11f256c1df4d83
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Nir Soffer has uploaded a new change for review.
Change subject: contrib: Simple jsonrpc client
......................................................................
contrib: Simple jsonrpc client
This is a simple jsonrpc client for communicating with the jsonrpc
server from the command line.
Arguments
method one of the mehtods described in json schema
params optionl json object with message parameters
Examples
Calling method without arguements:
# jsonrpc Host.getVMList
{
"jsonrpc": "2.0",
"id": "0e043d83-294a-4d31-b1b6-6dc2f2747494",
"result": [
"b3f6fa00-b315-4ad4-8108-f73da817b5c5"
]
}
Calling method with arguements:
# jsonrpc VM.getStats '{"vmID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5"}'
{
"jsonrpc": "2.0",
"id": "cefd25a3-6250-4123-8a56-d7047899e19e",
"result": [
{
"status": "Down",
"exitMessage": "Admin shut down from the engine",
"vmId": "b3f6fa00-b315-4ad4-8108-f73da817b5c5",
"exitReason": 6,
"timeOffset": "0",
"exitCode": 0
}
]
}
Requires stomp.py library:
https://pypi.python.org/pypi/stomp.py
Change-Id: Ia6273eabf6f3601602659d1e4e748d8025ae8084
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
A contrib/jsonrpc
1 file changed, 104 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/35181/1
diff --git a/contrib/jsonrpc b/contrib/jsonrpc
new file mode 100755
index 0000000..3080193
--- /dev/null
+++ b/contrib/jsonrpc
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+"""
+jsonrpc-cli - Vdsm jsonrpc client
+"""
+
+import json
+import os
+import signal
+import sys
+import time
+import uuid
+import optparse
+
+import stomp
+
+# Copied from lib/vdsm/vdscli.py
+PKIDIR = '/etc/pki/vdsm'
+KEYFILE = os.path.join(PKIDIR, 'keys/vdsmkey.pem')
+CERTFILE = os.path.join(PKIDIR, 'certs/vdsmcert.pem')
+CACERT = os.path.join(PKIDIR, 'certs/cacert.pem')
+
+PORT = 54321
+DESTINATION = "/queue/_local/vdsm/requests"
+
+
+class Listener(stomp.ConnectionListener):
+
+ def on_error(self, headers, message):
+ print 'Error: %s' % message
+ terminate()
+
+ def on_message(self, headers, message):
+ msg = json.loads(message)
+ print json.dumps(msg, indent=4)
+ terminate()
+
+
+def main(args):
+ parser = option_parser()
+ options, args = parser.parse_args(args)
+ if not args:
+ parser.error("method required")
+
+ msg = {
+ "id": str(uuid.uuid4()),
+ "jsonrpc": "2.0",
+ "method": args[0]
+ }
+
+ if len(args) > 1:
+ msg["params"] = json.loads(args[1])
+
+ conn = stomp.Connection10(
+ host_and_ports=((options.host, PORT),),
+ use_ssl=True,
+ ssl_key_file=KEYFILE,
+ ssl_cert_file=CERTFILE,
+ ssl_ca_certs=CACERT)
+
+ conn.set_listener("", Listener())
+ conn.start()
+ conn.send(body=json.dumps(msg), destination=DESTINATION)
+
+ try:
+ signal.pause()
+ except KeyboardInterrupt:
+ pass
+
+ conn.disconnect()
+
+
+def option_parser():
+ parser = optparse.OptionParser(usage='%prog [options] method [params]')
+ parser.add_option("-a", "--host", dest="host",
+ help="host address (default localhost)")
+ parser.set_defaults(host="localhost")
+ return parser
+
+
+def terminate():
+ os.kill(os.getpid(), signal.SIGINT)
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
--
To view, visit http://gerrit.ovirt.org/35181
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6273eabf6f3601602659d1e4e748d8025ae8084
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Dan Kenigsberg has uploaded a new change for review.
Change subject: spbackends: simplify over-general evaluation
......................................................................
spbackends: simplify over-general evaluation
The removed code is too clever for the use case of only two values.
Change-Id: I775c4a6003a03c6b65bee3abc8559a88e3eaec01
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/storage/spbackends.py
1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/41253/1
diff --git a/vdsm/storage/spbackends.py b/vdsm/storage/spbackends.py
index 953e01e..f6ce02b 100644
--- a/vdsm/storage/spbackends.py
+++ b/vdsm/storage/spbackends.py
@@ -229,8 +229,11 @@
def setSpmStatus(self, lVer=None, spmId=None):
self.invalidateMetadata()
- metaParams = dict(filter(lambda kv: kv[1] is not None,
- ((PMDK_LVER, lVer), (PMDK_SPM_ID, spmId))))
+ metaParams = {}
+ if lVer is not None:
+ metaParams[PMDK_LVER] = lVer
+ if spmId is not None:
+ metaParams[PMDK_SPM_ID] = spmId
self._metadata.update(metaParams)
@unsecured
--
To view, visit https://gerrit.ovirt.org/41253
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I775c4a6003a03c6b65bee3abc8559a88e3eaec01
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>