本文整理汇总了Python中jnpr.junos.utils.sw.SW.remote_checksum方法的典型用法代码示例。如果您正苦于以下问题:Python SW.remote_checksum方法的具体用法?Python SW.remote_checksum怎么用?Python SW.remote_checksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jnpr.junos.utils.sw.SW
的用法示例。
在下文中一共展示了SW.remote_checksum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSW
# 需要导入模块: from jnpr.junos.utils.sw import SW [as 别名]
# 或者: from jnpr.junos.utils.sw.SW import remote_checksum [as 别名]
#.........这里部分代码省略.........
<chassis>
<redundancy>
<graceful-switchover>
</graceful-switchover>
</redundancy>
</chassis>
</configuration>"""), etree.fromstring("""
<configuration>
<system>
<commit>
<synchronize/>
</commit>
</system>
</configuration>"""), etree.fromstring("""<configuration>
<routing-options></routing-options>
</configuration>""")])
self.sw.log = MagicMock()
self.assertFalse(self.sw.validate('package.tgz', issu=True))
self.sw.log.assert_called_with(
'Requirement FAILED: NSR is not Enabled in configuration')
@patch('jnpr.junos.Device.execute')
def test_sw_validate_issu_validation_succeeded(self, mock_execute):
rpc_reply = """<rpc-reply><output>mgd: commit complete
Validation succeeded
</output>
<package-result>1</package-result>
</rpc-reply>"""
mock_execute.side_effect = etree.fromstring(rpc_reply)
package = 'package.tgz'
self.assertFalse(self.sw.validate(package, issu=True))
@patch('jnpr.junos.Device.execute')
def test_sw_remote_checksum_not_found(self, mock_execute):
xml = '''<rpc-error>
<error-severity>error</error-severity>
<error-message>
md5: /var/tmp/123: No such file or directory
</error-message>
</rpc-error>'''
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = 'test.tgz'
self.assertEqual(self.sw.remote_checksum(package), None)
@patch('jnpr.junos.Device.execute')
def test_sw_remote_checksum_not_rpc_error(self, mock_execute):
xml = '''<rpc-error>
<error-severity>error</error-severity>
<error-message>
something else!
</error-message>
</rpc-error>'''
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = 'test.tgz'
with self.assertRaises(RpcError):
self.sw.remote_checksum(package)
@patch('jnpr.junos.Device.execute')
def test_sw_remote_checksum_md5(self, mock_execute):
xml = '''<rpc-reply>
<checksum-information>
<file-checksum>
<computation-method>MD5</computation-method>
<input-file>/var/tmp/foo.tgz</input-file>
<checksum>8a04cfc475e21507be5145bc0e82ce09</checksum>
</file-checksum>
示例2: TestSW
# 需要导入模块: from jnpr.junos.utils.sw import SW [as 别名]
# 或者: from jnpr.junos.utils.sw.SW import remote_checksum [as 别名]
#.........这里部分代码省略.........
def test_sw_pkgadd_pkg_set(self, mock_execute):
mock_execute.side_effect = self._mock_manager
pkg_set = ['abc.tgz', 'pqr.tgz']
self.sw._mixed_VC = True
self.sw.pkgadd(pkg_set)
self.assertEqual([i.text for i in
mock_execute.call_args[0][0].findall('set')],
pkg_set)
@patch('jnpr.junos.Device.execute')
def test_sw_validate(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = 'package.tgz'
self.assertTrue(self.sw.validate(package))
@patch('jnpr.junos.Device.execute')
def test_sw_validate_issu(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = 'package.tgz'
self.assertTrue(self.sw.validate(package, issu=True))
@patch('jnpr.junos.Device.execute')
def test_sw_validate_issu(self, mock_execute):
rpc_reply = """<rpc-reply><output>mgd: commit complete
Validation succeeded
</output>
<package-result>1</package-result>
</rpc-reply>"""
mock_execute.side_effect = etree.fromstring(rpc_reply)
package = 'package.tgz'
self.assertFalse(self.sw.validate(package, issu=True))
@patch('jnpr.junos.Device.execute')
def test_sw_remote_checksum_not_found(self, mock_execute):
xml = '''<rpc-error>
<error-severity>error</error-severity>
<error-message>
md5: /var/tmp/123: No such file or directory
</error-message>
</rpc-error>'''
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = 'test.tgz'
self.assertEqual(self.sw.remote_checksum(package), None)
@patch('jnpr.junos.Device.execute')
def test_sw_remote_checksum_not_rpc_error(self, mock_execute):
xml = '''<rpc-error>
<error-severity>error</error-severity>
<error-message>
something else!
</error-message>
</rpc-error>'''
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = 'test.tgz'
with self.assertRaises(RpcError):
self.sw.remote_checksum(package)
@patch('jnpr.junos.Device.execute')
def test_sw_safe_copy(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = 'safecopy.tgz'
self.sw.put = MagicMock()
with patch('jnpr.junos.utils.sw.SW.local_md5'):
self.assertTrue(self.sw.safe_copy(package, progress=self._myprogress,
cleanfs=True,
checksum='96a35ab371e1ca10408c3caecdbd8a67'))
示例3: TestSW
# 需要导入模块: from jnpr.junos.utils.sw import SW [as 别名]
# 或者: from jnpr.junos.utils.sw.SW import remote_checksum [as 别名]
#.........这里部分代码省略.........
@patch("jnpr.junos.utils.scp.SCP.__init__")
@patch("jnpr.junos.utils.scp.SCP.__enter__")
def test_sw_put_progress(self, mock_enter, mock_scp, mock_exit):
package = "test.tgz"
mock_scp.side_effect = self._fake_scp
self.sw.put(package, progress=self._myprogress)
self.assertEqual(mock_scp.call_args_list[0][1]["progress"].by10pct, 50)
def _fake_scp(self, *args, **kwargs):
progress = kwargs["progress"]
progress("test.tgz", 100, 50)
@patch("jnpr.junos.Device.execute")
def test_sw_pkgadd(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = "test.tgz"
self.assertTrue(self.sw.pkgadd(package))
@patch("jnpr.junos.Device.execute")
def test_sw_pkgadd_pkg_set(self, mock_execute):
mock_execute.side_effect = self._mock_manager
pkg_set = ["abc.tgz", "pqr.tgz"]
self.sw._mixed_VC = True
self.sw.pkgadd(pkg_set)
self.assertEqual([i.text for i in mock_execute.call_args[0][0].findall("set")], pkg_set)
@patch("jnpr.junos.Device.execute")
def test_sw_validate(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = "package.tgz"
self.assertTrue(self.sw.validate(package))
@patch("jnpr.junos.Device.execute")
def test_sw_remote_checksum_not_found(self, mock_execute):
xml = """<rpc-error>
<error-severity>error</error-severity>
<error-message>
md5: /var/tmp/123: No such file or directory
</error-message>
</rpc-error>"""
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = "test.tgz"
self.assertEqual(self.sw.remote_checksum(package), None)
@patch("jnpr.junos.Device.execute")
def test_sw_remote_checksum_not_rpc_error(self, mock_execute):
xml = """<rpc-error>
<error-severity>error</error-severity>
<error-message>
something else!
</error-message>
</rpc-error>"""
mock_execute.side_effect = RpcError(rsp=etree.fromstring(xml))
package = "test.tgz"
with self.assertRaises(RpcError):
self.sw.remote_checksum(package)
@patch("jnpr.junos.Device.execute")
def test_sw_safe_copy(self, mock_execute):
mock_execute.side_effect = self._mock_manager
package = "safecopy.tgz"
self.sw.put = MagicMock()
with patch("jnpr.junos.utils.sw.SW.local_md5"):
self.assertTrue(
self.sw.safe_copy(
package, progress=self._myprogress, cleanfs=True, checksum="96a35ab371e1ca10408c3caecdbd8a67"