test_class.declarator: dao
test_class.original_string: RedisDao dao;
test_class.type: RedisDao
test_class.var_name: dao
test_class.file: vsm/src/test/java/com/abiquo/vsm/migration/MigratorTest.java
test_class.identifier: MigratorTest
test_class.superclass: extends TestBase
test_case.body: @Test(enabled = false)
      public void test_persitedMigration()
      {
          // Populate old model (1.6.8)
          String es = "http://uknwon:8080/es";
  
          String uuid0 = randomUUID();
          String uuid1 = randomUUID();
          String uuid2 = randomUUID();
          String uuid3 = randomUUID();
  
          RedisWrapper wrapper = new RedisWrapper(TEST_HOST, TEST_PORT, TEST_DATABASE);
  
          wrapper.insertSubscription(uuid0, es, "http://10.60.1.79:8889/", "KVM", "user0",
              "password0");
          wrapper.insertSubscription(uuid1, es, "http://10.60.1.80:8889/", "vmx-04", "user1",
              "password1");
          wrapper.insertSubscription(uuid2, es, "http://10.60.1.80:8889/", "vmx-04", "user1",
              "password1");
          wrapper.insertSubscription(uuid3, es, "http://10.60.1.80:8889/", "vmx-04", "user1",
              "password1");
  
          // Migrate to new model (1.7)
          new Migrator(TEST_HOST, TEST_PORT, TEST_DATABASE).migratePersistedModel();
  
          assertTrue(wrapper.getAllSubscriptionIds().isEmpty());
  
          RedisTestDaoFactory.selectDatabase(TEST_HOST, TEST_PORT, TEST_DATABASE);
  
          assertEquals(dao.findAllPhysicalMachines().size(), 2);
          assertEquals(dao.findAllVirtualMachines().size(), 4);
  
          PhysicalMachine machine79 = dao.findPhysicalMachineByAddress("http://10.60.1.79:8889/");
          PhysicalMachine machine80 = dao.findPhysicalMachineByAddress("http://10.60.1.80:443/");
  
          assertNotNull(machine79);
          assertNotNull(machine80);
  
          assertEquals(machine79.getAddress(), "http://10.60.1.79:8889/");
          assertEquals(machine79.getType(), "KVM");
          assertEquals(machine79.getUsername(), "user0");
          assertEquals(machine79.getPassword(), "password0");
  
          assertEquals(machine80.getAddress(), "http://10.60.1.80:443/");
          assertEquals(machine80.getType(), "VMX_04");
          assertEquals(machine80.getUsername(), "user1");
          assertEquals(machine80.getPassword(), "password1");
  
          VirtualMachine vmachine0 = dao.findVirtualMachineByName(uuid0);
          VirtualMachine vmachine1 = dao.findVirtualMachineByName(uuid1);
          VirtualMachine vmachine2 = dao.findVirtualMachineByName(uuid2);
          VirtualMachine vmachine3 = dao.findVirtualMachineByName(uuid3);
  
          assertNotNull(vmachine0);
          assertNotNull(vmachine1);
          assertNotNull(vmachine2);
          assertNotNull(vmachine3);
  
          assertEquals(vmachine0.getName(), uuid0);
          assertEquals(vmachine0.getPhysicalMachine().getId(), machine79.getId());
          assertNull(vmachine0.getLastKnownState());
  
          assertEquals(vmachine1.getName(), uuid1);
          assertEquals(vmachine1.getPhysicalMachine().getId(), machine80.getId());
          assertNull(vmachine1.getLastKnownState());
  
          assertEquals(vmachine2.getName(), uuid2);
          assertEquals(vmachine2.getPhysicalMachine().getId(), machine80.getId());
          assertNull(vmachine2.getLastKnownState());
  
          assertEquals(vmachine3.getName(), uuid3);
          assertEquals(vmachine3.getPhysicalMachine().getId(), machine80.getId());
          assertNull(vmachine3.getLastKnownState());
      }
