當前位置: 首頁>>代碼示例>>Python>>正文


Python VCA.get_gateway方法代碼示例

本文整理匯總了Python中pyvcloud.vcloudair.VCA.get_gateway方法的典型用法代碼示例。如果您正苦於以下問題:Python VCA.get_gateway方法的具體用法?Python VCA.get_gateway怎麽用?Python VCA.get_gateway使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyvcloud.vcloudair.VCA的用法示例。


在下文中一共展示了VCA.get_gateway方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_gateway [as 別名]

#.........這裏部分代碼省略.........
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.name == vapp_name
        details = the_vapp.get_vms_details()
        assert details[0].get('cpus') == cpus
        task = the_vapp.modify_vm_cpu(vm_name, cpus_new)
        assert task
        result = self.vca.block_until_completed(task)
        assert result
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.name == vapp_name
        details = the_vapp.get_vms_details()
        assert details[0].get('cpus') == cpus_new

    def test_0009(self):
        """Add NAT rule"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        gateway_name = config['vcloud']['gateway']
        rule_type = config['vcloud']['nat_rule_type']
        original_ip = config['vcloud']['nat_original_ip']
        original_port = config['vcloud']['nat_original_port']
        translated_ip = config['vcloud']['nat_translated_ip']
        translated_port = config['vcloud']['nat_translated_port']
        protocol = config['vcloud']['nat_protocol']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        the_gateway = self.vca.get_gateway(vdc_name, gateway_name)
        assert the_gateway
        assert the_gateway.get_name() == gateway_name
        the_gateway.add_nat_rule(rule_type, original_ip, original_port, translated_ip, translated_port, protocol)
        task = the_gateway.save_services_configuration()
        assert task
        result = self.vca.block_until_completed(task)
        assert result

    def test_0010(self):
        """Get NAT rule"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        gateway_name = config['vcloud']['gateway']
        rule_type = config['vcloud']['nat_rule_type']
        original_ip = config['vcloud']['nat_original_ip']
        original_port = str(config['vcloud']['nat_original_port'])
        translated_ip = config['vcloud']['nat_translated_ip']
        translated_port = str(config['vcloud']['nat_translated_port'])
        protocol = config['vcloud']['nat_protocol']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        the_gateway = self.vca.get_gateway(vdc_name, gateway_name)
        assert the_gateway
        assert the_gateway.get_name() == gateway_name
        nat_rules = the_gateway.get_nat_rules()
        found_rule = False
        for natRule in nat_rules:
            ruleId = natRule.get_Id()
            if rule_type == natRule.get_RuleType():
                gatewayNatRule = natRule.get_GatewayNatRule()
開發者ID:piraz,項目名稱:pyvcloud,代碼行數:70,代碼來源:vcloud_tests.py


注:本文中的pyvcloud.vcloudair.VCA.get_gateway方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。