Hello community,

here is the log from the commit of package salt-shaptools for openSUSE:Factory 
checked in at 2019-12-21 12:32:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/salt-shaptools (Old)
 and      /work/SRC/openSUSE:Factory/.salt-shaptools.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "salt-shaptools"

Sat Dec 21 12:32:32 2019 rev:7 rq:758455 version:0.2.7

Changes:
--------
--- /work/SRC/openSUSE:Factory/salt-shaptools/salt-shaptools.changes    
2019-12-16 15:20:48.487128181 +0100
+++ /work/SRC/openSUSE:Factory/.salt-shaptools.new.6675/salt-shaptools.changes  
2019-12-21 12:33:01.251410015 +0100
@@ -1,0 +2,6 @@
+Mon Dec 16 09:31:18 UTC 2019 - Xabier Arbulu <[email protected]>
+
+- Version 0.2.7
+  * Add automatic cloud detection method to the salt module 
+
+-------------------------------------------------------------------

Old:
----
  salt-shaptools-0.2.6.tar.gz

New:
----
  salt-shaptools-0.2.7.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ salt-shaptools.spec ++++++
--- /var/tmp/diff_new_pack.VRzNeU/_old  2019-12-21 12:33:02.923410810 +0100
+++ /var/tmp/diff_new_pack.VRzNeU/_new  2019-12-21 12:33:02.927410811 +0100
@@ -19,7 +19,7 @@
 # See also https://en.opensuse.org/openSUSE:Specfile_guidelines
 
 Name:           salt-shaptools
-Version:        0.2.6
+Version:        0.2.7
 Release:        0
 Summary:        Salt modules and states for SAP Applications and SLE-HA 
components management
 

