def test_create_complex_lan(self):
        nic_resource = NIC(**self.resource['nic'])

        nic1 = self.client.create_nic(
            datacenter_id=self.datacenter['id'],
            server_id=self.server['id'],
            nic=nic_resource)
        self.client.wait_for_completion(nic1)
        self.assertFalse(nic1['properties']['nat'])
        self.assertEqual(nic1['properties']['name'], 'Python SDK Test')
        self.assertTrue(nic1['properties']['dhcp'])
        self.assertEqual(nic1['properties']['lan'], 1)
        self.assertTrue(nic1['properties']['firewallActive'])

        nics = [nic1['id']]
        lan = LAN(nics=nics, **self.resource['lan'])

        response = self.client.create_lan(
            datacenter_id=self.datacenter['id'],
            lan=lan)
        self.client.wait_for_completion(response)

        self.assertEqual(response['type'], 'lan')
        self.assertEqual(response['properties']['name'], self.resource['lan']['name'])
        self.assertFalse(response['properties']['public'])
 def test_create_failure(self):
     try:
         self.client.create_lan(
             datacenter_id='00000000-0000-0000-0000-000000000000',
             lan=LAN())
     except ICNotFoundError as e:
         self.assertIn(self.resource['not_found_error'],
                       e.content[0]['message'])
Ejemplo n.º 3
0
def getLANObject(defdict=None):
    if not defdict or not isinstance(defdict, dict):
        raise ValueError("argument 'defdict' must be non-empty dict")
    props = dict()
    for k, v in defdict['properties'].items():
        # no renaming needed here, but this accounts for optional props too
        props[k] = v
    # end for(defdict)
    apiobj = LAN(**props)
    return apiobj
    def setUpClass(cls):
        warnings.filterwarnings("ignore", category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        cls.resource = resource()
        cls.client = IonosEnterpriseService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Create test datacenter.
        cls.datacenter = cls.client.create_datacenter(
            datacenter=Datacenter(**cls.resource['datacenter']))
        cls.client.wait_for_completion(cls.datacenter)

        # Create test LAN.
        cls.lan = cls.client.create_lan(
            datacenter_id=cls.datacenter['id'],
            lan=LAN(**cls.resource['lan']))
        cls.client.wait_for_completion(cls.lan)

        # Create test server.
        cls.server = cls.client.create_server(
            datacenter_id=cls.datacenter['id'],
            server=Server(**cls.resource['server']))
        cls.client.wait_for_completion(cls.server)

        # Create test NIC1.
        nic1 = NIC(**cls.resource['nic'])
        nic1.lan = cls.lan['id']
        cls.nic1 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic1)
        cls.client.wait_for_completion(cls.nic1)

        # Create test Firewall Rule
        fwrule = FirewallRule(**cls.resource['fwrule'])
        cls.fwrule = cls.client.create_firewall_rule(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic_id=cls.nic1['id'],
            firewall_rule=fwrule)
        cls.client.wait_for_completion(cls.fwrule)

        # Create test Firewall Rule 2
        fwrule2 = FirewallRule(**cls.resource['fwrule'])
        fwrule2.port_range_start = 8080
        fwrule2.port_range_end = 8080
        fwrule2.name = "8080"
        cls.fwrule2 = cls.client.create_firewall_rule(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic_id=cls.nic1['id'],
            firewall_rule=fwrule2)
        cls.client.wait_for_completion(cls.fwrule2)
    def test_remove_lan(self):
        lan = self.client.create_lan(
            datacenter_id=self.datacenter['id'],
            lan=LAN(**self.resource['lan']))

        self.client.wait_for_completion(lan)

        lan = self.client.delete_lan(datacenter_id=self.datacenter['id'], lan_id=lan['id'])

        self.assertTrue(lan)
        assertRegex(self, lan['requestId'], self.resource['uuid_match'])
    def setUpClass(cls):
        warnings.filterwarnings("ignore", category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        cls.resource = resource()
        cls.client = IonosEnterpriseService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Create test datacenter.
        cls.datacenter = cls.client.create_datacenter(
            datacenter=Datacenter(**cls.resource['datacenter']))
        cls.client.wait_for_completion(cls.datacenter)

        # Create pcc.
        pcc = PrivateCrossConnect(name="TEST NAME - %s" % uuid.uuid1(),
                                  description="TEST DESCRIPTION 1")

        cls.pcc = cls.client.create_pcc(pcc)
        cls.client.wait_for_completion(cls.pcc)

        # Create test LAN.
        lan_properties = cls.resource['lan']
        lan_properties['pcc_id'] = cls.pcc['id']
        cls.lan = cls.client.create_lan(
            datacenter_id=cls.datacenter['id'],
            lan=LAN(**lan_properties))
        cls.client.wait_for_completion(cls.lan)

        # Create test server.
        cls.server = cls.client.create_server(
            datacenter_id=cls.datacenter['id'],
            server=Server(**cls.resource['server']))
        cls.client.wait_for_completion(cls.server)

        # Create test NIC1.
        nic1 = NIC(**cls.resource['nic'])
        nic1.lan = cls.lan['id']
        cls.nic1 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic1)
        cls.client.wait_for_completion(cls.nic1)

        # Create test NIC2.
        nic2 = NIC(**cls.resource['nic'])
        nic2.lan = cls.lan['id']
        cls.nic2 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic2)
        cls.client.wait_for_completion(cls.nic2)
    def setUpClass(cls):
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        cls.resource = resource()
        cls.client = IonosEnterpriseService(username=configuration.USERNAME,
                                            password=configuration.PASSWORD,
                                            headers=configuration.HEADERS)

        # Create test datacenter.
        cls.datacenter = cls.client.create_datacenter(datacenter=Datacenter(
            **cls.resource['datacenter']))
        cls.client.wait_for_completion(cls.datacenter)

        # Create test LAN.
        cls.lan = cls.client.create_lan(datacenter_id=cls.datacenter['id'],
                                        lan=LAN(
                                            name=cls.resource['lan']['name'],
                                            public=False))
        cls.client.wait_for_completion(cls.lan)

        # Create test server.
        cls.server = cls.client.create_server(
            datacenter_id=cls.datacenter['id'],
            server=Server(**cls.resource['server']))
        cls.client.wait_for_completion(cls.server)

        # Create test NIC1.
        nic1 = NIC(**cls.resource['nic'])
        nic1.lan = cls.lan['id']
        cls.ips = ['10.0.0.1']
        nic1.ips = cls.ips
        cls.nic1 = cls.client.create_nic(datacenter_id=cls.datacenter['id'],
                                         server_id=cls.server['id'],
                                         nic=nic1)
        cls.client.wait_for_completion(cls.nic1)

        # Create test NIC2.
        nic2 = NIC(**cls.resource['nic'])
        nic2.lan = cls.lan['id']
        cls.nic2 = cls.client.create_nic(datacenter_id=cls.datacenter['id'],
                                         server_id=cls.server['id'],
                                         nic=nic2)
        cls.client.wait_for_completion(cls.nic2)