test_case.class_method_signature: MigratorTest.test_persitedMigration()
test_case.full_signature: @Test(enabled = false) public void test_persitedMigration()
test_case.identifier: test_persitedMigration
test_case.invocations: randomUUID randomUUID randomUUID randomUUID insertSubscription insertSubscription insertSubscription insertSubscription migratePersistedModel assertTrue isEmpty getAllSubscriptionIds selectDatabase assertEquals size findAllPhysicalMachines assertEquals size findAllVirtualMachines findPhysicalMachineByAddress findPhysicalMachineByAddress assertNotNull assertNotNull assertEquals getAddress assertEquals getType assertEquals getUsername assertEquals getPassword assertEquals getAddress assertEquals getType assertEquals getUsername assertEquals getPassword findVirtualMachineByName findVirtualMachineByName findVirtualMachineByName findVirtualMachineByName assertNotNull assertNotNull assertNotNull assertNotNull assertEquals getName assertEquals getId getPhysicalMachine getId assertNull getLastKnownState assertEquals getName assertEquals getId getPhysicalMachine getId assertNull getLastKnownState assertEquals getName assertEquals getId getPhysicalMachine getId assertNull getLastKnownState assertEquals getName assertEquals getId getPhysicalMachine getId assertNull getLastKnownState
test_case.modifiers: @Test(enabled = false) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test_persitedMigration()
focal_class.declarator: logger = LoggerFactory.getLogger(Migrator.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger logger = LoggerFactory.getLogger(Migrator.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: MachineListKey = "tomigrate"
focal_class.modifier: public final static
focal_class.original_string: public final static String MachineListKey = "tomigrate";
focal_class.type: String
focal_class.var_name: MachineListKey
focal_class.declarator: host
focal_class.modifier: private
focal_class.original_string: private String host;
focal_class.type: String
focal_class.var_name: host
focal_class.declarator: port
focal_class.modifier: private
focal_class.original_string: private int port;
focal_class.type: int
focal_class.var_name: port
focal_class.declarator: database
focal_class.modifier: private
focal_class.original_string: private int database;
focal_class.type: int
focal_class.var_name: database
focal_class.declarator: machinesCount
focal_class.modifier: private
focal_class.original_string: private int machinesCount;
focal_class.type: int
focal_class.var_name: machinesCount
focal_class.declarator: subscriptionsCount
focal_class.modifier: private
focal_class.original_string: private int subscriptionsCount;
focal_class.type: int
focal_class.var_name: subscriptionsCount
focal_class.declarator: ports
focal_class.modifier: private
focal_class.original_string: private Map<String, Integer> ports;
focal_class.type: Map<String, Integer>
focal_class.var_name: ports
focal_class.declarator: hypervisors
focal_class.modifier: private
focal_class.original_string: private Map<String, Type> hypervisors;
focal_class.type: Map<String, Type>
focal_class.var_name: hypervisors
focal_class.file: vsm/src/main/java/com/abiquo/vsm/migration/Migrator.java
focal_class.identifier: Migrator
focal_class.class_method_signature: Migrator.Migrator(String host, int port, int database)
focal_class.full_signature: public  Migrator(String host, int port, int database)
focal_class.identifier: Migrator
focal_class.modifiers: public
focal_class.parameters: (String host, int port, int database)
focal_class.signature:  Migrator(String host, int port, int database)
focal_class.class_method_signature: Migrator.migratePersistedModel()
focal_class.full_signature: public void migratePersistedModel()
focal_class.identifier: migratePersistedModel
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void migratePersistedModel()
focal_class.class_method_signature: Migrator.migrateNonPersistedModelFromFile(final File file)
focal_class.full_signature: public void migrateNonPersistedModelFromFile(final File file)
focal_class.identifier: migrateNonPersistedModelFromFile
focal_class.modifiers: public
focal_class.parameters: (final File file)
focal_class.return: void
focal_class.signature: void migrateNonPersistedModelFromFile(final File file)
focal_class.class_method_signature: Migrator.migrateNonPersistedModelFromRedis()
focal_class.full_signature: public void migrateNonPersistedModelFromRedis()
focal_class.identifier: migrateNonPersistedModelFromRedis
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void migrateNonPersistedModelFromRedis()
focal_class.class_method_signature: Migrator.insertMachineFromCSVLine(final RedisDao dao, final String csvLine)
focal_class.full_signature: private void insertMachineFromCSVLine(final RedisDao dao, final String csvLine)
focal_class.identifier: insertMachineFromCSVLine
focal_class.modifiers: private
focal_class.parameters: (final RedisDao dao, final String csvLine)
focal_class.return: void
focal_class.signature: void insertMachineFromCSVLine(final RedisDao dao, final String csvLine)
focal_class.class_method_signature: Migrator.insertMachine(final RedisDao dao, final String address,
          final String type, final String username, final String password)
focal_class.full_signature: private PhysicalMachine insertMachine(final RedisDao dao, final String address,
          final String type, final String username, final String password)
focal_class.identifier: insertMachine
focal_class.modifiers: private
focal_class.parameters: (final RedisDao dao, final String address,
          final String type, final String username, final String password)
focal_class.return: PhysicalMachine
focal_class.signature: PhysicalMachine insertMachine(final RedisDao dao, final String address,
          final String type, final String username, final String password)
focal_class.class_method_signature: Migrator.getMachinesCount()
focal_class.full_signature: public int getMachinesCount()
focal_class.identifier: getMachinesCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMachinesCount()
focal_class.class_method_signature: Migrator.getSubscriptionsCount()
focal_class.full_signature: public int getSubscriptionsCount()
focal_class.identifier: getSubscriptionsCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getSubscriptionsCount()
focal_class.class_method_signature: Migrator.buildOptions()
focal_class.full_signature: private static Options buildOptions()
focal_class.identifier: buildOptions
focal_class.modifiers: private static
focal_class.parameters: ()
focal_class.return: Options
focal_class.signature: Options buildOptions()
focal_class.class_method_signature: Migrator.printUsage()
focal_class.full_signature: private static void printUsage()
focal_class.identifier: printUsage
focal_class.modifiers: private static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void printUsage()
focal_class.class_method_signature: Migrator.main(String[] args)
focal_class.full_signature: public static void main(String[] args)
focal_class.identifier: main
focal_class.modifiers: public static
focal_class.parameters: (String[] args)
focal_class.return: void
focal_class.signature: void main(String[] args)
focal_class.class_method_signature: Migrator.getProperty(String name, String defaultValue)
focal_class.full_signature: private static String getProperty(String name, String defaultValue)
focal_class.identifier: getProperty
focal_class.modifiers: private static
focal_class.parameters: (String name, String defaultValue)
focal_class.return: String
focal_class.signature: String getProperty(String name, String defaultValue)
focal_method.body: public void migratePersistedModel()
      {
          RedisWrapper wrapper = new RedisWrapper(host, port, database);
          RedisDao dao = RedisDaoFactory.getInstance();
  
          for (String id : wrapper.getAllSubscriptionIds())
          {
              String address = wrapper.getHypervisorUrl(id);
              String type = wrapper.getHypervisorType(id);
              String username = wrapper.getUser(id);
              String password = wrapper.getPassword(id);
              String virtualMachineName = wrapper.getVirtualSystemId(id);
  
              PhysicalMachine machine = insertMachine(dao, address, type, username, password);
  
              if (machine != null)
              {
                  VirtualMachine virtualMachine = dao.findVirtualMachineByName(virtualMachineName);
  
                  if (virtualMachine == null)
                  {
                      virtualMachine = new VirtualMachine();
                      virtualMachine.setName(virtualMachineName);
                      virtualMachine.setPhysicalMachine(machine);
  
                      dao.save(virtualMachine);
  
                      this.subscriptionsCount++;
                      logger.info("Subscription migrated: {}", virtualMachineName);
                  }
  
                  wrapper.deleteSubscription(id);
              }
          }
      }
focal_method.class_method_signature: Migrator.migratePersistedModel()
focal_method.full_signature: public void migratePersistedModel()
focal_method.identifier: migratePersistedModel
focal_method.invocations: getInstance getAllSubscriptionIds getHypervisorUrl getHypervisorType getUser getPassword getVirtualSystemId insertMachine findVirtualMachineByName setName setPhysicalMachine save info deleteSubscription
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void migratePersistedModel()