summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2012-08-02 11:47:02 +0200
committerRadek Novacek <rnovacek@redhat.com>2012-08-02 12:07:47 +0200
commitab81c6fc893e34de159b25290f7313082351d992 (patch)
treed0ca8f9f94aa762cb771075c79ec8d8b490d1b4a
parent97a06662a7d51d0a9beaa73a47b2c5dd437b13be (diff)
downloadopenlmi-providers-ab81c6fc893e34de159b25290f7313082351d992.tar.gz
openlmi-providers-ab81c6fc893e34de159b25290f7313082351d992.tar.xz
openlmi-providers-ab81c6fc893e34de159b25290f7313082351d992.zip
Always use .reg file instead of .registration
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/modules/CuraMacros.cmake6
-rw-r--r--reg2pegasus.py (renamed from registration2pegasus.py)39
-rwxr-xr-xregister.sh16
4 files changed, 35 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ff9c2e..ca84467 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,4 +30,4 @@ find_package(KonkretCMPI REQUIRED)
add_subdirectory(src)
add_subdirectory(mof)
-install(PROGRAMS register.sh registration2pegasus.py DESTINATION share/cura-providers/)
+install(PROGRAMS register.sh reg2pegasus.py DESTINATION share/cura-providers/)
diff --git a/cmake/modules/CuraMacros.cmake b/cmake/modules/CuraMacros.cmake
index 8bbb7ae..25fd0b3 100644
--- a/cmake/modules/CuraMacros.cmake
+++ b/cmake/modules/CuraMacros.cmake
@@ -86,12 +86,12 @@ macro(cim_registration PROVIDER_NAME LIBRARY_NAME MOF)
# Create registration out of shared library
add_custom_command(TARGET ${LIBRARY_NAME}
POST_BUILD
- COMMAND ${KONKRETCMPI_KONKRETREG} -r lib${LIBRARY_NAME}.so > Cura_${PROVIDER_NAME}.registration
+ COMMAND ${KONKRETCMPI_KONKRETREG} lib${LIBRARY_NAME}.so > Cura_${PROVIDER_NAME}.reg
COMMENT "Generating .reg file from library for ${PROVIDER_NAME}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
# Install it
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Cura_${PROVIDER_NAME}.registration DESTINATION share/cura-providers/)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Cura_${PROVIDER_NAME}.reg DESTINATION share/cura-providers/)
# Add custom target for registration
find_file(MOF_FILE
@@ -99,5 +99,5 @@ macro(cim_registration PROVIDER_NAME LIBRARY_NAME MOF)
PATHS ${CMAKE_SOURCE_DIR}/mof/
)
add_custom_target(register-${PROVIDER_NAME}
- ${CMAKE_SOURCE_DIR}/register.sh ${MOF_FILE} ${CMAKE_CURRENT_BINARY_DIR}/Cura_${PROVIDER_NAME}.registration)
+ ${CMAKE_SOURCE_DIR}/register.sh ${MOF_FILE} ${CMAKE_CURRENT_BINARY_DIR}/Cura_${PROVIDER_NAME}.reg)
endmacro(cim_registration)
diff --git a/registration2pegasus.py b/reg2pegasus.py
index 62947c7..08f8662 100644
--- a/registration2pegasus.py
+++ b/reg2pegasus.py
@@ -1,6 +1,13 @@
#!/usr/bin/python
import sys
+import re
+
+reg_parse = re.compile(r"\[([^\]]+)\]\s+"
+"provider: (\w+)\s+"
+"location: (\w+)\s+"
+"type: ([^\n]+)\s+"
+"namespace: ([^\n]+)")
Types = {
'instance': '2',
@@ -11,18 +18,18 @@ Types = {
'instanceQuery': '7'
}
-def define_module(provider):
+def define_module(location):
return """instance of PG_ProviderModule
{
- Name = "%(provider)sModule";
- Location = "%(provider)s";
+ Name = "%(location)s";
+ Location = "%(location)s";
Vendor = "RedHat";
Version = "0.0.1";
InterfaceType = "CMPI";
InterfaceVersion = "2.0.0";
ModuleGroupName = "cura-providers";
};
-""" % { 'provider': provider }
+""" % { 'location': location }
def getTypes(types):
l = []
@@ -31,17 +38,17 @@ def getTypes(types):
l.append(value)
return ",".join(l)
-def define_capability(provider, name, cls, types):
+def define_capability(location, cls, types):
return """instance of PG_Provider
{
- Name = "%(name)s";
- ProviderModuleName = "%(provider)sModule";
+ Name = "%(class)s";
+ ProviderModuleName = "%(location)s";
};
instance of PG_ProviderCapabilities
{
- ProviderModuleName = "%(provider)sModule";
- ProviderName = "%(name)s";
+ ProviderModuleName = "%(location)s";
+ ProviderName = "%(class)s";
CapabilityID = "%(class)s";
ClassName = "%(class)s";
Namespaces = { "root/cimv2" };
@@ -49,14 +56,14 @@ instance of PG_ProviderCapabilities
SupportedProperties = NULL;
SupportedMethods = NULL;
};
-""" % { 'provider': provider, 'name': name, 'class': cls, 'types': getTypes(types) }
+""" % { 'location': location, 'class': cls, 'types': getTypes(types) }
modules_defined = {}
-for line in sys.stdin:
- cls, namespace, name, provider, types = line.strip().split(" ", 4)
+for record in reg_parse.findall(sys.stdin.read()):
+ cls, provider, location, types, namespace = record
- if provider not in modules_defined:
- print define_module(provider)
- modules_defined[provider] = True
+ if location not in modules_defined:
+ print define_module(location)
+ modules_defined[location] = True
- print define_capability(provider, name, cls, types)
+ print define_capability(location, cls, types)
diff --git a/register.sh b/register.sh
index cef7f59..cb9e02f 100755
--- a/register.sh
+++ b/register.sh
@@ -4,16 +4,16 @@ pegasus_repository="/var/lib/Pegasus/repository"
function usage()
{
- printf "Usage: $0 [ register | unregister ] mof registration\n"
+ printf "Usage: $0 [ register | unregister ] mof reg\n"
}
function register()
{
mof=$1
- registration=$2
+ reg=$2
if [ $HAS_SFCBD -eq 1 ];
then
- /usr/bin/sfcbstage -r $registration $mof
+ /usr/bin/sfcbstage -r $reg $mof
/usr/bin/sfcbrepos -f
/usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
@@ -29,26 +29,26 @@ function register()
fi
$CIMMOF -uc $mof
- cat $registration | /usr/bin/python2 $(dirname $0)/registration2pegasus.py | $CIMMOF -uc -n root/PG_Interop -
+ cat $reg | /usr/bin/python2 $(dirname $0)/reg2pegasus.py | $CIMMOF -uc -n root/PG_Interop -
fi
}
function unregister()
{
mof=$1
- registration=$2
+ reg=$2
if [ $HAS_SFCBD -eq 1 ];
then
- /usr/bin/sfcbunstage -r $(basename $registration) $(basename $mof)
+ /usr/bin/sfcbunstage -r $(basename $reg) $(basename $mof)
/usr/bin/sfcbrepos -f
/usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
if [ $HAS_PEGASUS -eq 1 ];
then
- for module in $(cut -d' ' -f 4 $registration | sort | uniq);
+ for provider in $(sed -n 's/ *location: *//p' $reg | sort | uniq);
do
- /usr/bin/cimprovider -d -m ${module}Module && /usr/bin/cimprovider -r -m ${module}Module
+ /usr/bin/cimprovider -d -m ${provider} && /usr/bin/cimprovider -r -m ${provider}
done
fi
}