Пример #1
0
def add_mac_pool_to_cluster(pname, pfrom, pto, pcluster):

    print('Adding MAC Pool : ' + pname + 'to Cluster...')
    # Add a new MAC pool:
    pool = pools_service.add(
        types.MacPool(
            name=pname,
            ranges=[
                types.Range(
                    from_=pfrom,
                    to=pto,
                ),
            ],
        ), )

    # Find the cluster:
    cluster = clusters_service.list(search='name=' + pcluster)[0]

    # Find the service that manages the cluster, as we need it in order to
    # do the update:
    cluster_service = clusters_service.cluster_service(cluster.id)

    # Update the cluster so that it uses the new MAC pool:
    cluster_service.update(
        types.Cluster(mac_pool=types.MacPool(id=pool.id, ), ), )
Пример #2
0
def add_mac_pool_to_dc(pname, pfrom, pto, pdc):

    print('Adding MAC Pool : ' + pname + 'to DC ...')
    # Add a new MAC pool:
    pool = pools_service.add(
        types.MacPool(
            name=pname,
            ranges=[
                types.Range(
                    from_=pfrom,
                    to=pto,
                ),
            ],
        ), )

    # Find the DC:
    dc = dcs_service.list(search='name=' + pdc)[0]

    # Find the service that manages the DC, as we need it in order to
    # do the update:
    dc_service = dcs_service.data_center_service(dc.id)

    # Update the DC so that it uses the new MAC pool:
    dc_service.update(types.DataCenter(mac_pool=types.MacPool(
        id=pool.id, ), ), )
Пример #3
0
 def create(self, name, ranges, allow_duplicates=False):
     """
     :param name: string
     :param ranges: []MacPoolRange
     """
     sdk_type = types.MacPool(
         name=name,
         ranges=[types.Range(from_=r.start, to=r.end) for r in ranges],
         allow_duplicates=allow_duplicates)
     self._create_sdk_entity(sdk_type)
Пример #4
0
 def build_entity(self):
     return otypes.MacPool(
         name=self._module.params['name'],
         allow_duplicates=self._module.params['allow_duplicates'],
         description=self._module.params['description'],
         ranges=[
             otypes.Range(
                 from_=mac_range.split(',')[0],
                 to=mac_range.split(',')[1],
             ) for mac_range in self._module.params['ranges']
         ],
     )
Пример #5
0
    password='******',
    ca_file='ca.pem',
    debug=True,
    log=logging.getLogger(),
)

# Get the reference to the service that manages the MAC address pools:
pools_service = connection.system_service().mac_pools_service()

# Add a new MAC pool:
pool = pools_service.add(
    types.MacPool(
        name='mymacpool',
        ranges=[
            types.Range(
                from_='02:00:00:00:00:00',
                to='02:00:00:01:00:00',
            ),
        ],
    ), )

# Find the service that manages clusters, as we need it in order to
# find the cluster where we want to set the MAC pool:
clusters_service = connection.system_service().clusters_service()

# Find the cluster:
cluster = clusters_service.list(search='name=mycluster')[0]

# Find the service that manages the cluster, as we need it in order to
# do the update:
cluster_service = clusters_service.cluster_service(cluster.id)