Ejemplo n.º 8
0
    def setUpClass(cls):
        cls.resource = resource()
        cls.client = IonosEnterpriseService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Create test datacenter.
        cls.datacenter = cls.client.create_datacenter(
            datacenter=Datacenter(**cls.resource['datacenter']))
        cls.client.wait_for_completion(cls.datacenter)

        # Create test LAN.
        cls.lan = cls.client.create_lan(
            datacenter_id=cls.datacenter['id'],
            lan=LAN(**cls.resource['lan']))
        cls.client.wait_for_completion(cls.lan)

        # Create test server.
        cls.server = cls.client.create_server(
            datacenter_id=cls.datacenter['id'],
            server=Server(**cls.resource['server']))
        cls.client.wait_for_completion(cls.server)

        # Create test NIC1.
        nic1 = NIC(**cls.resource['nic'])
        nic1.lan = cls.lan['id']
        cls.nic1 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic1)
        cls.client.wait_for_completion(cls.nic1)

        # Create test NIC2.
        nic2 = NIC(**cls.resource['nic'])
        nic2.lan = cls.lan['id']
        cls.nic2 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic2)
        cls.client.wait_for_completion(cls.nic2)
Ejemplo n.º 9
0
                 size=56,
                 image=image_id,
                 bus='VIRTIO',
                 image_password="******")

