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


Python NetworkManager.list_vlans方法代碼示例

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


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

示例1: execute

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import list_vlans [as 別名]
    def execute(self, args):
        mgr = NetworkManager(self.client)

        table = Table([
            'id', 'number', 'datacenter', 'name', 'IPs', 'hardware', 'ccis',
            'networking', 'firewall'
        ])
        table.sortby = args.get('--sortby') or 'id'

        vlans = mgr.list_vlans(
            datacenter=args.get('--datacenter'),
            vlan_number=args.get('--number'),
            name=args.get('--name'),
        )
        for vlan in vlans:
            table.add_row([
                vlan['id'],
                vlan['vlanNumber'],
                vlan['primaryRouter']['datacenter']['name'],
                vlan.get('name') or blank(),
                vlan['totalPrimaryIpAddressCount'],
                len(vlan['hardware']),
                len(vlan['virtualGuests']),
                len(vlan['networkComponents']),
                'Yes' if vlan['firewallInterfaces'] else 'No',
            ])

        return table
開發者ID:TimurNurlygayanov,項目名稱:softlayer-python,代碼行數:30,代碼來源:vlan.py

示例2: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import list_vlans [as 別名]

#.........這裏部分代碼省略.........
        service = self.client['Account']
        service.getSubnets.return_value = [
            {
                'id': 100,
                'networkIdentifier': '10.0.0.1',
                'datacenter': {'name': 'dal00'},
                'version': 4,
                'subnetType': 'PRIMARY',
            },
        ]

        result = self.network.list_subnets(
            identifier=identifier,
            datacenter=datacenter,
            subnet_type=subnet_type,
            version=version,
        )

        _filter = {
            'subnets': {
                'datacenter': {
                    'name': {'operation': '_= dal00'}
                },
                'version': {'operation': 4},
                'subnetType': {'operation': '_= PRIMARY'},
                'networkIdentifier': {'operation': '_= 10.0.0.1'}
            }
        }
        mask = 'mask[hardware,datacenter,ipAddressCount,virtualGuests]'
        service.getSubnets.assert_called_with(filter=_filter, mask=mask)

        self.assertEqual([service.getSubnets.return_value[0]], result)

    def test_list_vlans_default(self):
        mcall = call(filter={}, mask=ANY)
        service = self.client['Account']

        self.network.list_vlans()

        service.getNetworkVlans.assert_has_calls(mcall)

    def test_list_vlans_with_filters(self):
        number = 5
        datacenter = 'dal00'
        self.network.list_vlans(
            vlan_number=number,
            datacenter=datacenter,
        )

        service = self.client['Account']
        service.getNetworkVlans.assert_has_calls(call(
            filter={
                'networkVlans': {
                    'primaryRouter': {
                        'datacenter': {
                            'name': {'operation': '_= ' + datacenter}},
                    },
                    'vlanNumber': {'operation': number},
                },
            },
            mask=ANY
        ))

    def test_summary_by_datacenter(self):
        mcall = call(mask=ANY)
        service = self.client['Account']
開發者ID:crvidya,項目名稱:softlayer-api-python-client,代碼行數:70,代碼來源:network_tests.py

示例3: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import list_vlans [as 別名]