++++++ salt-shaptools-0.2.6.tar.gz -> salt-shaptools-0.2.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/salt-shaptools-0.2.6/salt/__init__.py 
new/salt-shaptools-0.2.7/salt/__init__.py
--- old/salt-shaptools-0.2.6/salt/__init__.py   2019-12-16 09:03:42.874852476 
+0100
+++ new/salt-shaptools-0.2.7/salt/__init__.py   2019-12-19 13:09:10.379511814 
+0100
@@ -6,4 +6,4 @@
 :since: 2018-11-30
 """
 
-__version__ = "0.2.6"
+__version__ = "0.2.7"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/salt-shaptools-0.2.6/salt/modules/crmshmod.py 
new/salt-shaptools-0.2.7/salt/modules/crmshmod.py
--- old/salt-shaptools-0.2.6/salt/modules/crmshmod.py   2019-12-16 
09:03:42.878852476 +0100
+++ new/salt-shaptools-0.2.7/salt/modules/crmshmod.py   2019-12-19 
13:09:10.379511814 +0100
@@ -63,7 +63,8 @@
             'The crmsh execution module failed to load: the ha-cluster-init'
             ' package is not available.')
 
-    __salt__['crm.version'] = use_crm
+    __salt__['crm.version'] = version
+    __salt__['crm.use_crm'] = use_crm
     return __virtualname__
 
 
@@ -429,7 +430,7 @@
 
     # INFO: 2 different methods are created to make easy to read/understand
     # and create the corresponing UT
-    if __salt__['crm.version']:
+    if __salt__['crm.use_crm']:
         return _crm_init(
             name, watchdog, interface, unicast, admin_ip, sbd, sbd_dev, quiet)
 
@@ -515,7 +516,7 @@
     '''
     # INFO: 2 different methods are created to make easy to read/understand
     # and create the corresponing UT
-    if __salt__['crm.version']:
+    if __salt__['crm.use_crm']:
         return _crm_join(host, watchdog, interface, quiet)
 
     return _ha_cluster_join(host, watchdog, interface, quiet)
@@ -582,3 +583,32 @@
         method=method, url=url)
 
     return __salt__['cmd.retcode'](cmd)
+
+
+def detect_cloud():
+    '''
+    Detect if crmsh is being executed in some cloud provider
+
+    INFO: The code is implemented this way because crmsh is still using 
python2 in
+    SLE12SP3 and python3 beyond, but salt is running python2 until SLE15, so 
SLE12SP4 breaks
+    the rule.
+
+    Otherwise we could just use:
+    from crmsh import utils
+    return utils.detect_cloud()
+
+    These are the currently known platforms:
+    * amazon-web-services
+    * microsoft-azure
+    * google-cloud-platform
+    * None (as string)(otherwise)
+    '''
+    if int(__salt__['crm.version'][0]) <= 3:
+        version = 'python'
+    else:
+        version = 'python3'
+
+    cmd = '{version} -c "from crmsh import utils; 
print(utils.detect_cloud());"'.format(
+        version=version)
+    provider = __salt__['cmd.run'](cmd).strip()
+    return provider
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/salt-shaptools-0.2.6/salt-shaptools.changes 
new/salt-shaptools-0.2.7/salt-shaptools.changes
--- old/salt-shaptools-0.2.6/salt-shaptools.changes     2019-12-16 
09:03:42.878852476 +0100
+++ new/salt-shaptools-0.2.7/salt-shaptools.changes     2019-12-19 
13:09:10.379511814 +0100
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Mon Dec 16 09:31:18 UTC 2019 - Xabier Arbulu <[email protected]>
+
+- Version 0.2.7
+  * Add automatic cloud detection method to the salt module 
+
+-------------------------------------------------------------------
 Wed Dec 11 10:16:53 UTC 2019 - Xabier Arbulu <[email protected]>
 
 - Version 0.2.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/salt-shaptools-0.2.6/salt-shaptools.spec 
new/salt-shaptools-0.2.7/salt-shaptools.spec
--- old/salt-shaptools-0.2.6/salt-shaptools.spec        2019-12-16 
09:03:42.878852476 +0100
+++ new/salt-shaptools-0.2.7/salt-shaptools.spec        2019-12-19 
13:09:10.379511814 +0100
@@ -19,7 +19,7 @@
 # See also https://en.opensuse.org/openSUSE:Specfile_guidelines
 
 Name:           salt-shaptools
-Version:        0.2.6
+Version:        0.2.7
 Release:        0
 Summary:        Salt modules and states for SAP Applications and SLE-HA 
components management
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/salt-shaptools-0.2.6/tests/unit/modules/test_crmshmod.py 
new/salt-shaptools-0.2.7/tests/unit/modules/test_crmshmod.py
--- old/salt-shaptools-0.2.6/tests/unit/modules/test_crmshmod.py        
2019-12-16 09:03:42.878852476 +0100
+++ new/salt-shaptools-0.2.7/tests/unit/modules/test_crmshmod.py        
2019-12-19 13:09:10.379511814 +0100
@@ -462,7 +462,7 @@
 
         manage_sbd.return_value = ('sbd', 'devs')
 
-        with patch.dict(crmshmod.__salt__, {'crm.version': True}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}):
             crm_init.return_value = 0
             value = crmshmod.cluster_init('hacluster', 'dog', 'eth1')
             assert value == 0
@@ -470,7 +470,7 @@
                 'hacluster', 'dog', 'eth1', None, None, 'sbd', 'devs', None)
             crm_init.reset_mock()
 
-        with patch.dict(crmshmod.__salt__, {'crm.version': True}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}):
             crm_init.return_value = 0
             value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', 
sbd_dev=['disk1', 'disk2'])
             assert value == 0
@@ -478,7 +478,7 @@
                 'hacluster', 'dog', 'eth1', None, None, 'sbd', 'devs', None)
             crm_init.reset_mock()
 
-        with patch.dict(crmshmod.__salt__, {'crm.version': True}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}):
             crm_init.return_value = 0
             value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', 
sbd_dev='disk1')
             assert value == 0
@@ -494,7 +494,7 @@
         '''
         manage_sbd.return_value = ('sbd', 'devs')
 
-        with patch.dict(crmshmod.__salt__, {'crm.version': False}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': False}):
             ha_cluster_init.return_value = 0
             value = crmshmod.cluster_init('hacluster', 'dog', 'eth1')
             assert value == 0
@@ -588,7 +588,7 @@
         '''
         Test cluster_join with crm option
         '''
-        with patch.dict(crmshmod.__salt__, {'crm.version': True}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}):
             crm_join.return_value = 0
             value = crmshmod.cluster_join('host', 'dog', 'eth1')
             assert value == 0
@@ -600,7 +600,7 @@
         '''
         Test cluster_join with ha_cluster_join option
         '''
-        with patch.dict(crmshmod.__salt__, {'crm.version': False}):
+        with patch.dict(crmshmod.__salt__, {'crm.use_crm': False}):
             ha_cluster_join.return_value = 0
             value = crmshmod.cluster_join('host', 'dog', 'eth1')
             assert value == 0
@@ -662,3 +662,35 @@
                     crm_command=crmshmod.CRM_COMMAND,
                     method='update',
                     url='file.conf'))
+
+    def test_detect_cloud_py2(self):
+        '''
+        Test detect_cloud
+        '''
+        mock_versin = '3.0.0'
+        mock_cmd_run = MagicMock(return_value='my-cloud ')
+
+        with patch.dict(crmshmod.__salt__, {
+                'crm.version': mock_versin,
+                'cmd.run': mock_cmd_run}):
+            result = crmshmod.detect_cloud()
+            assert result == 'my-cloud'
+
+        mock_cmd_run.assert_called_once_with(
+            'python -c "from crmsh import utils; 
print(utils.detect_cloud());"')
+
+    def test_detect_cloud_py3(self):
+        '''
+        Test detect_cloud
+        '''
+        mock_versin = '4.0.0'
+        mock_cmd_run = MagicMock(return_value='my-cloud ')
+
+        with patch.dict(crmshmod.__salt__, {
+                'crm.version': mock_versin,
+                'cmd.run': mock_cmd_run}):
+            result = crmshmod.detect_cloud()
+            assert result == 'my-cloud'
+
+        mock_cmd_run.assert_called_once_with(
+            'python3 -c "from crmsh import utils; 
print(utils.detect_cloud());"')


Reply via email to