volumes = [volume2]

server1 = Server(name='My New Server1',
                 ram=4096,
                 cores=4,
                 nics=nics,
                 create_volumes=[volume1])

servers = [server1]

lan1 = LAN(name='public Lan 4', public=True)

lan2 = LAN(name='public Lan 5', public=True)

lans = [lan1, lan2]

loadbalancer1 = LoadBalancer(name='LB01', ip='10.2.2.5', dhcp=False)

loadbalancers = [loadbalancer1]

d = Datacenter(name='My New Datacenter',
               description='Production environment',
               location='de/fkb',
               servers=servers,
               volumes=volumes,
               lans=lans,
Ejemplo n.º 10
0
    def setUpClass(cls):
        cls.resource = resource()
        cls.client = IonosEnterpriseService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Create test datacenter.
        cls.datacenter = cls.client.create_datacenter(
            datacenter=Datacenter(**cls.resource['datacenter']))
        cls.client.wait_for_completion(cls.datacenter)

        # Create test LAN.
        cls.lan = cls.client.create_lan(
            datacenter_id=cls.datacenter['id'],
            lan=LAN(**cls.resource['lan']))
        cls.client.wait_for_completion(cls.lan)

        # Create test server.
        cls.server = cls.client.create_server(
            datacenter_id=cls.datacenter['id'],
            server=Server(**cls.resource['server']))
        cls.client.wait_for_completion(cls.server)

        # Create test NIC1.
        nic1 = NIC(**cls.resource['nic'])
        nic1.lan = cls.lan['id']
        cls.nic1 = cls.client.create_nic(
            datacenter_id=cls.datacenter['id'],
            server_id=cls.server['id'],
            nic=nic1)
        cls.client.wait_for_completion(cls.nic1)

        # Create test NIC2.
        # nic2 = NIC(**cls.resource['nic'])
        # nic2.lan = cls.lan['id']
        # cls.nic2 = cls.client.create_nic(
        #     datacenter_id=cls.datacenter['id'],
        #     server_id=cls.server['id'],
        #     nic=nic2)
        # cls.client.wait_for_completion(cls.nic2)

        # Create test LoadBalancer
        loadbalancer = LoadBalancer(**cls.resource['loadbalancer'])
        loadbalancer.balancednics = [cls.nic1['id']]
        cls.loadbalancer = cls.client.create_loadbalancer(
            datacenter_id=cls.datacenter['id'],
            loadbalancer=loadbalancer
        )

        cls.client.wait_for_completion(cls.loadbalancer)

        # Create test LoadBalancer2
        loadbalancer2 = LoadBalancer(**cls.resource['loadbalancer'])
        loadbalancer2.name = "Python SDK Test 2"
        cls.loadbalancer2 = cls.client.create_loadbalancer(
            datacenter_id=cls.datacenter['id'],
            loadbalancer=loadbalancer2
        )

        cls.client.wait_for_completion(cls.loadbalancer2)

        # Create test LoadBalancer3
        loadbalancer3 = LoadBalancer(**cls.resource['loadbalancer'])
        loadbalancer3.balancednics = [cls.nic1['id']]
        loadbalancer3.name = "Python SDK Test 3"
        cls.loadbalancer3 = cls.client.create_loadbalancer(
            datacenter_id=cls.datacenter['id'],
            loadbalancer=loadbalancer3
        )

        cls.client.wait_for_completion(cls.loadbalancer3)
lans = client.list_lans(datacenter_id=datacenter_id)

print(lans)
"""Create Complex LAN
"""
from ionosenterprise.client import IonosEnterpriseService, LAN  # noqa

lan_id = '4'
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'

client = IonosEnterpriseService(username='******', password='******')

nics = ['<NIC-ID-1>', '<NIC-ID-2>']

i = LAN(name='public Lan 4', public=True, nics=nics)

response = client.create_lan(datacenter_id=datacenter_id, lan=i)
"""Create LAN
"""
from ionosenterprise.client import IonosEnterpriseService, LAN  # noqa

lan_id = '4'
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'

client = IonosEnterpriseService(username='******', password='******')

i = LAN(name='public Lan 4', public=True)

response = client.create_lan(datacenter_id=datacenter_id, lan=i)
"""Get LAN Members