#.........這裏部分代碼省略.........
    def test_list_subnets_default(self):
        _filter = {'subnets': {'subnetType': {'operation': '!= GLOBAL_IP'}}}
        mask = 'hardware,datacenter,ipAddressCount,virtualGuests'
        service = self.client['Account']

        self.network.list_subnets()

        service.getSubnets.assert_has_calls(call(filter=_filter, mask=mask))

    def test_list_subnets_with_filters(self):
        result = self.network.list_subnets(
            identifier='10.0.0.1',
            datacenter='dal00',
            subnet_type='PRIMARY',
            version=4,
        )

        _filter = {
            'subnets': {
                'datacenter': {
                    'name': {'operation': '_= dal00'}
                },
                'version': {'operation': 4},
                'subnetType': {'operation': '_= PRIMARY'},
                'networkIdentifier': {'operation': '_= 10.0.0.1'}
            }
        }
        mask = 'hardware,datacenter,ipAddressCount,virtualGuests'
        self.client['Account'].getSubnets.assert_called_with(filter=_filter,
                                                             mask=mask)
        self.assertEqual(self.client['Account'].getSubnets.return_value,
                         result)

    def test_list_vlans_default(self):
        service = self.client['Account']

        self.network.list_vlans()
        service.getNetworkVlans.assert_has_calls(call(filter={}, mask=ANY))

    def test_list_vlans_with_filters(self):
        self.network.list_vlans(
            vlan_number=5,
            datacenter='dal00',
            name='primary-vlan',
        )

        service = self.client['Account']
        service.getNetworkVlans.assert_has_calls(call(
            filter={
                'networkVlans': {
                    'primaryRouter': {
                        'datacenter': {
                            'name': {'operation': '_= dal00'}},
                    },
                    'vlanNumber': {'operation': 5},
                    'name': {'operation': '_= primary-vlan'},
                },
            },
            mask=ANY
        ))

    def test_summary_by_datacenter(self):
        result = self.network.summary_by_datacenter()

        expected = {
            'dal00': {
開發者ID:MayaY2014,項目名稱:softlayer-python,代碼行數:70,代碼來源:network_tests.py

示例4: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import list_vlans [as 別名]

#.........這裏部分代碼省略.........
        identifier = "10.0.0.1"
        datacenter = "dal00"
        subnet_type = "PRIMARY"
        version = 4

        service = self.client["Account"]
        service.getSubnets.return_value = [
            {
                "id": 100,
                "networkIdentifier": "10.0.0.1",
                "datacenter": {"name": "dal00"},
                "version": 4,
                "subnetType": "PRIMARY",
            }
        ]

        result = self.network.list_subnets(
            identifier=identifier, datacenter=datacenter, subnet_type=subnet_type, version=version
        )

        _filter = {
            "subnets": {
                "datacenter": {"name": {"operation": "_= dal00"}},
                "version": {"operation": 4},
                "subnetType": {"operation": "_= PRIMARY"},
                "networkIdentifier": {"operation": "_= 10.0.0.1"},
            }
        }
        mask = "hardware,datacenter,ipAddressCount,virtualGuests"
        service.getSubnets.assert_called_with(filter=_filter, mask=mask)

        self.assertEqual([service.getSubnets.return_value[0]], result)

    def test_list_vlans_default(self):
        mcall = call(filter={}, mask=ANY)
        service = self.client["Account"]

        self.network.list_vlans()

        service.getNetworkVlans.assert_has_calls(mcall)

    def test_list_vlans_with_filters(self):
        self.network.list_vlans(vlan_number=5, datacenter="dal00", name="primary-vlan")

        service = self.client["Account"]
        service.getNetworkVlans.assert_has_calls(
            call(
                filter={
                    "networkVlans": {
                        "primaryRouter": {"datacenter": {"name": {"operation": "_= dal00"}}},
                        "vlanNumber": {"operation": 5},
                        "name": {"operation": "_= primary-vlan"},
                    }
                },
                mask=ANY,
            )
        )

    def test_summary_by_datacenter(self):
        mcall = call(mask=ANY, filter=ANY)
        service = self.client["Account"]

        service.getNetworkVlans.return_value = [
            {
                "name": "dal00",
                "hardware": [{"id": 1}],
開發者ID:ryanrhanson,項目名稱:softlayer-python,代碼行數:70,代碼來源:network_tests.py

示例5: listVlans

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import list_vlans [as 別名]
def listVlans():
    netManager = NetworkManager(client)
    vlans = netManager.list_vlans()

    print json.dumps(vlans, sort_keys=True, indent=4)
    return vlans
開發者ID:mcltn,項目名稱:softlayer-scripts,代碼行數:8,代碼來源:softlayer-burst.py


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