Ejemplo n.º 1
0
    def test_updateToMany(self):
        from ZenPacks.zenoss.AWS.utils import updateToMany

        device_facade = getFacade('device')

        instance = self.account.getObjByPath(
            'regions/region/instances/instance')

        # Add one volume.
        updateToMany(instance.volumes,
                     instance.region().volumes, CLASS_NAME['EC2Volume'],
                     ['volume1'])

        self.assertEqual(instance.volumes.countObjects(), 1)
        self.assertEqual(instance.volumes()[0].id, 'volume1')

        instance_volumes = device_facade.getComponents(
            instance.getPrimaryUrlPath(), meta_type='EC2Volume')

        self.assertTrue('volume1' in [b.id for b in instance_volumes.results])

        # Add two volumes.
        updateToMany(instance.volumes,
                     instance.region().volumes, CLASS_NAME['EC2Volume'],
                     ['volume1', 'volume2'])

        self.assertEqual(instance.volumes.countObjects(), 2)
        self.assertEqual(set(x.id for x in instance.volumes()),
                         set(('volume1', 'volume2')))

        instance_volumes = device_facade.getComponents(
            instance.getPrimaryUrlPath(), meta_type='EC2Volume')

        self.assertEqual(instance_volumes.total, 2)

        # Remove one volume.
        updateToMany(instance.volumes,
                     instance.region().volumes, CLASS_NAME['EC2Volume'],
                     ['volume2'])

        self.assertEqual(instance.volumes.countObjects(), 1)
        self.assertEqual(instance.volumes()[0].id, 'volume2')

        instance_volumes = device_facade.getComponents(
            instance.getPrimaryUrlPath(), meta_type='EC2Volume')

        self.assertTrue('volume2' in [b.id for b in instance_volumes.results])

        # Remove all volumes.
        updateToMany(instance.volumes,
                     instance.region().volumes, CLASS_NAME['EC2Volume'], [])

        self.assertEqual(instance.volumes.countObjects(), 0)

        instance_volumes = device_facade.getComponents(
            instance.getPrimaryUrlPath(), meta_type='EC2Volume')

        self.assertEqual(instance_volumes.total, 0)
Ejemplo n.º 2
0
    def test_updateToMany(self):
        from ZenPacks.zenoss.AWS.utils import updateToMany

        device_facade = getFacade("device")

        instance = self.account.getObjByPath("regions/region/instances/instance")

        # Add one volume.
        updateToMany(instance.volumes, instance.region().volumes, CLASS_NAME["EC2Volume"], ["volume1"])

        self.assertEqual(instance.volumes.countObjects(), 1)
        self.assertEqual(instance.volumes()[0].id, "volume1")

        instance_volumes = device_facade.getComponents(instance.getPrimaryUrlPath(), meta_type="EC2Volume")

        self.assertTrue("volume1" in [b.id for b in instance_volumes.results])

        # Add two volumes.
        updateToMany(instance.volumes, instance.region().volumes, CLASS_NAME["EC2Volume"], ["volume1", "volume2"])

        self.assertEqual(instance.volumes.countObjects(), 2)
        self.assertEqual(set(x.id for x in instance.volumes()), set(("volume1", "volume2")))

        instance_volumes = device_facade.getComponents(instance.getPrimaryUrlPath(), meta_type="EC2Volume")

        self.assertEqual(instance_volumes.total, 2)

        # Remove one volume.
        updateToMany(instance.volumes, instance.region().volumes, CLASS_NAME["EC2Volume"], ["volume2"])

        self.assertEqual(instance.volumes.countObjects(), 1)
        self.assertEqual(instance.volumes()[0].id, "volume2")

        instance_volumes = device_facade.getComponents(instance.getPrimaryUrlPath(), meta_type="EC2Volume")

        self.assertTrue("volume2" in [b.id for b in instance_volumes.results])

        # Remove all volumes.
        updateToMany(instance.volumes, instance.region().volumes, CLASS_NAME["EC2Volume"], [])

        self.assertEqual(instance.volumes.countObjects(), 0)

        instance_volumes = device_facade.getComponents(instance.getPrimaryUrlPath(), meta_type="EC2Volume")

        self.assertEqual(instance_volumes.total, 0)
Ejemplo n.º 3
0
 def setVPCSubnetIds(self, ids):
     updateToMany(
         relationship=self.vpc_subnets,
         root=self.region().vpc_subnets,
         type_=CLASS_NAME['EC2VPCSubnets'],
         ids=ids)
 def setVolumeIds(self, ids):
     updateToMany(
         self.volumes,
         self.region().volumes,
         CLASS_NAME['EC2Volume'],
         ids)
Ejemplo n.º 5
0
 def setVPCSubnetIds(self, ids):
     updateToMany(relationship=self.vpc_subnets,
                  root=self.region().vpc_subnets,
                  type_=CLASS_NAME['EC2VPCSubnets'],
                  ids=ids)
Ejemplo n.º 6
0
 def setVolumeIds(self, ids):
     updateToMany(relationship=self.volumes,
                  root=self.region().volumes,
                  type_=CLASS_NAME['EC2Volumes'],
                  ids=ids)
Ejemplo n.º 7
0
 def setInstanceIds(self, ids):
     updateToMany(relationship=self.instances,
                  root=self.region().instances,
                  type_=CLASS_NAME['EC2Instance'],
                  ids=ids)
Ejemplo n.º 8
0
 def setInstanceIds(self, ids):
     updateToMany(
         relationship=self.instances,
         root=self.region().instances,
         type_=CLASS_NAME['EC2Instance'],
         ids=ids)
Ejemplo n.º 9
0
 def setSnapshotIds(self, ids):
     updateToMany(
         relationship=self.snapshots,
         root=self.region().snapshots,
         type_=CLASS_NAME['EC2Snapshot'],
         ids=ids)
Ejemplo n.º 10
0
 def setVolumeIds(self, ids):
     updateToMany(
         relationship=self.volumes,
         root=self.region().volumes,
         type_=CLASS_NAME['EC2Volumes'],
         ids=ids)
Ejemplo n.º 11
0
 def setVolumeIds(self, ids):
     updateToMany(
         self.volumes,
         self.region().volumes,
         CLASS_NAME['EC2Volume'],
         ids)